gallium: Finer grained is_format_supported.
authorJosé Fonseca <jrfonseca@tungstengraphics.com>
Sat, 19 Jul 2008 03:04:37 +0000 (12:04 +0900)
committerJosé Fonseca <jrfonseca@tungstengraphics.com>
Sat, 19 Jul 2008 03:32:29 +0000 (12:32 +0900)
20 files changed:
src/gallium/auxiliary/util/u_blit.c
src/gallium/auxiliary/util/u_gen_mipmap.c
src/gallium/drivers/cell/ppu/cell_screen.c
src/gallium/drivers/i915simple/i915_screen.c
src/gallium/drivers/i965simple/brw_screen.c
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_screen.h
src/gallium/state_trackers/python/gallium.i
src/gallium/state_trackers/python/samples/tri.py
src/gallium/state_trackers/python/tests/texture.py
src/mesa/state_tracker/st_atom_pixeltransfer.c
src/mesa/state_tracker/st_cb_bitmap.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_extensions.c
src/mesa/state_tracker/st_format.c
src/mesa/state_tracker/st_format.h
src/mesa/state_tracker/st_gen_mipmap.c
src/mesa/state_tracker/st_texture.c

index 3dc9fdd11e78a7c2ed92b65643147283213a2f81..ae087df4cf7923a8f63a2dfad674d2cdd3e335d7 100644 (file)
@@ -307,8 +307,10 @@ util_blit_pixels(struct blit_state *ctx,
       dstY1 = tmp;
    }
 
-   assert(screen->is_format_supported(screen, src->format, PIPE_TEXTURE));
-   assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE));
+   assert(screen->is_format_supported(screen, src->format, PIPE_TEXTURE_2D,
+                                      PIPE_TEXTURE_USAGE_SAMPLER, 0));
+   assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
+                                      PIPE_TEXTURE_USAGE_SAMPLER, 0));
 
    if(dst->format == src->format && (dstX1 - dstX0) == srcW && (dstY1 - dstY0) == srcH) {
       /* FIXME: this will most surely fail for overlapping rectangles */
@@ -319,7 +321,8 @@ util_blit_pixels(struct blit_state *ctx,
       return;
    }
    
-   assert(screen->is_format_supported(screen, dst->format, PIPE_SURFACE));
+   assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
+                                      PIPE_TEXTURE_USAGE_RENDER_TARGET, 0));
 
    /*
     * XXX for now we're always creating a temporary texture.
@@ -449,7 +452,8 @@ util_blit_pixels_tex(struct blit_state *ctx,
    t0 = srcY0 / (float)tex->height[0];
    t1 = srcY1 / (float)tex->height[0];
 
-   assert(screen->is_format_supported(screen, dst->format, PIPE_SURFACE));
+   assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
+                                      PIPE_TEXTURE_USAGE_RENDER_TARGET, 0));
 
    /* save state (restored below) */
    cso_save_blend(ctx->cso);
index 5313a8008a969f17fb4d6d843d9a3dcdd8914d62..4999822068a8ec07e9b25b7ad1aa49cbb1d2fffe 100644 (file)
@@ -858,7 +858,8 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
    uint zslice = 0;
 
    /* check if we can render in the texture's format */
-   if (!screen->is_format_supported(screen, pt->format, PIPE_SURFACE)) {
+   if (!screen->is_format_supported(screen, pt->format, PIPE_TEXTURE_2D,
+                                    PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
       fallback_gen_mipmap(ctx, pt, face, baseLevel, lastLevel);
       return;
    }
index 5198b51441a1ca826605592ec4f461e8c4f1918c..cf9b68b695f7738fb605a0b76ad6a1ad56c764d0 100644 (file)
@@ -115,23 +115,17 @@ cell_get_paramf(struct pipe_screen *screen, int param)
 
 static boolean
 cell_is_format_supported( struct pipe_screen *screen,
-                          enum pipe_format format, uint type )
+                          enum pipe_format format, 
+                          enum pipe_texture_target target,
+                          unsigned tex_usage, 
+                          unsigned geom_flags )
 {
-   switch (type) {
-   case PIPE_TEXTURE:
-      /* cell supports most texture formats, XXX for now anyway */
-      if (format == PIPE_FORMAT_DXT5_RGBA ||
-          format == PIPE_FORMAT_R8G8B8A8_SRGB)
-         return FALSE;
-      else
-         return TRUE;
-   case PIPE_SURFACE:
-      /* cell supports all (off-screen) surface formats, XXX for now */
-      return TRUE;
-   default:
-      assert(0);
+   /* cell supports most formats, XXX for now anyway */
+   if (format == PIPE_FORMAT_DXT5_RGBA ||
+       format == PIPE_FORMAT_R8G8B8A8_SRGB)
       return FALSE;
-   }
+   else
+      return TRUE;
 }
 
 
index ba8f183bdf022586d6f84a1aea1fec22f0da3f43..4b1b8af7da8f6472a406158d2e9190eb58254c8f 100644 (file)
@@ -148,7 +148,10 @@ i915_get_paramf(struct pipe_screen *screen, int param)
 
 static boolean
 i915_is_format_supported( struct pipe_screen *screen,
-                          enum pipe_format format, uint type )
+                          enum pipe_format format, 
+                          enum pipe_texture_target target,
+                          unsigned tex_usage, 
+                          unsigned geom_flags )
 {
    static const enum pipe_format tex_supported[] = {
       PIPE_FORMAT_R8G8B8A8_UNORM,
@@ -173,17 +176,10 @@ i915_is_format_supported( struct pipe_screen *screen,
    const enum pipe_format *list;
    uint i;
 
-   switch (type) {
-   case PIPE_TEXTURE:
-      list = tex_supported;
-      break;
-   case PIPE_SURFACE:
+   if(tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
       list = surface_supported;
-      break;
-   default:
-      assert(0);
-      return FALSE;
-   }
+   else
+      list = tex_supported;
 
    for (i = 0; list[i] != PIPE_FORMAT_NONE; i++) {
       if (list[i] == format)
index b700f7e4f5d7dd173c1457d2a14a9946ac00d267..6d8f24d1c498d0793528326277278221ed8df5a4 100644 (file)
@@ -136,7 +136,10 @@ brw_get_paramf(struct pipe_screen *screen, int param)
 
 static boolean
 brw_is_format_supported( struct pipe_screen *screen,
-                         enum pipe_format format, uint type )
+                         enum pipe_format format, 
+                         enum pipe_texture_target target,
+                         unsigned tex_usage, 
+                         unsigned geom_flags )
 {
 #if 0
    /* XXX: This is broken -- rewrite if still needed. */
index f6193bfaf9a1fa01ae4542120a250c1cee00b0bc..3f9d4b0ed317aca8d29136ffa67b7147f9b2e77d 100644 (file)
@@ -115,23 +115,19 @@ softpipe_get_paramf(struct pipe_screen *screen, int param)
  */
 static boolean
 softpipe_is_format_supported( struct pipe_screen *screen,
-                              enum pipe_format format, uint type )
+                              enum pipe_format format, 
+                              enum pipe_texture_target target,
+                              unsigned tex_usage, 
+                              unsigned geom_flags )
 {
-   switch (type) {
-   case PIPE_TEXTURE:
-   case PIPE_SURFACE:
-      switch(format) {
-      case PIPE_FORMAT_DXT1_RGB:
-      case PIPE_FORMAT_DXT1_RGBA:
-      case PIPE_FORMAT_DXT3_RGBA:
-      case PIPE_FORMAT_DXT5_RGBA:
-         return FALSE;
-      default:
-         return TRUE;
-      }
-   default:
-      assert(0);
+   switch(format) {
+   case PIPE_FORMAT_DXT1_RGB:
+   case PIPE_FORMAT_DXT1_RGBA:
+   case PIPE_FORMAT_DXT3_RGBA:
+   case PIPE_FORMAT_DXT5_RGBA:
       return FALSE;
+   default:
+      return TRUE;
    }
 }
 
index bc4d7c845a98fc4d50347a88af7cd1786cb75a69..b1d100ef53ca7109a72a3fcb74611bdd3d4b55d7 100644 (file)
@@ -172,11 +172,8 @@ enum pipe_texture_target {
 #define PIPE_TEXTURE_USAGE_DEPTH_STENCIL   0x8
 #define PIPE_TEXTURE_USAGE_SAMPLER         0x10
 
-/**
- * Surfaces, textures, etc. (others may be added)
- */
-#define PIPE_TEXTURE        1
-#define PIPE_SURFACE        2  /**< user-created surfaces */
+#define PIPE_TEXTURE_GEOM_NON_SQUARE       0x1
+#define PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO 0x2
 
 
 /**
index cc8430dae1695c90295bf3b0e85332660f9902f1..b15affef7a559a350a04426856a7bc4aa6316d50 100644 (file)
@@ -77,11 +77,14 @@ struct pipe_screen {
    /**
     * Check if the given pipe_format is supported as a texture or
     * drawing surface.
-    * \param type  one of PIPE_TEXTURE, PIPE_SURFACE
+    * \param tex_usage  bitmask of PIPE_TEXTURE_USAGE_*
+    * \param flags  bitmask of PIPE_TEXTURE_GEOM_*
     */
    boolean (*is_format_supported)( struct pipe_screen *,
-                                   enum pipe_format format, 
-                                   uint type );
+                                   enum pipe_format format,
+                                   enum pipe_texture_target target,
+                                   unsigned tex_usage, 
+                                   unsigned geom_flags );
 
    /**
     * Create a new texture object, using the given template info.
index c08ac87acae9ec8f8564129b5e705531cb132fcf..8d8b762ea578557826e8ef26cd4a3a0818f78c96 100644 (file)
@@ -158,8 +158,15 @@ struct st_context {
     * drawing surface.
     * \param type  one of PIPE_TEXTURE, PIPE_SURFACE
     */
-   int is_format_supported( enum pipe_format format, unsigned type ) {
-      return $self->screen->is_format_supported( $self->screen, format, type);
+   int is_format_supported( enum pipe_format format, 
+                            enum pipe_texture_target target,
+                            unsigned tex_usage, 
+                            unsigned geom_flags ) {
+      return $self->screen->is_format_supported( $self->screen, 
+                                                 format, 
+                                                 target, 
+                                                 tex_usage, 
+                                                 geom_flags );
    }
 
    struct st_context *
@@ -175,7 +182,7 @@ struct st_context {
          unsigned depth = 1,
          unsigned last_level = 0,
          enum pipe_texture_target target = PIPE_TEXTURE_2D,
-         unsigned usage = 0
+         unsigned tex_usage = 0
       ) {
       struct pipe_texture templat;
       memset(&templat, 0, sizeof(templat));
@@ -186,7 +193,7 @@ struct st_context {
       templat.depth[0] = depth;
       templat.last_level = last_level;
       templat.target = target;
-      templat.tex_usage = usage;
+      templat.tex_usage = tex_usage;
       return $self->screen->texture_create($self->screen, &templat);
    }
    
index 366592292980946ebbf1b80276f42d7965a66f87..1271c67627d2921055f36d89019bb8791ea0cf67 100644 (file)
@@ -140,9 +140,11 @@ def test(dev):
     ctx.set_clip(clip)
 
     # framebuffer
-    cbuf = dev.texture_create(PIPE_FORMAT_X8R8G8B8_UNORM, 
-                              width, height,
-                              usage=PIPE_TEXTURE_USAGE_DISPLAY_TARGET)
+    cbuf = dev.texture_create(
+        PIPE_FORMAT_X8R8G8B8_UNORM, 
+        width, height,
+        tex_usage=PIPE_TEXTURE_USAGE_DISPLAY_TARGET,
+    )
     _cbuf = cbuf.get_surface(usage = PIPE_BUFFER_USAGE_GPU_READ|PIPE_BUFFER_USAGE_GPU_WRITE)
     fb = Framebuffer()
     fb.width = width
index 16ad78c8aa8037d49b4c1e8900be325764426572..b2ca9f416f5d4ea8120ffd9f7a22536a367b8ffa 100644 (file)
@@ -136,7 +136,7 @@ class TextureTest(TestCase):
         level = self.level
         zslice = self.zslice
         
-        if not dev.is_format_supported(format, PIPE_TEXTURE):
+        if not dev.is_format_supported(format, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER, 0):
             raise TestSkip
         
         ctx = self.dev.context_create()
@@ -199,6 +199,7 @@ class TextureTest(TestCase):
             height = height,
             depth = depth, 
             last_level = last_level,
+            tex_usage = PIPE_TEXTURE_USAGE_SAMPLER,
         )
         
         expected_rgba = FloatArray(height*width*4) 
@@ -212,10 +213,12 @@ class TextureTest(TestCase):
         ctx.set_sampler_texture(0, texture)
 
         #  framebuffer 
-        cbuf_tex = dev.texture_create(PIPE_FORMAT_A8R8G8B8_UNORM, 
-                                      width, 
-                                      height,
-                                      usage = PIPE_TEXTURE_USAGE_RENDER_TARGET)
+        cbuf_tex = dev.texture_create(
+            PIPE_FORMAT_A8R8G8B8_UNORM, 
+            width, 
+            height,
+            tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET,
+        )
 
         cbuf = cbuf_tex.get_surface(usage = PIPE_BUFFER_USAGE_GPU_WRITE|PIPE_BUFFER_USAGE_GPU_READ)
         fb = Framebuffer()
index e4de875e8c92e4317ef91253d000a0892240068a..a357b716771c53811dfe5c19fe49102a4457830f 100644 (file)
@@ -122,7 +122,7 @@ create_color_map_texture(GLcontext *ctx)
    const uint texSize = 256; /* simple, and usually perfect */
 
    /* find an RGBA texture format */
-   format = st_choose_format(pipe, GL_RGBA, PIPE_TEXTURE);
+   format = st_choose_format(pipe, GL_RGBA, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER);
 
    /* create texture for color map/table */
    pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, format, 0,
index de86832342cff2228abdd5edfb8e2d6664cec06f..d5696a909f78bcbb1a7373ee68bcead5ee71d2cc 100644 (file)
@@ -746,7 +746,8 @@ st_init_bitmap(struct st_context *st)
    st->bitmap.rasterizer.bypass_vs = 1;
 
    /* find a usable texture format */
-   if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM, PIPE_TEXTURE)) {
+   if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM, PIPE_TEXTURE_2D, 
+                                   PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
       st->bitmap.tex_format = PIPE_FORMAT_I8_UNORM;
    }
    else {
index 2ebfcaf82b1f4a1e0fd78179b86e4205146249fc..db0c9fbd09cdb57c7de25fc9de58226bb928f93a 100644 (file)
@@ -995,18 +995,21 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
 
    srcFormat = rbRead->texture->format;
 
-   if (screen->is_format_supported(screen, srcFormat, PIPE_TEXTURE)) {
+   if (screen->is_format_supported(screen, srcFormat, PIPE_TEXTURE_2D, 
+                                   PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
       texFormat = srcFormat;
    }
    else {
       /* srcFormat can't be used as a texture format */
       if (type == GL_DEPTH) {
-         texFormat = st_choose_format(pipe, GL_DEPTH_COMPONENT, PIPE_TEXTURE);
+         texFormat = st_choose_format(pipe, GL_DEPTH_COMPONENT, PIPE_TEXTURE_2D, 
+                                      PIPE_TEXTURE_USAGE_DEPTH_STENCIL);
          assert(texFormat != PIPE_FORMAT_NONE); /* XXX no depth texture formats??? */
       }
       else {
          /* default color format */
-         texFormat = st_choose_format(pipe, GL_RGBA, PIPE_TEXTURE);
+         texFormat = st_choose_format(pipe, GL_RGBA, PIPE_TEXTURE_2D, 
+                                      PIPE_TEXTURE_USAGE_SAMPLER);
          assert(texFormat != PIPE_FORMAT_NONE);
       }
    }
index de782e8232e25eb4b5850c8b8f7f8e351353fcaa..1f94a0b9ef0d1e83291e41ab23706286281651cb 100644 (file)
@@ -1210,9 +1210,13 @@ do_copy_texsubimage(GLcontext *ctx,
          use_fallback = GL_FALSE;
       }
       else if (screen->is_format_supported(screen, strb->surface->format,
-                                           PIPE_TEXTURE) &&
+                                           PIPE_TEXTURE_2D, 
+                                           PIPE_TEXTURE_USAGE_SAMPLER,
+                                           0) &&
                screen->is_format_supported(screen, dest_surface->format,
-                                           PIPE_SURFACE)) {
+                                           PIPE_TEXTURE_2D, 
+                                           PIPE_TEXTURE_USAGE_RENDER_TARGET,
+                                           0)) {
          boolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP);
          int srcY0, srcY1;
          if (do_flip) {
index d804d2b453d326b9624baf9a560f881081cd5d17..cacf972a1bad182e866bf25ee2f365de0249c2b7 100644 (file)
@@ -213,18 +213,24 @@ void st_init_extensions(struct st_context *st)
    }
 
    if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SRGB,
-                                   PIPE_TEXTURE)) {
+                                   PIPE_TEXTURE_2D, 
+                                   PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
       ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
    }
 
 #if 01
    if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
-                                   PIPE_TEXTURE)) {
+                                   PIPE_TEXTURE_2D, 
+                                   PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
       ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE;
    }
 #endif
-   if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR, PIPE_TEXTURE) ||
-       screen->is_format_supported(screen, PIPE_FORMAT_YCBCR_REV, PIPE_TEXTURE)) {
+   if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR, 
+                                   PIPE_TEXTURE_2D, 
+                                   PIPE_TEXTURE_USAGE_SAMPLER, 0) ||
+       screen->is_format_supported(screen, PIPE_FORMAT_YCBCR_REV, 
+                                   PIPE_TEXTURE_2D, 
+                                   PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
       ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
    }
 
index 50a06868dfca32582d3c8bdcfc0c47ddff6d3967..b6d97ef65937106809e4f46988a5707128d76a49 100644 (file)
@@ -281,7 +281,10 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat)
  * Find an RGBA format supported by the context/winsys.
  */
 static enum pipe_format
-default_rgba_format(struct pipe_screen *screen, uint type)
+default_rgba_format(struct pipe_screen *screen, 
+                    enum pipe_texture_target target,
+                    unsigned tex_usage, 
+                    unsigned geom_flags)
 {
    static const enum pipe_format colorFormats[] = {
       PIPE_FORMAT_A8R8G8B8_UNORM,
@@ -291,7 +294,7 @@ default_rgba_format(struct pipe_screen *screen, uint type)
    };
    uint i;
    for (i = 0; i < Elements(colorFormats); i++) {
-      if (screen->is_format_supported( screen, colorFormats[i], type )) {
+      if (screen->is_format_supported( screen, colorFormats[i], target, tex_usage, geom_flags )) {
          return colorFormats[i];
       }
    }
@@ -303,13 +306,16 @@ default_rgba_format(struct pipe_screen *screen, uint type)
  * Search list of formats for first RGBA format with >8 bits/channel.
  */
 static enum pipe_format
-default_deep_rgba_format(struct pipe_screen *screen, uint type)
+default_deep_rgba_format(struct pipe_screen *screen, 
+                         enum pipe_texture_target target,
+                         unsigned tex_usage, 
+                         unsigned geom_flags)
 {
-   if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_SNORM, type)) {
+   if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_SNORM, target, tex_usage, geom_flags)) {
       return PIPE_FORMAT_R16G16B16A16_SNORM;
    }
