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 <mary.guillemard@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Benjamin Lee <benjamin.lee@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33736>
This commit is contained in:
Mary Guillemard
2025-02-11 14:49:42 +01:00
committed by Marge Bot
parent 3aa1687829
commit e9d1e2b61e
5 changed files with 93 additions and 93 deletions

View File

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

View File

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

View File

@@ -1903,30 +1903,8 @@
</struct>
<struct name="Draw" align="64">
<!-- DCD flags 0 -->
<field name="Allow forward pixel to kill" size="1" start="0:0" type="bool"/>
<field name="Allow forward pixel to be killed" size="1" start="0:1" type="bool"/>
<field name="Pixel kill operation" size="2" start="0:2" type="Pixel Kill"/>
<field name="ZS update operation" size="2" start="0:4" type="Pixel Kill"/>
<field name="Allow primitive reorder" size="1" start="0:6" type="bool"/>
<field name="Overdraw alpha0" start="0:7" size="1" type="bool"/>
<field name="Overdraw alpha1" size="1" start="0:8" type="bool"/>
<field name="Clean Fragment Write" size="1" start="0:9" type="bool"/>
<field name="Primitive Barrier" size="1" start="0:10" type="bool"/>
<field name="Evaluate per-sample" size="1" start="0:11" type="bool"/>
<field name="Single-sampled lines" size="1" start="0:13" type="bool"/>
<field name="Occlusion query" size="2" start="0:14" type="Occlusion Mode" default="Disabled"/>
<field name="Front face CCW" size="1" start="0:16" type="bool"/>
<field name="Cull front face" size="1" start="0:17" type="bool"/>
<field name="Cull back face" size="1" start="0:18" type="bool"/>
<field name="Multisample enable" size="1" start="0:19" type="bool"/>
<field name="Shader modifies coverage" size="1" start="0:20" type="bool"/>
<field name="Alpha-to-coverage Invert" size="1" start="0:21" type="bool"/>
<field name="Alpha-to-coverage" size="1" start="0:22" type="bool"/>
<field name="Scissor to bounding box" size="1" start="0:23" type="bool"/>
<!-- DCD flags 1 -->
<field name="Sample mask" size="16" start="1:0" type="uint"/>
<field name="Render target mask" start="1:16" size="8" type="hex"/>
<field name="Flags 0" size="32" start="0:0" type="DCD Flags 0"/>
<field name="Flags 1" size="32" start="1:0" type="DCD Flags 1"/>
<field name="Vertex array" start="2:0" size="96" type="Vertex Array"/>
<field name="Flags 2" start="5:0" size="32" type="DCD Flags 2"/>
<field name="Minimum Z" start="6:0" size="32" type="float"/>

View File

@@ -1397,29 +1397,37 @@
<field name="Vertex attribute stride" size="16" start="2:16" type="uint"/>
</struct>
<struct name="DCD Flags 0" size="1">
<field name="Allow forward pixel to kill" size="1" start="0" type="bool"/>
<field name="Allow forward pixel to be killed" size="1" start="1" type="bool"/>
<field name="Pixel kill operation" size="2" start="2" type="Pixel Kill"/>
<field name="ZS update operation" size="2" start="4" type="Pixel Kill"/>
<field name="Allow primitive reorder" size="1" start="6" type="bool"/>
<field name="Overdraw alpha0" start="7" size="1" type="bool"/>
<field name="Overdraw alpha1" size="1" start="8" type="bool"/>
<field name="Clean Fragment Write" size="1" start="9" type="bool"/>
<field name="Primitive Barrier" size="1" start="10" type="bool"/>
<field name="Evaluate per-sample" size="1" start="11" type="bool"/>
<field name="Single-sampled lines" size="1" start="13" type="bool"/>
<field name="Occlusion query" size="2" start="14" type="Occlusion Mode" default="Disabled"/>
<field name="Front face CCW" size="1" start="16" type="bool"/>
<field name="Cull front face" size="1" start="17" type="bool"/>
<field name="Cull back face" size="1" start="18" type="bool"/>
<field name="Multisample enable" size="1" start="19" type="bool"/>
<field name="Shader modifies coverage" size="1" start="20" type="bool"/>
<field name="Alpha-to-coverage Invert" size="1" start="21" type="bool"/>
<field name="Alpha-to-coverage" size="1" start="22" type="bool"/>
<field name="Scissor to bounding box" size="1" start="23" type="bool"/>
</struct>
<struct name="DCD Flags 1" size="1">
<field name="Sample mask" size="16" start="0" type="uint"/>
<field name="Render target mask" start="16" size="8" type="hex"/>
</struct>
<struct name="Draw" align="64">
<field name="Allow forward pixel to kill" size="1" start="0:0" type="bool"/>
<field name="Allow forward pixel to be killed" size="1" start="0:1" type="bool"/>
<field name="Pixel kill operation" size="2" start="0:2" type="Pixel Kill"/>
<field name="ZS update operation" size="2" start="0:4" type="Pixel Kill"/>
<field name="Allow primitive reorder" size="1" start="0:6" type="bool"/>
<field name="Overdraw alpha0" start="0:7" size="1" type="bool"/>
<field name="Overdraw alpha1" size="1" start="0:8" type="bool"/>
<field name="Clean Fragment Write" size="1" start="0:9" type="bool"/>
<field name="Primitive Barrier" size="1" start="0:10" type="bool"/>
<field name="Evaluate per-sample" size="1" start="0:11" type="bool"/>
<field name="Single-sampled lines" size="1" start="0:13" type="bool"/>
<field name="Occlusion query" size="2" start="0:14" type="Occlusion Mode" default="Disabled"/>
<field name="Front face CCW" size="1" start="0:16" type="bool"/>
<field name="Cull front face" size="1" start="0:17" type="bool"/>
<field name="Cull back face" size="1" start="0:18" type="bool"/>
<field name="Multisample enable" size="1" start="0:19" type="bool"/>
<field name="Shader modifies coverage" size="1" start="0:20" type="bool"/>
<field name="Alpha-to-coverage Invert" size="1" start="0:21" type="bool"/>
<field name="Alpha-to-coverage" size="1" start="0:22" type="bool"/>
<field name="Scissor to bounding box" size="1" start="0:23" type="bool"/>
<field name="Sample mask" size="16" start="1:0" type="uint"/>
<field name="Render target mask" start="1:16" size="8" type="hex"/>
<field name="Flags 0" size="32" start="0:0" type="DCD Flags 0"/>
<field name="Flags 1" size="32" start="1:0" type="DCD Flags 1"/>
<field name="Vertex array" start="2:0" size="96" type="Vertex Array"/>
<field name="Minimum Z" start="6:0" size="32" type="float"/>
<field name="Maximum Z" start="7:0" size="32" type="float"/>

View File

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