gallium: make all checks for PIPE_TEXTURE_2D check for PIPE_TEXTURE_RECT too
authorLuca Barbieri <luca@luca-barbieri.com>
Wed, 18 Aug 2010 15:28:08 +0000 (17:28 +0200)
committerLuca Barbieri <luca@luca-barbieri.com>
Fri, 20 Aug 2010 10:04:00 +0000 (12:04 +0200)
Searched for them with:
git grep -E '[!=]=.*PIPE_TEXTURE_2D|PIPE_TEXTURE_2D.*[!=]=|case.*PIPE_TEXTURE_2D'

Behavior hasn't been changed.

25 files changed:
src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
src/gallium/auxiliary/util/u_blit.c
src/gallium/auxiliary/util/u_blitter.c
src/gallium/auxiliary/util/u_gen_mipmap.c
src/gallium/auxiliary/util/u_surfaces.h
src/gallium/drivers/i915/i915_resource_texture.c
src/gallium/drivers/i965/brw_resource_texture.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/llvmpipe/lp_texture.c
src/gallium/drivers/nv50/nv50_miptree.c
src/gallium/drivers/nv50/nv50_tex.c
src/gallium/drivers/nvfx/nv30_fragtex.c
src/gallium/drivers/nvfx/nv40_fragtex.c
src/gallium/drivers/nvfx/nvfx_miptree.c
src/gallium/drivers/r300/r300_hyperz.c
src/gallium/drivers/r300/r300_texture.c
src/gallium/drivers/r300/r300_texture_desc.c
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_texture.c
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/softpipe/sp_tex_sample.c
src/gallium/drivers/svga/svga_resource_texture.c
src/gallium/drivers/svga/svga_tgsi_emit.h
src/gallium/tests/python/tests/texture_blit.py
src/mesa/state_tracker/st_cb_bitmap.c

index 806c7d56a87529a1291d3a802298d2080671fc88..f6b6162f63a42bbfb885f837d3c2d8339d600079 100644 (file)
@@ -176,6 +176,7 @@ texture_dims(enum pipe_texture_target tex)
    case PIPE_TEXTURE_1D:
       return 1;
    case PIPE_TEXTURE_2D:
+   case PIPE_TEXTURE_RECT:
    case PIPE_TEXTURE_CUBE:
       return 2;
    case PIPE_TEXTURE_3D:
@@ -1749,7 +1750,8 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld,
    LLVMValueRef unswizzled[4];
    LLVMValueRef stride;
 
-   assert(bld->static_state->target == PIPE_TEXTURE_2D);
+   assert(bld->static_state->target == PIPE_TEXTURE_2D
+         || bld->static_state->target == PIPE_TEXTURE_RECT);
    assert(bld->static_state->min_img_filter == PIPE_TEX_FILTER_LINEAR);
    assert(bld->static_state->mag_img_filter == PIPE_TEX_FILTER_LINEAR);
    assert(bld->static_state->min_mip_filter == PIPE_TEX_MIPFILTER_NONE);
