diff --git a/renderdoc/driver/gl/gl_common.cpp b/renderdoc/driver/gl/gl_common.cpp index 8ed2c3113..8631b3a12 100644 --- a/renderdoc/driver/gl/gl_common.cpp +++ b/renderdoc/driver/gl/gl_common.cpp @@ -2058,7 +2058,7 @@ ResourceFormat MakeResourceFormat(GLenum target, GLenum fmt) } GL.glGetInternalformativ(target, fmt, eGL_COLOR_ENCODING, sizeof(GLint), &data[0]); - if(edata[0] == eGL_SRGB) + if(edata[0] == eGL_SRGB || fmt == eGL_SR8_EXT || fmt == eGL_SRG8_EXT) ret.compType = CompType::UNormSRGB; } else if(isdepth == GL_TRUE || isstencil == GL_TRUE) @@ -2302,7 +2302,11 @@ GLenum MakeGLFormat(ResourceFormat fmt) } else if(fmt.compCount == 2) { - if(fmt.compByteWidth == 4) + if(fmt.SRGBCorrected()) + { + ret = eGL_SRG8_EXT; + } + else if(fmt.compByteWidth == 4) { if(fmt.compType == CompType::Float) ret = eGL_RG32F; @@ -2348,7 +2352,11 @@ GLenum MakeGLFormat(ResourceFormat fmt) } else if(fmt.compCount == 1) { - if(fmt.compByteWidth == 4) + if(fmt.SRGBCorrected()) + { + ret = eGL_SR8_EXT; + } + else if(fmt.compByteWidth == 4) { if(fmt.compType == CompType::Float) ret = eGL_R32F; @@ -2502,10 +2510,12 @@ TEST_CASE("GL formats", "[format][gl]") eGL_R8_SNORM, eGL_R8UI, eGL_R8I, + eGL_SR8_EXT, eGL_RG8, eGL_RG8_SNORM, eGL_RG8UI, eGL_RG8I, + eGL_SRG8_EXT, eGL_RGB8, eGL_RGB8_SNORM, eGL_RGB8UI, @@ -2678,7 +2688,7 @@ TEST_CASE("GL formats", "[format][gl]") if(fmt.type != ResourceFormatType::Regular) continue; - INFO("Format is " << f); + INFO("Format is " << ToStr(f)); uint32_t size = fmt.compCount * fmt.compByteWidth * 123 * 456; diff --git a/renderdoc/driver/gl/gl_driver.cpp b/renderdoc/driver/gl/gl_driver.cpp index 8e49dba2d..cd239545d 100644 --- a/renderdoc/driver/gl/gl_driver.cpp +++ b/renderdoc/driver/gl/gl_driver.cpp @@ -241,6 +241,7 @@ void WrappedOpenGL::BuildGLExtensions() m_GLExtensions.push_back("GL_EXT_texture_snorm"); m_GLExtensions.push_back("GL_EXT_texture_sRGB"); m_GLExtensions.push_back("GL_EXT_texture_sRGB_decode"); + m_GLExtensions.push_back("GL_EXT_texture_sRGB_R8"); m_GLExtensions.push_back("GL_EXT_texture_swizzle"); m_GLExtensions.push_back("GL_EXT_texture3D"); m_GLExtensions.push_back("GL_EXT_timer_query"); diff --git a/renderdoc/driver/gl/gl_resources.cpp b/renderdoc/driver/gl/gl_resources.cpp index fa2bb1cbc..667c425ea 100644 --- a/renderdoc/driver/gl/gl_resources.cpp +++ b/renderdoc/driver/gl/gl_resources.cpp @@ -362,6 +362,7 @@ GLenum GetBaseFormat(GLenum internalFormat) { case eGL_R8: case eGL_R8_SNORM: + case eGL_SR8_EXT: case eGL_R16: case eGL_R16_SNORM: case eGL_R16F: @@ -381,6 +382,7 @@ GLenum GetBaseFormat(GLenum internalFormat) case eGL_RED_INTEGER: return eGL_RED_INTEGER; case eGL_RG8: case eGL_RG8_SNORM: + case eGL_SRG8_EXT: case eGL_RG16: case eGL_RG16_SNORM: case eGL_RG16F: @@ -478,6 +480,8 @@ GLenum GetDataType(GLenum internalFormat) case eGL_BGRA8_EXT: case eGL_SRGB8_ALPHA8: case eGL_SRGB8: + case eGL_SRG8_EXT: + case eGL_SR8_EXT: case eGL_SRGB_ALPHA: case eGL_SRGB: case eGL_RED: diff --git a/renderdoc/driver/gl/wrappers/gl_emulated.cpp b/renderdoc/driver/gl/wrappers/gl_emulated.cpp index 49caf0ba1..7d6c359b7 100644 --- a/renderdoc/driver/gl/wrappers/gl_emulated.cpp +++ b/renderdoc/driver/gl/wrappers/gl_emulated.cpp @@ -890,10 +890,12 @@ static const format_data formats[] = { // colour formats {eGL_R8, eGL_UNSIGNED_NORMALIZED, 1, 8, 0, 0}, {eGL_R8_SNORM, eGL_SIGNED_NORMALIZED, 1, 8, 0, 0}, + {eGL_SR8_EXT, eGL_UNSIGNED_NORMALIZED, 1, 8, 0, 0}, {eGL_R16, eGL_UNSIGNED_NORMALIZED, 1, 16, 0, 0}, {eGL_R16_SNORM, eGL_SIGNED_NORMALIZED, 1, 16, 0, 0}, {eGL_RG8, eGL_UNSIGNED_NORMALIZED, 2, 8, 0, 0}, {eGL_RG8_SNORM, eGL_SIGNED_NORMALIZED, 2, 8, 0, 0}, + {eGL_SRG8_EXT, eGL_UNSIGNED_NORMALIZED, 2, 8, 0, 0}, {eGL_RG16, eGL_UNSIGNED_NORMALIZED, 2, 16, 0, 0}, {eGL_RG16_SNORM, eGL_SIGNED_NORMALIZED, 2, 16, 0, 0}, {eGL_RGB4, eGL_UNSIGNED_NORMALIZED, 3, 4, 0, 0}, @@ -1022,7 +1024,8 @@ void APIENTRY _glGetInternalformativ(GLenum target, GLenum internalformat, GLenu if(pname == eGL_COLOR_ENCODING) { - if(internalformat == eGL_SRGB8 || internalformat == eGL_SRGB8_ALPHA8 || + if(internalformat == eGL_SR8_EXT || internalformat == eGL_SRG8_EXT || + internalformat == eGL_SRGB8 || internalformat == eGL_SRGB8_ALPHA8 || internalformat == eGL_SRGB_ALPHA) *params = eGL_SRGB; else