llvmpipe: get rid of linear_img struct
authorRoland Scheidegger <sroland@vmware.com>
Tue, 1 Jul 2014 00:18:56 +0000 (02:18 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Tue, 1 Jul 2014 23:55:59 +0000 (01:55 +0200)
Just use a tex_data pointer directly - the description was no longer correct
neither.

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 046611aa7366b26dbb56e9e9c3060d8ca340e8ba..cbf465e65d127bb83e923233eeb8ab505be57476 100644 (file)
@@ -818,7 +818,7 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
                 */
                mip_ptr = llvmpipe_get_texture_image_all(lp_tex, first_level,
                                                         LP_TEX_USAGE_READ);
-               jit_tex->base = lp_tex->linear_img.data;
+               jit_tex->base = lp_tex->tex_data;
             }
             else {
                mip_ptr = lp_tex->data;
index 0b227ea2ffe5e3a5ce1eb3fa544e2f1fa2732232..d204378e556992fd851e043ce986e4b4fbb35b59 100644 (file)
@@ -244,7 +244,7 @@ prepare_shader_sampling(
                /* 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->linear_img.data;
+               addr = lp_tex->tex_data;
 
                for (j = first_level; j <= last_level; j++) {
                   mip_ptr = llvmpipe_get_texture_image_all(lp_tex, j,
index d60d10158de1124d2fc76e801daafc735be6ce1b..a156449a002f4ed36154fa866dacd927eee49d9a 100644 (file)
@@ -301,9 +301,9 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen,
    }
    else if (llvmpipe_resource_is_texture(pt)) {
       /* free linear image data */
-      if (lpr->linear_img.data) {
-         align_free(lpr->linear_img.data);
-         lpr->linear_img.data = NULL;
+      if (lpr->tex_data) {
+         align_free(lpr->tex_data);
+         lpr->tex_data = NULL;
       }
    }
    else if (!lpr->userBuffer) {
@@ -359,7 +359,7 @@ llvmpipe_resource_map(struct pipe_resource *resource,
       map = winsys->displaytarget_map(winsys, lpr->dt, dt_usage);
 
       /* install this linear image in texture data structure */
-      lpr->linear_img.data = map;
+      lpr->tex_data = map;
 
       return map;
    }
@@ -726,16 +726,14 @@ ubyte *
 llvmpipe_get_texture_image_address(struct llvmpipe_resource *lpr,
                                    unsigned face_slice, unsigned level)
 {
-   struct llvmpipe_texture_image *img;
    unsigned offset;
 
-   img = &lpr->linear_img;
    offset = lpr->mip_offsets[level];
 
    if (face_slice > 0)
       offset += face_slice * tex_image_face_size(lpr, level);
 
-   return (ubyte *) img->data + offset;
+   return (ubyte *) lpr->tex_data + offset;
 }
 
 
@@ -759,7 +757,7 @@ alloc_image_data(struct llvmpipe_resource *lpr)
 
       assert(lpr->base.last_level == 0);
 
-      lpr->linear_img.data =
+      lpr->tex_data =
          winsys->displaytarget_map(winsys, lpr->dt,
                                    PIPE_TRANSFER_READ_WRITE);
    }
@@ -774,9 +772,9 @@ alloc_image_data(struct llvmpipe_resource *lpr)
          lpr->mip_offsets[level] = offset;
          offset += align(buffer_size, alignment);
       }
-      lpr->linear_img.data = align_malloc(offset, alignment);
-      if (lpr->linear_img.data) {
-         memset(lpr->linear_img.data, 0, offset);
+      lpr->tex_data = align_malloc(offset, alignment);
+      if (lpr->tex_data) {
+         memset(lpr->tex_data, 0, offset);
       }
    }
 }
@@ -795,7 +793,6 @@ llvmpipe_get_texture_image(struct llvmpipe_resource *lpr,
                            unsigned face_slice, unsigned level,
                            enum lp_texture_usage usage)
 {
-   struct llvmpipe_texture_image *target_img;
    void *target_data;
    unsigned target_offset;
    unsigned *target_off_ptr;
@@ -805,17 +802,14 @@ llvmpipe_get_texture_image(struct llvmpipe_resource *lpr,
           usage == LP_TEX_USAGE_WRITE_ALL);
 
    if (lpr->dt) {
-      assert(lpr->linear_img.data);
+      assert(lpr->tex_data);
    }
 
-   target_img = &lpr->linear_img;
    target_off_ptr = lpr->mip_offsets;
-   target_data = target_img->data;
 
-   if (!target_data) {
+   if (!lpr->tex_data) {
       /* allocate memory for the target image now */
       alloc_image_data(lpr);
-      target_data = target_img->data;
    }
 
    target_offset = target_off_ptr[level];
@@ -824,8 +818,8 @@ llvmpipe_get_texture_image(struct llvmpipe_resource *lpr,
       target_offset += face_slice * tex_image_face_size(lpr, level);
    }
 
-   if (target_data) {
-      target_data = (uint8_t *) target_data + target_offset;
+   if (lpr->tex_data) {
+      target_data = (uint8_t *) lpr->tex_data + target_offset;
    }
 
    return target_data;
@@ -865,19 +859,18 @@ llvmpipe_get_texture_tile_linear(struct llvmpipe_resource *lpr,
                                  enum lp_texture_usage usage,
                                  unsigned x, unsigned y)
 {
-   struct llvmpipe_texture_image *linear_img = &lpr->linear_img;
    uint8_t *linear_image;
 
    assert(llvmpipe_resource_is_texture(&lpr->base));
    assert(x % TILE_SIZE == 0);
    assert(y % TILE_SIZE == 0);
 
-   if (!linear_img->data) {
+   if (!lpr->tex_data) {
       /* allocate memory for the linear image now */
       /* XXX should probably not do that here? */
       alloc_image_data(lpr);
    }
-   assert(linear_img->data);
+   assert(lpr->tex_data);
 
    /* compute address of the slice/face of the image that contains the tile */
    linear_image = llvmpipe_get_texture_image_address(lpr, face_slice, level);
@@ -897,7 +890,7 @@ llvmpipe_resource_size(const struct pipe_resource *resource)
 
    if (llvmpipe_resource_is_texture(resource)) {
       for (lvl = 0; lvl <= lpr->base.last_level; lvl++) {
-         if (lpr->linear_img.data)
+         if (lpr->tex_data)
             size += tex_image_size(lpr, lvl);
       }
    }
index e26d044421f013041d2c6bbbfe11d6adf29e5cea..0731918933830784145a1ced4a4a9887f418002e 100644 (file)
@@ -49,13 +49,6 @@ struct llvmpipe_context;
 struct sw_displaytarget;
 
 
-/** A 1D/2D/3D image, one mipmap level */
-struct llvmpipe_texture_image
-{
-   void *data;
-};
-
-
 /**
  * llvmpipe subclass of pipe_resource.  A texture, drawing surface,
  * vertex buffer, const buffer, etc.
@@ -85,7 +78,7 @@ struct llvmpipe_resource
    /**
     * Malloc'ed data for regular textures, or a mapping to dt above.
     */
-   struct llvmpipe_texture_image linear_img;
+   void *tex_data;
 
    /**
     * Data for non-texture resources.