diff options
| author | Luigi Rosso <luigi.rosso@gmail.com> | 2026-01-14 10:30:08 -0800 |
|---|---|---|
| committer | Luigi Rosso <luigi.rosso@gmail.com> | 2026-01-14 10:30:08 -0800 |
| commit | 78a982bb4d802a6adf55f929b91856fd46e54803 (patch) | |
| tree | f12f04edd44f205598956c220ff081e4bc57ffed | |
| parent | 79847279e42a3b2ffbeb0700927ec57aafaf388e (diff) | |
fix: GLES3 FBO depth attachment switching
| -rw-r--r-- | sokol_gfx.h | 10 |
1 files changed, 10 insertions, 0 deletions
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); |