-   if (type == PIPE_TEXTURE)
-      return default_rgba_format(screen, type);
+   if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
+      return default_rgba_format(screen, target, tex_usage, geom_flags);
    else
       return PIPE_FORMAT_NONE;
 }
@@ -319,7 +325,10 @@ default_deep_rgba_format(struct pipe_screen *screen, uint type)
  * Find an Z format supported by the context/winsys.
  */
 static enum pipe_format
-default_depth_format(struct pipe_screen *screen, uint type)
+default_depth_format(struct pipe_screen *screen, 
+                     enum pipe_texture_target target,
+                     unsigned tex_usage, 
+                     unsigned geom_flags)
 {
    static const enum pipe_format zFormats[] = {
       PIPE_FORMAT_Z16_UNORM,
@@ -329,7 +338,7 @@ default_depth_format(struct pipe_screen *screen, uint type)
    };
    uint i;
    for (i = 0; i < Elements(zFormats); i++) {
-      if (screen->is_format_supported( screen, zFormats[i], type )) {
+      if (screen->is_format_supported( screen, zFormats[i], target, tex_usage, geom_flags )) {
          return zFormats[i];
       }
    }
@@ -343,12 +352,10 @@ default_depth_format(struct pipe_screen *screen, uint type)
  */
 enum pipe_format
 st_choose_format(struct pipe_context *pipe, GLint internalFormat,
-                 uint surfType)
+                 enum pipe_texture_target target, unsigned tex_usage)
 {
    struct pipe_screen *screen = pipe->screen;
-
-   assert(surfType == PIPE_SURFACE ||
-          surfType == PIPE_TEXTURE);
+   unsigned geom_flags = 0;
 
    switch (internalFormat) {
    case 4:
@@ -360,38 +367,38 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat,
    case GL_RGBA8:
    case GL_RGB10_A2:
    case GL_RGBA12:
-      return default_rgba_format( screen, surfType );
+      return default_rgba_format( screen, target, tex_usage, geom_flags );
    case GL_RGBA16:
-      if (surfType == PIPE_SURFACE)
-         return default_deep_rgba_format( screen, surfType );
+      if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
+         return default_deep_rgba_format( screen, target, tex_usage, geom_flags );
       else
-         return default_rgba_format( screen, surfType );
+         return default_rgba_format( screen, target, tex_usage, geom_flags );
 
    case GL_RGBA4:
    case GL_RGBA2:
-      if (screen->is_format_supported( screen, PIPE_FORMAT_A4R4G4B4_UNORM, surfType ))
+      if (screen->is_format_supported( screen, PIPE_FORMAT_A4R4G4B4_UNORM, target, tex_usage, geom_flags ))
          return PIPE_FORMAT_A4R4G4B4_UNORM;
-      return default_rgba_format( screen, surfType );
+      return default_rgba_format( screen, target, tex_usage, geom_flags );
 
    case GL_RGB5_A1:
-      if (screen->is_format_supported( screen, PIPE_FORMAT_A1R5G5B5_UNORM, surfType ))
+      if (screen->is_format_supported( screen, PIPE_FORMAT_A1R5G5B5_UNORM, target, tex_usage, geom_flags ))
          return PIPE_FORMAT_A1R5G5B5_UNORM;
-      return default_rgba_format( screen, surfType );
+      return default_rgba_format( screen, target, tex_usage, geom_flags );
 
    case GL_RGB8:
    case GL_RGB10:
    case GL_RGB12:
    case GL_RGB16:
-      return default_rgba_format( screen, surfType );
+      return default_rgba_format( screen, target, tex_usage, geom_flags );
 
    case GL_RGB5:
    case GL_RGB4:
    case GL_R3_G3_B2:
-      if (screen->is_format_supported( screen, PIPE_FORMAT_A1R5G5B5_UNORM, surfType ))
+      if (screen->is_format_supported( screen, PIPE_FORMAT_A1R5G5B5_UNORM, target, tex_usage, geom_flags ))
          return PIPE_FORMAT_A1R5G5B5_UNORM;
-      if (screen->is_format_supported( screen, PIPE_FORMAT_R5G6B5_UNORM, surfType ))
+      if (screen->is_format_supported( screen, PIPE_FORMAT_R5G6B5_UNORM, target, tex_usage, geom_flags ))
          return PIPE_FORMAT_R5G6B5_UNORM;
-      return default_rgba_format( screen, surfType );
+      return default_rgba_format( screen, target, tex_usage, geom_flags );
 
    case GL_ALPHA:
    case GL_ALPHA4:
@@ -399,9 +406,9 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat,
    case GL_ALPHA12:
    case GL_ALPHA16:
    case GL_COMPRESSED_ALPHA:
-      if (screen->is_format_supported( screen, PIPE_FORMAT_A8_UNORM, surfType ))
+      if (screen->is_format_supported( screen, PIPE_FORMAT_A8_UNORM, target, tex_usage, geom_flags ))
          return PIPE_FORMAT_A8_UNORM;
-      return default_rgba_format( screen, surfType );
+      return default_rgba_format( screen, target, tex_usage, geom_flags );
 
    case 1:
    case GL_LUMINANCE:
@@ -410,9 +417,9 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat,
    case GL_LUMINANCE12:
    case GL_LUMINANCE16:
    case GL_COMPRESSED_LUMINANCE:
-      if (screen->is_format_supported( screen, PIPE_FORMAT_L8_UNORM, surfType ))
+      if (screen->is_format_supported( screen, PIPE_FORMAT_L8_UNORM, target, tex_usage, geom_flags ))
          return PIPE_FORMAT_L8_UNORM;
-      return default_rgba_format( screen, surfType );
+      return default_rgba_format( screen, target, tex_usage, geom_flags );
 
    case 2:
    case GL_LUMINANCE_ALPHA:
@@ -423,9 +430,9 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat,
    case GL_LUMINANCE12_ALPHA12:
    case GL_LUMINANCE16_ALPHA16:
    case GL_COMPRESSED_LUMINANCE_ALPHA:
-      if (screen->is_format_supported( screen, PIPE_FORMAT_A8L8_UNORM, surfType ))
+      if (screen->is_format_supported( screen, PIPE_FORMAT_A8L8_UNORM, target, tex_usage, geom_flags ))
          return PIPE_FORMAT_A8L8_UNORM;
-      return default_rgba_format( screen, surfType );
+      return default_rgba_format( screen, target, tex_usage, geom_flags );
 
    case GL_INTENSITY:
    case GL_INTENSITY4:
@@ -433,17 +440,17 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat,
    case GL_INTENSITY12:
    case GL_INTENSITY16:
    case GL_COMPRESSED_INTENSITY:
-      if (screen->is_format_supported( screen, PIPE_FORMAT_I8_UNORM, surfType ))
+      if (screen->is_format_supported( screen, PIPE_FORMAT_I8_UNORM, target, tex_usage, geom_flags ))
          return PIPE_FORMAT_I8_UNORM;
-      return default_rgba_format( screen, surfType );
+      return default_rgba_format( screen, target, tex_usage, geom_flags );
 
    case GL_YCBCR_MESA:
       if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR,
-                                      PIPE_TEXTURE)) {
+                                      target, tex_usage, geom_flags)) {
          return PIPE_FORMAT_YCBCR;
       }
       if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR_REV,
