On Mon, Oct 29, 2018 at 3:39 AM Gert Wollny <gert.wol...@collabora.com> wrote: > > EXT_texture_sRGB_R8 adds a GLES sRGB texture format with only one channel. > > v2: - fix format definition line > - disable for desktop GL > - don't add GL_R8_EXT to glext.h since it is already in > GLES2/gl2ext.h in glext.h and include this header where needed > (all Emil) > v3: - swrast: Fill the function table for sRGB_R8 > The size of the function table is checked at compile time and must > correspond to the number of mesa texture formats. > dri/swrast being gles-2.0 doesn't support the extension though > > Signed-off-by: Gert Wollny <gert.wol...@collabora.com> > --- > src/mesa/main/extensions_table.h | 1 + > src/mesa/main/formats.c | 2 ++ > src/mesa/main/formats.csv | 1 + > src/mesa/main/formats.h | 1 + > src/mesa/main/glformats.c | 17 +++++++++++++++-- > src/mesa/main/mtypes.h | 1 + > src/mesa/main/texformat.c | 7 +++++++ > src/mesa/swrast/s_texfetch.c | 1 + > src/mesa/swrast/s_texfetch_tmp.h | 1 + > 9 files changed, 30 insertions(+), 2 deletions(-) > > diff --git a/src/mesa/main/extensions_table.h > b/src/mesa/main/extensions_table.h > index 09bf923bd0..b5a1d00906 100644 > --- a/src/mesa/main/extensions_table.h > +++ b/src/mesa/main/extensions_table.h > @@ -295,6 +295,7 @@ EXT(EXT_texture_object , dummy_true > EXT(EXT_texture_rectangle , NV_texture_rectangle > , GLL, x , x , x , 2004) > 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 > , x , x , x , 30, 2015) > EXT(EXT_texture_sRGB_decode , EXT_texture_sRGB_decode > , GLL, GLC, x , 30, 2006) > EXT(EXT_texture_shared_exponent , EXT_texture_shared_exponent > , GLL, GLC, x , x , 2004) > EXT(EXT_texture_snorm , EXT_texture_snorm > , GLL, GLC, x , x , 2009) > diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c > index d4cd5d2182..cf2d2bc555 100644 > --- a/src/mesa/main/formats.c > +++ b/src/mesa/main/formats.c > @@ -1108,6 +1108,7 @@ _mesa_uncompressed_format_to_type_and_comps(mesa_format > format, > *comps = 4; > return; > case MESA_FORMAT_L_SRGB8: > + case MESA_FORMAT_R_SRGB8: > *datatype = GL_UNSIGNED_BYTE; > *comps = 1; > return; > @@ -1670,6 +1671,7 @@ _mesa_format_matches_format_and_type(mesa_format > mesa_format, > (type == GL_UNSIGNED_SHORT_8_8_REV_MESA && littleEndian != > swapBytes)); > > case MESA_FORMAT_R_UNORM8: > + case MESA_FORMAT_R_SRGB8: > return format == GL_RED && type == GL_UNSIGNED_BYTE; > case MESA_FORMAT_R8G8_UNORM: > return format == GL_RG && type == GL_UNSIGNED_BYTE && littleEndian; > diff --git a/src/mesa/main/formats.csv b/src/mesa/main/formats.csv > index ce53f8f056..cb821fec62 100644 > --- a/src/mesa/main/formats.csv > +++ b/src/mesa/main/formats.csv > @@ -158,6 +158,7 @@ MESA_FORMAT_L8A8_SRGB , packed, 1, 1, > 1, un8 , un8 , , > MESA_FORMAT_A8L8_SRGB , packed, 1, 1, 1, un8 , un8 , > , , yyyx, srgb > > # 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_BGR_SRGB8 , array , 1, 1, 1, un8 , un8 , un8 > , , zyx1, srgb > > diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h > index 335e4de995..7033e2a88a 100644 > --- a/src/mesa/main/formats.h > +++ b/src/mesa/main/formats.h > @@ -440,6 +440,7 @@ typedef enum > MESA_FORMAT_X8B8G8R8_SRGB, /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx > */ > MESA_FORMAT_L8A8_SRGB, /* AAAA AAAA LLLL LLLL > */ > MESA_FORMAT_A8L8_SRGB, /* LLLL LLLL AAAA AAAA > */ > + MESA_FORMAT_R_SRGB8, /* RRRR */
RRRR RRRR > > /* Array sRGB formats */ > MESA_FORMAT_L_SRGB8, /* ubyte[i] = L */ > diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c > index 6cb3435dea..3ed35f84e2 100644 > --- a/src/mesa/main/glformats.c > +++ b/src/mesa/main/glformats.c > @@ -31,6 +31,10 @@ > #include "texcompress.h" > #include "enums.h" > > +/* For GL_SR8_EXT */ > +#include <GLES2/gl2.h> > +#include <GLES2/gl2ext.h> > + > enum { > ZERO = 4, > ONE = 5 > @@ -2486,6 +2490,15 @@ _mesa_base_tex_format(const struct gl_context *ctx, > GLint internalFormat) > } > } > > + if (ctx->Extensions.EXT_texture_sRGB_R8) { > + switch (internalFormat) { > + case GL_SR8_EXT: > + return GL_RED; > + default: > + ; /* fallthrough */ > + } > + } > + > if (ctx->Version >= 30 || > ctx->Extensions.EXT_texture_integer) { > switch (internalFormat) { > @@ -3200,11 +3213,11 @@ _mesa_es3_error_check_format_and_type(const struct > gl_context *ctx, > break; > > case GL_RED: > - if (!ctx->Extensions.ARB_texture_rg) > + if (!ctx->Extensions.ARB_texture_rg || > !ctx->Extensions.EXT_texture_sRGB_R8) && > return GL_INVALID_OPERATION; > switch (type) { > case GL_UNSIGNED_BYTE: > - if (internalFormat != GL_R8) > + if (internalFormat != GL_R8 && internalFormat != GL_SR8_EXT) > return GL_INVALID_OPERATION; > break; > > diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h > index 9ed49b7ff2..656e1226f9 100644 > --- a/src/mesa/main/mtypes.h > +++ b/src/mesa/main/mtypes.h > @@ -4264,6 +4264,7 @@ struct gl_extensions > GLboolean EXT_texture_shared_exponent; > GLboolean EXT_texture_snorm; > GLboolean EXT_texture_sRGB; > + GLboolean EXT_texture_sRGB_R8; > GLboolean EXT_texture_sRGB_decode; > GLboolean EXT_texture_swizzle; > GLboolean EXT_texture_type_2_10_10_10_REV; > diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c > index 822f80f89e..e4d21b0f0b 100644 > --- a/src/mesa/main/texformat.c > +++ b/src/mesa/main/texformat.c > @@ -40,6 +40,10 @@ > #include "texformat.h" > #include "glformats.h" > > +/* FOR GL_SR8_EXT */ > +#include <GLES2/gl2.h> > +#include <GLES2/gl2ext.h> > + > #define RETURN_IF_SUPPORTED(f) do { \ > if (ctx->TextureFormatSupported[f]) \ > return f; \ > @@ -477,6 +481,9 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum > target, > RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB); > RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB); > break; > + case GL_SR8_EXT: > + RETURN_IF_SUPPORTED(MESA_FORMAT_R_SRGB8); > + break; > case GL_SLUMINANCE_EXT: > case GL_SLUMINANCE8_EXT: > RETURN_IF_SUPPORTED(MESA_FORMAT_L_SRGB8); > diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c > index fec8728a7a..e8f4eb598a 100644 > --- a/src/mesa/swrast/s_texfetch.c > +++ b/src/mesa/swrast/s_texfetch.c > @@ -257,6 +257,7 @@ texfetch_funcs[] = > FETCH_FUNCS(A8L8_SRGB), > > /* Array sRGB formats */ > + FETCH_FUNCS(R_SRGB8), > FETCH_FUNCS(L_SRGB8), > FETCH_FUNCS(BGR_SRGB8), > > diff --git a/src/mesa/swrast/s_texfetch_tmp.h > b/src/mesa/swrast/s_texfetch_tmp.h > index 45bd839504..8261ebf46e 100644 > --- a/src/mesa/swrast/s_texfetch_tmp.h > +++ b/src/mesa/swrast/s_texfetch_tmp.h > @@ -153,6 +153,7 @@ FETCH_RGBA(A8R8G8B8_SRGB, GLuint, 1) > FETCH_RGBA(R8G8B8A8_SRGB, GLuint, 1) > FETCH_RGBA(R8G8B8X8_SRGB, GLuint, 1) > FETCH_RGBA(X8B8G8R8_SRGB, GLuint, 1) > +FETCH_RGBA(R_SRGB8, GLubyte, 1) > FETCH_RGBA(L_SRGB8, GLubyte, 1) > FETCH_RGBA(L8A8_SRGB, GLushort, 1) > FETCH_RGBA(A8L8_SRGB, GLushort, 2) > -- > 2.19.1 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev