From 66f6e9780d6db6200759d34e8f00cd3811358b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Tue, 27 Oct 2026 12:15:20 -0700 Subject: [PATCH] D3D12, GL: Fixed write-only color render targets. (#4099) --- src/renderer_d3d12.cpp | 7 +++++-- src/renderer_gl.cpp | 18 +++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index c4131d366..5ab86d596 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -7271,8 +7271,11 @@ namespace bgfx { namespace d3d12 if (writeOnly) { - resourceDesc.Flags |= D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE; - state &= ~D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; + resourceDesc.Flags |= depth + ? D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE + : D3D12_RESOURCE_FLAG_NONE + ; + state &= ~D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; } if (computeWrite) diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index e472931c9..dd11ad1fc 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -8151,16 +8151,16 @@ namespace bgfx { namespace gl { const TextureGL& texture = s_renderGL->m_textures[at.handle.idx]; + GLenum attachment = attachmentFor(TextureFormat::Enum(texture.m_textureFormat) ); + + if (GL_COLOR_ATTACHMENT0 == attachment) + { + attachment = GL_COLOR_ATTACHMENT0 + colorIdx; + ++colorIdx; + } + if (0 != texture.m_rbo && 0 != texture.m_id) { - GLenum attachment = attachmentFor(TextureFormat::Enum(texture.m_textureFormat) ); - - if (GL_COLOR_ATTACHMENT0 == attachment) - { - attachment = GL_COLOR_ATTACHMENT0 + colorIdx; - ++colorIdx; - } - GLenum target = texture.isCubeMap() ? GL_TEXTURE_CUBE_MAP_POSITIVE_X + at.layer : texture.m_target @@ -8533,7 +8533,7 @@ namespace bgfx { namespace gl bimg::TextureFormat::Enum format = bimg::TextureFormat::Enum(texture.m_textureFormat); if (!bimg::isDepth(format) - && 0 == texture.m_rbo) + && (0 == texture.m_rbo || 0 == texture.m_id) ) { colorIdx++; }