llvmpipe: get rid of llvmpipe_get_texture_image_all
authorRoland Scheidegger <sroland@vmware.com>
Tue, 1 Jul 2014 01:09:44 +0000 (03:09 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Tue, 1 Jul 2014 23:55:59 +0000 (01:55 +0200)
Once used for invoking swizzled->linear conversion for all needed images.
But we now have a single allocation for all images in a resource, thus looping
through all slices is rather pointless, conversion doesn't happen neither.
Also simplify the sampling setup code to use the mip_offsets array in the
resource directly - if the (non display target) resource exists its memory
will already be allocated as well.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_state_sampler.c
src/gallium/drivers/llvmpipe/lp_texture.c
src/gallium/drivers/llvmpipe/lp_texture.h

index cbf465e65d127bb83e923233eeb8ab505be57476..d728e85dcb67ff8d588d3a4d50fb6365a0c1f4a7 100644 (file)
@@ -802,7 +802,6 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
 
          if (!lp_tex->dt) {
             /* regular texture - setup array of mipmap level offsets */
-            void *mip_ptr;
             int j;
             unsigned first_level = 0;
             unsigned last_level = 0;
@@ -812,22 +811,14 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
                last_level = view->u.tex.last_level;
                assert(first_level <= last_level);
                assert(last_level <= res->last_level);
-
-               /*
-                * The complexity here should no longer be necessary.
-                */
-               mip_ptr = llvmpipe_get_texture_image_all(lp_tex, first_level,
-                                                        LP_TEX_USAGE_READ);
                jit_tex->base = lp_tex->tex_data;
             }
             else {
-               mip_ptr = lp_tex->data;
-               jit_tex->base = mip_ptr;
+              jit_tex->base = lp_tex->data;
             }
 
-            if ((LP_PERF & PERF_TEX_MEM) || !mip_ptr) {
-               /* out of memory - use dummy tile memory */
-               /* Note if using PERF_TEX_MEM will also skip tile conversion */
+            if (LP_PERF & PERF_TEX_MEM) {
+               /* use dummy tile memory */
                jit_tex->base = lp_dummy_tile;
                jit_tex->width = TILE_SIZE/8;
                jit_tex->height = TILE_SIZE/8;
@@ -847,14 +838,7 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
 
                if (llvmpipe_resource_is_texture(res)) {
                   for (j = first_level; j <= last_level; j++) {
-                     mip_ptr = llvmpipe_get_texture_image_all(lp_tex, j,
-                                                              LP_TEX_USAGE_READ);
-                     jit_tex->mip_offsets[j] = (uint8_t *)mip_ptr - (uint8_t *)jit_tex->base;
-                     /*
-                      * could get mip offset directly but need call above to
-                      * invoke tiled->linear conversion.
-                      */
-                     assert(lp_tex->mip_offsets[j] == jit_tex->mip_offsets[j]);
+                     jit_tex->mip_offsets[j] = lp_tex->mip_offsets[j];
                      jit_tex->row_stride[j] = lp_tex->row_stride[j];
                      jit_tex->img_stride[j] = lp_tex->img_stride[j];
                   }
index d204378e556992fd851e043ce986e4b4fbb35b59..a14a64f9a3d854190b24d473f1580e8a7597483f 100644 (file)
@@ -232,29 +232,16 @@ prepare_shader_sampling(
             /* regular texture - setup array of mipmap level offsets */
             struct pipe_resource *res = view->texture;
             int j;
-            void *mip_ptr;
 
             if (llvmpipe_resource_is_texture(res)) {
                first_level = view->u.tex.first_level;
                last_level = view->u.tex.last_level;
                assert(first_level <= last_level);
                assert(last_level <= res->last_level);
-
-               /* must trigger allocation first before we can get base ptr */
-               /* XXX this may fail due to OOM ? */
-               mip_ptr = llvmpipe_get_texture_image_all(lp_tex, view->u.tex.first_level,
-                                                        LP_TEX_USAGE_READ);
                addr = lp_tex->tex_data;
 
                for (j = first_level; j <= last_level; j++) {
-                  mip_ptr = llvmpipe_get_texture_image_all(lp_tex, j,
-                                                           LP_TEX_USAGE_READ);
-                  mip_offsets[j] = (uint8_t *)mip_ptr - (uint8_t *)addr;
-                  /*
-                   * could get mip offset directly but need call above to
-                   * invoke tiled->linear conversion.
-                   */
-                  assert(lp_tex->mip_offsets[j] == mip_offsets[j]);
+                  mip_offsets[j] = lp_tex->mip_offsets[j];
                   row_stride[j] = lp_tex->row_stride[j];
                   img_stride[j] = lp_tex->img_stride[j];
                }
@@ -271,8 +258,7 @@ prepare_shader_sampling(
             }
             else {
                unsigned view_blocksize = util_format_get_blocksize(view->format);
-               mip_ptr = lp_tex->data;
-               addr = mip_ptr;
+               addr = lp_tex->data;
                /* probably don't really need to fill that out */
                mip_offsets[0] = 0;
                row_stride[0] = 0;
@@ -310,7 +296,7 @@ prepare_shader_sampling(
       }
    }
 }
-                        
+
 
 /**
  * Called during state validation when LP_NEW_SAMPLER_VIEW is set.
index f95b2a2b47e583ec978d1006a65f6a4d759726b5..f5383dc6255f90a3d71f50eb1c4c9b5c41c3a736 100644 (file)
@@ -833,29 +833,6 @@ llvmpipe_get_texture_image(struct llvmpipe_resource *lpr,
 }
 
 
-/**
- * Return pointer to start of a texture image (1D, 2D, 3D, CUBE).
- * This is typically used when we're about to sample from a texture.
- */
-void *
-llvmpipe_get_texture_image_all(struct llvmpipe_resource *lpr,
-                               unsigned level,
-                               enum lp_texture_usage usage)
-{
-   const int slices = lpr->num_slices_faces[level];
-   int slice;
-   void *map = NULL;
-
-   assert(slices > 0);
-
-   for (slice = slices - 1; slice >= 0; slice--) {
-      map = llvmpipe_get_texture_image(lpr, slice, level, usage);
-   }
-
-   return map;
-}
-
-
 /**
  * Get pointer to a linear image (not the tile!) at tile (x,y).
  * \return pointer to start of image/face (not the tile)
index 0731918933830784145a1ced4a4a9887f418002e..5eb0f5ab07eb4cd3c3099b1800b8bb57684a6b22 100644 (file)
@@ -222,11 +222,6 @@ llvmpipe_get_texture_image(struct llvmpipe_resource *resource,
                            unsigned face_slice, unsigned level,
                            enum lp_texture_usage usage);
 
-void *
-llvmpipe_get_texture_image_all(struct llvmpipe_resource *lpr,
-                               unsigned level,
-                               enum lp_texture_usage usage);
-
 ubyte *
 llvmpipe_get_texture_tile_linear(struct llvmpipe_resource *lpr,
                                  unsigned face_slice, unsigned level,