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>
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;
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;
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];
}
/* 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];
}
}
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;
}
}
}
-
+
/**
* Called during state validation when LP_NEW_SAMPLER_VIEW is set.
}
-/**
- * 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)
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,