Jump to content

  • Log In with Google      Sign In   
  • Create Account


Unbind render targets and resource viewes


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Tournicoti   Prime Members   -  Reputation: 683

Like
0Likes
Like

Posted 09 March 2012 - 09:47 AM

Hello

I regularly get this kind of warnings :

D3D10: WARNING: ID3D10Device::OMSetRenderTargets: Resource being set to OM RenderTarget slot 0 is still bound on input! [ STATE_SETTING WARNING #9: DEVICE_OMSETRENDERTARGETS_HAZARD ]

As an example, I get this message from this code :
bool renderEmissiveBlur(UINT sizeOfVertexQuad,ID3D10Buffer * quadBuffer)
{
  d3dDevice->IASetInputLayout(quadInputLayout);  UINT offset=0;
  UINT stride=sizeOfVertexQuad;
  d3dDevice->IASetVertexBuffers(0,1,&quadBuffer,&stride,&offset);

  d3dDevice->OMSetRenderTargets(1,&renderTargetView_WT,NULL);
  if (!emissiveBlurEffect.setResourceVariable("g_Texture",shaderResourceViewes[2])) return false;
  ID3D10EffectTechnique * technique=emissiveBlurEffect.getTechnique("EMISSIVEBLURH");
  if (technique==NULL) return false;
  if FAILED(technique->GetPassByIndex(0)->Apply(0)) return false;  d3dDevice->Draw(6,0);
d3dDevice->OMSetRenderTargets(1,&renderTargetViewes[2],NULL); (triggers the warning message)
  if (!emissiveBlurEffect.setResourceVariable("g_Texture",shaderResourceView_WT)) return false;  technique=emissiveBlurEffect.getTechnique("EMISSIVEBLURV");
  if (technique==NULL) return false;
  if FAILED(technique->GetPassByIndex(0)->Apply(0)) return false;
  d3dDevice->Draw(6,0);  return true;
}

(it's used to blur the emissive layer in the G Buffer)

So what should I do to unbind properly my resources (renders targets and resource viewes) please ?

Thank you

Nico

Sponsor:

#2 kauna   Crossbones+   -  Reputation: 2279

Like
1Likes
Like

Posted 09 March 2012 - 10:32 AM

Seems that texture object related to renderTargetViewes[2] is bound as a texture somewhere? (PSSetShaderResources)

Simply call PSSetShaderResources again with the same Index and an array containing NULL pointer.

Best regards!

#3 Tournicoti   Prime Members   -  Reputation: 683

Like
0Likes
Like

Posted 09 March 2012 - 12:07 PM

Hello kauna and thank you it works fine with what you said.

So : after the first draw call, I added this (as a test) :
  ID3D10ShaderResourceView * tab[1];
  tab[0]=NULL;
  d3dDevice->PSSetShaderResources(0,1,tab);
.... and the warning vanished !
I can now fix this at all the locations where this warning occurs Posted Image

Nico

#4 Tsus   Members   -  Reputation: 1003

Like
1Likes
Like

Posted 09 March 2012 - 04:34 PM

When I’m coding, I sometimes realize that I need an additional shader resource view in a shader and then - of course - add it in the rendering loop. Unfortunately, I constantly keep forgetting to unbind the newly added SRV at the end of the function. Posted Image …which can lead to such errors you had before, e.g.:
ID3D10ShaderResourceView* srvs[2] = {m_srv0, m_srv1};
d3dDevice->PSSetShaderResources(0, 2, srvs);
// some draw calls…
ID3D10ShaderResourceView* nosrvs[1] = {0}; // I forgot to unbind the second srv...
d3dDevice->PSSetShaderResources(0, 1, nosrvs);

To keep my mind from this, I’m sometimes lazy and just unbind everything.
ID3D10ShaderResourceView* srvs[D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT] = {0};
d3dDevice->PSSetShaderResources(0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, srvs);

Maybe this helps you to prevent some errors. Posted Image
Cheers!

Acagamics e.V. – IGDA Student Game Development Club (University of Magdeburg, Germany)


#5 Jason Z   Crossbones+   -  Reputation: 4846

Like
1Likes
Like

Posted 09 March 2012 - 06:12 PM

Or you can go one step further and create a simple layer between your engine and the API calls that monitors what is set and what isn't. Then you can unbind only the necessary views in between stages, and develop customized ways to handle when you are trying to write to a resource that is bound for input or vice versa. Hieroglyph 3 uses this concept, but only in a simple way...

#6 360GAMZ   Members   -  Reputation: 133

Like
0Likes
Like

Posted 10 March 2012 - 06:08 PM

Jason, FWIW, I hope Microsoft addresses this in a future release. It would be nice if when you bound a resource, DX just automatically unbound it from whatever it was bound to before. If DX did this, we'd all benefit from it instead of each of us having to write that management layer!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS