PDA

View Full Version : shader: same texture as source and destination



rexguo
04-20-2009, 09:23 AM
I need to implement a kind of accumulation buffer,
which means reading from the buffer, perform some
shader ops on it, and write the data back to the
same buffer. Is it possible to set this up without
having to make a separate copy of the buffer?
TIA!

.rex

Jan
04-20-2009, 09:45 AM
Nope, only if your operations can be done through blending.

Otherwise use ping-pong RTT.

Jan.

rexguo
04-20-2009, 09:55 PM
Thanks Jan!

Jackis
04-21-2009, 06:20 AM
By the way, rexguo, if you are targeting nVidia hardware, you can use the same texture for input and output (but it's kinda hack). It is unpredictable result following the spec, but reality shows, that if you are reading from the same texel, where you are going to write modified value - it works. But you must be very careful, because that option is no way legal, and this approach may not work on future chipsets (for example).