[Mesa-dev] [PATCH] st/mesa: add fallback pipe formats for (compressed) R, RG formats

Brian Paul brianp at vmware.com
Thu Jan 19 07:54:25 PST 2012


If we don't find an exact PIPE_FORMAT_x for a GL_(COMPRESSED)_RED/RG format,
try uncompressed formats.  We were already doing this for the RGB(A) formats.

Fixes piglit arb_texture_compression-internal-format-query test.

NOTE: This is a candidate for the stable branches.
---
 configs/default                    |    4 +++-
 configs/linux-dri                  |    3 ++-
 src/mesa/main/context.c            |   13 +++++++++++++
 src/mesa/main/texparam.c           |    4 ++++
 src/mesa/state_tracker/st_format.c |   34 ++++++++++++++++++++++------------
 5 files changed, 44 insertions(+), 14 deletions(-)

diff --git a/configs/default b/configs/default
index 2ca6fe4..5e7bc64 100644
--- a/configs/default
+++ b/configs/default
@@ -119,7 +119,9 @@ GBM_BACKEND_DIRS = dri
 # Gallium directories and
 GALLIUM_DIRS = auxiliary drivers state_trackers
 GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a
-GALLIUM_DRIVERS_DIRS = softpipe trace rbug noop identity galahad i915 svga r300 nvfx nv50
+#GALLIUM_DRIVERS_DIRS = softpipe trace rbug noop identity galahad i915 svga r300 nvfx nv50
+GALLIUM_DRIVERS_DIRS = softpipe trace rbug noop identity galahad i915 svga r300
+
 GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
 GALLIUM_WINSYS_DIRS = sw sw/xlib
 GALLIUM_TARGET_DIRS = libgl-xlib
diff --git a/configs/linux-dri b/configs/linux-dri
index dde6408..6db0aca 100644
--- a/configs/linux-dri
+++ b/configs/linux-dri
@@ -62,7 +62,8 @@ GALLIUM_WINSYS_DIRS = sw sw/xlib drm/vmware drm/intel svga/drm
 GALLIUM_TARGET_DIRS = dri-vmwgfx
 GALLIUM_STATE_TRACKERS_DIRS = egl dri
 
