'Shader resource view' problem

Started by
5 comments, last by DividedByZero 6 years, 8 months ago

Hi Guys,

I am revisiting an old DX11 framework I was creating a while back and am scratching my head with a small issue.

I am trying to set the pixel shader resources and am getting the following error on every loop.

Quote

D3D11 WARNING: ID3D11DeviceContext::PSSetShaderResources: Resource being set to PS shader resource slot 0 is still bound on output! Forcing to NULL. [ STATE_SETTING WARNING #7: DEVICE_PSSETSHADERRESOURCES_HAZARD]

As you can see in the below code, I am clearing out the shader resources as per the documentation. (Even going overboard and doing it both sides of the main PSSet call). But I just can't get rid of the error. Which results in the render target not being drawn.


	ID3D11ShaderResourceView* srv = { 0 };
	d3dContext->PSSetShaderResources(0, 1, &srv);

	for (std::vector<RenderTarget>::iterator it = rtVector.begin(); it != rtVector.end(); ++it)
	{
		if (it->szName == name)
		{
			//std::cout << it->srv <<"\r\n";
			d3dContext->PSSetShaderResources(0, 1, &it->srv);
			break;
		}
	}

	d3dContext->PSSetShaderResources(0, 1, &srv);

 

I am storing the RT's in a vector and setting them by name. I have tested the it->srv and am retrieving a valid pointer.

At this stage I am out of ideas.

Any help would be greatly appreciated :)

 

Advertisement

You are missing a call to clear the given shader resource view as a render target.

Thanks man, which call is that though? I'm drawing a blank here - Hehe.

Arrgh, simple mistake in the end. I wasn't setting the back buffer as the target before drawing the render target back.

In this case, the error reported back was misleading.

8 hours ago, lonewolff said:

D3D11 WARNING: ID3D11DeviceContext::PSSetShaderResources: Resource being set to PS shader resource slot 0 is still bound on output! Forcing to NULL. [ STATE_SETTING WARNING #7: DEVICE_PSSETSHADERRESOURCES_HAZARD]

This warning usually means that the resource you're using in **SetShaderResources is bound as a render target.  The D3D11 runtime will remove it for you and give you a warning, but for correctness (warning-free output) you should either overwrite what's bound to the output merger before setting the shader resources


OMSetRenderTargets(1, &newRTV, nullptr);

or clear what's currently bound by setting it to null:


OMSetRenderTargets(0, nullptr, nullptr);

 

Cool, that makes sense.

Sounds like I got rid of the error (unknowingly) by setting the backbuffer as the render target, in you OMSetRenderTargets() example.

Thanks again!

This topic is closed to new replies.

Advertisement