Jump to content
  • Advertisement
Sign in to follow this  
cskelton

[SOLVED]MRT problem

This topic is 3999 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am rendering to four different textures that I use later in the same frame to do post processing(deferred renderer). The first pass goes well, but then on the second go around I get this: Direct3D9: (WARN) :Can not render to a render target that is also used as a texture. A render target was detected as bound, but couldn't detect if texture was actually used in rendering. What i'm doing is essentially this: clearRenderTarget( 0xFF000000 ) x4 //clear all textures to black setRenderTarget x4 render resetRenderTarget x4 //resets first render target(0) to the back buffer and everything else to NULL setTexture x4 render2 resetTexture x4 //this is a settexture with the name of the texture and NULL as arguments as you can see by my brilliantly composed pseudocode, I am resetting the rendertargets before I use them as textures, and reseting the textures before I use them as render targets again. Any insights? Thanks in advance, c [Edited by - cskelton on November 6, 2007 5:10:31 PM]

Share this post


Link to post
Share on other sites
Advertisement
That warning tells you that you've got that render target selected in one of the source texture stages when you begin rendering to it, and D3D can't both render to and from one texture at the same time.

The simplest solution is just to do a for (int n=0; n < 8; n++) SetTexture(n, NULL); before changing render target.

Share this post


Link to post
Share on other sites
Sweet, that could definitely work. I'm a little confused on something though...

But since i'm using shaders, all I ever do is call effect->settexture( texName, texture ), and I don't use d3dDevice->settexture( stage, texture ). And I reset all the textures to NULL by name, so would I still have to run through each stage and set it to NULL? It seems counter-intuitive to have to go reset the stages when I'm not technically using them...

Share this post


Link to post
Share on other sites
Does anyone have an idea what's going on? I tried Adam_42's idea, and it worked, but I'm not sure why...I call setTexture( name, NULL ) on every texture from the effect. Why would I also have to call it from the device as well?

Share this post


Link to post
Share on other sites
The reason that the textures were not resetting completely is that I was resetting them and then calling setrendertarget before the effect had a chance to update the d3d state.

A better version of my pseudocode can explain this:

//build pass
clearRenderTarget( 0xFF000000 ) x4 //clear all textures to black
setRenderTarget x4
SetTechnique
render
resetRenderTarget x4 //resets first render target(0) to the back buffer and everything else to NULL
//lighting pass
SetTechnique
setTexture x4
render2
resetTexture x4 //this is a settexture with the name of the texture and NULL as arguments

the state gets saved, or not, when you call the d3d effect function begin( numpasses, flags ) and gets reset, or not, when you call End(). In order to fix this problem, I simply set it to save the state when it ran the lighting pass. That way, when End() gets called, the state is restored, and voila, no texture bound.

Thanks, Adam_42, for setting my thinking on the right path. When I realized that I actually had to reset the texture stages, it got me thinking about it, and with a little help, realized that the d3d state wasn't being updated.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!