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

Started by
2 comments, last by MetaKnight 14 years, 1 month ago
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
Advertisement
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.
That would explain what I'm seeing!

Thanks for the quick response,
T
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!

This topic is closed to new replies.

Advertisement