From 78a982bb4d802a6adf55f929b91856fd46e54803 Mon Sep 17 00:00:00 2001 From: Luigi Rosso Date: Wed, 14 Jan 2026 10:30:08 -0800 Subject: fix: GLES3 FBO depth attachment switching --- sokol_gfx.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sokol_gfx.h b/sokol_gfx.h index aaadb456..e1ab6cb1 100644 --- a/sokol_gfx.h +++ b/sokol_gfx.h @@ -11365,6 +11365,16 @@ _SOKOL_PRIVATE void _sg_gl_begin_pass(const sg_pass* pass, const _sg_attachments glFramebufferTexture2D(GL_FRAMEBUFFER, gl_att_type, GL_TEXTURE_2D, 0, 0); } if (atts->ds_view) { + // GLES3 FBO fix: When switching between depth-only and depth-stencil attachments, + // explicitly detach BOTH attachment types first. Some GLES3 drivers (e.g., Pixel 8 Pro) + // fail with GL_FRAMEBUFFER_UNSUPPORTED if both attachment types are bound to the same FBO, + // even if one is bound to a different texture. + #if defined(SOKOL_GLES3) + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); + #endif const _sg_view_t* view = atts->ds_view; const _sg_image_t* img = _sg_image_ref_ptr(&view->cmn.img.ref); const GLenum gl_att_type = _sg_gl_depth_stencil_attachment_type(img); -- cgit v1.2.3 From 71dbb51d9a7b60f91e085c7acfaf34082f85aed3 Mon Sep 17 00:00:00 2001 From: Luigi Rosso Date: Thu, 15 Jan 2026 10:13:40 -0800 Subject: fix: clear depth attachments before switching types on all gl implementations --- sokol_gfx.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sokol_gfx.h b/sokol_gfx.h index e1ab6cb1..887f08a0 100644 --- a/sokol_gfx.h +++ b/sokol_gfx.h @@ -11365,16 +11365,14 @@ _SOKOL_PRIVATE void _sg_gl_begin_pass(const sg_pass* pass, const _sg_attachments glFramebufferTexture2D(GL_FRAMEBUFFER, gl_att_type, GL_TEXTURE_2D, 0, 0); } if (atts->ds_view) { - // GLES3 FBO fix: When switching between depth-only and depth-stencil attachments, - // explicitly detach BOTH attachment types first. Some GLES3 drivers (e.g., Pixel 8 Pro) - // fail with GL_FRAMEBUFFER_UNSUPPORTED if both attachment types are bound to the same FBO, - // even if one is bound to a different texture. - #if defined(SOKOL_GLES3) + // When switching between depth-only and depth-stencil attachments, + // explicitly detach BOTH attachment types first. Some GL drivers + // fail with GL_FRAMEBUFFER_UNSUPPORTED if both attachment types + // are bound to the same FBO. glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); - #endif const _sg_view_t* view = atts->ds_view; const _sg_image_t* img = _sg_image_ref_ptr(&view->cmn.img.ref); const GLenum gl_att_type = _sg_gl_depth_stencil_attachment_type(img); -- cgit v1.2.3 From 9989bacc7dd05e149806b8ee188ebcb25944edc2 Mon Sep 17 00:00:00 2001 From: Andre Weissflog Date: Sun, 18 Jan 2026 17:51:43 +0100 Subject: update changelog (https://github.com/floooh/sokol/pull/1412) --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dff9e78..3e9043c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ ## Updates +### 18-Jan-2026 + +Happy New Year! + +- sokol_gfx.h gl: merged PR https://github.com/floooh/sokol/pull/1412 which fixes + a GL error on some drivers when switching between `GL_DEPTH_ATTACHMENT` and + `GL_DEPTH_STENCIL_ATTACHMENT`. Many thanks to @luigi-rosso for identifying + the issue and providing a fix! + ### 13-Dec-2025 A WebGPU backend code cleanup round: -- cgit v1.2.3