aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2025-12-02 14:14:09 +0100
committerAndre Weissflog <floooh@gmail.com>2025-12-02 14:14:09 +0100
commitfb1883c895ed27114e68fa9478e93e46cd9ede62 (patch)
tree3ffe22f2d2ec2790ca93addff375cb55bbd9d240
parent3103277b7dc5c339a6f475816014e7963c9a5474 (diff)
parentab5d26a475584ad04b3d53107aa79ab6c710e95d (diff)
Merge branch 'etherbound-dev-fix-gl-fbo-attachment-leak'
-rw-r--r--CHANGELOG.md6
-rw-r--r--sokol_gfx.h10
2 files changed, 16 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e87785cf..9f2aaf3d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
## Updates
+### 02-Dec-2025
+
+- sokol_gfx.h gl: unused framebuffer attachment slots are now explicitly cleared
+ in `sg_begin_pass()`. See PR #1390 for details! Many thanks to @etherbound-dev
+ for catching and fixing the issue!
+
### 13-Nov-2025
- sokol_audio.h gained a new backend for the Nintendo 3DS.
diff --git a/sokol_gfx.h b/sokol_gfx.h
index 11d387e2..c53702b3 100644
--- a/sokol_gfx.h
+++ b/sokol_gfx.h
@@ -10909,6 +10909,12 @@ _SOKOL_PRIVATE void _sg_gl_begin_pass(const sg_pass* pass, const _sg_attachments
_sg_gl_fb_attach_texture(view, gl_att_type);
}
}
+ // explicitly detach unused color attachments
+ for (int i = atts->num_color_views; i < _sg.limits.max_color_attachments; i++) {
+ const GLenum gl_att_type = (GLenum)(GL_COLOR_ATTACHMENT0 + i);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, gl_att_type, GL_RENDERBUFFER, 0);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, gl_att_type, GL_TEXTURE_2D, 0, 0);
+ }
if (atts->ds_view) {
const _sg_view_t* view = atts->ds_view;
const _sg_image_t* img = _sg_image_ref_ptr(&view->cmn.img.ref);
@@ -10918,6 +10924,10 @@ _SOKOL_PRIVATE void _sg_gl_begin_pass(const sg_pass* pass, const _sg_attachments
} else {
_sg_gl_fb_attach_texture(view, gl_att_type);
}
+ } else {
+ // explicitly detach depth-stencil attachment if not used in this pass
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
}
if (!_sg_gl_check_framebuffer_status()) {
_sg.cur_pass.valid = false;