From: Italo Nicola Date: Fri, 11 Dec 2020 16:47:35 +0000 (+0000) Subject: panfrost: implement gallium->set_shader_images X-Git-Tag: upstream/21.2.3~8904 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0b9b0ee5321d9b483ed3c734b97135d04d039f18;p=platform%2Fupstream%2Fmesa.git 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 Reviewed-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 95ee7e5..3382c35 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -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, @@ -1187,16 +1228,6 @@ panfrost_set_shader_buffers( } 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) { diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index 39ee218..8a0ea8f 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -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];