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

4

7

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.

Rapparee answered 21/6, 2012 at 13:18 Comment(1)
Are you debugging this on the same machine that built your app?Urinalysis
M
3

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.

Mormon answered 7/2, 2013 at 11:35 Comment(1)
This is a different issue. When you are in Graphics Diagnostics mode and using the debugging options in a graphics capture, then by default you are debugging graphics already. The MSDN bullet point means you cannot put CPU breakpoints while stepping through HLSL code, and vice versa.Splenetic
S
4

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.

Splenetic answered 1/10, 2013 at 16:28 Comment(0)
S
3

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.

Sibilla answered 30/7, 2012 at 10:36 Comment(1)
Something similar is for SharpDX (Toolkit), e.g., var compiledEffect = (new EffectCompiler()).CompileFromFile(@"Content\MiniTri - Copy.fx", EffectCompilerFlags.Debug|EffectCompilerFlags.SkipOptimization);Preordain
M
3

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.

Mormon answered 7/2, 2013 at 11:35 Comment(1)
This is a different issue. When you are in Graphics Diagnostics mode and using the debugging options in a graphics capture, then by default you are debugging graphics already. The MSDN bullet point means you cannot put CPU breakpoints while stepping through HLSL code, and vice versa.Splenetic
P
1

I was able to debug shaders in VS2012.

I used this command line:

fxc /TTargetProfile /EShaderMainFunctionName /Od /Zi /FdMyShader.pdb MyShaderFile

In code, I used:

D3DX11CompileFromFile(filename, NULL, NULL, "ShaderMainFunctionName, "TargetProfile", D3D10_SHADER_DEBUG | D3D10_SHADER_SKIP_OPTIMIZATION, ...);

TargetProfile is something like vs_5_0 or ps_5_0.

I'm pretty sure it would work with D3DCompile.

When I forgot to put D3D10_SHADER_DEBUG | D3D10_SHADER_SKIP_OPTIMIZATION, and I tried to load the pdb file manually, it said the symbols didn't match.

When I got it right, the Pixel Shader in the Pixel History view was a blue link. When I clicked it, it automatically loaded the correct file and I could start debugging it.

I couldn't find an in-code equivalend to /Fd that generated the pdb file, which is why I had to go through command line.

Penton answered 7/2, 2014 at 2:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.