Hi,
Is it possible to use a texture both as a render target (color attachment) and as a normal texture inside a fragment shader ?
I want to read the texture content inside a fragment shader, and also use the same texture as a color attachment to write on it...
My attempt to set such a configuration was accepted at runtime, but I want to be sure that there is no side effect...
if small amount of texture gets covered, then copy out just these texels. For example by coupling same vertex shader you use for running depth peeling with simple fragment shader reading from texture values of which you want to save. Be careful to setup rendering pass so that load operation is "don't care".
If I understand what you're doing then, with many passes per frame, it makes sense to conserve bandwidth.
Alternate solution is to use buffers, with 2D raster organized on your own. You can read and write these in single compute kernel execution. But then you have other problems, for example with operating on a part of buffer only. The only way to make sure is to implement alternative versions and profile.
hope that helps
MIchal