• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Migi0027

DX11
DX11 - Preparing for Release Mode

20 posts in this topic

Hi guys,

 

a few weeks ago my computer went completely into a Blue Screen of Death, with the WHEA error (Windows Hardware Error Architecture, [that's bad]), but luckily, I kept a backup of everything.

 

Now as I'm writing, I'm porting my project to the new pc, and the repair shop managed to create a complete backup, but they switched two hard drives, so D:\ was now F:, which messed up some stuff. dry.png

 

Now, To the POINT!

 

I re-installed Visual Studio (IDE), but it somehow didn't support the debug version of the runtime c++, which I find wierd (notes obtained from external sources), so now I'm trying to make my Project work in the release mode, which is quite a pain in the ass... laugh.png

 

I managed to make it run, but at a certain point (found that 'point' by the way), it crashes the NVIDIA Kernel Driver, which isn't exactly what was supposed to happen, unless I was drunk making my application, but I don't remember so. huh.png

 

The crash seems to occur when I send some shader resources to the pixel shader, as so:

devcon->PSSetShaderResources(3, 1, &random);

The resource is created in a class called C3DEngineObject, which a member called PostProcess, which has a function called Render.

 

The function render has a paremeter called random, as seen above, but the wierd thing is that in debugging mode (in the dead pc), it worked fine! Perfect actually!

 

So why fail now? Does it have something to do with the release mode?

 

So my real question is, how can sending a resource to the pixel shader cause a Graphics Driver crash? ohmy.png

 

Thanks! 

 

PS. If you need more, please say so.

0

Share this post


Link to post
Share on other sites


I re-installed Visual Studio (IDE), but it somehow didn't support the debug version of the runtime c++, which I find wierd (notes obtained from external sources), so now I'm trying to make my Project work in the release mode, which is quite a pain in the ass... 

 

So your project can't compile and run in debug mode right now?

0

Share this post


Link to post
Share on other sites

Do you mean it doesn't cmpile in debug, or device creation fails when using the debug dx runtimes? If you mean the latter, and are using vs2010, you need to install the remove vs2012 debugging tools (free), and it will work again.

0

Share this post


Link to post
Share on other sites

It compiles fine, but when I run (in debug mode), this message arrives (From memory): The dll MMSVCP100d.dll could not be found. 

 

PS. I'm using VS 2012

0

Share this post


Link to post
Share on other sites

looks like the debug version has dependencies on a dll that's no longer installed. a Google search should tell you what package its from (earlier version of VS, some MS runtime of some sort, etc). then all you have to do is get the dll.

 

long ago i learned that games can behave differently in debug a release mode. stuff that works in debug doesn't in release (string pooling in my case - a long time ago). so i don't use debug at all anymore. haven't for years. i start a new project, set it to release mode, set my compiler options, and then code away with no worries.

 

when i need hardcore debugging i use trace variables and hi-rez timers. used to use trace files for debugging graphics when you can't display stuff on the screen easily, but i have't even needed that in years either. i think the last time i used trace files was when i was writing my own 3d p-correct t-mapped poly engine between the time that MS bought Brender (when i was about to license a copy) and the time they released it as DirectX v1.0 (with no retained mode!).

 

if you can live without the features of debug mode, you may want to just switch to release mode and be done with it. in the long run, debug mode is irrelevant to the final version of the game, its just a crutch to help get you there.

0

Share this post


Link to post
Share on other sites

Working in release mode may be a bit difficult especially if you're working on an experimental or unstable system. Because of the code optimizations, it is almost impossible to debug your code unless you disable those optimization in your project properties. The best way is to probably make sure you have a debug and release version of your application from time to time to make sure everything is working fine and immediately spot any problems that may cause a bigger problem later on.

 

I have encountered problems similar to that where it would run completely fine in debug but crash in release mode 3-4 times many years ago. Sadly i don't exactly remember what it was. But mine i think was more or uninitialized variables than missing libraries and or dlls.

 

@Migi0027: I don't really have any solutions but a few simple questions comes into mind:

 

* Are you sure your device context is a valid pointer? Your device context may be valid in debug mode but you might have a different setting in creating your device context in release mode.

 

* Is there a possibility of memory leaks? Are you constantly creating graphics resources and possibly not properly releasing or leaking them? I would sometimes do this and feel really stupid after realizing how simple the problem was but insanely hard to track down.

 

* If you're hundred percent sure your code should work then there may be a bug with your graphics driver. Try updating your graphics driver to the latest one.

 

* Based on your original post, i'm going to assume you've managed to recover the OS and use that existing OS for your new computer. I normally don't trust my OS after having a problem something like yours. Maybe some of your libraries were deleted or corrupted. Maybe try just to do a fresh install and see if that would work?

0

Share this post


Link to post
Share on other sites

 Norman: I agree with the information you gave, also because I have previous experience where the debugger automatically initialized variables for me, which, as in your case, was very hard to track down.

 

Brent: One very important note that you told me (which I am going to experiment with), is to disable code optimization, just for testing, to track down the issue in a simpler manner.

 

Your Questions:

  1. I'm not sure how a device context can be created differently based on the mode, please tell me how.
  2. I actually haven't paid much attention in my code to this, so thanks for reminding me!
  3. I don't believe that that's the case, but I'll keep that in mind.
  4. I'll keep that in mind, but that will be my last decision.
Edited by Migi0027
0

Share this post


Link to post
Share on other sites

Ok, now I've figured out that it doesn't only crash in that function, but also when sending the constant buffers wacko.png

 

Is there a difference in how you initialize directx in debug and release mode?

0

Share this post


Link to post
Share on other sites

When you create your device context the D3D11CreateDevice(...) has a parameter that accepts a creation flag. I'm not really doing anything special but adding an extra flag whenever i'm in debug mode.

UINT createFlags = 0;
...

if ( pDesc->bDebug )
	createFlags |= D3D11_CREATE_DEVICE_DEBUG;
...

Having that flag, D3D gives me some additional debug info whenever there is something wrong or any warning messages that i may have. Try doing that in release mode and see if anything unusual shows up in visual studio's output window.

0

Share this post


Link to post
Share on other sites

That flag was removed when porting to the new pc.

 

Do you have any idea how you can get the inside information on what wen't wrong? If possible.

0

Share this post


Link to post
Share on other sites

If useful, here's how I initialize Directx:

#pragma region NativeDirectx
	HRESULT result;
	IDXGIFactory* factory;
	IDXGIAdapter* adapter;
	IDXGIOutput* adapterOutput;
	unsigned int numModes, i, numerator, denominator, stringLength;
	DXGI_MODE_DESC* displayModeList;
	DXGI_ADAPTER_DESC adapterDesc;
	int error;
	DXGI_SWAP_CHAIN_DESC swapChainDesc;
	D3D_FEATURE_LEVEL featureLevel;
	ID3D11Texture2D* backBufferPtr;
	D3D11_TEXTURE2D_DESC depthBufferDesc;
	D3D11_DEPTH_STENCIL_DESC depthStencilDesc;
	D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc;
	D3D11_RASTERIZER_DESC rasterDesc;
	D3D11_VIEWPORT viewport;
	float fieldOfView, screenAspect;


	// Store the vsync setting.
	bool m_vsync_enabled = false;

	// Create a DirectX graphics interface factory.
	result = CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&factory);
	if(FAILED(result))
	{
		CE_ERROR("Error in creating CESDK", "FATAL ERROR");
	}

	// Use the factory to create an adapter for the primary graphics interface (video card).
	result = factory->EnumAdapters(0, &adapter);
	if(FAILED(result))
	{
		CE_ERROR("Error in creating CESDK", "FATAL ERROR");
	}

	// Enumerate the primary adapter output (monitor).
	result = adapter->EnumOutputs(0, &adapterOutput);
	if(FAILED(result))
	{
		CE_ERROR("Error in creating CESDK", "FATAL ERROR");
	}

	// Get the number of modes that fit the DXGI_FORMAT_R8G8B8A8_UNORM display format for the adapter output (monitor).
	result = adapterOutput->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numModes, NULL);
	if(FAILED(result))
	{
		CE_ERROR("Error in creating CESDK", "FATAL ERROR");
	}

	// Create a list to hold all the possible display modes for this monitor/video card combination.
	displayModeList = new DXGI_MODE_DESC[numModes];
	if(!displayModeList)
	{
		CE_ERROR("Error in creating CESDK", "FATAL ERROR");
	}

	// Now fill the display mode list structures.
	result = adapterOutput->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numModes, displayModeList);
	if(FAILED(result))
	{
		CE_ERROR("Error in creating CESDK", "FATAL ERROR");
	}

	// Now go through all the display modes and find the one that matches the screen width and height.
	// When a match is found store the numerator and denominator of the refresh rate for that monitor.
	for(i=0; i<numModes; i++)
	{
		if(displayModeList[i].Width == (unsigned int)sw)
		{
			if(displayModeList[i].Height == (unsigned int)sh)
			{
				numerator = displayModeList[i].RefreshRate.Numerator;
				denominator = displayModeList[i].RefreshRate.Denominator;
			}
		}
	}

	// Get the adapter (video card) description.
	result = adapter->GetDesc(&adapterDesc);
	if(FAILED(result))
	{
		CE_ERROR("Error in creating CESDK", "FATAL ERROR");
	}

	// Store the dedicated video card memory in megabytes.
	m_videoCardMemory = (int)(adapterDesc.DedicatedVideoMemory / 1024 / 1024);

	// Convert the name of the video card to a character array and store it.
	error = wcstombs_s(&stringLength, m_videoCardDescription, 128, adapterDesc.Description, 128);
	if(error != 0)
	{
		CE_ERROR("Error in creating CESDK", "FATAL ERROR");
	}

	// Release the display mode list.
	delete [] displayModeList;
	displayModeList = 0;

	// Release the adapter output.
	adapterOutput->Release();
	adapterOutput = 0;

	// Release the adapter.
	adapter->Release();
	adapter = 0;

	// Release the factory.
	factory->Release();
	factory = 0;

	// Initialize the swap chain description.
	ZeroMemory(&swapChainDesc, sizeof(swapChainDesc));

	// Set to a single back buffer.
	swapChainDesc.BufferCount = 1;

	// Set the width and height of the back buffer.
	swapChainDesc.BufferDesc.Width = sw;
	swapChainDesc.BufferDesc.Height = sh;

	// Set regular 32-bit surface for the back buffer.
	swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;

	// Set the refresh rate of the back buffer.
	if(m_vsync_enabled)
	{
		swapChainDesc.BufferDesc.RefreshRate.Numerator = numerator;
		swapChainDesc.BufferDesc.RefreshRate.Denominator = denominator;
	}
	else
	{
		swapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
		swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
	}

	// Set the usage of the back buffer.
	swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;

	// Set the handle for the window to render to.
	swapChainDesc.OutputWindow = hWnd;

	// Turn multi sampling off.
	swapChainDesc.SampleDesc.Count = 1;
	swapChainDesc.SampleDesc.Quality = 0;

	// Set to full screen or windowed mode.
	if(windowed)
	{
		swapChainDesc.Windowed = true;
	}
	else
	{
		swapChainDesc.Windowed = false;
	}

	// Set the scan line ordering and scaling to unspecified.
	swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
	swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;

	// Discard the back buffer contents after presenting.
	swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;

	// Don't set the advanced flags.
	swapChainDesc.Flags = 0;

	// Set the feature level to DirectX 11.
	featureLevel = D3D_FEATURE_LEVEL_11_0;

	// Create the swap chain, Direct3D device, and Direct3D device context.
	result = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, &featureLevel, 1, 
		D3D11_SDK_VERSION, &swapChainDesc, &swapchain, &dev, NULL, &devcon);
	if(FAILED(result))
	{
		CE_ERROR("Error in creating CESDK", "FATAL ERROR");
	}

	ZeroMemory(&texd, sizeof(texd));

	texd.Width = sw;
	texd.Height = sh;
	texd.ArraySize = 1;
	texd.MipLevels = 1;
	texd.SampleDesc.Count = 1;	
	texd.SampleDesc.Quality = 0;
	texd.Format = DXGI_FORMAT_D32_FLOAT;
	texd.BindFlags = D3D11_BIND_DEPTH_STENCIL;

	ID3D11Texture2D *pDepthBuffer;
	dev->CreateTexture2D(&texd, NULL, &pDepthBuffer);

	ZeroMemory(&dsvd, sizeof(dsvd));

	dsvd.Format = DXGI_FORMAT_D32_FLOAT;
	dsvd.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;

	dev->CreateDepthStencilView(pDepthBuffer, &dsvd, &zbuffer);

	if (pDepthBuffer != nullptr)
		pDepthBuffer->Release();

	// get the address of the back buffer
	ID3D11Texture2D *pBackBuffer;
	swapchain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer);

	// use the back buffer address to create the render target
	dev->CreateRenderTargetView(pBackBuffer, NULL, &backbuffer);

	if (pBackBuffer != nullptr)
		pBackBuffer->Release();

	// set the render target as the back buffer
	devcon->OMSetRenderTargets(1, &backbuffer, zbuffer);


	// Set the viewport
	ZeroMemory(&viewport, sizeof(D3D11_VIEWPORT));

	viewport.TopLeftX = 0;    // set the left to 0
	viewport.TopLeftY = 0;    // set the top to 0
	viewport.Width = sw;    // set the width to the window's width
	viewport.Height = sh;    // set the height to the window's height
	viewport.MinDepth = 0;    // the closest an object can be on the depth buffer is 0.0
	viewport.MaxDepth = 1;    // the farthest an object can be on the depth buffer is 1.0

	devcon->RSSetViewports(1, &viewport);
	#pragma endregion
