mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-07 17:20:21 +01:00
llvmpipe/cs: migrate cs image handle to common jit code.
This moves some of the code over, and uses the generic paths. Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25416>
This commit is contained in:
parent
2c74f825f4
commit
c45ae052f0
2 changed files with 24 additions and 66 deletions
|
|
@ -587,9 +587,29 @@ lp_jit_image_from_pipe(struct lp_jit_image *jit, const struct pipe_image_view *v
|
|||
jit->sample_stride = lp_res->sample_stride;
|
||||
jit->base = (uint8_t *)jit->base + mip_offset;
|
||||
} else {
|
||||
unsigned view_blocksize = util_format_get_blocksize(view->format);
|
||||
jit->width = view->u.buf.size / view_blocksize;
|
||||
jit->base = (uint8_t *)jit->base + view->u.buf.offset;
|
||||
unsigned image_blocksize = util_format_get_blocksize(view->format);
|
||||
|
||||
jit->img_stride = 0;
|
||||
|
||||
/* If it's not a 2D image view of a buffer, adjust using size. */
|
||||
if (!(view->access & PIPE_IMAGE_ACCESS_TEX2D_FROM_BUFFER)) {
|
||||
/* everything specified in number of elements here. */
|
||||
jit->width = view->u.buf.size / image_blocksize;
|
||||
jit->row_stride = 0;
|
||||
|
||||
/* Adjust base pointer with offset. */
|
||||
jit->base = (uint8_t *)jit->base + view->u.buf.offset;
|
||||
|
||||
/* XXX Unsure if we need to sanitize parameters? */
|
||||
assert(view->u.buf.offset + view->u.buf.size <= res->width0);
|
||||
} else {
|
||||
jit->width = view->u.tex2d_from_buf.width;
|
||||
jit->height = view->u.tex2d_from_buf.height;
|
||||
jit->row_stride = view->u.tex2d_from_buf.row_stride * image_blocksize;
|
||||
|
||||
jit->base = (uint8_t *)jit->base +
|
||||
view->u.tex2d_from_buf.offset * image_blocksize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1566,70 +1566,8 @@ lp_csctx_set_cs_images(struct lp_cs_context *csctx,
|
|||
jit_image = &csctx->cs.current.jit_resources.images[i];
|
||||
if (!lp_res)
|
||||
continue;
|
||||
if (!lp_res->dt) {
|
||||
/* regular texture - csctx array of mipmap level offsets */
|
||||
if (llvmpipe_resource_is_texture(res)) {
|
||||
jit_image->base = lp_res->tex_data;
|
||||
} else
|
||||
jit_image->base = lp_res->data;
|
||||
|
||||
jit_image->width = res->width0;
|
||||
jit_image->height = res->height0;
|
||||
jit_image->depth = res->depth0;
|
||||
jit_image->num_samples = res->nr_samples;
|
||||
|
||||
if (llvmpipe_resource_is_texture(res)) {
|
||||
uint32_t mip_offset = lp_res->mip_offsets[image->u.tex.level];
|
||||
|
||||
jit_image->width = u_minify(jit_image->width, image->u.tex.level);
|
||||
jit_image->height = u_minify(jit_image->height, image->u.tex.level);
|
||||
|
||||
if (res->target == PIPE_TEXTURE_1D_ARRAY ||
|
||||
res->target == PIPE_TEXTURE_2D_ARRAY ||
|
||||
res->target == PIPE_TEXTURE_3D ||
|
||||
res->target == PIPE_TEXTURE_CUBE ||
|
||||
res->target == PIPE_TEXTURE_CUBE_ARRAY) {
|
||||
/*
|
||||
* For array textures, we don't have first_layer, instead
|
||||
* adjust last_layer (stored as depth) plus the mip level
|
||||
* offsets (as we have mip-first layout can't just adjust base
|
||||
* ptr). XXX For mip levels, could do something similar.
|
||||
*/
|
||||
jit_image->depth = image->u.tex.last_layer - image->u.tex.first_layer + 1;
|
||||
mip_offset += image->u.tex.first_layer * lp_res->img_stride[image->u.tex.level];
|
||||
} else
|
||||
jit_image->depth = u_minify(jit_image->depth, image->u.tex.level);
|
||||
|
||||
jit_image->row_stride = lp_res->row_stride[image->u.tex.level];
|
||||
jit_image->img_stride = lp_res->img_stride[image->u.tex.level];
|
||||
jit_image->sample_stride = lp_res->sample_stride;
|
||||
jit_image->base = (uint8_t *)jit_image->base + mip_offset;
|
||||
} else {
|
||||
unsigned image_blocksize = util_format_get_blocksize(image->format);
|
||||
|
||||
jit_image->img_stride = 0;
|
||||
|
||||
/* If it's not a 2D image view of a buffer, adjust using size. */
|
||||
if (!(image->access & PIPE_IMAGE_ACCESS_TEX2D_FROM_BUFFER)) {
|
||||
/* everything specified in number of elements here. */
|
||||
jit_image->width = image->u.buf.size / image_blocksize;
|
||||
jit_image->row_stride = 0;
|
||||
|
||||
/* Adjust base pointer with offset. */
|
||||
jit_image->base = (uint8_t *)jit_image->base + image->u.buf.offset;
|
||||
|
||||
/* XXX Unsure if we need to sanitize parameters? */
|
||||
assert(image->u.buf.offset + image->u.buf.size <= res->width0);
|
||||
} else {
|
||||
jit_image->width = image->u.tex2d_from_buf.width;
|
||||
jit_image->height = image->u.tex2d_from_buf.height;
|
||||
jit_image->row_stride = image->u.tex2d_from_buf.row_stride * image_blocksize;
|
||||
|
||||
jit_image->base = (uint8_t *)jit_image->base +
|
||||
image->u.tex2d_from_buf.offset * image_blocksize;
|
||||
}
|
||||
}
|
||||
}
|
||||
lp_jit_image_from_pipe(jit_image, image);
|
||||
}
|
||||
for (; i < ARRAY_SIZE(csctx->images); i++) {
|
||||
util_copy_image_view(&csctx->images[i].current, NULL);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue