From 8fea35a1ad6a878c4c98df41271e2d825b600557 Mon Sep 17 00:00:00 2001 From: hzqst <113660872@qq.com> Date: Mon, 28 Jul 2025 22:09:12 +0800 Subject: [PATCH 01/10] Add TEX_FORMAT_X24_TYPELESS_G8_UINT, TEX_FORMAT_X32_TYPELESS_G8X24_UINT and GL_STENCIL_INDEX support --- .../src/GLTypeConversions.cpp | 4 ++-- .../src/RenderDeviceGLImpl.cpp | 4 ++-- .../GraphicsEngineOpenGL/src/TextureBaseGL.cpp | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Graphics/GraphicsEngineOpenGL/src/GLTypeConversions.cpp b/Graphics/GraphicsEngineOpenGL/src/GLTypeConversions.cpp index 9c911f7f9b..5de0314c34 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLTypeConversions.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/GLTypeConversions.cpp @@ -72,7 +72,7 @@ class FormatToGLInternalTexFormatMap m_FmtToGLFmtMap[TEX_FORMAT_R32G8X24_TYPELESS] = GL_DEPTH32F_STENCIL8; m_FmtToGLFmtMap[TEX_FORMAT_D32_FLOAT_S8X24_UINT] = GL_DEPTH32F_STENCIL8; m_FmtToGLFmtMap[TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS]=GL_DEPTH32F_STENCIL8; - m_FmtToGLFmtMap[TEX_FORMAT_X32_TYPELESS_G8X24_UINT]= 0;//GL_DEPTH32F_STENCIL8; + m_FmtToGLFmtMap[TEX_FORMAT_X32_TYPELESS_G8X24_UINT]= GL_DEPTH32F_STENCIL8; m_FmtToGLFmtMap[TEX_FORMAT_RGB10A2_TYPELESS] = GL_RGB10_A2; m_FmtToGLFmtMap[TEX_FORMAT_RGB10A2_UNORM] = GL_RGB10_A2; @@ -102,7 +102,7 @@ class FormatToGLInternalTexFormatMap m_FmtToGLFmtMap[TEX_FORMAT_R24G8_TYPELESS] = GL_DEPTH24_STENCIL8; m_FmtToGLFmtMap[TEX_FORMAT_D24_UNORM_S8_UINT] = GL_DEPTH24_STENCIL8; m_FmtToGLFmtMap[TEX_FORMAT_R24_UNORM_X8_TYPELESS] = GL_DEPTH24_STENCIL8; - m_FmtToGLFmtMap[TEX_FORMAT_X24_TYPELESS_G8_UINT] = 0;//GL_DEPTH24_STENCIL8; + m_FmtToGLFmtMap[TEX_FORMAT_X24_TYPELESS_G8_UINT] = GL_DEPTH24_STENCIL8; m_FmtToGLFmtMap[TEX_FORMAT_RG8_TYPELESS] = GL_RG8; m_FmtToGLFmtMap[TEX_FORMAT_RG8_UNORM] = GL_RG8; diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp index e52596b94f..82b1e0eb75 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp @@ -1253,7 +1253,7 @@ void RenderDeviceGLImpl::FlagSupportedTexFormats() FlagFormat(TEX_FORMAT_R32G8X24_TYPELESS, true ); FlagFormat(TEX_FORMAT_D32_FLOAT_S8X24_UINT, true, BIND_DEPTH_STENCIL ); FlagFormat(TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS, true, TexBindFlags, bDekstopGL); - FlagFormat(TEX_FORMAT_X32_TYPELESS_G8X24_UINT, false ); + FlagFormat(TEX_FORMAT_X32_TYPELESS_G8X24_UINT, true, BIND_SHADER_RESOURCE, false); FlagFormat(TEX_FORMAT_RGB10A2_TYPELESS, true ); FlagFormat(TEX_FORMAT_RGB10A2_UNORM, true, BindSrvRtvUav, true); FlagFormat(TEX_FORMAT_RGB10A2_UINT, true, BindSrvRtvUav ); @@ -1278,7 +1278,7 @@ void RenderDeviceGLImpl::FlagSupportedTexFormats() FlagFormat(TEX_FORMAT_R24G8_TYPELESS, true ); FlagFormat(TEX_FORMAT_D24_UNORM_S8_UINT, true, BIND_DEPTH_STENCIL ); FlagFormat(TEX_FORMAT_R24_UNORM_X8_TYPELESS, true, TexBindFlags, true); - FlagFormat(TEX_FORMAT_X24_TYPELESS_G8_UINT, false ); + FlagFormat(TEX_FORMAT_X24_TYPELESS_G8_UINT, true, BIND_SHADER_RESOURCE, false); FlagFormat(TEX_FORMAT_RG8_TYPELESS, true ); FlagFormat(TEX_FORMAT_RG8_UNORM, true, U8BindFlags, true); FlagFormat(TEX_FORMAT_RG8_UINT, true, UI8BindFlags ); diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp index 49dfaf507c..7e51411d35 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp @@ -490,9 +490,23 @@ void TextureBaseGL::CreateViewInternal(const TextureViewDesc& OrigViewDesc, ITex LOG_ERROR_AND_THROW("glTextureView is not supported"); glTextureView(pViewOGL->GetHandle(), GLViewTarget, m_GlTexture, GLViewFormat, ViewDesc.MostDetailedMip, ViewDesc.NumMipLevels, ViewDesc.FirstArraySlice, NumLayers); + DEV_CHECK_GL_ERROR_AND_THROW("Failed to create texture view"); pViewOGL->SetBindTarget(GLViewTarget); + if(GLViewFormat == TEX_FORMAT_X24_TYPELESS_G8_UINT || GLViewFormat == TEX_FORMAT_X32_TYPELESS_G8X24_UINT) + { + RefCntAutoPtr pDeviceContext = pDeviceGLImpl->GetImmediateContext(0); + VERIFY(pDeviceContext, "Immediate device context has been destroyed"); + GLContextState& GLState = pDeviceContext->GetContextState(); + + GLState.BindTexture(-1, GLViewTarget, pViewOGL->GetHandle()); + + glTexParameteri(GLViewTarget, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX); + + GLState.BindTexture(-1, GLViewTarget, GLObjectWrappers::GLTextureObj::Null()); + } + if (!IsIdentityComponentMapping(ViewDesc.Swizzle)) { RefCntAutoPtr pDeviceContext = pDeviceGLImpl->GetImmediateContext(0); @@ -508,6 +522,7 @@ void TextureBaseGL::CreateViewInternal(const TextureViewDesc& OrigViewDesc, ITex DEV_CHECK_GL_ERROR("Failed to set GL_TEXTURE_SWIZZLE_B texture parameter"); glTexParameteri(GLViewTarget, GL_TEXTURE_SWIZZLE_A, TextureComponentSwizzleToGLTextureSwizzle(ViewDesc.Swizzle.A, GL_ALPHA)); DEV_CHECK_GL_ERROR("Failed to set GL_TEXTURE_SWIZZLE_A texture parameter"); + GLState.BindTexture(-1, GLViewTarget, GLObjectWrappers::GLTextureObj::Null()); } } From 9e3dcada3b417def7d6a749afb71d614b3556b5e Mon Sep 17 00:00:00 2001 From: hzqst <113660872@qq.com> Date: Mon, 28 Jul 2025 23:08:28 +0800 Subject: [PATCH 02/10] Fix typo --- Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp index 7e51411d35..f2d69277b3 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp @@ -494,7 +494,7 @@ void TextureBaseGL::CreateViewInternal(const TextureViewDesc& OrigViewDesc, ITex DEV_CHECK_GL_ERROR_AND_THROW("Failed to create texture view"); pViewOGL->SetBindTarget(GLViewTarget); - if(GLViewFormat == TEX_FORMAT_X24_TYPELESS_G8_UINT || GLViewFormat == TEX_FORMAT_X32_TYPELESS_G8X24_UINT) + if(ViewDesc.Format == TEX_FORMAT_X24_TYPELESS_G8_UINT || ViewDesc.Format == TEX_FORMAT_X32_TYPELESS_G8X24_UINT) { RefCntAutoPtr pDeviceContext = pDeviceGLImpl->GetImmediateContext(0); VERIFY(pDeviceContext, "Immediate device context has been destroyed"); From 98064f92d515ea95e3cfc3ce78daf414a6e076f3 Mon Sep 17 00:00:00 2001 From: hzqst <113660872@qq.com> Date: Tue, 29 Jul 2025 17:42:08 +0800 Subject: [PATCH 03/10] Add GL_ARB_stencil_texturing capability checking, and FormatInfo.Supported checking. --- .../src/RenderDeviceGLImpl.cpp | 7 +++++-- .../src/TextureBaseGL.cpp | 21 +++++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp index 82b1e0eb75..3963726ede 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp @@ -1138,13 +1138,16 @@ void RenderDeviceGLImpl::FlagSupportedTexFormats() { const RenderDeviceInfo& DeviceInfo = GetDeviceInfo(); const bool bDekstopGL = DeviceInfo.Type == RENDER_DEVICE_TYPE_GL; + const bool bGL430OrAbove = DeviceInfo.Type == RENDER_DEVICE_TYPE_GL && DeviceInfo.APIVersion >= Version{4, 3}; const bool bGLES30OrAbove = DeviceInfo.Type == RENDER_DEVICE_TYPE_GLES && DeviceInfo.APIVersion >= Version{3, 0}; + const bool bGLES31OrAbove = DeviceInfo.Type == RENDER_DEVICE_TYPE_GLES && DeviceInfo.APIVersion >= Version{3, 1}; const bool bRGTC = CheckExtension("GL_EXT_texture_compression_rgtc") || CheckExtension("GL_ARB_texture_compression_rgtc"); const bool bBPTC = CheckExtension("GL_EXT_texture_compression_bptc") || CheckExtension("GL_ARB_texture_compression_bptc"); const bool bS3TC = CheckExtension("GL_EXT_texture_compression_s3tc") || CheckExtension("GL_WEBGL_compressed_texture_s3tc"); const bool bTexNorm16 = bDekstopGL || CheckExtension("GL_EXT_texture_norm16"); // Only for ES3.1+ const bool bTexSwizzle = bDekstopGL || bGLES30OrAbove || CheckExtension("GL_ARB_texture_swizzle"); + const bool bStencilTex = bGL430OrAbove || bGLES31OrAbove || CheckExtension("GL_ARB_stencil_texturing"); #if PLATFORM_WEB const bool bETC2 = CheckExtension("GL_WEBGL_compressed_texture_etc"); @@ -1253,7 +1256,7 @@ void RenderDeviceGLImpl::FlagSupportedTexFormats() FlagFormat(TEX_FORMAT_R32G8X24_TYPELESS, true ); FlagFormat(TEX_FORMAT_D32_FLOAT_S8X24_UINT, true, BIND_DEPTH_STENCIL ); FlagFormat(TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS, true, TexBindFlags, bDekstopGL); - FlagFormat(TEX_FORMAT_X32_TYPELESS_G8X24_UINT, true, BIND_SHADER_RESOURCE, false); + FlagFormat(TEX_FORMAT_X32_TYPELESS_G8X24_UINT, bStencilTex, BIND_SHADER_RESOURCE, false); FlagFormat(TEX_FORMAT_RGB10A2_TYPELESS, true ); FlagFormat(TEX_FORMAT_RGB10A2_UNORM, true, BindSrvRtvUav, true); FlagFormat(TEX_FORMAT_RGB10A2_UINT, true, BindSrvRtvUav ); @@ -1278,7 +1281,7 @@ void RenderDeviceGLImpl::FlagSupportedTexFormats() FlagFormat(TEX_FORMAT_R24G8_TYPELESS, true ); FlagFormat(TEX_FORMAT_D24_UNORM_S8_UINT, true, BIND_DEPTH_STENCIL ); FlagFormat(TEX_FORMAT_R24_UNORM_X8_TYPELESS, true, TexBindFlags, true); - FlagFormat(TEX_FORMAT_X24_TYPELESS_G8_UINT, true, BIND_SHADER_RESOURCE, false); + FlagFormat(TEX_FORMAT_X24_TYPELESS_G8_UINT, bStencilTex, BIND_SHADER_RESOURCE, false); FlagFormat(TEX_FORMAT_RG8_TYPELESS, true ); FlagFormat(TEX_FORMAT_RG8_UNORM, true, U8BindFlags, true); FlagFormat(TEX_FORMAT_RG8_UINT, true, UI8BindFlags ); diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp index f2d69277b3..0fddef9d5c 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp @@ -490,21 +490,25 @@ void TextureBaseGL::CreateViewInternal(const TextureViewDesc& OrigViewDesc, ITex LOG_ERROR_AND_THROW("glTextureView is not supported"); glTextureView(pViewOGL->GetHandle(), GLViewTarget, m_GlTexture, GLViewFormat, ViewDesc.MostDetailedMip, ViewDesc.NumMipLevels, ViewDesc.FirstArraySlice, NumLayers); - DEV_CHECK_GL_ERROR_AND_THROW("Failed to create texture view"); pViewOGL->SetBindTarget(GLViewTarget); - if(ViewDesc.Format == TEX_FORMAT_X24_TYPELESS_G8_UINT || ViewDesc.Format == TEX_FORMAT_X32_TYPELESS_G8X24_UINT) + if (ViewDesc.Format == TEX_FORMAT_X24_TYPELESS_G8_UINT || ViewDesc.Format == TEX_FORMAT_X32_TYPELESS_G8X24_UINT) { - RefCntAutoPtr pDeviceContext = pDeviceGLImpl->GetImmediateContext(0); - VERIFY(pDeviceContext, "Immediate device context has been destroyed"); - GLContextState& GLState = pDeviceContext->GetContextState(); + const auto &FormatInfo = pDeviceGLImpl->GetTextureFormatInfo(ViewDesc.Format); - GLState.BindTexture(-1, GLViewTarget, pViewOGL->GetHandle()); + if (FormatInfo.Supported) + { + RefCntAutoPtr pDeviceContext = pDeviceGLImpl->GetImmediateContext(0); + VERIFY(pDeviceContext, "Immediate device context has been destroyed"); + GLContextState& GLState = pDeviceContext->GetContextState(); - glTexParameteri(GLViewTarget, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX); + GLState.BindTexture(-1, GLViewTarget, pViewOGL->GetHandle()); - GLState.BindTexture(-1, GLViewTarget, GLObjectWrappers::GLTextureObj::Null()); + glTexParameteri(GLViewTarget, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX); + + GLState.BindTexture(-1, GLViewTarget, GLObjectWrappers::GLTextureObj::Null()); + } } if (!IsIdentityComponentMapping(ViewDesc.Swizzle)) @@ -522,7 +526,6 @@ void TextureBaseGL::CreateViewInternal(const TextureViewDesc& OrigViewDesc, ITex DEV_CHECK_GL_ERROR("Failed to set GL_TEXTURE_SWIZZLE_B texture parameter"); glTexParameteri(GLViewTarget, GL_TEXTURE_SWIZZLE_A, TextureComponentSwizzleToGLTextureSwizzle(ViewDesc.Swizzle.A, GL_ALPHA)); DEV_CHECK_GL_ERROR("Failed to set GL_TEXTURE_SWIZZLE_A texture parameter"); - GLState.BindTexture(-1, GLViewTarget, GLObjectWrappers::GLTextureObj::Null()); } } From 086a4c5ebc814f651464b8928741a41b47ac792d Mon Sep 17 00:00:00 2001 From: hzqst <113660872@qq.com> Date: Fri, 1 Aug 2025 16:40:09 +0800 Subject: [PATCH 04/10] Add DEV_CHECK_GL_ERROR for glTexParameteri GL_DEPTH_STENCIL_TEXTURE_MODE. Add error thrown when format not supported --- Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp index 0fddef9d5c..7ccfa5d522 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp @@ -504,11 +504,15 @@ void TextureBaseGL::CreateViewInternal(const TextureViewDesc& OrigViewDesc, ITex GLContextState& GLState = pDeviceContext->GetContextState(); GLState.BindTexture(-1, GLViewTarget, pViewOGL->GetHandle()); - glTexParameteri(GLViewTarget, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX); - + DEV_CHECK_GL_ERROR("Failed to set GL_DEPTH_STENCIL_TEXTURE_MODE texture parameter"); GLState.BindTexture(-1, GLViewTarget, GLObjectWrappers::GLTextureObj::Null()); } + else + { + // Throw an error if the format is not supported + LOG_ERROR_AND_THROW("Format ", GetTextureFormatAttribs(ViewDesc.Format).Name, " is not supported"); + } } if (!IsIdentityComponentMapping(ViewDesc.Swizzle)) From f9e63f24e2439b40b7e20bab9ab7a3bc2a4d9829 Mon Sep 17 00:00:00 2001 From: hzqst <113660872@qq.com> Date: Fri, 1 Aug 2025 22:54:11 +0800 Subject: [PATCH 05/10] Fix formatting --- Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp | 2 +- Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp index 3963726ede..80e70b9108 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp @@ -1138,7 +1138,7 @@ void RenderDeviceGLImpl::FlagSupportedTexFormats() { const RenderDeviceInfo& DeviceInfo = GetDeviceInfo(); const bool bDekstopGL = DeviceInfo.Type == RENDER_DEVICE_TYPE_GL; - const bool bGL430OrAbove = DeviceInfo.Type == RENDER_DEVICE_TYPE_GL && DeviceInfo.APIVersion >= Version{4, 3}; + const bool bGL430OrAbove = DeviceInfo.Type == RENDER_DEVICE_TYPE_GL && DeviceInfo.APIVersion >= Version{4, 3}; const bool bGLES30OrAbove = DeviceInfo.Type == RENDER_DEVICE_TYPE_GLES && DeviceInfo.APIVersion >= Version{3, 0}; const bool bGLES31OrAbove = DeviceInfo.Type == RENDER_DEVICE_TYPE_GLES && DeviceInfo.APIVersion >= Version{3, 1}; diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp index 7ccfa5d522..dfa27663df 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp @@ -495,7 +495,7 @@ void TextureBaseGL::CreateViewInternal(const TextureViewDesc& OrigViewDesc, ITex if (ViewDesc.Format == TEX_FORMAT_X24_TYPELESS_G8_UINT || ViewDesc.Format == TEX_FORMAT_X32_TYPELESS_G8X24_UINT) { - const auto &FormatInfo = pDeviceGLImpl->GetTextureFormatInfo(ViewDesc.Format); + const auto& FormatInfo = pDeviceGLImpl->GetTextureFormatInfo(ViewDesc.Format); if (FormatInfo.Supported) { From cda2b7c0e2a0053497544a9d317b3a3f93ba7704 Mon Sep 17 00:00:00 2001 From: hzqst <113660872@qq.com> Date: Fri, 1 Aug 2025 22:56:24 +0800 Subject: [PATCH 06/10] Replace auto with actual type --- Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp index dfa27663df..9c28a43809 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp @@ -495,9 +495,9 @@ void TextureBaseGL::CreateViewInternal(const TextureViewDesc& OrigViewDesc, ITex if (ViewDesc.Format == TEX_FORMAT_X24_TYPELESS_G8_UINT || ViewDesc.Format == TEX_FORMAT_X32_TYPELESS_G8X24_UINT) { - const auto& FormatInfo = pDeviceGLImpl->GetTextureFormatInfo(ViewDesc.Format); + const TextureFormatInfo& FmtInfo = pDeviceGLImpl->GetTextureFormatInfo(ViewDesc.Format); - if (FormatInfo.Supported) + if (FmtInfo.Supported) { RefCntAutoPtr pDeviceContext = pDeviceGLImpl->GetImmediateContext(0); VERIFY(pDeviceContext, "Immediate device context has been destroyed"); From 81e77a13805c2eb9822b909d6356d5addc079842 Mon Sep 17 00:00:00 2001 From: hzqst <113660872@qq.com> Date: Fri, 1 Aug 2025 23:20:48 +0800 Subject: [PATCH 07/10] Add missing definition for GL_DEPTH_STENCIL_TEXTURE_MODE and GL_STENCIL_INDEX for iOS and Android --- Graphics/GraphicsEngineOpenGL/include/GLStubsAndroid.h | 9 +++++++++ Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/Graphics/GraphicsEngineOpenGL/include/GLStubsAndroid.h b/Graphics/GraphicsEngineOpenGL/include/GLStubsAndroid.h index 1e39c1e8cf..44313936d2 100644 --- a/Graphics/GraphicsEngineOpenGL/include/GLStubsAndroid.h +++ b/Graphics/GraphicsEngineOpenGL/include/GLStubsAndroid.h @@ -155,6 +155,15 @@ # define GL_MIRROR_CLAMP_TO_EDGE 0 #endif +// Define unsupported texture parameters +#ifndef GL_DEPTH_STENCIL_TEXTURE_MODE +# define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#endif + +#ifndef GL_STENCIL_INDEX +# define GL_STENCIL_INDEX 0x1901 +#endif + // Define unsupported bind points #ifndef GL_ARB_draw_indirect # define GL_ARB_draw_indirect 1 diff --git a/Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h b/Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h index 20b282b250..2aaf8241dd 100644 --- a/Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h +++ b/Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h @@ -170,6 +170,14 @@ # define GL_DEPTH_CLAMP 0x864F #endif +// Define unsupported texture parameters +#ifndef GL_DEPTH_STENCIL_TEXTURE_MODE +# define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#endif + +#ifndef GL_STENCIL_INDEX +# define GL_STENCIL_INDEX 0x1901 +#endif // Define unsupported formats for OpenGL ES #ifndef GL_RGBA16 From d8e2b47beae277ed029b31e0248c5ed5664e6012 Mon Sep 17 00:00:00 2001 From: hzqst <113660872@qq.com> Date: Fri, 1 Aug 2025 23:32:06 +0800 Subject: [PATCH 08/10] Fix formatting in GLStubsIOS.h --- Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h b/Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h index 2aaf8241dd..d4225093f4 100644 --- a/Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h +++ b/Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h @@ -172,11 +172,11 @@ // Define unsupported texture parameters #ifndef GL_DEPTH_STENCIL_TEXTURE_MODE -# define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +# define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA #endif #ifndef GL_STENCIL_INDEX -# define GL_STENCIL_INDEX 0x1901 +# define GL_STENCIL_INDEX 0x1901 #endif // Define unsupported formats for OpenGL ES From a018741b5b91a25785656f597d6152ce13b446a6 Mon Sep 17 00:00:00 2001 From: hzqst <113660872@qq.com> Date: Sat, 2 Aug 2025 18:48:51 +0800 Subject: [PATCH 09/10] Fixed an issue that SwapChainDesc.DepthBufferFormat = TEX_FORMAT_R24G8_TYPELESS was not supported in D3D12 with error -> D3D12_CLEAR_VALUE::Format cannot be a typeless format. A fully qualified format must be supplied. Format = R24G8_TYPELESS. [ STATE_CREATION ERROR #817: ] --- Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp index 75bd2c8d91..fbfcacdc48 100644 --- a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp @@ -112,7 +112,7 @@ void SwapChainD3D12Impl::InitBuffersAndViews() DepthBufferDesc.Usage = USAGE_DEFAULT; DepthBufferDesc.BindFlags = BIND_DEPTH_STENCIL; - DepthBufferDesc.ClearValue.Format = DepthBufferDesc.Format; + DepthBufferDesc.ClearValue.Format = TEX_FORMAT_UNKNOWN; DepthBufferDesc.ClearValue.DepthStencil.Depth = m_SwapChainDesc.DefaultDepthValue; DepthBufferDesc.ClearValue.DepthStencil.Stencil = m_SwapChainDesc.DefaultStencilValue; DepthBufferDesc.Name = "Main depth buffer"; From d43f82c9f985384f6194945f55c3a0aebfe649f0 Mon Sep 17 00:00:00 2001 From: hzqst <113660872@qq.com> Date: Sun, 3 Aug 2025 11:09:51 +0800 Subject: [PATCH 10/10] Fill ClearValue.Format with GetDefaultTextureViewFormat instead of DepthBufferDesc.Format or TEX_FORMAT_UNKNOWN to support R24G8_TYPELESS. --- Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp index fbfcacdc48..9987bdf43c 100644 --- a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp @@ -112,7 +112,7 @@ void SwapChainD3D12Impl::InitBuffersAndViews() DepthBufferDesc.Usage = USAGE_DEFAULT; DepthBufferDesc.BindFlags = BIND_DEPTH_STENCIL; - DepthBufferDesc.ClearValue.Format = TEX_FORMAT_UNKNOWN; + DepthBufferDesc.ClearValue.Format = GetDefaultTextureViewFormat(DepthBufferDesc.Format, TEXTURE_VIEW_DEPTH_STENCIL, DepthBufferDesc.BindFlags); DepthBufferDesc.ClearValue.DepthStencil.Depth = m_SwapChainDesc.DefaultDepthValue; DepthBufferDesc.ClearValue.DepthStencil.Stencil = m_SwapChainDesc.DefaultStencilValue; DepthBufferDesc.Name = "Main depth buffer";