0

Share this post


Link to post
Share on other sites

A quick look at your code seems to have enough security checks to catch if there's anything wrong with the device creation and setup process. I'm afraid i have no more suggestions to your problem. sad.png

 

The worse bug that i can actually think of is if somewhere in your code is doing a buffer overflow and overwrites your graphics device context. I'm not sure if this can be detected with the use of _CrtSetDbgFlag() and _CrtDumpMemoryLeaks() but with those security checks that you have above i doubt you're doing this mistake somewhere in your code.

 

I hope someone here can help you out and i'm also eager to learn what exactly is the problem with your code and its fix.

Edited by BrentChua
0

Share this post


Link to post
Share on other sites

Do you think using a copy pasted DX11 SDK folder could cause this problem?

 

(I didn't download the sdk again... too lazy... laugh.png )

0

Share this post


Link to post
Share on other sites

I'm not sure... I don't exactly know the exact content of the SDK installer but i'm guessing besides the API it installs some additional DX runtimes in your systems folder as well. That may be a reason to have a crash like a wrong version of the runtime libraries? But then again it should cause an error message just before your app runs instead of having a weird crash.

 

Is the crash a BSOD?

0

Share this post


Link to post
Share on other sites

It even fails when sending the shader: (Though, here it doesn't crash, but it sends an exception [ Access violation reading location 0xBAADF015. ] )

 

devcon->VSSetShader(pVS, 0, 0);

 

, and the shader is created and validated, no errors!

 

This is really wierd.

0

Share this post


Link to post
Share on other sites

Ok, just tweaking, looking and stuff. 

 

And it finally ran! (... in debug mode happy.png ) 

 

But black...

 

So I ran PIX, and found out that the full screen quad was being rendered, with color. So looking over the code again, the stencils weren't being restored properly.

 

But I guess the next goal is to make it run in Release Mode, but for now, I'm just going to play around a bit.

 

Just one question: Can Directx 11 with c++ corrupt the system, or cause BSOD, even if the system is healthy?

 

Thanks for your help! wink.png

0

Share this post


Link to post
Share on other sites

Ok, just tweaking, looking and stuff. 

 

And it finally ran! (... in debug mode happy.png ) 

 

But black...

 

So I ran PIX, and found out that the full screen quad was being rendered, with color. So looking over the code again, the stencils weren't being restored properly.

 

But I guess the next goal is to make it run in Release Mode, but for now, I'm just going to play around a bit.

 

Just one question: Can Directx 11 with c++ corrupt the system, or cause BSOD, even if the system is healthy?

 

Thanks for your help! wink.png

The code itself shouldn't cause BSOD or other "enjoyable" Windows hangs and crashes... 

Any crashes/hangs/BSOD/nuclear disaster/celin dion song/zombie pandemic/etc. caused by a direct3d application are related with the quality of the video drivers only; with the introduction of WDDM (since Vista), most of problems appear as driver crashes with reset to desktop (or just with some seconds of hangs without the application crash if you are lucky)...

Edited by Alessio1989
0

Share this post


Link to post
Share on other sites

 

Ok, just tweaking, looking and stuff. 

 

And it finally ran! (... in debug mode happy.png ) 

 

But black...

 

So I ran PIX, and found out that the full screen quad was being rendered, with color. So looking over the code again, the stencils weren't being restored properly.

 

But I guess the next goal is to make it run in Release Mode, but for now, I'm just going to play around a bit.

 

Just one question: Can Directx 11 with c++ corrupt the system, or cause BSOD, even if the system is healthy?

 

Thanks for your help! wink.png

The code itself shouldn't cause BSOD or other "enjoyable" Windows hangs and crashes... 

Any crashes/hangs/BSOD/nuclear disaster/celin dion song/zombie pandemic/etc. caused by a direct3d application are related with the quality of the video drivers only; with the introduction of WDDM (since Vista), most of problems appear as driver crashes with reset to desktop (or just with some seconds of hangs without the application crash if you are lucky)...

 

 

Phew.. happy.png

 

Ok, thanks!

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • By lonewolff
      Hi Guys,
      I am revisiting an old DX11 framework I was creating a while back and am scratching my head with a small issue.
      I am trying to set the pixel shader resources and am getting the following error on every loop.
      As you can see in the below code, I am clearing out the shader resources as per the documentation. (Even going overboard and doing it both sides of the main PSSet call). But I just can't get rid of the error. Which results in the render target not being drawn.
      ID3D11ShaderResourceView* srv = { 0 }; d3dContext->PSSetShaderResources(0, 1, &srv); for (std::vector<RenderTarget>::iterator it = rtVector.begin(); it != rtVector.end(); ++it) { if (it->szName == name) { //std::cout << it->srv <<"\r\n"; d3dContext->PSSetShaderResources(0, 1, &it->srv); break; } } d3dContext->PSSetShaderResources(0, 1, &srv);  
      I am storing the RT's in a vector and setting them by name. I have tested the it->srv and am retrieving a valid pointer.
      At this stage I am out of ideas.
      Any help would be greatly appreciated
       
    • By bowerbirdcn
      hi, guys, how to understand the math used in CDXUTDirectionWidget ::UpdateLightDir 
      the  following code snippet is taken from MS DXTU source code
       
        D3DXMATRIX mInvView;
          D3DXMatrixInverse( &mInvView, NULL, &m_mView );
          mInvView._41 = mInvView._42 = mInvView._43 = 0;
          D3DXMATRIX mLastRotInv;
          D3DXMatrixInverse( &mLastRotInv, NULL, &m_mRotSnapshot );
          D3DXMATRIX mRot = *m_ArcBall.GetRotationMatrix();
          m_mRotSnapshot = mRot;
          // Accumulate the delta of the arcball's rotation in view space.
          // Note that per-frame delta rotations could be problematic over long periods of time.
          m_mRot *= m_mView * mLastRotInv * mRot * mInvView;
          // Since we're accumulating delta rotations, we need to orthonormalize 
          // the matrix to prevent eventual matrix skew
          D3DXVECTOR3* pXBasis = ( D3DXVECTOR3* )&m_mRot._11;
          D3DXVECTOR3* pYBasis = ( D3DXVECTOR3* )&m_mRot._21;
          D3DXVECTOR3* pZBasis = ( D3DXVECTOR3* )&m_mRot._31;
          D3DXVec3Normalize( pXBasis, pXBasis );
          D3DXVec3Cross( pYBasis, pZBasis, pXBasis );
          D3DXVec3Normalize( pYBasis, pYBasis );
          D3DXVec3Cross( pZBasis, pXBasis, pYBasis );
       
       
      https://github.com/Microsoft/DXUT/blob/master/Optional/DXUTcamera.cpp
    • By YixunLiu
      Hi,
      I have a surface mesh and I want to use a cone to cut a hole on the surface mesh.
      Anybody know a fast method to calculate the intersected boundary of these two geometries?
       
      Thanks.
       
      YL
       
    • By hiya83
      Hi, I tried searching for this but either I failed or couldn't find anything. I know there's D11/D12 interop and there are extensions for GL/D11 (though not very efficient). I was wondering if there's any Vulkan/D11 or Vulkan/D12 interop?
      Thanks!
    • By lonewolff
      Hi Guys,
      I am just wondering if it is possible to acquire the address of the backbuffer if an API (based on DX11) only exposes the 'device' and 'context' pointers?
      Any advice would be greatly appreciated
  • Popular Now