From f94f2e1223ada056663c4c54c8098504eb091f55 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Tue, 4 May 2021 10:59:31 +0200 Subject: mesa: add an extension MESA_bgra This GLES extension allows to combine the formats BGR and BGRA as host-side formatsto be combined with the internal formats RGB8/SRGB8 and RGBA8/SRGB8_ALPHA8 respectively. This extension is of interest to support a subset of OpenGL in virtualized environments where the host only supports GLES. Initial mesa/glformat.c patch: rohan.garg@collabora.com v2: - Correct names for ClearTexture calls - Add BGR(A)_EXT tokens - Add format check for BGR_EXT (All Adam Jackson) v3: Fix ordering in extension table (Marge) Signed-off-by: Gert Wollny Reviewed-by: Adam Jackson (v2) Part-of: --- docs/_extra/specs/MESA_bgra.txt | 106 +++++++++++++++++++++++++++++++++++++++ src/mesa/main/extensions_table.h | 1 + src/mesa/main/glformats.c | 12 ++++- 3 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 docs/_extra/specs/MESA_bgra.txt diff --git a/docs/_extra/specs/MESA_bgra.txt b/docs/_extra/specs/MESA_bgra.txt new file mode 100644 index 00000000000..05de73593a0 --- /dev/null +++ b/docs/_extra/specs/MESA_bgra.txt @@ -0,0 +1,106 @@ +Name + + MESA_bgra + +Name Strings + + GL_MESA_bgra + +Contact + + Gert Wollny (gert.wollny 'at' collabora.com) + +Notice + + Copyright (c) 2021 Collabora LTD + Copyright (c) 2009-2013 The Khronos Group Inc. Copyright terms at + http://www.khronos.org/registry/speccopyright.html + +Version + + Version 1, 2021/04/30. + Based on EXT_bgra version 1, modified 1997/05/19. + +Number + + TBD + +Dependencies + + OpenGL ES 2.0 is required. + Written based on the wording of the OpenGL ES 3.2 specification. + There are interactions with the extensions EXT_clear_texture. + +Overview + + MESA_bgra extends the list of combinations host-memory color formats + with internal formats to include BGRA and BGR as acceptable formats + with RGB8/SRGB8 and RGBA/sRGB8_ALPHA8 as internal formats respectively. + This feature is of interest in virtualized environments, where the host + supports OpenGL ES only, and the virtualized guest is supposed to support + a subset of OpenGL including textures created with the format BGRA. + +IP Status + + Open-source; freely implementable. + +Issues + + None. + +New Procedures and Functions + + None + +New Tokens + + Accepted by the parameter of TexImage2D and TexSubImage2D: + + GL_BGR_EXT 0x80E0 + GL_BGRA_EXT 0x80E1 + +Additions to Chapter 8 of the GLES 3.2 Specification (Textures and Samplers) + + Add to table 8.2 (Pixels data formats, valid combinations of format, + type, and unsized internalformat). + + Format Type External Internal Format + Bytes + per Pixel + ------------------------------------------------------------- + BGRA UNSIGNED_BYTE 4 RGBA + BGR UNSIGNED_BYTE 3 RGB + + + + Add to table 8.5 (Pixels data formats). + + Format Name Elements Meaning and Order Target Buffer + ------------------------------------------------------------- + BGR_EXT B, G, R Color + BGRA_EXT B, G, R, A Color + + + Add to table 8.9 (Effective internal format correspondig to + external format). + + Format Type Effective + Internal format + ------------------------------------------------------------- + BGRA_EXT UNSIGNED_BYTE RGBA8 + BGR_EXT UNSIGNED_BYTE RGB8 + +Interactions with EXT_clear_texture + + When EXT_clear_texture is supported the accepted formats for + ClearTextureEXT and ClearSubTextureEXT are extended to include + the entries added above. + + +Revision History + + Original draft, revision 1.0, May 4, 2021 (Gert Wollny) + rewrite EXT_bgra against OpenGL ES 3.2 instead of OpenGL 1,0. + + Revision 1.1 (May 5. 2021): Add the new tokens, and fix + Clear*Texture function names. diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index 0afa5d365b3..37f1febd4f2 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -367,6 +367,7 @@ EXT(KHR_texture_compression_astc_hdr , KHR_texture_compression_astc_hdr EXT(KHR_texture_compression_astc_ldr , KHR_texture_compression_astc_ldr , GLL, GLC, x , ES2, 2012) EXT(KHR_texture_compression_astc_sliced_3d , KHR_texture_compression_astc_sliced_3d , GLL, GLC, x , ES2, 2015) +EXT(MESA_bgra , dummy_true , x , x , x , ES2, 2021) EXT(MESA_framebuffer_flip_y , MESA_framebuffer_flip_y , 43, 43, x , 30, 2018) EXT(MESA_pack_invert , dummy_true , GLL, GLC, x , x , 2002) EXT(MESA_shader_integer_functions , MESA_shader_integer_functions , GLL, GLC, x , 30, 2016) diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index 3d34a226fbd..641b103a914 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -2859,7 +2859,17 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx, switch (format) { case GL_BGRA_EXT: - if (type != GL_UNSIGNED_BYTE || internalFormat != GL_BGRA) + if (type != GL_UNSIGNED_BYTE || + (internalFormat != GL_BGRA && + internalFormat != GL_RGBA8 && + internalFormat != GL_SRGB8_ALPHA8)) + return GL_INVALID_OPERATION; + break; + + case GL_BGR_EXT: + if (type != GL_UNSIGNED_BYTE || + (internalFormat != GL_RGB8 && + internalFormat != GL_SRGB8)) return GL_INVALID_OPERATION; break; -- cgit v1.2.3