-                                      PIPE_TEXTURE)) {
+                                      target, tex_usage, geom_flags)) {
          return PIPE_FORMAT_YCBCR_REV;
       }
       return PIPE_FORMAT_NONE;
@@ -472,40 +479,40 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat,
 #endif
 
    case GL_DEPTH_COMPONENT16:
-      if (screen->is_format_supported( screen, PIPE_FORMAT_Z16_UNORM, surfType ))
+      if (screen->is_format_supported( screen, PIPE_FORMAT_Z16_UNORM, target, tex_usage, geom_flags ))
          return PIPE_FORMAT_Z16_UNORM;
       /* fall-through */
    case GL_DEPTH_COMPONENT24:
-      if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, surfType ))
+      if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags ))
          return PIPE_FORMAT_S8Z24_UNORM;
-      if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, surfType ))
+      if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags ))
          return PIPE_FORMAT_Z24S8_UNORM;
       /* fall-through */
    case GL_DEPTH_COMPONENT32:
-      if (screen->is_format_supported( screen, PIPE_FORMAT_Z32_UNORM, surfType ))
+      if (screen->is_format_supported( screen, PIPE_FORMAT_Z32_UNORM, target, tex_usage, geom_flags ))
          return PIPE_FORMAT_Z32_UNORM;
       /* fall-through */
    case GL_DEPTH_COMPONENT:
-      return default_depth_format( screen, surfType );
+      return default_depth_format( screen, target, tex_usage, geom_flags );
 
    case GL_STENCIL_INDEX:
    case GL_STENCIL_INDEX1_EXT:
    case GL_STENCIL_INDEX4_EXT:
    case GL_STENCIL_INDEX8_EXT:
    case GL_STENCIL_INDEX16_EXT:
-      if (screen->is_format_supported( screen, PIPE_FORMAT_S8_UNORM, surfType ))
+      if (screen->is_format_supported( screen, PIPE_FORMAT_S8_UNORM, target, tex_usage, geom_flags ))
          return PIPE_FORMAT_S8_UNORM;
-      if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, surfType ))
+      if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags ))
          return PIPE_FORMAT_S8Z24_UNORM;
-      if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, surfType ))
+      if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags ))
          return PIPE_FORMAT_Z24S8_UNORM;
       return PIPE_FORMAT_NONE;
 
    case GL_DEPTH_STENCIL_EXT:
    case GL_DEPTH24_STENCIL8_EXT:
-      if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, surfType ))
+      if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags ))
          return PIPE_FORMAT_S8Z24_UNORM;
-      if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, surfType ))
+      if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags ))
          return PIPE_FORMAT_Z24S8_UNORM;
       return PIPE_FORMAT_NONE;
 
