mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 11:48:06 +02:00
llvmpipe/cs: migrate to generic jit texture from pipe code.
This moves some cs specific bits to the generic code and uses it. Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25416>
This commit is contained in:
parent
ea92bd8d44
commit
2c74f825f4
2 changed files with 25 additions and 129 deletions
|
|
@ -444,21 +444,34 @@ lp_jit_texture_from_pipe(struct lp_jit_texture *jit, const struct pipe_sampler_v
|
|||
}
|
||||
} else {
|
||||
/*
|
||||
* For buffers, we don't have "offset", instead adjust
|
||||
* the size (stored as width) plus the base pointer.
|
||||
* For tex2d_from_buf, adjust width and height with application
|
||||
* values. If is_tex2d_from_buf is false (1D images),
|
||||
* adjust using size value (stored as width).
|
||||
*/
|
||||
const unsigned view_blocksize =
|
||||
util_format_get_blocksize(view->format);
|
||||
/* probably don't really need to fill that out */
|
||||
unsigned view_blocksize = util_format_get_blocksize(view->format);
|
||||
|
||||
jit->mip_offsets[0] = 0;
|
||||
jit->row_stride[0] = 0;
|
||||
jit->img_stride[0] = 0;
|
||||
|
||||
/* everything specified in number of elements here. */
|
||||
jit->width = view->u.buf.size / view_blocksize;
|
||||
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);
|
||||
/* If it's not a 2D texture view of a buffer, adjust using size. */
|
||||
if (!view->is_tex2d_from_buf) {
|
||||
/* everything specified in number of elements here. */
|
||||
jit->width = view->u.buf.size / view_blocksize;
|
||||
jit->row_stride[0] = 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[0] = view->u.tex2d_from_buf.row_stride * view_blocksize;
|
||||
|
||||
jit->base = (uint8_t *)jit->base +
|
||||
view->u.tex2d_from_buf.offset * view_blocksize;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1459,7 +1459,6 @@ lp_csctx_set_sampler_views(struct lp_cs_context *csctx,
|
|||
|
||||
if (view) {
|
||||
struct pipe_resource *res = view->texture;
|
||||
struct llvmpipe_resource *lp_tex = llvmpipe_resource(res);
|
||||
struct lp_jit_texture *jit_tex;
|
||||
jit_tex = &csctx->cs.current.jit_resources.textures[i];
|
||||
|
||||
|
|
@ -1468,123 +1467,7 @@ lp_csctx_set_sampler_views(struct lp_cs_context *csctx,
|
|||
*/
|
||||
pipe_resource_reference(&csctx->cs.current_tex[i], res);
|
||||
|
||||
if (!lp_tex->dt) {
|
||||
/* regular texture - csctx array of mipmap level offsets */
|
||||
int j;
|
||||
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);
|
||||
jit_tex->base = lp_tex->tex_data;
|
||||
} else {
|
||||
jit_tex->base = lp_tex->data;
|
||||
}
|
||||
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;
|
||||
jit_tex->depth = 1;
|
||||
jit_tex->first_level = 0;
|
||||
jit_tex->last_level = 0;
|
||||
jit_tex->mip_offsets[0] = 0;
|
||||
jit_tex->row_stride[0] = 0;
|
||||
jit_tex->img_stride[0] = 0;
|
||||
jit_tex->num_samples = 0;
|
||||
jit_tex->sample_stride = 0;
|
||||
} else {
|
||||
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;
|
||||
jit_tex->num_samples = res->nr_samples;
|
||||
jit_tex->sample_stride = 0;
|
||||
|
||||
if (llvmpipe_resource_is_texture(res)) {
|
||||
for (j = first_level; j <= last_level; 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];
|
||||
}
|
||||
jit_tex->sample_stride = lp_tex->sample_stride;
|
||||
|
||||
if (res->target == PIPE_TEXTURE_1D_ARRAY ||
|
||||
res->target == PIPE_TEXTURE_2D_ARRAY ||
|
||||
res->target == PIPE_TEXTURE_CUBE ||
|
||||
res->target == PIPE_TEXTURE_CUBE_ARRAY ||
|
||||
(res->target == PIPE_TEXTURE_3D && view->target == PIPE_TEXTURE_2D)) {
|
||||
/*
|
||||
* 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_tex->depth = view->u.tex.last_layer - view->u.tex.first_layer + 1;
|
||||
for (j = first_level; j <= last_level; j++) {
|
||||
jit_tex->mip_offsets[j] += view->u.tex.first_layer *
|
||||
lp_tex->img_stride[j];
|
||||
}
|
||||
if (view->target == PIPE_TEXTURE_CUBE ||
|
||||
view->target == PIPE_TEXTURE_CUBE_ARRAY) {
|
||||
assert(jit_tex->depth % 6 == 0);
|
||||
}
|
||||
assert(view->u.tex.first_layer <= view->u.tex.last_layer);
|
||||
if (res->target == PIPE_TEXTURE_3D)
|
||||
assert(view->u.tex.last_layer < res->depth0);
|
||||
else
|
||||
assert(view->u.tex.last_layer < res->array_size);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* For tex2d_from_buf, adjust width and height with application
|
||||
* values. If is_tex2d_from_buf is false (1D images),
|
||||
* adjust using size value (stored as width).
|
||||
*/
|
||||
unsigned view_blocksize = util_format_get_blocksize(view->format);
|
||||
|
||||
jit_tex->mip_offsets[0] = 0;
|
||||
jit_tex->img_stride[0] = 0;
|
||||
|
||||
/* If it's not a 2D texture view of a buffer, adjust using size. */
|
||||
if (!view->is_tex2d_from_buf) {
|
||||
/* everything specified in number of elements here. */
|
||||
jit_tex->width = view->u.buf.size / view_blocksize;
|
||||
jit_tex->row_stride[0] = 0;
|
||||
|
||||
/* Adjust base pointer with offset. */
|
||||
jit_tex->base = (uint8_t *)jit_tex->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_tex->width = view->u.tex2d_from_buf.width;
|
||||
jit_tex->height = view->u.tex2d_from_buf.height;
|
||||
jit_tex->row_stride[0] = view->u.tex2d_from_buf.row_stride * view_blocksize;
|
||||
|
||||
jit_tex->base = (uint8_t *)jit_tex->base +
|
||||
view->u.tex2d_from_buf.offset * view_blocksize;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* display target texture/surface */
|
||||
jit_tex->base = llvmpipe_resource_map(res, 0, 0, LP_TEX_USAGE_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;
|
||||
jit_tex->num_samples = res->nr_samples;
|
||||
jit_tex->sample_stride = 0;
|
||||
assert(jit_tex->base);
|
||||
}
|
||||
lp_jit_texture_from_pipe(jit_tex, view);
|
||||
} else {
|
||||
pipe_resource_reference(&csctx->cs.current_tex[i], NULL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue