panfrost: Adjust the renderer state definition
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7206>
diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c
index f2bc19d..f237ded 100644
--- a/src/gallium/drivers/panfrost/pan_assemble.c
+++ b/src/gallium/drivers/panfrost/pan_assemble.c
@@ -45,19 +45,23 @@
{
pan_prepare(&state->properties, RENDERER_PROPERTIES);
state->properties.uniform_buffer_count = state->ubo_count;
- state->properties.uniform_count = state->uniform_count;
- state->properties.writes_globals = state->writes_global;
- state->properties.suppress_inf_nan = true; /* XXX */
+ state->properties.midgard.uniform_count = state->uniform_count;
+ state->properties.midgard.shader_has_side_effects = state->writes_global;
+
+ /* TODO: Select the appropriate mode. Suppresing inf/nan works around
+ * some bugs in gles2 apps (eg glmark2's terrain scene) but isn't
+ * conformant on gles3 */
+ state->properties.midgard.fp_mode = MALI_FP_MODE_GL_INF_NAN_SUPPRESSED;
if (stage == MESA_SHADER_FRAGMENT) {
/* Work register count, early-z, reads at draw-time */
state->properties.stencil_from_shader = state->writes_stencil;
- state->properties.helper_invocation_enable = state->helper_invocations;
+ state->properties.shader_contains_barrier = state->helper_invocations;
state->properties.depth_source = state->writes_depth ?
MALI_DEPTH_SOURCE_SHADER :
MALI_DEPTH_SOURCE_FIXED_FUNCTION;
} else {
- state->properties.work_register_count = state->work_reg_count;
+ state->properties.midgard.work_register_count = state->work_reg_count;
}
}
@@ -69,7 +73,7 @@
switch (stage) {
case MESA_SHADER_VERTEX:
pan_prepare(&state->properties, RENDERER_PROPERTIES);
- state->properties.unknown = 0x800000; /* XXX */
+ state->properties.bifrost.zs_update_operation = MALI_PIXEL_KILL_STRONG_EARLY;
state->properties.uniform_buffer_count = state->ubo_count;
pan_prepare(&state->preload, PRELOAD);
@@ -80,10 +84,10 @@
case MESA_SHADER_FRAGMENT:
pan_prepare(&state->properties, RENDERER_PROPERTIES);
/* Early-Z set at draw-time */
- state->properties.unknown = 0x950020; /* XXX */
+ state->properties.bifrost.zs_update_operation = MALI_PIXEL_KILL_STRONG_EARLY;
state->properties.uniform_buffer_count = state->ubo_count;
- state->properties.helper_invocation_enable = state->helper_invocations;
- state->properties.shader_modifies_coverage = state->can_discard;
+ state->properties.shader_contains_barrier = state->helper_invocations;
+ state->properties.bifrost.shader_modifies_coverage = state->can_discard;
pan_prepare(&state->preload, PRELOAD);
state->preload.uniform_count = state->uniform_count;
diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c
index dd99e2c..d8cbb0b 100644
--- a/src/gallium/drivers/panfrost/pan_cmdstream.c
+++ b/src/gallium/drivers/panfrost/pan_cmdstream.c
@@ -404,8 +404,11 @@
unsigned rt_count = ctx->pipe_framebuffer.nr_cbufs;
if (!panfrost_fs_required(fs, blend, rt_count)) {
- state->properties.unknown = 0x950020; /* XXX */
- state->properties.allow_forward_pixel_to_kill = true;
+ state->properties.uniform_buffer_count = 32;
+ state->properties.bifrost.shader_modifies_coverage = true;
+ state->properties.bifrost.allow_forward_pixel_to_kill = true;
+ state->properties.bifrost.allow_forward_pixel_to_be_killed = true;
+ state->properties.bifrost.zs_update_operation = MALI_PIXEL_KILL_STRONG_EARLY;
} else {
bool no_blend = true;
@@ -413,7 +416,8 @@
no_blend &= (!blend[i].load_dest | blend[i].no_colour);
state->properties = fs->properties;
- state->properties.allow_forward_pixel_to_kill = !fs->can_discard && !fs->writes_depth && no_blend;
+ state->properties.bifrost.allow_forward_pixel_to_kill =
+ !fs->can_discard && !fs->writes_depth && no_blend;
state->shader = fs->shader;
state->preload = fs->preload;
}
@@ -432,9 +436,9 @@
if (!panfrost_fs_required(fs, blend, rt_count)) {
state->shader.shader = 0x1;
- state->properties.work_register_count = 1;
+ state->properties.midgard.work_register_count = 1;
state->properties.depth_source = MALI_DEPTH_SOURCE_FIXED_FUNCTION;
- state->properties.midgard_early_z_enable = true;
+ state->properties.midgard.force_early_z = true;
} else {
/* Reasons to disable early-Z from a shader perspective */
bool late_z = fs->can_discard || fs->writes_global ||
@@ -453,13 +457,19 @@
/* TODO: Reduce this limit? */
state->properties = fs->properties;
if (has_blend_shader)
- state->properties.work_register_count = MAX2(fs->work_reg_count, 8);
+ state->properties.midgard.work_register_count = MAX2(fs->work_reg_count, 8);
else
- state->properties.work_register_count = fs->work_reg_count;
+ state->properties.midgard.work_register_count = fs->work_reg_count;
- state->properties.midgard_early_z_enable = !(late_z || alpha_to_coverage);
- state->properties.reads_tilebuffer = fs->outputs_read || (!zs_enabled && fs->can_discard);
- state->properties.reads_depth_stencil = zs_enabled && fs->can_discard;
+ state->properties.midgard.force_early_z = !(late_z || alpha_to_coverage);
+
+ /* Workaround a hardware errata where early-z cannot be enabled
+ * when discarding even when the depth buffer is read-only, by
+ * lying to the hardware about the discard and setting the
+ * reads tilebuffer? flag to compensate */
+ state->properties.midgard.shader_reads_tilebuffer =
+ fs->outputs_read || (!zs_enabled && fs->can_discard);
+ state->properties.midgard.shader_contains_discard = zs_enabled && fs->can_discard;
state->shader = fs->shader;
}
diff --git a/src/panfrost/bifrost/test/bi_submit.c b/src/panfrost/bifrost/test/bi_submit.c
index 955142f..da3512c 100644
--- a/src/panfrost/bifrost/test/bi_submit.c
+++ b/src/panfrost/bifrost/test/bi_submit.c
@@ -177,7 +177,7 @@
cfg.shader.shader = shader->gpu;
cfg.shader.attribute_count = cfg.shader.varying_count = 1;
cfg.properties.uniform_buffer_count = 1;
- cfg.properties.uniform_count = 4;
+ cfg.properties.bifrost.zs_update_operation = MALI_PIXEL_KILL_STRONG_EARLY;
cfg.preload.vertex_id = true;
cfg.preload.instance_id = true;
cfg.preload.uniform_count = (sz_ubo / 16);
diff --git a/src/panfrost/lib/decode.c b/src/panfrost/lib/decode.c
index 3121ff5..f0da3fb 100644
--- a/src/panfrost/lib/decode.c
+++ b/src/panfrost/lib/decode.c
@@ -971,7 +971,7 @@
if (is_bifrost)
uniform_count = state.preload.uniform_count;
else
- uniform_count = state.properties.uniform_count;
+ uniform_count = state.properties.midgard.uniform_count;
pandecode_shader_prop("texture_count", texture_count, info.texture_count, false);
pandecode_shader_prop("sampler_count", sampler_count, info.sampler_count, false);
diff --git a/src/panfrost/lib/midgard.xml b/src/panfrost/lib/midgard.xml
index 6cca4eb..3b49715 100644
--- a/src/panfrost/lib/midgard.xml
+++ b/src/panfrost/lib/midgard.xml
@@ -635,26 +635,49 @@
<field name="Surfaces" size="64" start="4:0" type="address"/>
</struct>
+ <enum name="FP Mode">
+ <value name="GL Inf/NaN Allowed" value="0"/>
+ <value name="GL Inf/NaN Suppressed" value="1"/>
+ <value name="CL" value="2"/>
+ <value name="D3D11" value="3"/>
+ </enum>
+
+ <struct name="Midgard Renderer Properties" size="1" no-direct-packing="true">
+ <field name="Force early-z" size="1" start="10" type="bool"/>
+ <field name="Shader contains discard" size="1" start="12" type="bool"/>
+ <field name="Shader has side-effects" size="1" start="13" type="bool"/>
+ <field name="Shader reads tilebuffer" size="1" start="14" type="bool"/>
+ <field name="Forward pixel kill" size="1" start="15" type="bool"/>
+ <field name="Work register count" size="5" start="16" type="uint"/>
+ <field name="Uniform count" size="5" start="21" type="uint"/>
+ <field name="FP mode" size="3" start="29" type="FP Mode"/>
+ </struct>
+
+ <enum name="Shader Register Allocation">
+ <value name="64 Per Thread" value="0"/>
+ <value name="32 Per Thread" value="2"/>
+ </enum>
+
+ <struct name="Bifrost Renderer Properties" size="1" no-direct-packing="true">
+ <field name="Shader register allocation" size="2" start="12" type="Shader Register Allocation"/>
+ <field name="Secondary shader register allocation" size="2" start="14" type="Shader Register Allocation"/>
+ <field name="Shader modifies coverage" size="1" start="16" type="bool"/>
+ <field name="Allow forward pixel to kill" size="1" start="19" type="bool"/>
+ <field name="Allow forward pixel to be killed" size="1" start="20" type="bool"/>
+ <field name="Pixel kill operation" size="2" start="21" type="Pixel Kill"/>
+ <field name="ZS update operation" size="2" start="23" type="Pixel Kill"/>
+ <field name="Point sprite coord origin max Y" size="1" start="27" type="bool"/>
+ <field name="Shader wait dependency 6" size="1" start="30" type="bool"/>
+ <field name="Shader wait dependency 7" size="1" start="31" type="bool"/>
+ </struct>
+
<struct name="Renderer Properties" size="1">
+ <field name="Midgard" size="32" start="0" type="Midgard Renderer Properties"/>
+ <field name="Bifrost" size="32" start="0" type="Bifrost Renderer Properties"/>
<field name="Uniform buffer count" size="8" start="0" type="uint"/>
<field name="Depth source" size="2" start="8" type="Depth Source" default="None"/>
- <field name="Midgard Early-z enable" size="1" start="10" type="bool" default="false"/>
- <field name="Helper invocation enable" size="1" start="11" type="bool" default="false"/>
- <field name="Reads depth/stencil" size="1" start="12" type="bool" default="false"/>
- <field name="Writes globals" size="1" start="13" type="bool" default="false"/>
- <field name="Full thread" size="1" start="13" type="bool" default="false"/>
- <field name="Reads tilebuffer" size="1" start="14" type="bool" default="false"/>
- <field name="Work register count" size="5" start="16" type="uint"/>
- <field name="Shader modifies coverage" size="1" start="16" type="bool"/>
- <field name="Allow forward pixel to kill" size="1" start="19" type="bool" default="false"/>
- <field name="Allow forward pixel to be killed" size="1" start="20" type="bool" default="false"/>
- <field name="Pixel kill operation" size="2" start="21" type="Pixel Kill" default="Force early"/>
- <field name="Uniform count" size="5" start="21" type="uint"/>
+ <field name="Shader contains barrier" size="1" start="11" type="bool"/>
<field name="Stencil from shader" size="1" start="28" type="bool"/>
- <field name="Suppress Inf/NaN" size="1" start="29" type="bool"/>
- <field name="First ATEST" size="1" start="30" type="bool" default="false"/>
- <!-- XXX: This is awful -->
- <field name="Unknown" size="32" start="0" type="uint"/>
</struct>
<struct name="Preload" size="1">
diff --git a/src/panfrost/lib/pan_blit.c b/src/panfrost/lib/pan_blit.c
index 4d74dd4..c92f893 100644
--- a/src/panfrost/lib/pan_blit.c
+++ b/src/panfrost/lib/pan_blit.c
@@ -234,8 +234,8 @@
cfg.shader.texture_count = 1;
cfg.shader.sampler_count = 1;
- cfg.properties.work_register_count = 4;
- cfg.properties.midgard_early_z_enable = (loc >= FRAG_RESULT_DATA0);
+ cfg.properties.midgard.work_register_count = 4;
+ cfg.properties.midgard.force_early_z = (loc >= FRAG_RESULT_DATA0);
cfg.properties.stencil_from_shader = (loc == FRAG_RESULT_STENCIL);
cfg.properties.depth_source = (loc == FRAG_RESULT_DEPTH) ?
MALI_DEPTH_SOURCE_SHADER :