mesa: Implement GL_EXT_texture_sRGB_RG8 for softpipe and llvmpipe
sRGB_RG8 is not registered for big-GL yet, see this Khronos issue for updates on that: https://github.com/KhronosGroup/OpenGL-Registry/issues/450 Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8060>
This commit is contained in:
parent
7b38031fb6
commit
dd05cbf5e0
|
@ -323,6 +323,7 @@ EXT(EXT_texture_rectangle , NV_texture_rectangle
|
|||
EXT(EXT_texture_rg , ARB_texture_rg , x , x , x , ES2, 2011)
|
||||
EXT(EXT_texture_sRGB , EXT_texture_sRGB , GLL, GLC, x , x , 2004)
|
||||
EXT(EXT_texture_sRGB_R8 , EXT_texture_sRGB_R8 , GLL ,GLC, x , 30, 2015)
|
||||
EXT(EXT_texture_sRGB_RG8 , EXT_texture_sRGB_RG8 , x , x , x , 30, 2015)
|
||||
EXT(EXT_texture_sRGB_decode , EXT_texture_sRGB_decode , GLL, GLC, x , 30, 2006)
|
||||
EXT(EXT_texture_shadow_lod , EXT_texture_shadow_lod , GLL, GLC, x , 30, 2018)
|
||||
EXT(EXT_texture_shared_exponent , EXT_texture_shared_exponent , GLL, GLC, x , x , 2004)
|
||||
|
|
|
@ -814,6 +814,7 @@ is_format_color_renderable(const struct gl_context *ctx, mesa_format format,
|
|||
case GL_RGB10:
|
||||
case GL_RGB9_E5:
|
||||
case GL_SR8_EXT:
|
||||
case GL_SRG8_EXT:
|
||||
return GL_FALSE;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -1129,6 +1129,7 @@ _mesa_uncompressed_format_to_type_and_comps(mesa_format format,
|
|||
*comps = 1;
|
||||
return;
|
||||
case MESA_FORMAT_LA_SRGB8:
|
||||
case MESA_FORMAT_RG_SRGB8:
|
||||
*datatype = GL_UNSIGNED_BYTE;
|
||||
*comps = 2;
|
||||
return;
|
||||
|
|
|
@ -151,6 +151,7 @@ MESA_FORMAT_X8B8G8R8_SRGB , packed, 1, 1, 1, x8 , un8 , un8 , u
|
|||
# Array sRGB formats
|
||||
MESA_FORMAT_R_SRGB8 , array , 1, 1, 1, un8 , , , , x001, srgb
|
||||
MESA_FORMAT_L_SRGB8 , array , 1, 1, 1, un8 , , , , xxx1, srgb
|
||||
MESA_FORMAT_RG_SRGB8 , array , 1, 1, 1, un8 , un8 , , , xy01, srgb
|
||||
MESA_FORMAT_LA_SRGB8 , array , 1, 1, 1, un8 , un8 , , , xxxy, srgb
|
||||
MESA_FORMAT_BGR_SRGB8 , array , 1, 1, 1, un8 , un8 , un8 , , zyx1, srgb
|
||||
|
||||
|
|
Can't render this file because it contains an unexpected character in line 9 and column 3.
|
|
@ -432,6 +432,7 @@ typedef enum pipe_format mesa_format;
|
|||
#define MESA_FORMAT_R8G8B8X8_SRGB PIPE_FORMAT_RGBX8888_SRGB
|
||||
#define MESA_FORMAT_X8B8G8R8_SRGB PIPE_FORMAT_XBGR8888_SRGB
|
||||
#define MESA_FORMAT_R_SRGB8 PIPE_FORMAT_R8_SRGB
|
||||
#define MESA_FORMAT_RG_SRGB8 PIPE_FORMAT_R8G8_SRGB
|
||||
#define MESA_FORMAT_L_SRGB8 PIPE_FORMAT_L8_SRGB
|
||||
#define MESA_FORMAT_LA_SRGB8 PIPE_FORMAT_L8A8_SRGB
|
||||
#define MESA_FORMAT_BGR_SRGB8 PIPE_FORMAT_R8G8B8_SRGB
|
||||
|
|
|
@ -2511,6 +2511,15 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint internalFormat)
|
|||
}
|
||||
}
|
||||
|
||||
if (_mesa_has_EXT_texture_sRGB_RG8(ctx)) {
|
||||
switch (internalFormat) {
|
||||
case GL_SRG8_EXT:
|
||||
return GL_RG;
|
||||
default:
|
||||
; /* fallthrough */
|
||||
}
|
||||
}
|
||||
|
||||
if (_mesa_has_integer_textures(ctx)) {
|
||||
switch (internalFormat) {
|
||||
case GL_RGBA8UI_EXT:
|
||||
|
@ -3157,11 +3166,13 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
|
|||
return GL_INVALID_OPERATION;
|
||||
switch (type) {
|
||||
case GL_UNSIGNED_BYTE:
|
||||
if (internalFormat != GL_RG8 &&
|
||||
(!_mesa_has_EXT_texture_compression_rgtc(ctx) ||
|
||||
internalFormat != GL_COMPRESSED_RED_GREEN_RGTC2_EXT))
|
||||
return GL_INVALID_OPERATION;
|
||||
break;
|
||||
if (internalFormat == GL_RG8 ||
|
||||
(_mesa_has_EXT_texture_compression_rgtc(ctx) &&
|
||||
internalFormat == GL_COMPRESSED_RED_GREEN_RGTC2_EXT) ||
|
||||
(_mesa_has_EXT_texture_sRGB_RG8(ctx) &&
|
||||
internalFormat == GL_SRG8_EXT))
|
||||
break;
|
||||
return GL_INVALID_OPERATION;
|
||||
|
||||
case GL_BYTE:
|
||||
if (internalFormat != GL_RG8_SNORM &&
|
||||
|
|
|
@ -138,6 +138,10 @@ typedef int GLclampx;
|
|||
#define GL_SR8_EXT 0x8FBD
|
||||
#endif
|
||||
|
||||
#ifndef GL_EXT_texture_sRGB_RG8
|
||||
#define GL_SRG8_EXT 0x8FBE
|
||||
#endif
|
||||
|
||||
#ifndef GL_AMD_compressed_ATC_texture
|
||||
#define GL_ATC_RGB_AMD 0x8C92
|
||||
#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93
|
||||
|
|
|
@ -4437,6 +4437,7 @@ struct gl_extensions
|
|||
GLboolean EXT_texture_snorm;
|
||||
GLboolean EXT_texture_sRGB;
|
||||
GLboolean EXT_texture_sRGB_R8;
|
||||
GLboolean EXT_texture_sRGB_RG8;
|
||||
GLboolean EXT_texture_sRGB_decode;
|
||||
GLboolean EXT_texture_swizzle;
|
||||
GLboolean EXT_texture_type_2_10_10_10_REV;
|
||||
|
|
|
@ -479,6 +479,9 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
|
|||
case GL_SR8_EXT:
|
||||
RETURN_IF_SUPPORTED(MESA_FORMAT_R_SRGB8);
|
||||
break;
|
||||
case GL_SRG8_EXT:
|
||||
RETURN_IF_SUPPORTED(MESA_FORMAT_RG_SRGB8);
|
||||
break;
|
||||
case GL_SLUMINANCE_EXT:
|
||||
case GL_SLUMINANCE8_EXT:
|
||||
RETURN_IF_SUPPORTED(MESA_FORMAT_L_SRGB8);
|
||||
|
|
|
@ -169,6 +169,7 @@ static const struct internal_format_class_info compatible_internal_formats[] = {
|
|||
{GL_VIEW_CLASS_16_BITS, GL_RG8},
|
||||
{GL_VIEW_CLASS_16_BITS, GL_R16},
|
||||
{GL_VIEW_CLASS_16_BITS, GL_RG8_SNORM},
|
||||
{GL_VIEW_CLASS_16_BITS, GL_SRG8_EXT},
|
||||
{GL_VIEW_CLASS_16_BITS, GL_R16_SNORM},
|
||||
{GL_VIEW_CLASS_8_BITS, GL_R8UI},
|
||||
{GL_VIEW_CLASS_8_BITS, GL_R8I},
|
||||
|
|
|
@ -982,6 +982,9 @@ void st_init_extensions(struct pipe_screen *screen,
|
|||
{ { o(EXT_texture_sRGB_R8) },
|
||||
{ PIPE_FORMAT_R8_SRGB }, },
|
||||
|
||||
{ { o(EXT_texture_sRGB_RG8) },
|
||||
{ PIPE_FORMAT_R8G8_SRGB }, },
|
||||
|
||||
{ { o(EXT_texture_type_2_10_10_10_REV) },
|
||||
{ PIPE_FORMAT_R10G10B10A2_UNORM,
|
||||
PIPE_FORMAT_B10G10R10A2_UNORM },
|
||||
|
|
|
@ -427,6 +427,10 @@ static const struct format_mapping format_map[] = {
|
|||
{ GL_SR8_EXT, 0 },
|
||||
{ PIPE_FORMAT_R8_SRGB, 0 }
|
||||
},
|
||||
{
|
||||
{ GL_SRG8_EXT, 0 },
|
||||
{ PIPE_FORMAT_R8G8_SRGB, 0 }
|
||||
},
|
||||
|
||||
/* 16-bit float formats */
|
||||
{
|
||||
|
|
|
@ -240,6 +240,10 @@ util_format_test_cases[] =
|
|||
{PIPE_FORMAT_R8_SRGB, PACKED_1x8(0xff), PACKED_1x8(0xbc), UNPACKED_1x1(0.502886458033, 0.0, 0.0, 1.0)},
|
||||
{PIPE_FORMAT_R8_SRGB, PACKED_1x8(0xff), PACKED_1x8(0xff), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
|
||||
|
||||
{PIPE_FORMAT_R8G8_SRGB, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
|
||||
{PIPE_FORMAT_R8G8_SRGB, PACKED_2x8(0xff, 0xff), PACKED_2x8(0xbc, 0xbc), UNPACKED_1x1(0.502886458033, 0.502886458033, 0.0, 1.0)},
|
||||
{PIPE_FORMAT_R8G8_SRGB, PACKED_2x8(0xff, 0xff), PACKED_2x8(0xff, 0xff), UNPACKED_1x1(1.0, 1.0, 0.0, 1.0)},
|
||||
|
||||
{PIPE_FORMAT_L8A8_SRGB, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
|
||||
{PIPE_FORMAT_L8A8_SRGB, PACKED_1x16(0xffff), PACKED_1x16(0x00bc), UNPACKED_1x1(0.502886458033, 0.502886458033, 0.502886458033, 0.0)},
|
||||
{PIPE_FORMAT_L8A8_SRGB, PACKED_1x16(0xffff), PACKED_1x16(0x00ff), UNPACKED_1x1(1.0, 1.0, 1.0, 0.0)},
|
||||
|
|
Loading…
Reference in New Issue