From b10c3c869d9f1693198517c40b95acf3a11f80d4 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 11 Aug 2020 18:25:03 -0400 Subject: [PATCH] panfrost: XMLify Bifrost samplers Signed-off-by: Alyssa Rosenzweig Reviewed-by: Tomeu Vizoso Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 41 +++++++-------- src/gallium/drivers/panfrost/pan_cmdstream.h | 2 +- src/gallium/drivers/panfrost/pan_context.c | 2 +- src/panfrost/include/panfrost-job.h | 29 ----------- src/panfrost/lib/decode.c | 54 ++------------------ src/panfrost/lib/midgard.xml | 16 ++++++ 6 files changed, 41 insertions(+), 103 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 3d0a57aff24..97a5cff9626 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -427,30 +427,25 @@ void panfrost_sampler_desc_init(const struct pipe_sampler_state *cso, } void panfrost_sampler_desc_init_bifrost(const struct pipe_sampler_state *cso, - uint32_t *_hw) + struct mali_bifrost_sampler_packed *hw) { - struct bifrost_sampler_descriptor *hw = (struct bifrost_sampler_descriptor *) _hw; - *hw = (struct bifrost_sampler_descriptor) { - .unk1 = 0x1, - .wrap_s = translate_tex_wrap(cso->wrap_s), - .wrap_t = translate_tex_wrap(cso->wrap_t), - .wrap_r = translate_tex_wrap(cso->wrap_r), - .unk8 = 0x8, - .min_filter = cso->min_img_filter == PIPE_TEX_FILTER_NEAREST, - .norm_coords = cso->normalized_coords, - .mip_filter = cso->min_mip_filter == PIPE_TEX_MIPFILTER_LINEAR, - .mag_filter = cso->mag_img_filter == PIPE_TEX_FILTER_LINEAR, - .min_lod = FIXED_16(cso->min_lod, false), /* clamp at 0 */ - .max_lod = FIXED_16(cso->max_lod, false), - }; + pan_pack(hw, BIFROST_SAMPLER, cfg) { + cfg.magnify_linear = cso->mag_img_filter == PIPE_TEX_FILTER_LINEAR; + cfg.minify_linear = cso->min_img_filter == PIPE_TEX_FILTER_LINEAR; + cfg.mipmap_mode = pan_pipe_to_mipmode(cso->min_mip_filter); + cfg.normalized_coordinates = cso->normalized_coords; - /* If necessary, we disable mipmapping in the sampler descriptor by - * clamping the LOD as tight as possible (from 0 to epsilon, - * essentially -- remember these are fixed point numbers, so - * epsilon=1/256) */ + cfg.lod_bias = FIXED_16(cso->lod_bias, true); + cfg.minimum_lod = FIXED_16(cso->min_lod, false); + cfg.maximum_lod = FIXED_16(cso->max_lod, false); - if (cso->min_mip_filter == PIPE_TEX_MIPFILTER_NONE) - hw->max_lod = hw->min_lod + 1; + cfg.wrap_mode_s = translate_tex_wrap(cso->wrap_s); + cfg.wrap_mode_t = translate_tex_wrap(cso->wrap_t); + cfg.wrap_mode_r = translate_tex_wrap(cso->wrap_r); + + cfg.compare_function = panfrost_sampler_compare_func(cso); + cfg.seamless_cube_map = cso->seamless_cube_map; + } } static void @@ -1332,8 +1327,8 @@ panfrost_emit_sampler_descriptors(struct panfrost_batch *batch, if (!ctx->sampler_count[stage]) return; - size_t desc_size = sizeof(struct bifrost_sampler_descriptor); - assert(sizeof(struct bifrost_sampler_descriptor) == MALI_MIDGARD_SAMPLER_LENGTH); + size_t desc_size = MALI_BIFROST_SAMPLER_LENGTH; + assert(MALI_BIFROST_SAMPLER_LENGTH == MALI_MIDGARD_SAMPLER_LENGTH); size_t sz = desc_size * ctx->sampler_count[stage]; struct panfrost_transfer T = panfrost_pool_alloc(&batch->pool, sz); diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.h b/src/gallium/drivers/panfrost/pan_cmdstream.h index 089f192cb84..e0425ba449c 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.h +++ b/src/gallium/drivers/panfrost/pan_cmdstream.h @@ -33,7 +33,7 @@ #include "pan_job.h" void panfrost_sampler_desc_init(const struct pipe_sampler_state *cso, struct mali_midgard_sampler_packed *hw); -void panfrost_sampler_desc_init_bifrost(const struct pipe_sampler_state *cso, uint32_t *hw); +void panfrost_sampler_desc_init_bifrost(const struct pipe_sampler_state *cso, struct mali_bifrost_sampler_packed *hw); void panfrost_vt_init(struct panfrost_context *ctx, diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 6b916609486..6fd3f15d1f6 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -605,7 +605,7 @@ panfrost_create_sampler_state( so->base = *cso; if (device->quirks & IS_BIFROST) - panfrost_sampler_desc_init_bifrost(cso, (uint32_t *) &so->hw); + panfrost_sampler_desc_init_bifrost(cso, (struct mali_bifrost_sampler_packed *) &so->hw); else panfrost_sampler_desc_init(cso, &so->hw); diff --git a/src/panfrost/include/panfrost-job.h b/src/panfrost/include/panfrost-job.h index 534e5462545..62067a557f1 100644 --- a/src/panfrost/include/panfrost-job.h +++ b/src/panfrost/include/panfrost-job.h @@ -1271,35 +1271,6 @@ FIXED_16(float x, bool allow_negative) return (int) (x * 256.0); } -/* Bifrost sampler descriptors look pretty similar */ - -#define BIFROST_SAMP_MIN_NEAREST (1) -#define BIFROST_SAMP_MAG_LINEAR (1) - -struct bifrost_sampler_descriptor { - uint8_t unk1; - - enum mali_wrap_mode wrap_r : 4; - enum mali_wrap_mode wrap_t : 4; - enum mali_wrap_mode wrap_s : 4; - uint8_t unk8 : 4; - - uint8_t unk2 : 1; - uint8_t norm_coords : 1; - uint8_t unk3 : 1; - uint8_t min_filter : 1; - uint8_t zero1 : 1; - uint8_t mag_filter : 1; - uint8_t mip_filter : 1; - - int16_t min_lod; - int16_t max_lod; - - uint64_t zero2; - uint64_t zero3; - uint64_t zero4; -} __attribute__((packed)); - /* From presentations, 16x16 tiles externally. Use shift for fast computation * of tile numbers. */ diff --git a/src/panfrost/lib/decode.c b/src/panfrost/lib/decode.c index b39aba08145..4126ec54650 100644 --- a/src/panfrost/lib/decode.c +++ b/src/panfrost/lib/decode.c @@ -2422,56 +2422,12 @@ pandecode_textures(mali_ptr textures, unsigned texture_count, int job_no, bool i static void pandecode_samplers(mali_ptr samplers, unsigned sampler_count, int job_no, bool is_bifrost) { - struct pandecode_mapped_memory *smem = pandecode_find_mapped_gpu_mem_containing(samplers); - - if (!smem) - return; - - if (is_bifrost) { - struct bifrost_sampler_descriptor *s; - - for (int i = 0; i < sampler_count; ++i) { - s = pandecode_fetch_gpu_mem(smem, samplers + sizeof(*s) * i, sizeof(*s)); - - pandecode_log("struct bifrost_sampler_descriptor sampler_descriptor_%"PRIx64"_%d_%d = {\n", samplers + sizeof(*s) * i, job_no, i); - pandecode_indent++; - - if (s->unk1 != 1) { - pandecode_msg("XXX: unk1 tripped\n"); - pandecode_prop("unk1 = 0x%x", s->unk1); - } - - pandecode_prop("wrap_s = %s", mali_wrap_mode_as_str(s->wrap_s)); - pandecode_prop("wrap_t = %s", mali_wrap_mode_as_str(s->wrap_t)); - pandecode_prop("wrap_r = %s", mali_wrap_mode_as_str(s->wrap_r)); - - if (s->unk8 != 0x8) { - pandecode_msg("XXX: unk8 tripped\n"); - pandecode_prop("unk8 = 0x%x", s->unk8); - } - - pandecode_prop("unk2 = 0x%x", s->unk2); - pandecode_prop("unk3 = 0x%x", s->unk3); - pandecode_prop("min_filter = %s", s->min_filter ? "nearest" : "linear"); - pandecode_prop("norm_coords = 0x%x", s->norm_coords & 0x1); - pandecode_prop("zero1 = 0x%x", s->zero1 & 0x1); - pandecode_prop("mip_filter = %s", s->mip_filter ? "linear" : "nearest"); - pandecode_prop("mag_filter = %s", s->mag_filter ? "linear" : "nearest"); - - pandecode_prop("min_lod = FIXED_16(%f)", DECODE_FIXED_16(s->min_lod)); - pandecode_prop("max_lod = FIXED_16(%f)", DECODE_FIXED_16(s->max_lod)); - - if (s->zero1 || s->zero2 || s->zero3 || s->zero4) { - pandecode_msg("XXX: sampler zero tripped\n"); - pandecode_prop("zero = 0x%" PRIx8 ", 0x%" PRIx64 ", 0x%" PRIx64 ", 0x%" PRIx64 "\n", s->zero1, s->zero2, s->zero3, s->zero4); - } - - pandecode_indent--; - pandecode_log("};\n"); - } - } else { - for (int i = 0; i < sampler_count; ++i) + for (int i = 0; i < sampler_count; ++i) { + if (is_bifrost) { + DUMP_ADDR("Sampler", BIFROST_SAMPLER, samplers + (MALI_BIFROST_SAMPLER_LENGTH * i), 1); + } else { DUMP_ADDR("Sampler", MIDGARD_SAMPLER, samplers + (MALI_MIDGARD_SAMPLER_LENGTH * i), 1); + } } } diff --git a/src/panfrost/lib/midgard.xml b/src/panfrost/lib/midgard.xml index 09191accec5..7e4cf01c781 100644 --- a/src/panfrost/lib/midgard.xml +++ b/src/panfrost/lib/midgard.xml @@ -85,6 +85,22 @@ + + + + + + + + + + + + + + + + -- 2.30.2