diff options
author | Tomeu Vizoso <[email protected]> | 2020-04-17 14:23:49 +0200 |
---|---|---|
committer | Tomeu Vizoso <[email protected]> | 2020-04-24 06:53:42 +0200 |
commit | e41894ba15b4150a8dfd884503ba04c2c33aab6f (patch) | |
tree | 8badfcae88b4aef0637c3ecfff7b67619a194897 | |
parent | d3eb23adb50c621f49000191e6c024df01f090b7 (diff) |
panfrost: Emit texture descriptor on bifrost
Signed-off-by: Tomeu Vizoso <[email protected]>
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4680>
-rw-r--r-- | src/gallium/drivers/panfrost/pan_cmdstream.c | 45 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.c | 64 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.h | 3 | ||||
-rw-r--r-- | src/panfrost/encoder/pan_texture.c | 41 | ||||
-rw-r--r-- | src/panfrost/encoder/pan_texture.h | 15 |
5 files changed, 134 insertions, 34 deletions
diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index aae4880086a..dfc5174bef5 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -1243,11 +1243,11 @@ panfrost_get_tex_desc(struct panfrost_batch *batch, PAN_BO_ACCESS_SHARED | PAN_BO_ACCESS_READ | panfrost_bo_access_for_stage(st)); - panfrost_batch_add_bo(batch, view->bo, + panfrost_batch_add_bo(batch, view->midgard_bo, PAN_BO_ACCESS_SHARED | PAN_BO_ACCESS_READ | panfrost_bo_access_for_stage(st)); - return view->bo->gpu; + return view->midgard_bo->gpu; } void @@ -1256,20 +1256,45 @@ panfrost_emit_texture_descriptors(struct panfrost_batch *batch, struct mali_vertex_tiler_postfix *postfix) { struct panfrost_context *ctx = batch->ctx; + struct panfrost_device *device = pan_device(ctx->base.screen); if (!ctx->sampler_view_count[stage]) return; - uint64_t trampolines[PIPE_MAX_SHADER_SAMPLER_VIEWS]; + if (device->quirks & IS_BIFROST) { + struct bifrost_texture_descriptor *descriptors; + + descriptors = malloc(sizeof(struct bifrost_texture_descriptor) * + ctx->sampler_view_count[stage]); + + for (int i = 0; i < ctx->sampler_view_count[stage]; ++i) { + struct panfrost_sampler_view *view = ctx->sampler_views[stage][i]; + struct pipe_sampler_view *pview = &view->base; + struct panfrost_resource *rsrc = pan_resource(pview->texture); + + panfrost_batch_add_bo(batch, rsrc->bo, + PAN_BO_ACCESS_SHARED | PAN_BO_ACCESS_READ | + panfrost_bo_access_for_stage(stage)); - for (int i = 0; i < ctx->sampler_view_count[stage]; ++i) - trampolines[i] = panfrost_get_tex_desc(batch, stage, - ctx->sampler_views[stage][i]); + memcpy(&descriptors[i], view->bifrost_descriptor, sizeof(*view->bifrost_descriptor)); + } + + postfix->textures = panfrost_upload_transient(batch, + descriptors, + sizeof(struct bifrost_texture_descriptor) * + ctx->sampler_view_count[stage]); + } else { + uint64_t trampolines[PIPE_MAX_SHADER_SAMPLER_VIEWS]; - postfix->texture_trampoline = panfrost_upload_transient(batch, - trampolines, - sizeof(uint64_t) * - ctx->sampler_view_count[stage]); + for (int i = 0; i < ctx->sampler_view_count[stage]; ++i) + trampolines[i] = panfrost_get_tex_desc(batch, stage, + ctx->sampler_views[stage][i]); + + postfix->textures = panfrost_upload_transient(batch, + trampolines, + sizeof(uint64_t) * + ctx->sampler_view_count[stage]); + } } void diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index a9186591578..d8bcdd28fa5 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -929,29 +929,47 @@ panfrost_create_sampler_view( enum mali_texture_type type = panfrost_translate_texture_type(template->target); - unsigned size = panfrost_estimate_texture_size( - template->u.tex.first_level, - template->u.tex.last_level, - template->u.tex.first_layer, - template->u.tex.last_layer, - type, prsrc->layout); - - so->bo = pan_bo_create(device, size, 0); - - panfrost_new_texture( - so->bo->cpu, - texture->width0, texture->height0, - texture->depth0, array_size, - template->format, - type, prsrc->layout, - template->u.tex.first_level, - template->u.tex.last_level, - template->u.tex.first_layer, - template->u.tex.last_layer, - prsrc->cubemap_stride, - panfrost_translate_swizzle_4(user_swizzle), - prsrc->bo->gpu, - prsrc->slices); + if (device->quirks & IS_BIFROST) { + so->bifrost_descriptor = rzalloc(pctx, struct bifrost_texture_descriptor); + panfrost_new_texture_bifrost( + so->bifrost_descriptor, + texture->width0, texture->height0, + texture->depth0, array_size, + template->format, + type, prsrc->layout, + template->u.tex.first_level, + template->u.tex.last_level, + template->u.tex.first_layer, + template->u.tex.last_layer, + prsrc->cubemap_stride, + panfrost_translate_swizzle_4(user_swizzle), + prsrc->bo->gpu, + prsrc->slices); + } else { + unsigned size = panfrost_estimate_texture_size( + template->u.tex.first_level, + template->u.tex.last_level, + template->u.tex.first_layer, + template->u.tex.last_layer, + type, prsrc->layout); + + so->midgard_bo = pan_bo_create(device, size, 0); + + panfrost_new_texture( + so->midgard_bo->cpu, + texture->width0, texture->height0, + texture->depth0, array_size, + template->format, + type, prsrc->layout, + template->u.tex.first_level, + template->u.tex.last_level, + template->u.tex.first_layer, + template->u.tex.last_layer, + prsrc->cubemap_stride, + panfrost_translate_swizzle_4(user_swizzle), + prsrc->bo->gpu, + prsrc->slices); + } return (struct pipe_sampler_view *) so; } diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index bc952b4ec30..7a4315036f9 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -256,7 +256,8 @@ struct panfrost_sampler_state { struct panfrost_sampler_view { struct pipe_sampler_view base; - struct panfrost_bo *bo; + struct panfrost_bo *midgard_bo; + struct bifrost_texture_descriptor *bifrost_descriptor; }; static inline struct panfrost_context * diff --git a/src/panfrost/encoder/pan_texture.c b/src/panfrost/encoder/pan_texture.c index 0c92464af08..b0b630c7b93 100644 --- a/src/panfrost/encoder/pan_texture.c +++ b/src/panfrost/encoder/pan_texture.c @@ -242,6 +242,47 @@ panfrost_new_texture( } } +void +panfrost_new_texture_bifrost( + struct bifrost_texture_descriptor *descriptor, + uint16_t width, uint16_t height, + uint16_t depth, uint16_t array_size, + enum pipe_format format, + enum mali_texture_type type, + enum mali_texture_layout layout, + unsigned first_level, unsigned last_level, + unsigned first_layer, unsigned last_layer, + unsigned cube_stride, + unsigned swizzle, + mali_ptr base, + struct panfrost_slice *slices) +{ + const struct util_format_description *desc = + util_format_description(format); + + enum mali_format mali_format = panfrost_find_format(desc); + + descriptor->format_unk = 0x2; + descriptor->type = type; + descriptor->format_unk2 = 0x100; + descriptor->format = mali_format; + descriptor->srgb = (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB); + descriptor->format_unk3 = 0x0; + descriptor->width = MALI_POSITIVE(u_minify(width, first_level)); + descriptor->height = MALI_POSITIVE(u_minify(height, first_level)); + descriptor->swizzle = swizzle; + descriptor->unk0 = 0x1; + descriptor->levels = last_level - first_level; + descriptor->unk1 = 0x0; + descriptor->levels_unk = 0; + descriptor->level_2 = 0; + descriptor->payload = base; + descriptor->array_size = MALI_POSITIVE(array_size); + descriptor->unk4 = 0x0; + descriptor->depth = MALI_POSITIVE(u_minify(depth, first_level)); + descriptor->unk5 = 0x0; +} + /* Computes sizes for checksumming, which is 8 bytes per 16x16 tile. * Checksumming is believed to be a CRC variant (CRC64 based on the size?). * This feature is also known as "transaction elimination". */ diff --git a/src/panfrost/encoder/pan_texture.h b/src/panfrost/encoder/pan_texture.h index 241e1f8b4e6..77c0eaaf049 100644 --- a/src/panfrost/encoder/pan_texture.h +++ b/src/panfrost/encoder/pan_texture.h @@ -87,6 +87,21 @@ panfrost_new_texture( mali_ptr base, struct panfrost_slice *slices); +void +panfrost_new_texture_bifrost( + struct bifrost_texture_descriptor *descriptor, + uint16_t width, uint16_t height, + uint16_t depth, uint16_t array_size, + enum pipe_format format, + enum mali_texture_type type, + enum mali_texture_layout layout, + unsigned first_level, unsigned last_level, + unsigned first_layer, unsigned last_layer, + unsigned cube_stride, + unsigned swizzle, + mali_ptr base, + struct panfrost_slice *slices); + unsigned panfrost_get_layer_stride(struct panfrost_slice *slices, bool is_3d, unsigned cube_stride, unsigned level); |