From: Alyssa Rosenzweig Date: Thu, 20 Aug 2020 20:41:41 +0000 (-0400) Subject: panfrost: XMLify bifrost1 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=acf77cbb3980a9918b2dd476efbcacadeebc6a88;p=mesa.git panfrost: XMLify bifrost1 It's so poorly understood there's not much to do in this commit, sadly. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Tomeu Vizoso Part-of: --- diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 6ab809091a0..c214dd6ba72 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -322,10 +322,17 @@ panfrost_emit_compute_shader(struct panfrost_context *ctx, meta->sampler_count = ctx->sampler_count[st]; if (dev->quirks & IS_BIFROST) { - meta->bifrost1.unk1 = 0x800000; + struct mali_bifrost_properties_packed prop; + + pan_pack(&prop, BIFROST_PROPERTIES, cfg) { + cfg.unknown = 0x800000; /* XXX */ + cfg.uniform_buffer_count = panfrost_ubo_count(ctx, st); + } + + memcpy(&meta->bifrost_props, &prop, sizeof(prop)); + meta->bifrost2.preload_regs = 0xC0; meta->bifrost2.uniform_count = ss->uniform_count; - meta->bifrost1.uniform_buffer_count = panfrost_ubo_count(ctx, st); } else { struct mali_midgard_properties_packed prop; @@ -564,11 +571,21 @@ panfrost_emit_frag_shader(struct panfrost_context *ctx, fragmeta->sampler_count = ctx->sampler_count[PIPE_SHADER_FRAGMENT]; if (dev->quirks & IS_BIFROST) { - /* First clause ATEST |= 0x4000000. - * Lefs than 32 regs |= 0x200 */ - fragmeta->bifrost1.unk1 = 0x950020; + struct mali_bifrost_properties_packed prop; + + bool no_blend = true; + + for (unsigned i = 0; i < rt_count; ++i) + no_blend &= (!blend[i].load_dest | blend[i].no_colour); + + pan_pack(&prop, BIFROST_PROPERTIES, cfg) { + cfg.unknown = 0x950020; /* XXX */ + cfg.uniform_buffer_count = panfrost_ubo_count(ctx, PIPE_SHADER_FRAGMENT); + cfg.early_z_enable = !fs->can_discard && !fs->writes_depth && no_blend; + } + + memcpy(&fragmeta->bifrost_props, &prop, sizeof(prop)); - fragmeta->bifrost1.uniform_buffer_count = panfrost_ubo_count(ctx, PIPE_SHADER_FRAGMENT); fragmeta->bifrost2.preload_regs = 0x1; SET_BIT(fragmeta->bifrost2.preload_regs, 0x10, fs->reads_frag_coord); @@ -730,16 +747,6 @@ panfrost_emit_frag_shader(struct panfrost_context *ctx, break; } } - - if (dev->quirks & IS_BIFROST) { - bool no_blend = true; - - for (unsigned i = 0; i < rt_count; ++i) - no_blend &= (!blend[i].load_dest | blend[i].no_colour); - - SET_BIT(fragmeta->bifrost1.unk1, MALI_BIFROST_EARLY_Z, - !fs->can_discard && !fs->writes_depth && no_blend); - } } void diff --git a/src/panfrost/bifrost/test/bi_submit.c b/src/panfrost/bifrost/test/bi_submit.c index 85837eb4963..3688e2be1a5 100644 --- a/src/panfrost/bifrost/test/bi_submit.c +++ b/src/panfrost/bifrost/test/bi_submit.c @@ -175,10 +175,7 @@ bit_vertex(struct panfrost_device *dev, panfrost_program prog, .shader = shader->gpu, .attribute_count = 1, .varying_count = 1, - .bifrost1 = { - .unk1 = 0x800200, - .uniform_buffer_count = 1, - }, + .bifrost_props = { .opaque = { 0x80020001 } }, .bifrost2 = { .unk3 = 0x0, .preload_regs = 0xc0, diff --git a/src/panfrost/include/panfrost-job.h b/src/panfrost/include/panfrost-job.h index ae1578589ea..af70f56be3a 100644 --- a/src/panfrost/include/panfrost-job.h +++ b/src/panfrost/include/panfrost-job.h @@ -193,27 +193,6 @@ struct mali_blend_mode { #define MALI_CHANNEL_FLOAT 7 #define MALI_EXTRACT_BITS(fmt) (fmt & 0x7) -/* Flags for bifrost1.unk1 */ - -/* Shader uses less than 32 registers, partitioned as [R0, R15] U [R48, R63], - * allowing for full thread count. If clear, the full [R0, R63] register set is - * available at half thread count */ -#define MALI_BIFROST_FULL_THREAD (1 << 9) - -/* Enable early-z testing (presumably). This flag may not be set if the shader: - * - * - Uses blending - * - Uses discard - * - Writes gl_FragDepth - * - * This differs from Midgard which sets the MALI_EARLY_Z flag even with - * blending, although I've begun to suspect that flag does not in fact enable - * EARLY_Z alone. */ -#define MALI_BIFROST_EARLY_Z (1 << 15) - -/* First clause type is ATEST */ -#define MALI_BIFROST_FIRST_ATEST (1 << 26) - /* The raw Midgard blend payload can either be an equation or a shader * address, depending on the context */ @@ -322,10 +301,7 @@ struct mali_shader_meta { u16 varying_count; union { - struct { - u32 uniform_buffer_count : 4; - u32 unk1 : 28; // = 0x800000 for vertex, 0x958020 for tiler - } bifrost1; + struct mali_bifrost_properties_packed bifrost_props; struct mali_midgard_properties_packed midgard_props; }; diff --git a/src/panfrost/lib/decode.c b/src/panfrost/lib/decode.c index 53f6f301b9c..6b2e71ae12b 100644 --- a/src/panfrost/lib/decode.c +++ b/src/panfrost/lib/decode.c @@ -279,16 +279,6 @@ static const struct pandecode_flag_info mfbd_extra_flag_lo_info[] = { }; #undef FLAG_INFO -#define FLAG_INFO(flag) { MALI_BIFROST_##flag, "MALI_BIFROST_" #flag } -static const struct pandecode_flag_info shader_bifrost_info [] = { - FLAG_INFO(FULL_THREAD), - FLAG_INFO(EARLY_Z), - FLAG_INFO(FIRST_ATEST), - {} -}; - -#undef FLAG_INFO - #define FLAG_INFO(flag) { MALI_MFBD_##flag, "MALI_MFBD_" #flag } static const struct pandecode_flag_info mfbd_flag_info [] = { FLAG_INFO(DEPTH_WRITE), @@ -1740,6 +1730,7 @@ pandecode_vertex_tiler_postfix_pre( info = pandecode_shader_disassemble(s->shader & ~0xF, job_no, job_type, is_bifrost, gpu_id); struct MALI_MIDGARD_PROPERTIES midg_props; + struct MALI_BIFROST_PROPERTIES bi_props; pandecode_log("struct mali_shader_meta shader_meta_%"PRIx64"_%d%s = {\n", p->shader, job_no, suffix); pandecode_indent++; @@ -1751,8 +1742,11 @@ pandecode_vertex_tiler_postfix_pre( sampler_count = s->sampler_count; if (is_bifrost) { + uint32_t opaque = s->bifrost_props.opaque[0]; + MALI_BIFROST_PROPERTIES_unpack((const uint8_t *) &opaque, &bi_props); + uniform_count = s->bifrost2.uniform_count; - uniform_buffer_count = s->bifrost1.uniform_buffer_count; + uniform_buffer_count = bi_props.uniform_buffer_count; } else { uint32_t opaque = s->midgard_props.opaque[0]; MALI_MIDGARD_PROPERTIES_unpack((const uint8_t *) &opaque, &midg_props); @@ -1768,13 +1762,10 @@ pandecode_vertex_tiler_postfix_pre( pandecode_shader_prop("attribute_count", s->attribute_count, info.attribute_count, false); pandecode_shader_prop("varying_count", s->varying_count, info.varying_count, false); - if (is_bifrost) { - pandecode_log("bifrost1.unk1 = "); - pandecode_log_decoded_flags(shader_bifrost_info, s->bifrost1.unk1); - pandecode_log_cont(",\n"); - } else { + if (is_bifrost) + MALI_BIFROST_PROPERTIES_print(pandecode_dump_stream, &bi_props, 2); + else MALI_MIDGARD_PROPERTIES_print(pandecode_dump_stream, &midg_props, 2); - } if (s->depth_units || s->depth_factor) { pandecode_prop("depth_factor = %f", s->depth_factor); diff --git a/src/panfrost/lib/midgard.xml b/src/panfrost/lib/midgard.xml index 42e26232b29..352398b515f 100644 --- a/src/panfrost/lib/midgard.xml +++ b/src/panfrost/lib/midgard.xml @@ -353,6 +353,16 @@ + + + + + + + + + +