From 20183177a5803317fe69f1f1a8dfae4d18b3702f Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Feb 2013 20:23:18 +0100 Subject: [PATCH] llvmpipe: support GL_ARB_texture_buffer_object/GL_ARB_texture_buffer_range 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 --- src/gallium/auxiliary/draw/draw_context.c | 4 +- src/gallium/auxiliary/draw/draw_context.h | 2 +- src/gallium/auxiliary/draw/draw_llvm.c | 6 +- src/gallium/auxiliary/draw/draw_llvm.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_sample.h | 4 +- .../auxiliary/gallivm/lp_bld_sample_soa.c | 8 +- src/gallium/drivers/llvmpipe/lp_jit.h | 4 +- src/gallium/drivers/llvmpipe/lp_screen.c | 4 +- src/gallium/drivers/llvmpipe/lp_setup.c | 130 ++++++++++++------ .../drivers/llvmpipe/lp_state_sampler.c | 84 +++++++---- src/gallium/drivers/llvmpipe/lp_texture.c | 36 +---- src/gallium/drivers/llvmpipe/lp_texture.h | 22 +++ 12 files changed, 191 insertions(+), 115 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index dfa8927bc08..5020081b767 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -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); diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index a4937b6165f..e8e2d9487b3 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -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, diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 2467e5acff1..8e466879c93 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -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; diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h index 17ca3047594..c9f125b1f63 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.h +++ b/src/gallium/auxiliary/draw/draw_llvm.h @@ -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, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index f5022167123..63064550ee6 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -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, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index c5b48b52da3..50ccd2a1741 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -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), ""); } diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 472d3911e71..4eddb2a2f3c 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -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; diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index b9c1567bd55..05bbca5e19b 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -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); diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index b0bc4a8132f..4529775f907 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -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); } } diff --git a/src/gallium/drivers/llvmpipe/lp_state_sampler.c b/src/gallium/drivers/llvmpipe/lp_state_sampler.c index 9736ca94905..30547a69f0d 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_sampler.c +++ b/src/gallium/drivers/llvmpipe/lp_state_sampler.c @@ -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); } diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index f34882808a4..f9232923733 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -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); diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h index 172228dc3fb..58d719e51e5 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.h +++ b/src/gallium/drivers/llvmpipe/lp_texture.h @@ -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) -- 2.30.2