panfrost: Emit texture descriptor on bifrost

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4680>
This commit is contained in:
Tomeu Vizoso 2020-04-17 14:23:49 +02:00
parent d3eb23adb5
commit e41894ba15
5 changed files with 132 additions and 32 deletions

View file

@ -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;
for (int i = 0; i < ctx->sampler_view_count[stage]; ++i)
trampolines[i] = panfrost_get_tex_desc(batch, stage,
ctx->sampler_views[stage][i]);
descriptors = malloc(sizeof(struct bifrost_texture_descriptor) *
ctx->sampler_view_count[stage]);
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) {
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));
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];
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

View file

@ -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);
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->bo = pan_bo_create(device, size, 0);
so->midgard_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);
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;
}

View file

@ -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 *

View file

@ -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". */

View file

@ -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);