Jump to content
  • Advertisement
lonewolff

DX11 'Shader resource view' problem

Recommended Posts

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 :)

 

Edited by lonewolff

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites
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);

 

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!