floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
6.54k stars 469 forks source link

skip framebuffer invalidation when possible #1001

Closed danielchasehooper closed 4 months ago

danielchasehooper commented 4 months ago

sokol was invalidating the depth/stencil attachment when there was none attached. Because of this, we were seeing webGL's gl.InvalidateFramebuffer in performance profiles when the call wasn't needed at all.

This PR only clears the depth or stencil attachments if the pass has a depth/stencil attachment.

floooh commented 4 months ago

Good fix, thanks! Interesting that a function like glInvalidateFramebuffer() shows up in performance profiling, I would expect that this is more or less a no-op.

I'll replace the != 0 with != SG_INVALID_ID though and then merge.

(PS: maybe on WebGL it's actually clearing the framebuffer pixels to not leak information, dunno)

floooh commented 4 months ago

Ok, I did this minor code style fixed and merged: https://github.com/floooh/sokol/commit/d7110f6b9e2b4f8b460943b9f1a3d9e2738758c0

Thanks!