@@ -2077,7 +2079,8 @@ lp_build_sample_soa(LLVMBuilderRef builder,
    }
    else if (util_format_fits_8unorm(bld.format_desc) &&
             bld.format_desc->nr_channels > 1 &&
-            static_state->target == PIPE_TEXTURE_2D &&
+            (static_state->target == PIPE_TEXTURE_2D ||
+                  static_state->target == PIPE_TEXTURE_RECT) &&
             static_state->min_img_filter == PIPE_TEX_FILTER_LINEAR &&
             static_state->mag_img_filter == PIPE_TEX_FILTER_LINEAR &&
             static_state->min_mip_filter == PIPE_TEX_MIPFILTER_NONE &&
index 97fa99ec65d2e52ba3d49193ee20ada3cb297449..30c7a96462fb2486b605e28564bd32f79217c35f 100644 (file)
@@ -347,7 +347,8 @@ util_blit_pixels_writemask(struct blit_state *ctx,
        dst->face == srcsub.face &&
        dst->level == srcsub.level &&
        dst->zslice == srcZ0) ||
-       src_tex->target != PIPE_TEXTURE_2D)
+       (src_tex->target != PIPE_TEXTURE_2D &&
+       src_tex->target != PIPE_TEXTURE_RECT))
    {
       struct pipe_resource texTemp;
       struct pipe_resource *tex;
index 49ee7bb31df7c3400eed0c1a10096c3b69a1b90a..4b69a7fb6ab317200246088b52abdda04bc40e87 100644 (file)
@@ -569,6 +569,8 @@ pipe_tex_to_tgsi_tex(enum pipe_texture_target pipe_tex_target)
       return TGSI_TEXTURE_1D;
    case PIPE_TEXTURE_2D:
       return TGSI_TEXTURE_2D;
+   case PIPE_TEXTURE_RECT:
+      return TGSI_TEXTURE_2D;
    case PIPE_TEXTURE_3D:
       return TGSI_TEXTURE_3D;
    case PIPE_TEXTURE_CUBE:
@@ -807,6 +809,7 @@ void util_blitter_copy_region(struct blitter_context *blitter,
       /* Draw the quad with the draw_rectangle callback. */
       case PIPE_TEXTURE_1D:
       case PIPE_TEXTURE_2D:
+      case PIPE_TEXTURE_RECT:
          {
             /* Set texture coordinates. */
             float coord[4];
index b7fe2d3003a1483ba012857adca6a8dc663bd20d..6a931a95819cdd690b074870212dab49986cbf55 100644 (file)
@@ -1255,6 +1255,7 @@ fallback_gen_mipmap(struct gen_mipmap_state *ctx,
       make_1d_mipmap(ctx, pt, face, baseLevel, lastLevel);
       break;
    case PIPE_TEXTURE_2D:
+   case PIPE_TEXTURE_RECT:
    case PIPE_TEXTURE_CUBE:
       make_2d_mipmap(ctx, pt, face, baseLevel, lastLevel);
       break;
index af978c705793453ba0dd0f229267de52385178ce..46f3ec5d7da201061a3c53be87cf9c93e0548ef4 100644 (file)
@@ -22,7 +22,7 @@ struct pipe_surface *util_surfaces_do_get(struct util_surfaces *us, unsigned sur
 static INLINE struct pipe_surface *
 util_surfaces_get(struct util_surfaces *us, unsigned surface_struct_size, struct pipe_screen *pscreen, struct pipe_resource *pt, unsigned face, unsigned level, unsigned zslice, unsigned flags)
 {
-   if(likely(pt->target == PIPE_TEXTURE_2D && us->u.array))
+   if(likely((pt->target == PIPE_TEXTURE_2D || pt->target == PIPE_TEXTURE_RECT) && us->u.array))
    {
       struct pipe_surface *ps = us->u.array[level];
       if(ps)
@@ -52,7 +52,7 @@ void util_surfaces_do_detach(struct util_surfaces *us, struct pipe_surface *ps);
 static INLINE void
 util_surfaces_detach(struct util_surfaces *us, struct pipe_surface *ps)
 {
-   if(likely(ps->texture->target == PIPE_TEXTURE_2D))
+   if(likely(ps->texture->target == PIPE_TEXTURE_2D || ps->texture->target == PIPE_TEXTURE_RECT))
    {
       us->u.array[ps->level] = 0;
       return;
index 752ddaae7b1571719a2e788ab238867ff7cb6548..c5c6179b169e5bd3138b94bd62f1ef26e545c5f3 100644 (file)
@@ -360,6 +360,7 @@ i915_texture_layout(struct i915_texture * tex)
    switch (pt->target) {
    case PIPE_TEXTURE_1D:
    case PIPE_TEXTURE_2D:
+   case PIPE_TEXTURE_RECT:
       if (!i9x5_special_layout(tex))
          i915_texture_layout_2d(tex);
       break;
@@ -605,6 +606,7 @@ i945_texture_layout(struct i915_texture * tex)
    switch (pt->target) {
    case PIPE_TEXTURE_1D:
    case PIPE_TEXTURE_2D:
+   case PIPE_TEXTURE_RECT:
       if (!i9x5_special_layout(tex))
          i945_texture_layout_2d(tex);
       break;
@@ -829,7 +831,8 @@ i915_texture_from_handle(struct pipe_screen * screen,
    buffer = iws->buffer_from_handle(iws, whandle, &stride);
 
    /* Only supports one type */
-   if (template->target != PIPE_TEXTURE_2D ||
+   if ((template->target != PIPE_TEXTURE_2D &&
+       template->target != PIPE_TEXTURE_RECT) ||
        template->last_level != 0 ||
        template->depth0 != 1) {
       return NULL;
index ffd0f38672c7e7b32121fea8796d1571c4b72262..3860d18a7a2f10190d25f26efda9a20b9133bcc8 100644 (file)
@@ -66,6 +66,7 @@ static GLuint translate_tex_target( unsigned target )
       return BRW_SURFACE_1D;
 
    case PIPE_TEXTURE_2D: 
+   case PIPE_TEXTURE_RECT:
       return BRW_SURFACE_2D;
 
    case PIPE_TEXTURE_3D: 
@@ -498,7 +499,8 @@ brw_texture_from_handle(struct pipe_screen *screen,
    unsigned pitch;
    GLuint format;
 
-   if (template->target != PIPE_TEXTURE_2D ||
+   if ((template->target != PIPE_TEXTURE_2D
+         && template->target != PIPE_TEXTURE_RECT)  ||
        template->last_level != 0 ||
        template->depth0 != 1)
       return NULL;
index 167cb2ee2e05cde6710f0754582715038f7e90fb..6968cda62926ce168363b0c2049300d26925cf08 100644 (file)
@@ -230,6 +230,7 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
    assert(target == PIPE_BUFFER ||
           target == PIPE_TEXTURE_1D ||
           target == PIPE_TEXTURE_2D ||
+          target == PIPE_TEXTURE_RECT ||
           target == PIPE_TEXTURE_3D ||
           target == PIPE_TEXTURE_CUBE);
 
index 25112c10a662868c8393275a1ee798e3fda04f1d..ff4773fd7c502c27b853c98bc5d1b2a51a733fb9 100644 (file)
@@ -67,6 +67,7 @@ resource_is_texture(const struct pipe_resource *resource)
       return FALSE;
    case PIPE_TEXTURE_1D:
    case PIPE_TEXTURE_2D:
+   case PIPE_TEXTURE_RECT:
    case PIPE_TEXTURE_3D:
    case PIPE_TEXTURE_CUBE:
       return TRUE;
index b7cd92158febb35c55b138d29d3ad7e80a27e7bd..c0f5cc10dd7d4dcf4743947191042f07cb4aff43 100644 (file)
@@ -235,7 +235,8 @@ nv50_miptree_from_handle(struct pipe_screen *pscreen,
        unsigned stride;
 
        /* Only supports 2D, non-mipmapped textures for the moment */
-       if (template->target != PIPE_TEXTURE_2D ||
+       if ((template->target != PIPE_TEXTURE_2D &&
+             template->target != PIPE_TEXTURE_RECT) ||
            template->last_level != 0 ||
            template->depth0 != 1)
                return NULL;
index 5ea0c1d726452e6ab7b20d83f50edf4dc82f9018..4db53f7ec23136b39c7c9769df958c307535a356 100644 (file)
@@ -131,6 +131,7 @@ nv50_tex_construct(struct nv50_sampler_view *view)
                tic[2] |= NV50TIC_0_2_TARGET_1D;
                break;
        case PIPE_TEXTURE_2D:
+       case PIPE_TEXTURE_RECT:
                tic[2] |= NV50TIC_0_2_TARGET_2D;
                break;
        case PIPE_TEXTURE_3D:
index dec073ac9003622bee6f6a627cd021f0fb0bf447..0cd70ca10429b9d2335a0aeee0492038c1a0763f 100644 (file)
@@ -116,6 +116,7 @@ nv30_fragtex_set(struct nvfx_context *nvfx, int unit)
                txf |= NV34TCL_TX_FORMAT_CUBIC;
                /* fall-through */
        case PIPE_TEXTURE_2D:
+       case PIPE_TEXTURE_RECT:
                txf |= NV34TCL_TX_FORMAT_DIMS_2D;
                break;
        case PIPE_TEXTURE_3D:
index 0068b1ba54ac044884bb9416ddca619051c9a960..0d3e90dcb05c303d7408b47996b8c68e3619bdb4 100644 (file)
@@ -135,6 +135,7 @@ nv40_fragtex_set(struct nvfx_context *nvfx, int unit)
                txf |= NV34TCL_TX_FORMAT_CUBIC;
                /* fall-through */
        case PIPE_TEXTURE_2D:
+       case PIPE_TEXTURE_RECT:
                txf |= NV34TCL_TX_FORMAT_DIMS_2D;
                break;
        case PIPE_TEXTURE_3D:
index b5639bb46455ead6fc3f3829a9f3a0d171bed171..1fec1ffa42d212bd0c5d496af126a52ee4af6b0e 100644 (file)
@@ -205,7 +205,8 @@ nvfx_miptree_from_handle(struct pipe_screen *pscreen,
        unsigned stride;
 
        /* Only supports 2D, non-mipmapped textures for the moment */
-       if (template->target != PIPE_TEXTURE_2D ||
+       if ((template->target != PIPE_TEXTURE_2D &&
+             template->target != PIPE_TEXTURE_RECT) ||
            template->last_level != 0 ||
            template->depth0 != 1)
                return NULL;
index b2526d6e4141676f2ee30b11b751832c454e9df6..eb5b0c36f8fa893d8f1807ec36e4fd6386659b31 100644 (file)
@@ -354,7 +354,8 @@ void r300_zmask_alloc_block(struct r300_context *r300, struct r300_surface *surf
     /* We currently don't handle decompression for 3D textures and cubemaps
      * correctly. */
     if (tex->desc.b.b.target != PIPE_TEXTURE_1D &&
-        tex->desc.b.b.target != PIPE_TEXTURE_2D)
+        tex->desc.b.b.target != PIPE_TEXTURE_2D &&
+        tex->desc.b.b.target != PIPE_TEXTURE_RECT)
         return;
 
     /* Cannot flush zmask of 16-bit zbuffers. */
index da8eadd3b535c15fc1c3d5f2d5b0b0c5b01a1275..852acdd46202234b1b703dcf01ff7707d733cbcb 100644 (file)
@@ -754,7 +754,8 @@ struct pipe_resource *r300_texture_create(struct pipe_screen *screen,
     /* Refuse to create a texture with size 0. */
     if (!base->width0 ||
         (!base->height0 && (base->target == PIPE_TEXTURE_2D ||
-                            base->target == PIPE_TEXTURE_CUBE)) ||
+                            base->target == PIPE_TEXTURE_CUBE ||
+                            base->target == PIPE_TEXTURE_RECT)) ||
         (!base->depth0 && base->target == PIPE_TEXTURE_3D)) {
         fprintf(stderr, "r300: texture_create: "
                 "Got invalid texture dimensions: %ix%ix%i\n",
@@ -787,7 +788,8 @@ struct pipe_resource *r300_texture_from_handle(struct pipe_screen *screen,
     unsigned stride, size;
 
     /* Support only 2D textures without mipmaps */
-    if (base->target != PIPE_TEXTURE_2D ||
+    if ((base->target != PIPE_TEXTURE_2D &&
+          base->target != PIPE_TEXTURE_RECT) ||
         base->depth0 != 1 ||
         base->last_level != 0) {
         return NULL;
index 5d690e8c33276d44ba3c854d4b2bd5b3d6be48e2..2fe5d721881fd6a87d898a72dd642a173393a2ba 100644 (file)
@@ -184,7 +184,8 @@ static unsigned r300_texture_get_nblocksy(struct r300_texture_desc *desc,
 
         /* This is needed for the kernel checker, unfortunately. */
         if ((desc->b.b.target != PIPE_TEXTURE_1D &&
-             desc->b.b.target != PIPE_TEXTURE_2D) ||
+             desc->b.b.target != PIPE_TEXTURE_2D &&
+             desc->b.b.target != PIPE_TEXTURE_RECT) ||
             desc->b.b.last_level != 0) {
             height = util_next_power_of_two(height);
         }
@@ -202,7 +203,8 @@ static unsigned r300_texture_get_nblocksy(struct r300_texture_desc *desc,
                  * Do so for 3 or more macrotiles in the Y direction. */
                 if (level == 0 && desc->b.b.last_level == 0 &&
                     (desc->b.b.target == PIPE_TEXTURE_1D ||
-                     desc->b.b.target == PIPE_TEXTURE_2D) &&
+                     desc->b.b.target == PIPE_TEXTURE_2D ||
+                     desc->b.b.target == PIPE_TEXTURE_RECT) &&
                     height >= tile_height * 3) {
                     height = align(height, tile_height * 2);
                 }
index f78d1671ba82fff0112e5113dbda29594b67305b..7d2b61f9b0170cfe05614932a932d2f33fe47070 100644 (file)
@@ -1199,6 +1199,7 @@ static inline unsigned r600_tex_dim(unsigned dim)
        case PIPE_TEXTURE_1D:
                return V_038000_SQ_TEX_DIM_1D;
        case PIPE_TEXTURE_2D:
+       case PIPE_TEXTURE_RECT:
                return V_038000_SQ_TEX_DIM_2D;
        case PIPE_TEXTURE_3D:
                return V_038000_SQ_TEX_DIM_3D;
index eabd7f77051230b6be3725d7126242da37ea2c21..8a6b5f87648533fab362598bbf1ee251049b94a0 100644 (file)
@@ -170,7 +170,8 @@ struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen,
        }
 
        /* Support only 2D textures without mipmaps */
-       if (templ->target != PIPE_TEXTURE_2D || templ->depth0 != 1 || templ->last_level != 0)
+       if ((templ->target != PIPE_TEXTURE_2D && templ->target != PIPE_TEXTURE_RECT) ||
+             templ->depth0 != 1 || templ->last_level != 0)
                return NULL;
 
        rtex = CALLOC_STRUCT(r600_resource_texture);
index 93af6ee5b02a780b72c3ba4dc1fa7e7a437c59da..73ae2dea561e588ea24461be234ac611f20defa9 100644 (file)
@@ -199,6 +199,7 @@ softpipe_is_format_supported( struct pipe_screen *screen,
    assert(target == PIPE_BUFFER ||
           target == PIPE_TEXTURE_1D ||
           target == PIPE_TEXTURE_2D ||
+          target == PIPE_TEXTURE_RECT ||
           target == PIPE_TEXTURE_3D ||
           target == PIPE_TEXTURE_CUBE);
 
index cf7ab81405c5fb5ead4e4d4b5651550de6b3c838..e654bb77c29f5d3a70003a1e80ea25b308c23c1e 100644 (file)
@@ -1785,6 +1785,7 @@ get_lambda_func(const union sp_sampler_key key)
    case PIPE_TEXTURE_1D:
       return compute_lambda_1d;
    case PIPE_TEXTURE_2D:
+   case PIPE_TEXTURE_RECT:
    case PIPE_TEXTURE_CUBE:
       return compute_lambda_2d;
    case PIPE_TEXTURE_3D:
@@ -1809,6 +1810,7 @@ get_img_filter(const union sp_sampler_key key,
          return img_filter_1d_linear;
       break;
    case PIPE_TEXTURE_2D:
+   case PIPE_TEXTURE_RECT:
       /* Try for fast path:
        */
       if (key.bits.is_pot &&
index ff83c750aafa57085ecc7e2557301e4c9fd71335..26eb03a895a81ae4ad4ebb28c85c838f500c08a3 100644 (file)
@@ -583,7 +583,8 @@ svga_texture_from_handle(struct pipe_screen *screen,
    assert(screen);
 
    /* Only supports one type */
-   if (template->target != PIPE_TEXTURE_2D ||
+   if ((template->target != PIPE_TEXTURE_2D &&
+       template->target != PIPE_TEXTURE_RECT) ||
        template->last_level != 0 ||
        template->depth0 != 1) {
       return NULL;
index 48eced2ecea33d3fe266b45ca4d4fd8179991996..b4e90a957d0fb16af03ebb1f921698e7bc097da7 100644 (file)
@@ -353,6 +353,7 @@ static INLINE ubyte svga_tgsi_sampler_type( struct svga_shader_emitter *emit,
    case PIPE_TEXTURE_1D:
       return SVGA3DSAMP_2D;
    case PIPE_TEXTURE_2D:
+   case PIPE_TEXTURE_RECT:
       return SVGA3DSAMP_2D;
    case PIPE_TEXTURE_3D:
       return SVGA3DSAMP_VOLUME;
index 58706dab93d10fdf2c1db1012ba6011030f558db..089d05c62379e82c337e6558942e752133e30d60 100755 (executable)
@@ -55,7 +55,7 @@ def tex_coords(texture, face, level, zslice):
         [0.0, 1.0],
     ] 
     
-    if texture.target == PIPE_TEXTURE_2D:
+    if texture.target == PIPE_TEXTURE_2D or texture.target == PIPE_TEXTURE_RECT:
         return [[s, t, 0.0] for s, t in st]
     elif texture.target == PIPE_TEXTURE_3D:
         depth = texture.get_depth(level)
index 0b8ecd27cb99da8a03c1c8f6760ce4afb4a330b3..91037ab2233d42111d2fa8d4570349a7048921a2 100644 (file)
@@ -761,7 +761,7 @@ st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
    if (pt) {
       struct pipe_sampler_view *sv = st_create_texture_sampler_view(st->pipe, pt);
 
-      assert(pt->target == PIPE_TEXTURE_2D);
+      assert(pt->target == PIPE_TEXTURE_2D || pt->target == PIPE_TEXTURE_RECT);
 
       if (sv) {
          draw_bitmap_quad(ctx, x, y, ctx->Current.RasterPos[2],