Hi! It’s me yet again. I’m finished with my little compositor adventures for the time being, but I’m running into random error messages when running the effect, at seemingly random times. I’ve done everything I could to make sure those disappear, I’m checking if the textures are valid every _render_callback() before dispatching the shader, and it simply isn’t going away.
Those RIDs belong to the SubViewport’s render scene buffers. The main effect reads them back on its own callback afterwards as masktex and binds them at binding 1, which is the binding your error names, so I’m fairly confident that’s the texture going missing rather than any of the main viewport’s own.
Scene buffers get torn down and rebuilt when a viewport is reconfigured, and main_effect.gd line 191 sets aux_viewport.size = target_viewport.size every frame. On any frame where that size actually changes, the aux viewport rebuilds its buffers and the RID the main effect is still holding refers to a texture that isn’t there anymore. That would fit the randomness, since it’d only bite when a rebuild lands between the aux callback and yours.
As for the checks not catching it, RID.is_valid() only reports whether the id is non zero. It doesn’t ask the RenderingDevice whether the resource behind it still exists, so a handle to a freed texture sails through every one of those guards. That’s likely why adding more of them hasn’t moved anything.
What I’d try is copying instead of referencing. You already create and own prev_tex through texture_create, so the same treatment for mask and depth, have the aux effect copy its color and depth into textures the main effect owns and bind those. Then the lifetime belongs to you and a viewport rebuild can’t pull them out from under the dispatch. The destination would need CAN_COPY_TO in its usage bits.