简体   繁体   中英

Direct3D11 shaders compile flags problems

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 (ie 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).

The first thing you should try is to use theD3DCompiler API directly rather than using the deprecated D3DX11 'wrapper' for it. Currently you are using the "#43" June 2010 release of the HLSL compiler, and there's been many bug-fixes since. The Windows 10 SDK provides the "#47" version of the HLSL compiler.

Note that with VS 2012 or later, you need to use some special setup to make sure your include/lib paths are correct for mixing the legacy DirectX SDK with the modern Windows 10 SDK which has many newer, overlapped headers. See Microsoft Docs .

See this blog post for more about the D3DCompile API.

Frank's book is excellent, but it was published before the DirectX SDK was deprecated. See this blog post for relevant notes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM