aboutsummaryrefslogtreecommitdiff
path: root/sokol_gfx.h
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2026-01-18 17:51:59 +0100
committerAndre Weissflog <floooh@gmail.com>2026-01-18 17:51:59 +0100
commitd76e1f1d25d5dfb800b5f30dd76076ef50310af3 (patch)
tree9c72821ca4d243a5fcb0d262bb02125d0fa16144 /sokol_gfx.h
parent79847279e42a3b2ffbeb0700927ec57aafaf388e (diff)
parent9989bacc7dd05e149806b8ee188ebcb25944edc2 (diff)
Merge branch 'luigi-rosso-fix_fbo_depth_attachment_switching'
Diffstat (limited to 'sokol_gfx.h')
-rw-r--r--sokol_gfx.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/sokol_gfx.h b/sokol_gfx.h
index aaadb456..887f08a0 100644
--- a/sokol_gfx.h
+++ b/sokol_gfx.h
@@ -11365,6 +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) {
+ // 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);
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);