简体   繁体   English

在DirectX 11中添加更多Texture2D作为Pixel Shader资源时遇到问题

[英]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. 我正在使用延迟渲染,并尝试将光源的pov中的位置添加为新的g缓冲区纹理,并将深度缓冲区纹理添加为光通道中的着色器资源。 I handle all of the g-buffer textures in the exact same way. 我以完全相同的方式处理所有的g缓冲区纹理。

My problem is that these new shader resources are nowhere to be found on the GPU! 我的问题是在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. 我正在使用RenderDoc调试我的应用程序,在那里我可以看到一切都写到了这些新资源上,并且将它们绑定为着色器资源的调用看起来也不错,但是我仍然只有4个资源通过我以前的经历。

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: 调试DirectX应用程序有两个基本的第一步:

  • Make sure that for every function that returns an HRESULT that you check it at runtime. 确保在运行时检查返回HRESULT每个函数。 If it is safe to ignore the return, it would return void . 如果可以安全地忽略该返回,则它将返回void When checking the HRESULT don't use == S_OK , but use the FAILED or SUCCEEDED macro instead. 检查HRESULT请勿使用== S_OK ,而应使用FAILEDSUCCEEDED宏。 A nice option for 'fast fail' errors is to use C++ exception handling via ThrowIfFailed . 对于“快速失败”错误,一个不错的选择是通过ThrowIfFailed使用C ++异常处理。

  • Enable the DirectX Debug Device and look for errors, warnings, and other messages in the debug output window. 启用DirectX调试设备,并在调试输出窗口中查找错误,警告和其他消息。 For details on enabling it, see Anatomy of Direct3D 11 Create Device and Direct3D SDK Debug Layer Tricks . 有关启用它的详细信息,请参见Direct3D 11创建设备剖析Direct3D SDK调试层技巧

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 如果您不熟悉DirectX开发,请查看DirectX Tool Kit教程。

For debugging DirectX 11 applications, the Visual Studio Graphics diagnostics feature in VS 2012 or later is a good option. 对于调试DirectX 11应用程序,VS 2012或更高版本中的Visual Studio图形诊断功能是一个不错的选择。 You likely fit the license requirements to use the VS 2013 or VS 2015 Community edition , and it includes all features including the VSGS. 您可能符合使用VS 2013或VS 2015 Community Edition的许可要求,并且它包括VSGS在内的所有功能。 See MSDN . 参见MSDN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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