Depth Problem In Release Mode

Started by
13 comments, last by vinterberg 7 years, 12 months ago
Hello,
Sometimes, when I run the EXE file in release mode, I either don't see the depth working at all (most common) or I see a depth problem as it appear in the screenshot:
[attachment=31589:D Problem.png]
I'm doing assert(SUCCEEDED(hr)) on HRESULT for D3D11 initialization functions
I don't have this problem in debug mode, and mostly I don't have this problem if I'm running release mode from visual studio, the problem mostly appear if I'm running the EXE directly from release folder.
I'm using C++ / D3D11
Anyone know what could be causing the problem or how do I debug that kind of problem?
Advertisement

what could be causing the problem or how do I debug that kind of problem?

Could be uninitialized variables.

When compiled in debug mode, visual studio will initialize all variables with well-known values.

It doesn't mean it is initialized to something your code would expect, but at least program's behaviour will be deterministic.

In release mode uninitialized variables will have random garbage, so actual behavior will change randomly between runs, giving weird results.

@vstrakh: I'm doing ZeroMemory() on all the structures that I give to D3D11 in the initialization before I put any values, the weird thing is that the problem occur most of the time when I run the release EXE (but not all the time)

Use RenderDoc to inspect the depthstencil state during your draw calls, in both the broken case and the working case.

I'm doing ZeroMemory() on all the structures that I give to D3D11 in the initialization before I put any values, the weird thing is that the problem occur most of the time when I run the release EXE (but not all the time)

And you don't change render states between draw calls?

You may fill D3D structures correctly, but uninitialized variables in other place makes your code to take wrong actions.

It could be you're filling D3D structs based on wrong inputs.

1. add "while(true){Sleep(0);}" at the beginning of "main"

2. start the application externally

3. attach the debugger

4. break at the Sleep

5. set the next line as the point to continue the execution (right click context menu)

6. debug what's different :)

7. fix it

8. transfer out of gratefulness all your moneyz to my account (that's optional, but 7. might break if you don't.)

@Hodgman: When I start it with RenderDoc, the game crash after few seconds (during loading), when I attach VS debugger, I see it's crashing during a call to D3DX11CreateShaderResourceViewFromFile()

Unhandled exception at 0x0fa813e0 (renderdoc.dll) in Program.exe: 0xC0000005: Access violation writing location 0x00000000.

It's only crashing when I run the program from RenderDoc.

Okay, all the comments were helpful here.

With RenderDoc, I found a warning that the depth stencil buffer size is not the same as the render target view size, so I had to create a depth stencil view for each render target view based on it's size.

I also found that I have uninitialized variable m_depthEnabled

@Hodgman: I'm still trying to get RenderDoc to work, it's still crashing, please check out my above comment

@Krypt0n: Number 8 failed hence number 7 failed as well :D

Do you have any repro details you can share for the RenderDoc crash? e.g. is your application available online anywhere to test?

I found some source project that was using D3DX11CreateShaderResourceViewFromFile(), but it works OK - so I guess it's something particular that's crashing. If you download one of the latest nightly builds it comes with pdbs too, so getting the callstack with file:line information would be helpful.

Glad to see you solved the issue, but you could also find uninitialized variables by using tools like PVS-Studio or CppCheck.

Aether3D Game Engine: https://github.com/bioglaze/aether3d

Blog: http://twiren.kapsi.fi/blog.html

Control

This topic is closed to new replies.

Advertisement