🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Directx11 compile shaders

Started by
7 comments, last by markypooch 3 years, 4 months ago

I am reading a book from Frank Luna 3D Game Programming with DirectX 11.

I was using D3DX11CompileFromFileW() function to compile shaders with flag (D3D10_SHADER_DEBUG | D3D10_SHADER_SKIP_OPTIMIZATION) and it was working ,but in new projects and some more advanced programs although the project is compiled without errors it does not display objects.

After a lot working on it I realized if I use flag (D3D10_SHADER_DEBUG) or just (D3D10_SHADER_SKIP_OPTIMIZATION) it works properly but does not work when I OR them together (i.e D3D10_SHADER_DEBUG | D3D10_SHADER_SKIP_OPTIMIZATION )

I also tried fxc compiler and I ran into the same problem. Is there any solution to use the flags together or maybe I can use only one of them (I have use them together in many projects but not recently. The book also use them together).

Advertisement

You are using D3D11 right?

Try using D3D11_SHADER_DEBUG | D3D11_SHADER_SKIP_OPTIMIZATION

markypooch said:

You are using D3D11 right?

Try using D3D11_SHADER_DEBUG | D3D11_SHADER_SKIP_OPTIMIZATION

These are all just #defines with the same values behind them.

#define D3D10_SHADER_DEBUG (1 << 0)
#define D3D11_SHADER_DEBUG (1 << 0)
#define D3DCOMPILE_DEBUG (1 << 0)

Changing the define used won't make a single bit of difference. You could even pass in the raw values and get the same result.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

@21st Century Moose Begs the question why it wouldn't just be called D3D_SHADER_DEBUG, D3D_SHADER_SKIP_OPTIMIZATION in that case. Unless I'm missing something here…

markypooch said:

@21st Century Moose Begs the question why it wouldn't just be called D3D_SHADER_DEBUG, D3D_SHADER_SKIP_OPTIMIZATION in that case. Unless I'm missing something here…

It is in the D3DCompile API. Still the same value though.

#define D3DCOMPILE_DEBUG (1 << 0)

But here's the thing. Because it's a #define, because it's evaluated at (C/C++) compile time, you could compile a Direct3D 12 shader, use D3D10_SHADER_DEBUG (or even D3DXSHADER_DEBUG from the old DirectX 9 API, which also had the same value), and it wouldn't make a single bit of difference.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

For sure, but why have distinct defines for different D3D versions that are defined as the same thing? Something, something xbox?

markypooch said:

For sure, but why have distinct defines for different D3D versions that are defined as the same thing? Something, something xbox?

Don't ask me, ask Microsoft. Nonetheless, everything I said above holds true - they are just defines and your suggestion to use D3D11_ variants is unhelpful to the OP (as is your continued misunderstanding of how this actually works).

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Someones awfully aluminum today. While your lecture on blindingly obvious facts about how the preprocessor works is most welcomed. Maybe I should have checked what those defines evaluated to.

@arshia Have you tried RenderDoc, or have experience with graphics debugging tools? I assume the shader is plucked from frank lunas book. One thing I do recall is that text making heavy use of the effects framework which I remember little of, is it all the examples, or just some later ones? If possible, you could try using a tool like RenderDoc, and step through your shader, and see precisely whats happening. Without the flag for skipping optimization, it might not be very intuitive, but it's worth a shot.

Additionally, D3DX11 is deprecated, so one easy thing you could try is just replacing the call D3DX11CompileFromFileW with D3DCompileFromeFile the latter function can be found in d3dcompiler.h

This topic is closed to new replies.

Advertisement