summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
authorErik Faye-Lund <erik.faye-lund@collabora.com>2024-01-23 17:41:21 +0100
committerMarge Bot <emma+marge@anholt.net>2024-02-01 12:30:58 +0000
commit4de62731f4db56360026cbb6a3b8566f86f22466 (patch)
tree3a6fe29542a6f8194092ed2a9f76637a848fb926 /src/mesa/main
parent16f6f50ce49c965302c4d81fd65c96c9d630f66b (diff)
mesa/main: add support for EXT_texture_storage
It's sometimes really, really useful if GL_BGRA8 can be used as a sized internal format, and the combination of EXT_texture_storage and EXT_texture_format_BGRA8888 allows this (only when using texture-storage, which is good enough in some cases). Until now, we've only implemented ARB_texture_storage, and not the EXT version. So let's implement the EXT version as well, so we get the benefit of the interaction here. This pulls in a lot of other similar interactions as well, which also seems useful. ...because the ARB version is created from the EXT version, let's move the EXT function definitions to the EXT extension. These should probably have been suffixed with ARB in the ARB-version, but things seems to have just ended up kinda confused. Oh well. Reviewed-by: Daniel Stone <daniels@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27222>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/extensions_table.h1
-rw-r--r--src/mesa/main/texstorage.c50
2 files changed, 51 insertions, 0 deletions
diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
index 417ffe2a905..add6c849fbe 100644
--- a/src/mesa/main/extensions_table.h
+++ b/src/mesa/main/extensions_table.h
@@ -341,6 +341,7 @@ EXT(EXT_texture_sRGB_decode , EXT_texture_sRGB_decode
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)
EXT(EXT_texture_snorm , EXT_texture_snorm , GLL, GLC, x , x , 2009)
+EXT(EXT_texture_storage , dummy_true , GLL, GLC, x , ES2, 2009)
EXT(EXT_texture_swizzle , EXT_texture_swizzle , GLL, GLC, x , x , 2008)
EXT(EXT_texture_type_2_10_10_10_REV , EXT_texture_type_2_10_10_10_REV , x , x , x , ES2, 2008)
EXT(EXT_texture_view , OES_texture_view , x , x , x , 31, 2014)
diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c
index b1f8de70c41..636fcbf97e7 100644
--- a/src/mesa/main/texstorage.c
+++ b/src/mesa/main/texstorage.c
@@ -221,6 +221,56 @@ GLboolean
_mesa_is_legal_tex_storage_format(const struct gl_context *ctx,
GLenum internalformat)
{
+ if (!_mesa_is_desktop_gl(ctx)) {
+ assert(_mesa_has_EXT_texture_storage(ctx));
+
+ /* EXT_texture_storage allows us to use some sized internal formats
+ * for TexStorage* that aren't otherwise allowed in OpenGL ES.
+ **/
+ switch (internalformat) {
+ case GL_ALPHA8:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE8_ALPHA8:
+ return true;
+
+ case GL_RGBA32F:
+ case GL_RGB32F:
+ case GL_ALPHA32F_EXT:
+ case GL_LUMINANCE32F_EXT:
+ case GL_LUMINANCE_ALPHA32F_EXT:
+ return _mesa_has_OES_texture_float(ctx);
+
+ case GL_RGBA16F:
+ case GL_RGB16F:
+ case GL_ALPHA16F_EXT:
+ case GL_LUMINANCE16F_EXT:
+ case GL_LUMINANCE_ALPHA16F_EXT:
+ return _mesa_has_OES_texture_half_float(ctx);
+
+ case GL_RGB10_A2:
+ case GL_RGB10:
+ return _mesa_has_EXT_texture_type_2_10_10_10_REV(ctx);
+
+ case GL_BGRA8_EXT:
+ assert(_mesa_has_EXT_texture_format_BGRA8888(ctx));
+ return true;
+
+ case GL_R8:
+ case GL_RG8:
+ return _mesa_has_EXT_texture_rg(ctx);
+
+ case GL_R32F_EXT:
+ case GL_RG32F_EXT:
+ return _mesa_has_EXT_texture_rg(ctx) &&
+ _mesa_has_OES_texture_float(ctx);
+
+ case GL_R16F_EXT:
+ case GL_RG16F_EXT:
+ return _mesa_has_EXT_texture_rg(ctx) &&
+ _mesa_has_OES_texture_half_float(ctx);
+ }
+ }
+
/* check internal format - note that only sized formats are allowed */
switch (internalformat) {
case GL_ALPHA: