Sign in to follow this  
blairhartley

[DX9, C++] Pixel shader texture sources and targets

Recommended Posts

blairhartley    187
I have no doubt this is a stupid question, but... Is there any reason why I can't have a pixel shader that renders to a particular texture whilst using the same texture as one of its sources? Is this possible? If so, is there anything I need to look out for? Thanks in advance, Tim

Share this post


Link to post
Share on other sites
Evil Steve    2017
That's not valid in D3D9 (I don't know about D3D10). If you do that with the debug runtimes, you'll get errors about it, with the release runtimes it might work, or it might not - it depends on the driver.

The reason is that pixel shaders run in parallel - if you have an 8x8 texel region being processed by 64 pixel shader units, and each one needs to read from some of those 8x8 pixels, there's no way to tell what data is new and what is old, meaning the results wouldn't be deterministic.

You'll need to use two textures and alternate between them.

Share this post


Link to post
Share on other sites
MetaKnight    258
As far as I know you cannot do this.

So you'll have to create another texture to render to, and depending on what you're doing you'll want to switch the textures so you can read from the last rendered texture next frame.

edit: damn Evil Steve, you fast!

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

Sign in to follow this