Mesa (master): meta: Refactor texture format translation

Topi Pohjolainen tpohjola at kemper.freedesktop.org
Fri Jan 27 07:33:10 UTC 2017


Module: Mesa
Branch: master
Commit: a283a4ee2fba6c8efa4f4e4eeea6b3d7b21df4d0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a283a4ee2fba6c8efa4f4e4eeea6b3d7b21df4d0

Author: Topi Pohjolainen <topi.pohjolainen at intel.com>
Date:   Sat Nov 26 18:03:56 2016 +0200

meta: Refactor texture format translation

Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>

---

 src/mesa/drivers/common/meta_tex_subimage.c |  9 +++------
 src/mesa/main/glformats.c                   | 15 +++++++++++++++
 src/mesa/main/glformats.h                   |  4 ++++
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/common/meta_tex_subimage.c b/src/mesa/drivers/common/meta_tex_subimage.c
index 703efcd..b8c422b 100644
--- a/src/mesa/drivers/common/meta_tex_subimage.c
+++ b/src/mesa/drivers/common/meta_tex_subimage.c
@@ -72,7 +72,8 @@ create_texture_for_pbo(struct gl_context *ctx,
                        const struct gl_pixelstore_attrib *packing,
                        struct gl_buffer_object **tmp_pbo, GLuint *tmp_tex)
 {
-   uint32_t pbo_format;
+   const mesa_format pbo_format =
+      _mesa_tex_format_from_format_and_type(ctx, format, type);
    GLenum internal_format;
    unsigned row_stride;
    struct gl_buffer_object *buffer_obj;
@@ -85,11 +86,7 @@ create_texture_for_pbo(struct gl_context *ctx,
        packing->Invert)
       return NULL;
 
-   pbo_format = _mesa_format_from_format_and_type(format, type);
-   if (_mesa_format_is_mesa_array_format(pbo_format))
-      pbo_format = _mesa_format_from_array_format(pbo_format);
-
-   if (!pbo_format || !ctx->TextureFormatSupported[pbo_format])
+   if (pbo_format == MESA_FORMAT_NONE)
       return NULL;
 
    /* Account for SKIP_PIXELS, SKIP_ROWS, ALIGNMENT, and SKIP_IMAGES */
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index a95909c..4f24020 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -3632,6 +3632,21 @@ _mesa_format_from_format_and_type(GLenum format, GLenum type)
    unreachable("Unsupported format");
 }
 
+uint32_t
+_mesa_tex_format_from_format_and_type(const struct gl_context *ctx,
+                                      GLenum gl_format, GLenum type)
+{
+   mesa_format format = _mesa_format_from_format_and_type(gl_format, type);
+
+   if (_mesa_format_is_mesa_array_format(format))
+      format = _mesa_format_from_array_format(format);
+      
+   if (format == MESA_FORMAT_NONE || !ctx->TextureFormatSupported[format])
+      return MESA_FORMAT_NONE;
+
+   return format;
+}
+
 /**
  * Returns true if \p internal_format is a sized internal format that
  * is marked "Color Renderable" in Table 8.10 of the ES 3.2 specification.
diff --git a/src/mesa/main/glformats.h b/src/mesa/main/glformats.h
index 763307f..5c9d826 100644
--- a/src/mesa/main/glformats.h
+++ b/src/mesa/main/glformats.h
@@ -148,6 +148,10 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint internalFormat );
 extern uint32_t
 _mesa_format_from_format_and_type(GLenum format, GLenum type);
 
+extern uint32_t
+_mesa_tex_format_from_format_and_type(const struct gl_context *ctx,
+                                      GLenum gl_format, GLenum type);
+
 extern bool
 _mesa_is_es3_color_renderable(GLenum internal_format);
 




More information about the mesa-commit mailing list