[Mesa-dev] [PATCH 2/6] st/mesa: tweak surface format mapping table

Brian Paul brianp at vmware.com
Tue Jun 7 19:03:39 UTC 2016


1. Try to choose R8G8B8A8 unorm/srgb formats before others in an
effort to try to match component ordering for UINT/SINT/etc.

2. If we can't get a format such as PIPE_FORMAT_A16_UNORM, try
PIPE_FORMAT_R16G16B16A16_UNORM before shallower formats.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
---
 src/mesa/state_tracker/st_format.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 9a280fc..acb7725 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -1062,23 +1062,23 @@ struct format_mapping
 
 
 #define DEFAULT_RGBA_FORMATS \
-      PIPE_FORMAT_B8G8R8A8_UNORM, \
       PIPE_FORMAT_R8G8B8A8_UNORM, \
+      PIPE_FORMAT_B8G8R8A8_UNORM, \
       PIPE_FORMAT_A8R8G8B8_UNORM, \
       PIPE_FORMAT_A8B8G8R8_UNORM, \
       0
 
 #define DEFAULT_RGB_FORMATS \
-      PIPE_FORMAT_B8G8R8X8_UNORM, \
       PIPE_FORMAT_R8G8B8X8_UNORM, \
+      PIPE_FORMAT_B8G8R8X8_UNORM, \
       PIPE_FORMAT_X8R8G8B8_UNORM, \
       PIPE_FORMAT_X8B8G8R8_UNORM, \
       PIPE_FORMAT_B5G6R5_UNORM, \
       DEFAULT_RGBA_FORMATS
 
 #define DEFAULT_SRGBA_FORMATS \
-      PIPE_FORMAT_B8G8R8A8_SRGB, \
       PIPE_FORMAT_R8G8B8A8_SRGB, \
+      PIPE_FORMAT_B8G8R8A8_SRGB, \
       PIPE_FORMAT_A8R8G8B8_SRGB, \
       PIPE_FORMAT_A8B8G8R8_SRGB, \
       0
@@ -1169,8 +1169,8 @@ static const struct format_mapping format_map[] = {
    /* basic Alpha formats */
    {
       { GL_ALPHA12, GL_ALPHA16, 0 },
-      { PIPE_FORMAT_A16_UNORM, PIPE_FORMAT_A8_UNORM,
-        DEFAULT_RGBA_FORMATS }
+      { PIPE_FORMAT_A16_UNORM, PIPE_FORMAT_R16G16B16A16_UNORM,
+        PIPE_FORMAT_A8_UNORM, DEFAULT_RGBA_FORMATS }
    },
    {
       { GL_ALPHA, GL_ALPHA4, GL_ALPHA8, GL_COMPRESSED_ALPHA, 0 },
@@ -1180,7 +1180,8 @@ static const struct format_mapping format_map[] = {
    /* basic Luminance formats */
    {
       { GL_LUMINANCE12, GL_LUMINANCE16, 0 },
-      { PIPE_FORMAT_L16_UNORM, PIPE_FORMAT_L8_UNORM, DEFAULT_RGB_FORMATS }
+      { PIPE_FORMAT_L16_UNORM, PIPE_FORMAT_R16G16B16A16_UNORM,
+        PIPE_FORMAT_L8_UNORM, DEFAULT_RGB_FORMATS }
    },
    {
       { 1, GL_LUMINANCE, GL_LUMINANCE4, GL_LUMINANCE8, 0 },
@@ -1191,8 +1192,8 @@ static const struct format_mapping format_map[] = {
    {
       { GL_LUMINANCE12_ALPHA4, GL_LUMINANCE12_ALPHA12,
         GL_LUMINANCE16_ALPHA16, 0},
-      { PIPE_FORMAT_L16A16_UNORM, PIPE_FORMAT_L8A8_UNORM,
-        DEFAULT_RGBA_FORMATS }
+      { PIPE_FORMAT_L16A16_UNORM, PIPE_FORMAT_R16G16B16A16_UNORM,
+        PIPE_FORMAT_L8A8_UNORM, DEFAULT_RGBA_FORMATS }
    },
    {
       { 2, GL_LUMINANCE_ALPHA, GL_LUMINANCE6_ALPHA2, GL_LUMINANCE8_ALPHA8, 0 },
@@ -1207,7 +1208,8 @@ static const struct format_mapping format_map[] = {
    /* basic Intensity formats */
    {
       { GL_INTENSITY12, GL_INTENSITY16, 0 },
-      { PIPE_FORMAT_I16_UNORM, PIPE_FORMAT_I8_UNORM, DEFAULT_RGBA_FORMATS }
+      { PIPE_FORMAT_I16_UNORM, PIPE_FORMAT_R16G16B16A16_UNORM,
+        PIPE_FORMAT_I8_UNORM, DEFAULT_RGBA_FORMATS }
    },
    {
       { GL_INTENSITY, GL_INTENSITY4, GL_INTENSITY8,
-- 
1.9.1



More information about the mesa-dev mailing list