panfrost: implement gallium->set_shader_images

Implements gallium images endpoint.
If an AFBC resource is bound to an image, we convert it to tiled, since
images need pixel-level granularity and AFBC doesn't allow for that.

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:
Italo Nicola 2020-12-11 16:47:35 +00:00 committed by Marge Bot
parent f63a35baee
commit 0b9b0ee532
2 changed files with 44 additions and 10 deletions

View file

@ -637,6 +637,47 @@ panfrost_bind_rasterizer_state(
ctx->rasterizer = hwcso;
}
static void
panfrost_set_shader_images(
struct pipe_context *pctx,
enum pipe_shader_type shader,
unsigned start_slot, unsigned count,
const struct pipe_image_view *iviews)
{
struct panfrost_context *ctx = pan_context(pctx);
/* Unbind start_slot...start_slot+count */
if (!iviews) {
for (int i = start_slot; i < start_slot + count; i++) {
pipe_resource_reference(&ctx->images[shader][i].resource, NULL);
}
ctx->image_mask[shader] &= ~(((1ull << count) - 1) << start_slot);
return;
}
/* Bind start_slot...start_slot+count */
for (int i = 0; i < count; i++) {
const struct pipe_image_view *image = &iviews[i];
SET_BIT(ctx->image_mask[shader], 1 << (start_slot + i), image->resource);
if (!image->resource) {
util_copy_image_view(&ctx->images[shader][start_slot+i], NULL);
continue;
}
struct panfrost_resource *rsrc = pan_resource(image->resource);
/* Images don't work with AFBC, since they require pixel-level granularity */
if (drm_is_afbc(rsrc->layout.modifier)) {
pan_resource_modifier_convert(ctx, rsrc,
DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED);
}
util_copy_image_view(&ctx->images[shader][start_slot+i], image);
}
}
static void *
panfrost_create_vertex_elements_state(
struct pipe_context *pctx,
@ -1186,16 +1227,6 @@ panfrost_set_shader_buffers(
buffers, start, count);
}
static void
panfrost_set_shader_images(
struct pipe_context *pctx,
enum pipe_shader_type shader,
unsigned start, unsigned count,
const struct pipe_image_view *images)
{
/* TODO */
}
static void
panfrost_set_framebuffer_state(struct pipe_context *pctx,
const struct pipe_framebuffer_state *fb)

View file

@ -156,6 +156,9 @@ struct panfrost_context {
struct pipe_shader_buffer ssbo[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_BUFFERS];
uint32_t ssbo_mask[PIPE_SHADER_TYPES];
struct pipe_image_view images[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_IMAGES];
uint32_t image_mask[PIPE_SHADER_TYPES];
struct panfrost_sampler_state *samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
unsigned sampler_count[PIPE_SHADER_TYPES];