@@ -521,7 +528,8 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat,
 enum pipe_format
 st_choose_renderbuffer_format(struct pipe_context *pipe, GLint internalFormat)
 {
-   return st_choose_format(pipe, internalFormat, PIPE_SURFACE);
+   return st_choose_format(pipe, internalFormat, PIPE_TEXTURE_2D, 
+                           PIPE_TEXTURE_USAGE_RENDER_TARGET);
 }
 
 
@@ -587,7 +595,8 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
    (void) format;
    (void) type;
 
-   pFormat = st_choose_format(ctx->st->pipe, internalFormat, PIPE_TEXTURE);
+   pFormat = st_choose_format(ctx->st->pipe, internalFormat, PIPE_TEXTURE_2D, 
+                              PIPE_TEXTURE_USAGE_SAMPLER);
    if (pFormat == PIPE_FORMAT_NONE)
       return NULL;
 
index ff0fd042dbab3545fa971d76ee3a7a7dc1efcf11..3f5ac3201b1b2c35e73f245f2964592615df021b 100644 (file)
@@ -65,7 +65,7 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat);
 
 extern enum pipe_format
 st_choose_format(struct pipe_context *pipe, GLint internalFormat,
-                 uint surfType);
+                 enum pipe_texture_target target, unsigned tex_usage);
 
 extern enum pipe_format
 st_choose_renderbuffer_format(struct pipe_context *pipe, GLint internalFormat);
index 2fc00df4298a3c46e88ea9416b846deee4f7374d..6db9bc0dd58299fed59dfbd22151bf3e362f088f 100644 (file)
@@ -86,7 +86,8 @@ st_render_mipmap(struct st_context *st,
    assert(target != GL_TEXTURE_3D); /* not done yet */
 
    /* check if we can render in the texture's format */
-   if (!screen->is_format_supported(screen, pt->format, PIPE_SURFACE)) {
+   if (!screen->is_format_supported(screen, pt->format, target,
+                                    PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
       return FALSE;
    }
 
index 8222826e7a744851d6f370336391a2dd62e6407e..3e5054ecd2d7f5e347c5a5f326a5a4372e0ec4bc 100644 (file)
@@ -88,7 +88,8 @@ st_texture_create(struct st_context *st,
        _mesa_lookup_enum_by_nr(format), last_level);
 
    assert(format);
-   assert(screen->is_format_supported(screen, format, PIPE_TEXTURE));
+   assert(screen->is_format_supported(screen, format, target, 
+                                      PIPE_TEXTURE_USAGE_SAMPLER, 0));
 
    memset(&pt, 0, sizeof(pt));
    pt.target = target;