-DRI_DIRS = i915 nouveau r200 radeon swrast
+#DRI_DIRS = i915 i965 nouveau r200 radeon swrast
+DRI_DIRS =
 
 INTEL_LIBS = $(shell $(PKG_CONFIG) --libs libdrm_intel)
 INTEL_CFLAGS = $(shell $(PKG_CONFIG) --cflags libdrm_intel)
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index f39cab5..5409062 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -906,6 +906,19 @@ _mesa_initialize_context(struct gl_context *ctx,
    struct gl_shared_state *shared;
    int i;
 
+   if (1) {
+      FILE * f = fopen("/tmp/mesa.log", "a");
+      fprintf(f, "init %d\n", getpid());
+      fprintf(f, "Sleeping\n");
+      fflush(f);
+      sleep(1);
+      fprintf(f, "Done Sleeping\n");
+      fclose(f);
+   }
+
+#if 0
+#endif
+
    /*ASSERT(driverContext);*/
    assert(driverFunctions->NewTextureObject);
    assert(driverFunctions->FreeTextureImageBuffer);
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index 0f92a5b..e179e49 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -314,6 +314,7 @@ set_tex_parameteri(struct gl_context *ctx,
          return GL_FALSE;
       }
       incomplete(ctx, texObj);
+      printf("Set BASE LEVEL %d\n", params[0]);
       texObj->BaseLevel = params[0];
       return GL_TRUE;
 
@@ -326,6 +327,7 @@ set_tex_parameteri(struct gl_context *ctx,
          return GL_FALSE;
       }
       incomplete(ctx, texObj);
+      printf("Set MAX LEVEL %d\n", params[0]);
       texObj->MaxLevel = params[0];
       return GL_TRUE;
 
@@ -504,6 +506,7 @@ set_tex_parameterf(struct gl_context *ctx,
       if (texObj->Sampler.MinLod == params[0])
          return GL_FALSE;
       flush(ctx);
+      printf("Set MIN_LOD %f\n", params[0]);
       texObj->Sampler.MinLod = params[0];
       return GL_TRUE;
 
@@ -511,6 +514,7 @@ set_tex_parameterf(struct gl_context *ctx,
       if (texObj->Sampler.MaxLod == params[0])
          return GL_FALSE;
       flush(ctx);
+      printf("Set MAX_LOD %f\n", params[0]);
       texObj->Sampler.MaxLod = params[0];
       return GL_TRUE;
 
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 5f9ae91..620910d 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -839,6 +839,15 @@ struct format_mapping
       PIPE_FORMAT_S8_UINT_Z24_UNORM, \
       0
 
+#define DEFAULT_SNORM8_RGBA_FORMATS \
+      PIPE_FORMAT_R8G8B8A8_SNORM, \
+      0
+
+#define DEFAULT_UNORM16_RGBA_FORMATS \
+      PIPE_FORMAT_R16G16B16A16_UNORM, \
+      DEFAULT_RGBA_FORMATS
+
+
 /**
  * This table maps OpenGL texture format enums to Gallium pipe_format enums.
  * Multiple GL enums might map to multiple pipe_formats.
@@ -1145,54 +1154,55 @@ static const struct format_mapping format_map[] = {
    /* R, RG formats */
    {
       { GL_RED, GL_R8, 0 },
-      { PIPE_FORMAT_R8_UNORM, 0 }
+      { PIPE_FORMAT_R8_UNORM, PIPE_FORMAT_R8G8_UNORM, DEFAULT_RGBA_FORMATS }
    },
    {
       { GL_RG, GL_RG8, 0 },
-      { PIPE_FORMAT_R8G8_UNORM, 0 }
+      { PIPE_FORMAT_R8G8_UNORM, DEFAULT_RGBA_FORMATS }
    },
    {
       { GL_R16, 0 },
-      { PIPE_FORMAT_R16_UNORM, 0 }
+      { PIPE_FORMAT_R16_UNORM, PIPE_FORMAT_R16G16_UNORM,
+        DEFAULT_UNORM16_RGBA_FORMATS }
    },
    {
       { GL_RG16, 0 },
-      { PIPE_FORMAT_R16G16_UNORM, 0 }
+      { PIPE_FORMAT_R16G16_UNORM, DEFAULT_UNORM16_RGBA_FORMATS }
    },
 
    /* compressed R, RG formats */
    {
       { GL_COMPRESSED_RED, GL_COMPRESSED_RED_RGTC1, 0 },
-      { PIPE_FORMAT_RGTC1_UNORM, PIPE_FORMAT_R8_UNORM, 0 }
+      { PIPE_FORMAT_RGTC1_UNORM, PIPE_FORMAT_R8_UNORM, DEFAULT_RGBA_FORMATS }
    },
    {
       { GL_COMPRESSED_SIGNED_RED_RGTC1, 0 },
-      { PIPE_FORMAT_RGTC1_SNORM, 0 }
+      { PIPE_FORMAT_RGTC1_SNORM, DEFAULT_SNORM8_RGBA_FORMATS }
    },
    {
       { GL_COMPRESSED_RG, GL_COMPRESSED_RG_RGTC2, 0 },
-      { PIPE_FORMAT_RGTC2_UNORM, PIPE_FORMAT_R8G8_UNORM, 0 }
+      { PIPE_FORMAT_RGTC2_UNORM, PIPE_FORMAT_R8G8_UNORM, DEFAULT_RGBA_FORMATS }
    },
    {
       { GL_COMPRESSED_SIGNED_RG_RGTC2, 0 },
-      { PIPE_FORMAT_RGTC2_SNORM, 0 }
+      { PIPE_FORMAT_RGTC2_SNORM, DEFAULT_SNORM8_RGBA_FORMATS }
    },
    {
       { GL_COMPRESSED_LUMINANCE, GL_COMPRESSED_LUMINANCE_LATC1_EXT, 0 },
-      { PIPE_FORMAT_LATC1_UNORM, PIPE_FORMAT_L8_UNORM, 0 }
+      { PIPE_FORMAT_LATC1_UNORM, PIPE_FORMAT_L8_UNORM, DEFAULT_RGBA_FORMATS }
    },
    {
       { GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT, 0 },
-      { PIPE_FORMAT_LATC1_SNORM, 0 }
+      { PIPE_FORMAT_LATC1_SNORM, DEFAULT_SNORM8_RGBA_FORMATS }
    },
    {
       { GL_COMPRESSED_LUMINANCE_ALPHA, GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT,
         GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI, 0 },
-      { PIPE_FORMAT_LATC2_UNORM, PIPE_FORMAT_L8A8_UNORM, 0 }
+      { PIPE_FORMAT_LATC2_UNORM, PIPE_FORMAT_L8A8_UNORM, DEFAULT_RGBA_FORMATS }
    },
    {
       { GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT, 0 },
-      { PIPE_FORMAT_LATC2_SNORM, 0 }
+      { PIPE_FORMAT_LATC2_SNORM, DEFAULT_SNORM8_RGBA_FORMATS }
    },
 
    /* ETC1 */
-- 
1.7.3.4



More information about the mesa-dev mailing list