HLSL:最终像素颜色与像素着色器的计算返回值不同

horiac7

阅读并尝试应用如何启用硬件百分比更紧密过滤后的建议?进入像素着色器时,调试时得到了一些非常奇怪的结果-尽管着色器返回了更大的RGBfloat4值,但所有像素的RGB值都非常低

此问题仅在使用硬件(GPU)表现出来,并且在强制WARP(通过DirectX控制面板)时表现正常我以为是驱动程序问题,但是在两台不同的计算机上进行了测试,一台装有移动nVidia GPU,另一台装有台式机AMD卡,并且两者的行为相同-只能按预期使用WARP。

请查看以下调试Pixel Shader的屏幕快照,我认为这些屏幕快照对我遇到的问题很有帮助:

使用常规硬件运行来调试像素着色器: 在此处输入图片说明

在“ Graphics Pixel History”中的“ Pixel Shader” RGB值和“ Result”值中查看返回值-并在右侧-它们有何不同?几乎除以3因子。

Now, take a look at the same debugging - on a similar shadowed pixel - when running the same shader - only now using WARP instead of running on the GPU: 在此处输入图片说明

As you can see, the values are nearly identical - and I think the small diferences are because of the render target being 8 bit per channel while the float is 4 bytes (32 bits).

My previous version of the shader was inspired by this blog post and snippets, and : https://takinginitiative.wordpress.com/2011/05/25/directx10-tutorial-10-shadow-mapping-part-2/

I implemented a 16-tap PCF - taking 16 samples with the Sample function instead of using the SampleCmpLevelZero func and doing the comparison with the target value myself, in the shader - for deciding the extent the pixel should be shadowed. Upon reading the question mentioned above - I modified my shader to use SampleCmpLevelZero and that's when my problems appeared and my shaders only behaved as expected with WARP.

Can someone give me some suggestion on what else to check to further debug this situation?

horiac7

After enabling the D3D Device Debugging - following the valuable instructions from here - I got the following message - and hence found out the cause for my issue:

D3D11错误:ID3D11DeviceContext :: DrawIndexed:Pixel Shader单元的插槽1中的Shader资源视图正在使用格式(R16_FLOAT)。此格式不支持“ SampleCmp”或“ SampleCmpLevelZero”,着色器正在资源上至少使用其中一种。如果着色器实际使用了视图,则此不匹配无效(例如,由于着色器代码分支而没有跳过该视图)。[执行错误#372:DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_C_UNSUPPORTED]

这与我已设置DXGI_FORMAT_R16_FLOAT选项的深度纹理有关更改为DXGI_FORMAT_R32_FLOAT已解决此问题,并允许我通过启用PCF SampleCmpLevelZero

我想这是出于道德上的考虑,启用DirectX设备调试以找出您的执行是否处于损坏或错误状态非常有用。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

TOP 榜单

热门标签

归档