Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unbinding shader resources

If you want to unbind a shader resource in directx11, all code I've found does something along these lines:

ID3D10ShaderResourceView* nullSRV[1] = {nullptr};
context->PSSetShaderResources(0, 1, &nullSRV);

Why not simply use this?

context->PSSetShaderResources(0, 0, nullptr);

It seems supported by the docs (https://msdn.microsoft.com/en-us/library/windows/desktop/ff476473%28v=vs.85%29.aspx), is there really any difference between the two?

like image 555
KaiserJohaan Avatar asked Apr 21 '15 12:04

KaiserJohaan


1 Answers

In the first case, you are unbinding one SRV, starting in slot zero. In the second case, you are not unbinding anything because NumViews is zero. If you wanted to unbind in the second case, you'd have to use:

context->PSSetShaderResources(0, 1, nullptr);

However, this will cause the runtime to crash:

D3D11 CORRUPTION: ID3D11DeviceContext::PSSetShaderResources: Third parameter corrupt or unexpectedly NULL. [ MISCELLANEOUS CORRUPTION #15: CORRUPTED_PARAMETER3]

This is why the first form is used.

like image 139
MuertoExcobito Avatar answered Nov 09 '22 02:11

MuertoExcobito