Post

Replies

Boosts

Views

Activity

Reply to Using the same texture for both input & output of a fragment shader
Thank you both for your answers, however, I'm afraid they're assuming knowledge I'm lacking. This is my first foray into graphics programming so I suffer from the not knowing what I don't know syndrome. Let me make it clear what I'm trying to do: The setup: I'm working on a 2D graphics app targeting only iOS devices, using the latest Metal. Probably should have mentioned that earlier! What I'm trying to do (simplifying a bit) is blend multiple color layers using my own blending functions into a "master" texture. The implementation is a bunch of single-quad render passes, one per layer, where I use a fragment shader to blend the master texture (initially cleared) with the current layer. I output the result to the same master texture. Think reduce(blend, layers). So what we have is a fragment shader taking in a bunch of inputs, among them the master texture for reading, and outputting to that same master texture as an output color attachment. It only ever reads and writes to the same pixel location (so definitely same tile, IIUC). I realize I could avoid this by ping-ponging between 2 master textures, but that's exactly my question: am I supposed to? Why? Would it be more efficient for some reason? I'm trying to learn here :) Thanks ahead!
3w