简体   繁体   中英

Having trouble adding more Texture2D's as Pixel Shader resources in DirectX 11

I'm having a really annoying problem with my application that is a school project. I'm using deferred rendering and I'm trying to add positions from the light's pov as a new g-buffer texture, and the depth buffer texture as a shader resource in the light pass. I handle all of the g-buffer textures in the exact same way.

My problem is that these new shader resources are nowhere to be found on the GPU! I'm using RenderDoc to debug my application, and there I can see everything being written to these new resources just fine, and the call to bind them as shader resources looks good as well, but I still only have the 4 resources in the light pass that I had before.

My code is an absolute mess, and there's a lot(!) of it. So if you want to see something specific to be able to help me, I can post it.

I'd be really happy if I just got some tips as to how you go about debugging this kind of problem, and even happier if someone knows what the problem is.

Thanks in advance!

There are two essential first steps for debugging DirectX applications:

  • Make sure that for every function that returns an HRESULT that you check it at runtime. If it is safe to ignore the return, it would return void . When checking the HRESULT don't use == S_OK , but use the FAILED or SUCCEEDED macro instead. A nice option for 'fast fail' errors is to use C++ exception handling via ThrowIfFailed .

  • Enable the DirectX Debug Device and look for errors, warnings, and other messages in the debug output window. For details on enabling it, see Anatomy of Direct3D 11 Create Device and Direct3D SDK Debug Layer Tricks .

This may not solve your problem, but can really help avoid some silly mistakes that cost you a lot of time to track down.

If you are new to DirectX development, take a look at the DirectX Tool Kit tutorials

For debugging DirectX 11 applications, the Visual Studio Graphics diagnostics feature in VS 2012 or later is a good option. You likely fit the license requirements to use the VS 2013 or VS 2015 Community edition , and it includes all features including the VSGS. See MSDN .

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