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>
This commit is contained in:
Boris Brezillon 2020-10-13 18:32:14 +02:00 committed by Marge Bot
parent f2ae8d116a
commit 519643bbe0
6 changed files with 76 additions and 39 deletions

View File

@ -45,19 +45,23 @@ pan_prepare_midgard_props(struct panfrost_shader_state *state,
{
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 @@ pan_prepare_bifrost_props(struct panfrost_shader_state *state,
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 @@ pan_prepare_bifrost_props(struct panfrost_shader_state *state,
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;

View File

@ -404,8 +404,11 @@ panfrost_prepare_bifrost_fs_state(struct panfrost_context *ctx,
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 @@ panfrost_prepare_bifrost_fs_state(struct panfrost_context *ctx,
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 @@ panfrost_prepare_midgard_fs_state(struct panfrost_context *ctx,
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 @@ panfrost_prepare_midgard_fs_state(struct panfrost_context *ctx,
/* 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;
}

View File

@ -177,7 +177,7 @@ bit_vertex(struct panfrost_device *dev, panfrost_program prog,
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);

View File

@ -971,7 +971,7 @@ pandecode_vertex_tiler_postfix_pre(
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);

View File

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

View File

@ -234,8 +234,8 @@ panfrost_load_midg(
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 :