From e9d1e2b61e2e1643ec5a39e907cb65726b4afe69 Mon Sep 17 00:00:00 2001 From: Mary Guillemard Date: Tue, 11 Feb 2025 14:49:42 +0100 Subject: [PATCH] pan/genxml: Use DCD Flags in Draw struct on v9+ The first bits of the Draw struct were moved to DCD flags since v10. To keep things in sync, we now use DCD flags instead on v10 and define it on v9 to avoid uneeded PAN_ARCH if/else in preload logics. Signed-off-by: Mary Guillemard Reviewed-by: Boris Brezillon Reviewed-by: Benjamin Lee Part-of: --- src/gallium/drivers/panfrost/pan_fb_preload.c | 22 +++---- src/gallium/drivers/panfrost/pan_jm.c | 61 +++++++++++-------- src/panfrost/lib/genxml/v10.xml | 26 +------- src/panfrost/lib/genxml/v9.xml | 52 +++++++++------- src/panfrost/vulkan/panvk_vX_cmd_fb_preload.c | 25 ++++---- 5 files changed, 93 insertions(+), 93 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_fb_preload.c b/src/gallium/drivers/panfrost/pan_fb_preload.c index 5cba9a821f1..391194a0f79 100644 --- a/src/gallium/drivers/panfrost/pan_fb_preload.c +++ b/src/gallium/drivers/panfrost/pan_fb_preload.c @@ -1185,27 +1185,27 @@ pan_preload_emit_dcd(struct pan_fb_preload_cache *cache, struct pan_pool *pool, pan_pack(out, DRAW, cfg) { if (zs) { /* ZS_EMIT requires late update/kill */ - cfg.zs_update_operation = MALI_PIXEL_KILL_FORCE_LATE; - cfg.pixel_kill_operation = MALI_PIXEL_KILL_FORCE_LATE; + cfg.flags_0.zs_update_operation = MALI_PIXEL_KILL_FORCE_LATE; + cfg.flags_0.pixel_kill_operation = MALI_PIXEL_KILL_FORCE_LATE; cfg.blend_count = 0; } else { /* Skipping ATEST requires forcing Z/S */ - cfg.zs_update_operation = MALI_PIXEL_KILL_FORCE_EARLY; - cfg.pixel_kill_operation = MALI_PIXEL_KILL_FORCE_EARLY; + cfg.flags_0.zs_update_operation = MALI_PIXEL_KILL_FORCE_EARLY; + cfg.flags_0.pixel_kill_operation = MALI_PIXEL_KILL_FORCE_EARLY; cfg.blend = blend.gpu; cfg.blend_count = bd_count; - cfg.render_target_mask = 0x1; + cfg.flags_1.render_target_mask = 0x1; } - cfg.allow_forward_pixel_to_kill = !zs; - cfg.allow_forward_pixel_to_be_killed = true; + cfg.flags_0.allow_forward_pixel_to_kill = !zs; + cfg.flags_0.allow_forward_pixel_to_be_killed = true; cfg.depth_stencil = pan_preload_emit_zs(pool, z, s); - cfg.sample_mask = 0xFFFF; - cfg.multisample_enable = ms; - cfg.evaluate_per_sample = ms; + cfg.flags_1.sample_mask = 0xFFFF; + cfg.flags_0.multisample_enable = ms; + cfg.flags_0.evaluate_per_sample = ms; cfg.maximum_z = 1.0; - cfg.clean_fragment_write = clean_fragment_write; + cfg.flags_0.clean_fragment_write = clean_fragment_write; cfg.shader.resources = T.gpu | nr_tables; cfg.shader.shader = spd.gpu; cfg.shader.thread_storage = tsd; diff --git a/src/gallium/drivers/panfrost/pan_jm.c b/src/gallium/drivers/panfrost/pan_jm.c index db6aa20f6e5..9d329f3bef2 100644 --- a/src/gallium/drivers/panfrost/pan_jm.c +++ b/src/gallium/drivers/panfrost/pan_jm.c @@ -519,15 +519,28 @@ jm_emit_tiler_draw(struct mali_draw_packed *out, struct panfrost_batch *batch, * The hardware does not take primitive type into account when * culling, so we need to do that check ourselves. */ +#if PAN_ARCH == 9 + cfg.flags_0.cull_front_face = polygon && (rast->cull_face & PIPE_FACE_FRONT); + cfg.flags_0.cull_back_face = polygon && (rast->cull_face & PIPE_FACE_BACK); + cfg.flags_0.front_face_ccw = rast->front_ccw; +#else cfg.cull_front_face = polygon && (rast->cull_face & PIPE_FACE_FRONT); cfg.cull_back_face = polygon && (rast->cull_face & PIPE_FACE_BACK); cfg.front_face_ccw = rast->front_ccw; +#endif if (ctx->occlusion_query && ctx->active_queries) { +#if PAN_ARCH == 9 + if (ctx->occlusion_query->type == PIPE_QUERY_OCCLUSION_COUNTER) + cfg.flags_0.occlusion_query = MALI_OCCLUSION_MODE_COUNTER; + else + cfg.flags_0.occlusion_query = MALI_OCCLUSION_MODE_PREDICATE; +#else if (ctx->occlusion_query->type == PIPE_QUERY_OCCLUSION_COUNTER) cfg.occlusion_query = MALI_OCCLUSION_MODE_COUNTER; else cfg.occlusion_query = MALI_OCCLUSION_MODE_PREDICATE; +#endif struct panfrost_resource *rsrc = pan_resource(ctx->occlusion_query->rsrc); @@ -538,19 +551,19 @@ jm_emit_tiler_draw(struct mali_draw_packed *out, struct panfrost_batch *batch, #if PAN_ARCH >= 9 struct panfrost_compiled_shader *fs = ctx->prog[PIPE_SHADER_FRAGMENT]; - cfg.multisample_enable = rast->multisample; - cfg.sample_mask = rast->multisample ? ctx->sample_mask : 0xFFFF; + cfg.flags_0.multisample_enable = rast->multisample; + cfg.flags_1.sample_mask = rast->multisample ? ctx->sample_mask : 0xFFFF; /* Use per-sample shading if required by API Also use it when a * blend shader is used with multisampling, as this is handled * by a single ST_TILE in the blend shader with the current * sample ID, requiring per-sample shading. */ - cfg.evaluate_per_sample = + cfg.flags_0.evaluate_per_sample = (rast->multisample && ((ctx->min_samples > 1) || ctx->valhall_has_blend_shader)); - cfg.single_sampled_lines = !rast->multisample; + cfg.flags_0.single_sampled_lines = !rast->multisample; cfg.vertex_array.packet = true; @@ -560,8 +573,8 @@ jm_emit_tiler_draw(struct mali_draw_packed *out, struct panfrost_batch *batch, cfg.depth_stencil = batch->depth_stencil; if (prim == MESA_PRIM_LINES && rast->line_smooth) { - cfg.multisample_enable = true; - cfg.single_sampled_lines = false; + cfg.flags_0.multisample_enable = true; + cfg.flags_0.single_sampled_lines = false; } if (fs_required) { @@ -572,12 +585,12 @@ jm_emit_tiler_draw(struct mali_draw_packed *out, struct panfrost_batch *batch, ctx->blend->base.alpha_to_coverage, ctx->depth_stencil->zs_always_passes); - cfg.pixel_kill_operation = earlyzs.kill; - cfg.zs_update_operation = earlyzs.update; + cfg.flags_0.pixel_kill_operation = earlyzs.kill; + cfg.flags_0.zs_update_operation = earlyzs.update; - cfg.allow_forward_pixel_to_kill = + cfg.flags_0.allow_forward_pixel_to_kill = pan_allow_forward_pixel_to_kill(ctx, fs); - cfg.allow_forward_pixel_to_be_killed = !fs->info.writes_global; + cfg.flags_0.allow_forward_pixel_to_be_killed = !fs->info.writes_global; /* Mask of render targets that may be written. A render * target may be written if the fragment shader writes @@ -588,20 +601,20 @@ jm_emit_tiler_draw(struct mali_draw_packed *out, struct panfrost_batch *batch, * Only set when there is a fragment shader, since * otherwise no colour updates are possible. */ - cfg.render_target_mask = + cfg.flags_1.render_target_mask = (fs->info.outputs_written >> FRAG_RESULT_DATA0) & ctx->fb_rt_mask; /* Also use per-sample shading if required by the shader */ - cfg.evaluate_per_sample |= + cfg.flags_0.evaluate_per_sample |= (fs->info.fs.sample_shading && rast->multisample); /* Unlike Bifrost, alpha-to-coverage must be included in * this identically-named flag. Confusing, isn't it? */ - cfg.shader_modifies_coverage = fs->info.fs.writes_coverage || - fs->info.fs.can_discard || - ctx->blend->base.alpha_to_coverage; + cfg.flags_0.shader_modifies_coverage = + fs->info.fs.writes_coverage || fs->info.fs.can_discard || + ctx->blend->base.alpha_to_coverage; /* Blend descriptors are only accessed by a BLEND * instruction on Valhall. It follows that if the @@ -610,10 +623,10 @@ jm_emit_tiler_draw(struct mali_draw_packed *out, struct panfrost_batch *batch, */ cfg.blend = batch->blend; cfg.blend_count = MAX2(batch->key.nr_cbufs, 1); - cfg.alpha_to_coverage = ctx->blend->base.alpha_to_coverage; + cfg.flags_0.alpha_to_coverage = ctx->blend->base.alpha_to_coverage; - cfg.overdraw_alpha0 = panfrost_overdraw_alpha(ctx, 0); - cfg.overdraw_alpha1 = panfrost_overdraw_alpha(ctx, 1); + cfg.flags_0.overdraw_alpha0 = panfrost_overdraw_alpha(ctx, 0); + cfg.flags_0.overdraw_alpha1 = panfrost_overdraw_alpha(ctx, 1); jm_emit_shader_env(batch, &cfg.shader, PIPE_SHADER_FRAGMENT, batch->rsd[PIPE_SHADER_FRAGMENT]); @@ -621,22 +634,22 @@ jm_emit_tiler_draw(struct mali_draw_packed *out, struct panfrost_batch *batch, /* These operations need to be FORCE to benefit from the * depth-only pass optimizations. */ - cfg.pixel_kill_operation = MALI_PIXEL_KILL_FORCE_EARLY; - cfg.zs_update_operation = MALI_PIXEL_KILL_FORCE_EARLY; + cfg.flags_0.pixel_kill_operation = MALI_PIXEL_KILL_FORCE_EARLY; + cfg.flags_0.zs_update_operation = MALI_PIXEL_KILL_FORCE_EARLY; /* No shader and no blend => no shader or blend * reasons to disable FPK. The only FPK-related state * not covered is alpha-to-coverage which we don't set * without blend. */ - cfg.allow_forward_pixel_to_kill = true; + cfg.flags_0.allow_forward_pixel_to_kill = true; /* No shader => no shader side effects */ - cfg.allow_forward_pixel_to_be_killed = true; + cfg.flags_0.allow_forward_pixel_to_be_killed = true; /* Alpha isn't written so these are vacuous */ - cfg.overdraw_alpha0 = true; - cfg.overdraw_alpha1 = true; + cfg.flags_0.overdraw_alpha0 = true; + cfg.flags_0.overdraw_alpha1 = true; } #else cfg.position = batch->varyings.pos; diff --git a/src/panfrost/lib/genxml/v10.xml b/src/panfrost/lib/genxml/v10.xml index 52c144e78c8..c95ddf41b4b 100644 --- a/src/panfrost/lib/genxml/v10.xml +++ b/src/panfrost/lib/genxml/v10.xml @@ -1903,30 +1903,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/src/panfrost/lib/genxml/v9.xml b/src/panfrost/lib/genxml/v9.xml index c3ad25b14b9..421c4518740 100644 --- a/src/panfrost/lib/genxml/v9.xml +++ b/src/panfrost/lib/genxml/v9.xml @@ -1397,29 +1397,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/src/panfrost/vulkan/panvk_vX_cmd_fb_preload.c b/src/panfrost/vulkan/panvk_vX_cmd_fb_preload.c index 6302f1c240a..3150cfd7569 100644 --- a/src/panfrost/vulkan/panvk_vX_cmd_fb_preload.c +++ b/src/panfrost/vulkan/panvk_vX_cmd_fb_preload.c @@ -620,29 +620,30 @@ cmd_emit_dcd(struct panvk_cmd_buffer *cmdbuf, struct pan_fb_info *fbinfo, pan_pack(&dcds[dcd_idx], DRAW, cfg) { if (key->aspects == VK_IMAGE_ASPECT_COLOR_BIT) { /* Skipping ATEST requires forcing Z/S */ - cfg.zs_update_operation = MALI_PIXEL_KILL_FORCE_EARLY; - cfg.pixel_kill_operation = MALI_PIXEL_KILL_FORCE_EARLY; + cfg.flags_0.zs_update_operation = MALI_PIXEL_KILL_FORCE_EARLY; + cfg.flags_0.pixel_kill_operation = MALI_PIXEL_KILL_FORCE_EARLY; cfg.blend = bds.gpu; cfg.blend_count = bd_count; - cfg.render_target_mask = cmdbuf->state.gfx.render.bound_attachments & - MESA_VK_RP_ATTACHMENT_ANY_COLOR_BITS; + cfg.flags_1.render_target_mask = + cmdbuf->state.gfx.render.bound_attachments & + MESA_VK_RP_ATTACHMENT_ANY_COLOR_BITS; } else { /* ZS_EMIT requires late update/kill */ - cfg.zs_update_operation = MALI_PIXEL_KILL_FORCE_LATE; - cfg.pixel_kill_operation = MALI_PIXEL_KILL_FORCE_LATE; + cfg.flags_0.zs_update_operation = MALI_PIXEL_KILL_FORCE_LATE; + cfg.flags_0.pixel_kill_operation = MALI_PIXEL_KILL_FORCE_LATE; cfg.blend_count = 0; } - cfg.allow_forward_pixel_to_kill = + cfg.flags_0.allow_forward_pixel_to_kill = key->aspects == VK_IMAGE_ASPECT_COLOR_BIT; - cfg.allow_forward_pixel_to_be_killed = true; + cfg.flags_0.allow_forward_pixel_to_be_killed = true; cfg.depth_stencil = zsd.gpu; - cfg.sample_mask = 0xFFFF; - cfg.multisample_enable = key->samples > 1; - cfg.evaluate_per_sample = key->samples > 1; + cfg.flags_1.sample_mask = 0xFFFF; + cfg.flags_0.multisample_enable = key->samples > 1; + cfg.flags_0.evaluate_per_sample = key->samples > 1; cfg.maximum_z = 1.0; - cfg.clean_fragment_write = true; + cfg.flags_0.clean_fragment_write = true; cfg.shader.resources = res_table.gpu | 1; cfg.shader.shader = panvk_priv_mem_dev_addr(shader->spd); cfg.shader.thread_storage = cmdbuf->state.gfx.tsd;