Benefit of glInvalidateFramebuffer with shared attachments

Greetings,

as far as I know, glInvalidateFramebuffer can be used to prevent expensive copy operations for FBO attachments that are not used anymore after the FBO is unbound for the time being using glBindFramebuffer.

My question now is:

What happens if the FBO we come from shares an attachment with the FBO we switch to (like depth/stencil attachment) ? Is there any benefit from invalidating said attachment before switching away from the old FBO or is it even hurtful (since it is still used by the other FBO).

Problem is the documentation leaves me a littble bit confused whether glInvalidateFramebuffer is about saving FBO-attachment memory or attachment memory or both.

Regards

Hi,

glInvalidateFramebuffer prevents storing on-chip framebuffer data into main memory.

The benefit would be not writing out data to main memory. It could hurt as you loose all contents.

It sounds like you are confusing FBO memory and all that. Basically there’s a piece of memory allocated for the texture bound to an FBO somewhere in your DRAM. There’s also a tile memory located on the GPU (on-chip) which is much faster and has way more bandwidth. By invalidating an FBO you avoid storing tile memory into your DRAM (which is a lot slower and has less bandwidth).

I hope that explains.

Marton

Hello,

according to the glInvalidateFramebuffer spec, the function allows to declare the contents of FBO attachments no longer needed. My assumption was, that this means that the texture in DRAM is not updated with the data from the tile memory if the FBO is unbound. Now what I wonder about is what happens if the same texture is bound as attachment to two subsequently used FBOs. Will the gpu realise that it can reuse the tile memory belonging to said attachment and not copy at FBO change?

Hi,

no, the GPU will not re-use tile memory. For that you need to use PLS or Framebuffer fetch.

bests,
Marton

Ok, we’re zeroing in on the issue:

If I use glInvalidateFramebuffer with a certain attachment on a bound FBO will it only invalidate data belonging to the attachment in the context of the FBO or will the texture bound to the attachment become useless too?

Hi,

I think your texture data will probably be “undefined” after invalidating the FBO to which your texture is attached to.
"
invalidate the entire contents of a specified set of attachments of a framebuffer

The entire contents of each specified attachment become undefined after execution
"

bests,
Marton

now, we probably don’t do anything to the data, so if you try to read it as a texture you might get whatever was last written to it (ie. you’ll get whatever is currently in those bits), but it’s not guaranteed to contain anything. The GL driver might recycle that piece of memory etc.

© Imagination Technologies Limited. All rights reserved.
Privacy PolicyTerms & ConditionsTrademarksCookies