Celestia icon indicating copy to clipboard operation
Celestia copied to clipboard

Add support for backing framebuffer object with renderbuffer

Open levinli303 opened this issue 1 year ago • 2 comments

Most likely viewport effects do not need to read from depth attachment so we can use render buffers when available.

levinli303 avatar Feb 14 '24 02:02 levinli303

let me have some time to check this

375gnu avatar Feb 15 '24 14:02 375gnu

@levinli303 do you have any numbers to show benefit?

375gnu avatar Feb 19 '24 10:02 375gnu

@levinli303 do you have any numbers to show benefit?

I got time to test today, and sadly it seems to consistently and negatively impact the render time at least on iPad (to switch depth attachment from texture to renderbuffer in viewport effect)

For the demo script, the average frame time (without viewport effect) is around 6.45ms the average frame time (with viewport effect renderbuffer as depth attachment) is around 6.57ms the average frame time (with viewport effect texture as depth attachment) is around 6.5ms

levinli303 avatar Mar 04 '24 12:03 levinli303

but in terms of memory usage after booting up:

no viewport effect: 522.3M viewport effect renderbuffer as depth attachment: 525.8M viewport effect texture as depth attachment: 558.8M

it seems a good win to switch to render buffer.

levinli303 avatar Mar 04 '24 12:03 levinli303

What resolution your ipad has?

375gnu avatar Mar 05 '24 14:03 375gnu

What resolution your ipad has?

2388 x 1668.

levinli303 avatar Mar 06 '24 01:03 levinli303

What resolution your ipad has?

2388 x 1668.

The it should use 15MB less, not 30. Am I correct?

375gnu avatar Mar 06 '24 09:03 375gnu

The it should use 15MB less, not 30. Am I correct?

my bad. it seems GL_DEPTH_COMPONENT24 should be used instead of GL_DEPTH_COMPONENT in glRenderbufferStorage. and in my previous test, glCheckFramebufferStatus has been returning GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT thus the framebuffer is not really used for viewport effect.

After correcting this, the memory usage and render time of the two were negligible.

levinli303 avatar Mar 07 '24 14:03 levinli303