mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 20:20:18 +01:00
panfrost: implement image_size sysval
Since there's no hardware support for it, we use a sysval to implement nir_intrinsic_image_size. Signed-off-by: Italo Nicola <italonicola@collabora.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8066>
This commit is contained in:
parent
dc85f65e05
commit
0efe7a6eb9
2 changed files with 41 additions and 0 deletions
|
|
@ -789,6 +789,41 @@ static void panfrost_upload_txs_sysval(struct panfrost_batch *batch,
|
|||
uniform->i[dim] = tex->texture->array_size;
|
||||
}
|
||||
|
||||
static void panfrost_upload_image_size_sysval(struct panfrost_batch *batch,
|
||||
enum pipe_shader_type st,
|
||||
unsigned int sysvalid,
|
||||
struct sysval_uniform *uniform)
|
||||
{
|
||||
struct panfrost_context *ctx = batch->ctx;
|
||||
unsigned idx = PAN_SYSVAL_ID_TO_TXS_TEX_IDX(sysvalid);
|
||||
unsigned dim = PAN_SYSVAL_ID_TO_TXS_DIM(sysvalid);
|
||||
unsigned is_array = PAN_SYSVAL_ID_TO_TXS_IS_ARRAY(sysvalid);
|
||||
|
||||
assert(dim && dim < 4);
|
||||
|
||||
struct pipe_image_view *image = &ctx->images[st][idx];
|
||||
|
||||
if (image->resource->target == PIPE_BUFFER) {
|
||||
unsigned blocksize = util_format_get_blocksize(image->format);
|
||||
uniform->i[0] = image->resource->width0 / blocksize;
|
||||
return;
|
||||
}
|
||||
|
||||
uniform->i[0] = u_minify(image->resource->width0,
|
||||
image->u.tex.level);
|
||||
|
||||
if (dim > 1)
|
||||
uniform->i[1] = u_minify(image->resource->height0,
|
||||
image->u.tex.level);
|
||||
|
||||
if (dim > 2)
|
||||
uniform->i[2] = u_minify(image->resource->depth0,
|
||||
image->u.tex.level);
|
||||
|
||||
if (is_array)
|
||||
uniform->i[dim] = image->resource->array_size;
|
||||
}
|
||||
|
||||
static void
|
||||
panfrost_upload_ssbo_sysval(struct panfrost_batch *batch,
|
||||
enum pipe_shader_type st,
|
||||
|
|
@ -911,6 +946,11 @@ panfrost_upload_sysvals(struct panfrost_batch *batch, void *buf,
|
|||
PAN_SYSVAL_ID(sysval),
|
||||
&uniforms[i]);
|
||||
break;
|
||||
case PAN_SYSVAL_IMAGE_SIZE:
|
||||
panfrost_upload_image_size_sysval(batch, st,
|
||||
PAN_SYSVAL_ID(sysval),
|
||||
&uniforms[i]);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ enum {
|
|||
PAN_SYSVAL_SAMPLER = 7,
|
||||
PAN_SYSVAL_LOCAL_GROUP_SIZE = 8,
|
||||
PAN_SYSVAL_WORK_DIM = 9,
|
||||
PAN_SYSVAL_IMAGE_SIZE = 10,
|
||||
};
|
||||
|
||||
#define PAN_TXS_SYSVAL_ID(texidx, dim, is_array) \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue