llvmpipe: support GL_ARB_texture_buffer_object/GL_ARB_texture_buffer_range
authorRoland Scheidegger <sroland@vmware.com>
Mon, 25 Feb 2013 19:23:18 +0000 (20:23 +0100)
committerRoland Scheidegger <sroland@vmware.com>
Mon, 25 Feb 2013 19:38:23 +0000 (20:38 +0100)
This also fixes not honoring first/last_layer view parameters for array
textures, plus not honoring last_level view parameter for all textures
(neither is really used by OpenGL).
This mostly passes piglit arb_texture_buffer_object tests (it needs, however,
glsl 140 version override, plus GL 3.1 override, the latter only because
mesa does not allow ARB_tbo in non-core contexts).
Most arb_texture_buffer_object tests pass, with the exception of
arb_texture_buffer_object-formats. With "arb" parameter it passes most weirdo
formats before it segfaults in the state tracker, this looks to be some issue
with using legacy formats in core context (fails the same in softpipe).
With "core" parameter it passes with "fs", however fails with "vs" (for most
formats). This will be fixed later (debugging shows we're completely missing
the shader recompile depending on format).

v2: based on Jose's feedback, fix comments, variable/function names.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
12 files changed:
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_context.h
src/gallium/auxiliary/draw/draw_llvm.c
src/gallium/auxiliary/draw/draw_llvm.h
src/gallium/auxiliary/gallivm/lp_bld_sample.h
src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
src/gallium/drivers/llvmpipe/lp_jit.h
src/gallium/drivers/llvmpipe/lp_screen.c
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 dfa8927bc0808f63c44c980ba91addee5a64784a..5020081b7675a49f0b7932005c0563a96a2e3c51 100644 (file)
@@ -799,7 +799,7 @@ draw_set_samplers(struct draw_context *draw,
 void
 draw_set_mapped_texture(struct draw_context *draw,
                         unsigned shader_stage,
-                        unsigned sampler_idx,
+                        unsigned sview_idx,
                         uint32_t width, uint32_t height, uint32_t depth,
                         uint32_t first_level, uint32_t last_level,
                         const void *base_ptr,
@@ -811,7 +811,7 @@ draw_set_mapped_texture(struct draw_context *draw,
 #ifdef HAVE_LLVM
       if (draw->llvm)
          draw_llvm_set_mapped_texture(draw,
-                                      sampler_idx,
+                                      sview_idx,
                                       width, height, depth, first_level,
                                       last_level, base_ptr,
                                       row_stride, img_stride, mip_offsets);
index a4937b6165f4194165411405bfa912689c6e3234..e8e2d9487b39c7eec3414bb414973c560939090b 100644 (file)
@@ -151,7 +151,7 @@ draw_set_samplers(struct draw_context *draw,
 void
 draw_set_mapped_texture(struct draw_context *draw,
                         unsigned shader_stage,
-                        unsigned sampler_idx,
+                        unsigned sview_idx,
                         uint32_t width, uint32_t height, uint32_t depth,
                         uint32_t first_level, uint32_t last_level,
                         const void *base,
index 2467e5acff191969ebdf12d5b7325ef170405831..8e466879c93d481fc4f478369a457b7eec3b9286 100644 (file)
@@ -1497,7 +1497,7 @@ draw_llvm_dump_variant_key(struct draw_llvm_variant_key *key)
 
 void
 draw_llvm_set_mapped_texture(struct draw_context *draw,
-                             unsigned sampler_idx,
+                             unsigned sview_idx,
                              uint32_t width, uint32_t height, uint32_t depth,
                              uint32_t first_level, uint32_t last_level,
                              const void *base_ptr,
@@ -1508,9 +1508,9 @@ draw_llvm_set_mapped_texture(struct draw_context *draw,
    unsigned j;
    struct draw_jit_texture *jit_tex;
 
-   assert(sampler_idx < Elements(draw->llvm->jit_context.textures));
+   assert(sview_idx < Elements(draw->llvm->jit_context.textures));
 
-   jit_tex = &draw->llvm->jit_context.textures[sampler_idx];
+   jit_tex = &draw->llvm->jit_context.textures[sview_idx];
 
    jit_tex->width = width;
    jit_tex->height = height;
index 17ca3047594b9feff3f0ec674c53508d34700f56..c9f125b1f63201ee8ad688e35887654988998ede 100644 (file)
@@ -333,7 +333,7 @@ draw_llvm_set_sampler_state(struct draw_context *draw);
 
 void
 draw_llvm_set_mapped_texture(struct draw_context *draw,
-                             unsigned sampler_idx,
+                             unsigned sview_idx,
                              uint32_t width, uint32_t height, uint32_t depth,
                              uint32_t first_level, uint32_t last_level,
                              const void *base_ptr,
index f50221671232dce61d50baccdd86283f69ecfb79..63064550ee66396f198d3d24d0b49ba771b478e1 100644 (file)
@@ -127,7 +127,7 @@ struct lp_sampler_dynamic_state
 {
    /* First callbacks for sampler view state */
 
-   /** Obtain the base texture width (returns int32) */
+   /** Obtain the base texture width (or number of elements) (returns int32) */
    LLVMValueRef
    (*width)( const struct lp_sampler_dynamic_state *state,
              struct gallivm_state *gallivm,
@@ -139,7 +139,7 @@ struct lp_sampler_dynamic_state
               struct gallivm_state *gallivm,
               unsigned texture_unit);
 
-   /** Obtain the base texture depth (returns int32) */
+   /** Obtain the base texture depth (or array size) (returns int32) */
    LLVMValueRef
    (*depth)( const struct lp_sampler_dynamic_state *state,
              struct gallivm_state *gallivm,
index c5b48b52da3320ab83b0bc531c686c8f53ccc9c8..50ccd2a174113b380577afee4fd3ca02bf8de223 100644 (file)
@@ -1422,7 +1422,7 @@ lp_build_sample_soa(struct gallivm_state *gallivm,
    struct lp_static_sampler_state derived_sampler_state = *static_sampler_state;
    LLVMTypeRef i32t = LLVMInt32TypeInContext(gallivm->context);
    LLVMBuilderRef builder = gallivm->builder;
-   LLVMValueRef tex_width, tex_height, tex_depth;
+   LLVMValueRef tex_width;
    LLVMValueRef s;
    LLVMValueRef t;
    LLVMValueRef r;
@@ -1514,8 +1514,6 @@ lp_build_sample_soa(struct gallivm_state *gallivm,
 
    /* Get the dynamic state */
    tex_width = dynamic_state->width(dynamic_state, gallivm, texture_index);
-   tex_height = dynamic_state->height(dynamic_state, gallivm, texture_index);
-   tex_depth = dynamic_state->depth(dynamic_state, gallivm, texture_index);
    bld.row_stride_array = dynamic_state->row_stride(dynamic_state, gallivm, texture_index);
    bld.img_stride_array = dynamic_state->img_stride(dynamic_state, gallivm, texture_index);
    bld.base_ptr = dynamic_state->base_ptr(dynamic_state, gallivm, texture_index);
@@ -1534,9 +1532,13 @@ lp_build_sample_soa(struct gallivm_state *gallivm,
       bld.int_size = LLVMBuildInsertElement(builder, bld.int_size_in_bld.undef,
                                             tex_width, LLVMConstInt(i32t, 0, 0), "");
       if (dims >= 2) {
+         LLVMValueRef tex_height =
+            dynamic_state->height(dynamic_state, gallivm, texture_index);
          bld.int_size = LLVMBuildInsertElement(builder, bld.int_size,
                                                tex_height, LLVMConstInt(i32t, 1, 0), "");
          if (dims >= 3) {
+            LLVMValueRef tex_depth =
+               dynamic_state->depth(dynamic_state, gallivm, texture_index);
             bld.int_size = LLVMBuildInsertElement(builder, bld.int_size,
                                                   tex_depth, LLVMConstInt(i32t, 2, 0), "");
          }
index 472d3911e71937d7532b556b08cee7db840d10a9..4eddb2a2f3c7c42915dcda1d0f459b28e5cfca02 100644 (file)
@@ -49,9 +49,9 @@ struct llvmpipe_screen;
 
 struct lp_jit_texture
 {
-   uint32_t width;
+   uint32_t width;        /* same as number of elements */
    uint32_t height;
-   uint32_t depth;
+   uint32_t depth;        /* doubles as array size */
    uint32_t first_level;
    uint32_t last_level;
    const void *base;
index b9c1567bd55816f1d937d4733024c82dbe05fa96..05bbca5e19b0c4eb4d486c8d9bba23aa2b6f5645 100644 (file)
@@ -216,9 +216,11 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_MULTISAMPLE:
    case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
    case PIPE_CAP_CUBE_MAP_ARRAY:
+      return 0;
    case PIPE_CAP_TEXTURE_BUFFER_OBJECTS:
+      return 1;
    case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
-      return 0;
+      return 1;
    }
    /* should only get here on unhandled cases */
    debug_printf("Unexpected PIPE_CAP %d query\n", param);
index b0bc4a8132fe70724403135d938c9ea2dd056dc4..4529775f9072d5f85ebfaecfa55ffda4a5ec3e05 100644 (file)
@@ -674,70 +674,108 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
       struct pipe_sampler_view *view = i < num ? views[i] : NULL;
 
       if (view) {
-         struct pipe_resource *tex = view->texture;
-         struct llvmpipe_resource *lp_tex = llvmpipe_resource(tex);
+         struct pipe_resource *res = view->texture;
+         struct llvmpipe_resource *lp_tex = llvmpipe_resource(res);
          struct lp_jit_texture *jit_tex;
          jit_tex = &setup->fs.current.jit_context.textures[i];
-         jit_tex->width = tex->width0;
-         jit_tex->height = tex->height0;
-         jit_tex->first_level = view->u.tex.first_level;
-         jit_tex->last_level = tex->last_level;
-
-         if (tex->target == PIPE_TEXTURE_3D) {
-            jit_tex->depth = tex->depth0;
-         }
-         else {
-            jit_tex->depth = tex->array_size;
-         }
 
          /* We're referencing the texture's internal data, so save a
           * reference to it.
           */
-         pipe_resource_reference(&setup->fs.current_tex[i], tex);
+         pipe_resource_reference(&setup->fs.current_tex[i], res);
 
          if (!lp_tex->dt) {
             /* regular texture - setup array of mipmap level offsets */
             void *mip_ptr;
             int j;
-            /*
-             * XXX this is messed up we don't want to accidentally trigger
-             * tiled->linear conversion for levels we don't need.
-             * So ask for first_level data (which will allocate all levels)
-             * then if successful get base ptr.
-             */
-            mip_ptr = llvmpipe_get_texture_image_all(lp_tex, view->u.tex.first_level,
-                                                     LP_TEX_USAGE_READ,
-                                                     LP_TEX_LAYOUT_LINEAR);
+            unsigned first_level = 0;
+            unsigned last_level = 0;
+
+            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);
+
+               /*
+                * The complexity here is only necessary for depth textures which
+                * still are tiled.
+                */
+               mip_ptr = llvmpipe_get_texture_image_all(lp_tex, first_level,
+                                                        LP_TEX_USAGE_READ,
+                                                        LP_TEX_LAYOUT_LINEAR);
+               jit_tex->base = lp_tex->linear_img.data;
+            }
+            else {
+               mip_ptr = lp_tex->data;
+               jit_tex->base = mip_ptr;
+            }
+
             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 */
                jit_tex->base = lp_dummy_tile;
                jit_tex->width = TILE_SIZE/8;
                jit_tex->height = TILE_SIZE/8;
                jit_tex->depth = 1;
                jit_tex->first_level = 0;
                jit_tex->last_level = 0;
+               jit_tex->mip_offsets[j] = 0;
+               jit_tex->row_stride[j] = 0;
+               jit_tex->img_stride[j] = 0;
             }
             else {
-               jit_tex->base = lp_tex->linear_img.data;
-            }
-            for (j = view->u.tex.first_level; j <= tex->last_level; j++) {
-               mip_ptr = llvmpipe_get_texture_image_all(lp_tex, j,
-                                                        LP_TEX_USAGE_READ,
-                                                        LP_TEX_LAYOUT_LINEAR);
-               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->linear_mip_offsets[j] == jit_tex->mip_offsets[j]);
-               jit_tex->row_stride[j] = lp_tex->row_stride[j];
-               jit_tex->img_stride[j] = lp_tex->img_stride[j];
-
-               if (jit_tex->base == lp_dummy_tile) {
-                  /* out of memory - use dummy tile memory */
-                  jit_tex->mip_offsets[j] = 0;
-                  jit_tex->row_stride[j] = 0;
-                  jit_tex->img_stride[j] = 0;
+               jit_tex->width = res->width0;
+               jit_tex->height = res->height0;
+               jit_tex->depth = res->depth0;
+               jit_tex->first_level = first_level;
+               jit_tex->last_level = last_level;
+
+               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,
+                                                              LP_TEX_LAYOUT_LINEAR);
+                     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->linear_mip_offsets[j] == jit_tex->mip_offsets[j]);
+                     jit_tex->row_stride[j] = lp_tex->row_stride[j];
+                     jit_tex->img_stride[j] = lp_tex->img_stride[j];
+                  }
+
+                  /*
+                   * We don't use anything like first_element (for buffers) or
+                   * first_layer (for arrays), instead adjust the last_element
+                   * (width) or last_layer (depth) plus the base pointer.
+                   * Less parameters and faster at shader execution.
+                   * XXX Could do the same for mip levels.
+                   */
+                  if (res->target == PIPE_TEXTURE_1D_ARRAY ||
+                      res->target == PIPE_TEXTURE_2D_ARRAY) {
+                     jit_tex->depth = view->u.tex.last_layer - view->u.tex.first_layer + 1;
+                     jit_tex->base = (uint8_t *)jit_tex->base +
+                                     view->u.tex.first_layer * lp_tex->img_stride[0];
+                     assert(view->u.tex.first_layer <= view->u.tex.last_layer);
+                     assert(view->u.tex.last_layer < res->array_size);
+                  }
+               }
+               else {
+                  unsigned view_blocksize = util_format_get_blocksize(view->format);
+                  /* probably don't really need to fill that out */
+                  jit_tex->mip_offsets[0] = 0;
+                  jit_tex->row_stride[0] = 0;
+                  jit_tex->row_stride[0] = 0;
+
+                  /* everything specified in number of elements here. */
+                  jit_tex->width = view->u.buf.last_element - view->u.buf.first_element + 1;
+                  jit_tex->base = (uint8_t *)jit_tex->base + view->u.buf.first_element *
+                                  view_blocksize;
+                  /* XXX Unsure if we need to sanitize parameters? */
+                  assert(view->u.buf.first_element <= view->u.buf.last_element);
+                  assert(view->u.buf.last_element * view_blocksize < res->width0);
                }
             }
          }
@@ -746,13 +784,17 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
             /*
              * XXX: Where should this be unmapped?
              */
-            struct llvmpipe_screen *screen = llvmpipe_screen(tex->screen);
+            struct llvmpipe_screen *screen = llvmpipe_screen(res->screen);
             struct sw_winsys *winsys = screen->winsys;
             jit_tex->base = winsys->displaytarget_map(winsys, lp_tex->dt,
                                                          PIPE_TRANSFER_READ);
             jit_tex->row_stride[0] = lp_tex->row_stride[0];
             jit_tex->img_stride[0] = lp_tex->img_stride[0];
             jit_tex->mip_offsets[0] = 0;
+            jit_tex->width = res->width0;
+            jit_tex->height = res->height0;
+            jit_tex->depth = res->depth0;
+            jit_tex->first_level = jit_tex->last_level = 0;
             assert(jit_tex->base);
          }
       }
index 9736ca94905fddbfd3e05ed80f92e890f7099c4e..30547a69f0dc18c0625b3b3fc6afbf98a64dfcc0 100644 (file)
@@ -268,14 +268,10 @@ llvmpipe_prepare_vertex_sampling(struct llvmpipe_context *lp,
       if (view) {
          struct pipe_resource *tex = view->texture;
          struct llvmpipe_resource *lp_tex = llvmpipe_resource(tex);
-         unsigned num_layers;
-
-         if (tex->target == PIPE_TEXTURE_3D) {
-            num_layers = tex->depth0;
-         }
-         else {
-            num_layers = tex->array_size;
-         }
+         unsigned width0 = tex->width0;
+         unsigned num_layers = tex->depth0;
+         unsigned first_level = 0;
+         unsigned last_level = 0;
 
          /* We're referencing the texture's internal data, so save a
           * reference to it.
@@ -283,27 +279,61 @@ llvmpipe_prepare_vertex_sampling(struct llvmpipe_context *lp,
          pipe_resource_reference(&lp->mapped_vs_tex[i], tex);
 
          if (!lp_tex->dt) {
-            /* regular texture - setup array of mipmap level pointers */
-            /* XXX this may fail due to OOM ? */
+            /* regular texture - setup array of mipmap level offsets */
+            struct pipe_resource *res = view->texture;
             int j;
             void *mip_ptr;
-            /* must trigger allocation first before we can get base ptr */
-            mip_ptr = llvmpipe_get_texture_image_all(lp_tex, view->u.tex.first_level,
-                                                     LP_TEX_USAGE_READ,
-                                                     LP_TEX_LAYOUT_LINEAR);
-            addr = lp_tex->linear_img.data;
-            for (j = view->u.tex.first_level; j <= tex->last_level; j++) {
-               mip_ptr = llvmpipe_get_texture_image_all(lp_tex, j,
+
+            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,
                                                         LP_TEX_LAYOUT_LINEAR);
-               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->linear_mip_offsets[j] == mip_offsets[j]);
-               row_stride[j] = lp_tex->row_stride[j];
-               img_stride[j] = lp_tex->img_stride[j];
+               addr = lp_tex->linear_img.data;
+
+               for (j = first_level; j <= last_level; j++) {
+                  mip_ptr = llvmpipe_get_texture_image_all(lp_tex, j,
+                                                           LP_TEX_USAGE_READ,
+                                                           LP_TEX_LAYOUT_LINEAR);
+                  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->linear_mip_offsets[j] == mip_offsets[j]);
+                  row_stride[j] = lp_tex->row_stride[j];
+                  img_stride[j] = lp_tex->img_stride[j];
+               }
+               if (res->target == PIPE_TEXTURE_1D_ARRAY ||
+                   res->target == PIPE_TEXTURE_2D_ARRAY) {
+                  num_layers = view->u.tex.last_layer - view->u.tex.first_layer + 1;
+                  addr = (uint8_t *)addr +
+                                  view->u.tex.first_layer * lp_tex->img_stride[0];
+                  assert(view->u.tex.first_layer <= view->u.tex.last_layer);
+                  assert(view->u.tex.last_layer < res->array_size);
+               }
+            }
+            else {
+               unsigned view_blocksize = util_format_get_blocksize(view->format);
+               mip_ptr = lp_tex->data;
+               addr = mip_ptr;
+               /* probably don't really need to fill that out */
+               mip_offsets[0] = 0;
+               row_stride[0] = 0;
+               row_stride[0] = 0;
+
+               /* everything specified in number of elements here. */
+               width0 = view->u.buf.last_element - view->u.buf.first_element + 1;
+               addr = (uint8_t *)addr + view->u.buf.first_element *
+                               view_blocksize;
+               assert(view->u.buf.first_element <= view->u.buf.last_element);
+               assert(view->u.buf.last_element * view_blocksize < res->width0);
             }
          }
          else {
@@ -323,8 +353,8 @@ llvmpipe_prepare_vertex_sampling(struct llvmpipe_context *lp,
          draw_set_mapped_texture(lp->draw,
                                  PIPE_SHADER_VERTEX,
                                  i,
-                                 tex->width0, tex->height0, num_layers,
-                                 view->u.tex.first_level, tex->last_level,
+                                 width0, tex->height0, num_layers,
+                                 first_level, last_level,
                                  addr,
                                  row_stride, img_stride, mip_offsets);
       }
index f34882808a420f488c197639309f035c276cd5c1..f92329237339b83dcf24826714716b7cb4ab0a63 100644 (file)
@@ -60,28 +60,6 @@ static struct llvmpipe_resource resource_list;
 static unsigned id_counter = 0;
 
 
-static INLINE boolean
-resource_is_texture(const struct pipe_resource *resource)
-{
-   switch (resource->target) {
-   case PIPE_BUFFER:
-      return FALSE;
-   case PIPE_TEXTURE_1D:
-   case PIPE_TEXTURE_1D_ARRAY:
-   case PIPE_TEXTURE_2D:
-   case PIPE_TEXTURE_2D_ARRAY:
-   case PIPE_TEXTURE_RECT:
-   case PIPE_TEXTURE_3D:
-   case PIPE_TEXTURE_CUBE:
-      return TRUE;
-   default:
-      assert(0);
-      return FALSE;
-   }
-}
-
-
-
 /**
  * Allocate storage for llvmpipe_texture::layout array.
  * The number of elements is width_in_tiles * height_in_tiles.
@@ -294,7 +272,7 @@ llvmpipe_resource_create(struct pipe_screen *_screen,
 
    /* assert(lpr->base.bind); */
 
-   if (resource_is_texture(&lpr->base)) {
+   if (llvmpipe_resource_is_texture(&lpr->base)) {
       if (lpr->base.bind & (PIPE_BIND_DISPLAY_TARGET |
                             PIPE_BIND_SCANOUT |
                             PIPE_BIND_SHARED)) {
@@ -357,7 +335,7 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen,
 
       FREE(lpr->layout[0]);
    }
-   else if (resource_is_texture(pt)) {
+   else if (llvmpipe_resource_is_texture(pt)) {
       /* regular texture */
       uint level;
 
@@ -447,7 +425,7 @@ llvmpipe_resource_map(struct pipe_resource *resource,
 
       return map2;
    }
-   else if (resource_is_texture(resource)) {
+   else if (llvmpipe_resource_is_texture(resource)) {
 
       map = llvmpipe_get_texture_image(lpr, layer, level,
                                        tex_usage, layout);
@@ -492,7 +470,7 @@ llvmpipe_resource_data(struct pipe_resource *resource)
 {
    struct llvmpipe_resource *lpr = llvmpipe_resource(resource);
 
-   assert(!resource_is_texture(resource));
+   assert(!llvmpipe_resource_is_texture(resource));
 
    return lpr->data;
 }
@@ -967,7 +945,7 @@ llvmpipe_get_texture_tile_layout(const struct llvmpipe_resource *lpr,
                                  unsigned x, unsigned y)
 {
    uint i;
-   assert(resource_is_texture(&lpr->base));
+   assert(llvmpipe_resource_is_texture(&lpr->base));
    assert(x < lpr->tiles_per_row[level]);
    i = face_slice * lpr->tiles_per_image[level]
       + y * lpr->tiles_per_row[level] + x;
@@ -982,7 +960,7 @@ llvmpipe_set_texture_tile_layout(struct llvmpipe_resource *lpr,
                                  enum lp_texture_layout layout)
 {
    uint i;
-   assert(resource_is_texture(&lpr->base));
+   assert(llvmpipe_resource_is_texture(&lpr->base));
    assert(x < lpr->tiles_per_row[level]);
    i = face_slice * lpr->tiles_per_image[level]
       + y * lpr->tiles_per_row[level] + x;
@@ -1264,7 +1242,7 @@ llvmpipe_get_texture_tile_linear(struct llvmpipe_resource *lpr,
    boolean convert;
    uint8_t *tiled_image, *linear_image;
 
-   assert(resource_is_texture(&lpr->base));
+   assert(llvmpipe_resource_is_texture(&lpr->base));
    assert(x % TILE_SIZE == 0);
    assert(y % TILE_SIZE == 0);
 
index 172228dc3fbe618aff91f9e814af2a140c38a720..58d719e51e56a01097a4991337346eefefe45857 100644 (file)
@@ -163,6 +163,28 @@ llvmpipe_transfer(struct pipe_transfer *pt)
 void llvmpipe_init_screen_resource_funcs(struct pipe_screen *screen);
 void llvmpipe_init_context_resource_funcs(struct pipe_context *pipe);
 
+
+static INLINE boolean
+llvmpipe_resource_is_texture(const struct pipe_resource *resource)
+{
+   switch (resource->target) {
+   case PIPE_BUFFER:
+      return FALSE;
+   case PIPE_TEXTURE_1D:
+   case PIPE_TEXTURE_1D_ARRAY:
+   case PIPE_TEXTURE_2D:
+   case PIPE_TEXTURE_2D_ARRAY:
+   case PIPE_TEXTURE_RECT:
+   case PIPE_TEXTURE_3D:
+   case PIPE_TEXTURE_CUBE:
+      return TRUE;
+   default:
+      assert(0);
+      return FALSE;
+   }
+}
+
+
 static INLINE unsigned
 llvmpipe_resource_stride(struct pipe_resource *resource,
                         unsigned level)