[Fix] (DirectGLES): report distinct depth/stencil framebuffers as unsupported

GL only requires framebuffers whose depth and stencil attachments refer to the
same image; anything else may be answered GL_FRAMEBUFFER_UNSUPPORTED, and both
backends' real targets do exactly that - DirectVulkan cannot form two separate
attachments at all, and the ES drivers behind DirectGLES return UNSUPPORTED for
a separate depth renderbuffer plus stencil renderbuffer.

The frontend already knew how to detect the configuration, but only consulted it
for DirectVulkan. On DirectGLES it answered GL_FRAMEBUFFER_COMPLETE for a
framebuffer the driver had rejected, so every clear and draw against it was
silently dropped and the results read back as zeros - which is what
KHR-GL3x.packed_depth_stencil.verify_mixed_attachments saw. (That test
explicitly tolerates GL_FRAMEBUFFER_UNSUPPORTED; what it cannot survive is being
told the framebuffer works.)

Turned into a backend capability rather than a backend-type check, probed once
at init from a scratch framebuffer the same way the format-capability cache is,
so a driver that does support the configuration keeps using it. Defaults to
supported, leaving any backend that does not set it on the permissive path.

Fixes KHR-GL3{2,3}.packed_depth_stencil.verify_mixed_attachments for both
formats; DirectVulkan re-verified unchanged at 23/25 pass + 2 not-supported.
This commit is contained in:
BZLZHH
2026-08-01 14:05:28 -04:00
parent 4c7332d5e6
commit 9f3cac6691
3 changed files with 64 additions and 7 deletions
@@ -22,9 +22,21 @@
namespace MobileGL::MG_Impl::GLImpl {
namespace {
Bool IsActiveBackendDirectVulkan() {
// GL only requires support for framebuffers whose depth and stencil attachments
// are the same image; anything else may be reported GL_FRAMEBUFFER_UNSUPPORTED.
// DirectVulkan cannot form two separate attachments at all, and the real ES
// drivers behind DirectGLES answer UNSUPPORTED for it too - so saying COMPLETE
// and then rendering into a framebuffer the driver refuses produced silently
// empty results (KHR-GL3x.packed_depth_stencil.verify_mixed_attachments).
Bool ActiveBackendRejectsDistinctDepthStencil() {
auto* activeBackend = MG_Backend::pActiveBackendObject.get();
return activeBackend != nullptr && activeBackend->GetBackendType() == BackendType::DirectVulkan;
if (activeBackend == nullptr) {
return false;
}
if (activeBackend->GetBackendType() == BackendType::DirectVulkan) {
return true;
}
return !activeBackend->GetDynamicParameters().SupportsDistinctDepthStencilAttachments;
}
Bool HasDistinctCompleteDepthStencilTextureAttachments(
@@ -66,7 +78,7 @@ namespace MobileGL::MG_Impl::GLImpl {
(depthAttachment.IsTexture() || stencilAttachment.IsTexture());
}
Bool IsUnsupportedFramebufferForDirectVulkan(
Bool HasUnsupportedDistinctDepthStencilAttachments(
const MG_State::GLState::FramebufferObject& framebufferObject) {
// TODO: Keep this in sync with DirectVulkan renderbuffer support as color renderbuffer rendering lands.
return HasDistinctCompleteDepthStencilTextureAttachments(framebufferObject) ||
@@ -1631,8 +1643,8 @@ namespace MobileGL::MG_Impl::GLImpl {
if (HasNonRenderableColorAttachment(*framebufferObject)) {
return GL_FRAMEBUFFER_UNSUPPORTED;
}
if (IsActiveBackendDirectVulkan() &&
IsUnsupportedFramebufferForDirectVulkan(*framebufferObject)) {
if (ActiveBackendRejectsDistinctDepthStencil() &&
HasUnsupportedDistinctDepthStencilAttachments(*framebufferObject)) {
return GL_FRAMEBUFFER_UNSUPPORTED;
}
return GL_FRAMEBUFFER_COMPLETE;
@@ -1659,8 +1671,8 @@ namespace MobileGL::MG_Impl::GLImpl {
if (HasNonRenderableColorAttachment(*framebufferObject)) {
return GL_FRAMEBUFFER_UNSUPPORTED;
}
if (IsActiveBackendDirectVulkan() &&
IsUnsupportedFramebufferForDirectVulkan(*framebufferObject)) {
if (ActiveBackendRejectsDistinctDepthStencil() &&
HasUnsupportedDistinctDepthStencilAttachments(*framebufferObject)) {
return GL_FRAMEBUFFER_UNSUPPORTED;
}
return GL_FRAMEBUFFER_COMPLETE;