Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging Shaders on Visual Studio 2012, can't find the Symbols

I don't know if many of you tried the new excellent feature of Visual Studio 2012 to debug Direct3D based apps.

I successfully capture a frame of my app, then I want to debug the execution of a Vertex Shader: enter image description here

I click on the green triangle to debug a given vertex, but I got a "No Symbol Found" message which prevent me to debug it.

Someone knows what to do for Visual Studio to find the symbols?

Thanks.

like image 905
Nock Avatar asked Jun 21 '12 13:06

Nock


3 Answers

When using SlimDX you can pass ShaderFlags to the shader compiler. Passing ShaderFlags.Debug causes debug symbols to be included.

var bytecode = ShaderBytecode.CompileFromFile("shader.fx", "VShader", "vs_4_0", ShaderFlags.Debug, EffectFlags.None)

Hopefully it is something similar in native Direct3D.

like image 45
James Hulse Avatar answered Sep 19 '22 04:09

James Hulse


You need to compile your shaders with debug information. And in order to reliably debug, you likely will want to disable optimizations as well. Depending on how you compile your shaders, this will be one of two ways:

D3DCompile / D3DCompileFromFile: Pass the D3DCOMPILE_DEBUG and D3DCOMPILE_SKIP_OPTIMIZATION flags to D3DCompile. Note that depending on D3D version and whether you are using D3DX, these flags might have different prefixes.

fxc.exe: The compile flags have switch equivalents. For D3DCOMPILE_DEBUG, pass /Zi to fxc. For D3DCOMPILE_SKIP_OPTIMIZATION, pass /Od.

Visual Studio 2012 is fairly smart about finding the source for your shaders based on the embedded debug information, but should it fail to do this, it will prompt you to point to the appropriate file.

like image 83
Camille Avatar answered Sep 19 '22 04:09

Camille


From msdn:

It's not possible to debug an app and its shader code at the same time. However, you can alternate between them

It's possible that you are debugging the application and trying to debug shader at the same time.

like image 31
ghord Avatar answered Sep 18 '22 04:09

ghord