Texture Feedback

Has anyone tried using an RGBA texture as both and output and input. I realise this is not advised but I wonder if it would be possible to use the R channel as the output while reading from the B channels. Technically it is feedback but I would have thought it could be possible if they were on separate color channels, using a glcolor mask to ensure B channel is not written to ?

Thanks for any info

Hi John,

As far as I am aware reading & writing to the same texture (FBO attachment) could result in undefined behavior (may return garbage data); to prevent this the attachment should only be a data source or target not both at the same time. I would recommend using two textures, i.e. fill the first texture with some data then set it as an input to the next stage in your pipeline and use the second texture as an output. If you only require one channel you can set the texture format to R8 which will give you a texture with a single 8 bit channel.

Kind regards,
Shaun

Thanks for the reply Shaun,
Just leaving this as a note here - I did manage to get this working in the end, of course as I said at the outset, this is not a recommended approach. In our case we were very careful to ensure both reading (texture2d) and writing was not done to the same color channel.

Regards

Hi John,

I am glad to hear you got this working, one thing to keep in mind though is that different devices may handle this situation differently so it may work on one platform but not on another, the behavior is dependent on the implementation provided by the graphics driver.

Kind Regards,
Shaun