From 89d794ed5a2c3ecb6e06efa99750d2cb50bb55cd Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 28 Nov 2019 12:01:51 +0000 Subject: [PATCH] Ensure even for special format GL returns sensible compCount/compType --- renderdoc/driver/gl/gl_common.cpp | 60 ++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/renderdoc/driver/gl/gl_common.cpp b/renderdoc/driver/gl/gl_common.cpp index bc22b036c..eb49fc804 100644 --- a/renderdoc/driver/gl/gl_common.cpp +++ b/renderdoc/driver/gl/gl_common.cpp @@ -1870,6 +1870,35 @@ ResourceFormat MakeResourceFormat(GLenum target, GLenum fmt) case eGL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: case eGL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: ret.compCount = 4; break; + case eGL_COMPRESSED_RGBA_ASTC_4x4_KHR: + case eGL_COMPRESSED_RGBA_ASTC_5x4_KHR: + case eGL_COMPRESSED_RGBA_ASTC_5x5_KHR: + case eGL_COMPRESSED_RGBA_ASTC_6x5_KHR: + case eGL_COMPRESSED_RGBA_ASTC_6x6_KHR: + case eGL_COMPRESSED_RGBA_ASTC_8x5_KHR: + case eGL_COMPRESSED_RGBA_ASTC_8x6_KHR: + case eGL_COMPRESSED_RGBA_ASTC_8x8_KHR: + case eGL_COMPRESSED_RGBA_ASTC_10x5_KHR: + case eGL_COMPRESSED_RGBA_ASTC_10x6_KHR: + case eGL_COMPRESSED_RGBA_ASTC_10x8_KHR: + case eGL_COMPRESSED_RGBA_ASTC_10x10_KHR: + case eGL_COMPRESSED_RGBA_ASTC_12x10_KHR: + case eGL_COMPRESSED_RGBA_ASTC_12x12_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: ret.compCount = 4; break; + default: break; } @@ -2002,15 +2031,36 @@ ResourceFormat MakeResourceFormat(GLenum target, GLenum fmt) // handle certain non compressed but special formats switch(fmt) { - case eGL_R11F_G11F_B10F: ret.type = ResourceFormatType::R11G11B10; break; - case eGL_RGB565: ret.type = ResourceFormatType::R5G6B5; break; - case eGL_RGB5_A1: ret.type = ResourceFormatType::R5G5B5A1; break; - case eGL_RGB9_E5: ret.type = ResourceFormatType::R9G9B9E5; break; - case eGL_RGBA4: ret.type = ResourceFormatType::R4G4B4A4; break; + case eGL_R11F_G11F_B10F: + ret.type = ResourceFormatType::R11G11B10; + ret.compType = CompType::Float; + ret.compCount = 3; + break; + case eGL_RGB565: + ret.type = ResourceFormatType::R5G6B5; + ret.compType = CompType::UNorm; + ret.compCount = 3; + break; + case eGL_RGB5_A1: + ret.type = ResourceFormatType::R5G5B5A1; + ret.compType = CompType::UNorm; + ret.compCount = 4; + break; + case eGL_RGB9_E5: + ret.type = ResourceFormatType::R9G9B9E5; + ret.compType = CompType::Float; + ret.compCount = 3; + break; + case eGL_RGBA4: + ret.type = ResourceFormatType::R4G4B4A4; + ret.compType = CompType::UNorm; + ret.compCount = 4; + break; case eGL_RGB10_A2: case eGL_RGB10_A2UI: ret.type = ResourceFormatType::R10G10B10A2; ret.compType = fmt == eGL_RGB10_A2 ? CompType::UNorm : CompType::UInt; + ret.compCount = 4; break; default: break; }