diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c index f2bc19d6d52..f237ded9118 100644 --- a/src/gallium/drivers/panfrost/pan_assemble.c +++ b/src/gallium/drivers/panfrost/pan_assemble.c @@ -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; diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index dd99e2c6464..d8cbb0b3ede 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -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; } diff --git a/src/panfrost/bifrost/test/bi_submit.c b/src/panfrost/bifrost/test/bi_submit.c index 955142f1ac3..da3512c244e 100644 --- a/src/panfrost/bifrost/test/bi_submit.c +++ b/src/panfrost/bifrost/test/bi_submit.c @@ -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); diff --git a/src/panfrost/lib/decode.c b/src/panfrost/lib/decode.c index 3121ff538be..f0da3fb6561 100644 --- a/src/panfrost/lib/decode.c +++ b/src/panfrost/lib/decode.c @@ -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); diff --git a/src/panfrost/lib/midgard.xml b/src/panfrost/lib/midgard.xml index 6cca4ebadef..3b49715f62b 100644 --- a/src/panfrost/lib/midgard.xml +++ b/src/panfrost/lib/midgard.xml @@ -635,26 +635,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + - - - - diff --git a/src/panfrost/lib/pan_blit.c b/src/panfrost/lib/pan_blit.c index 4d74dd4345e..c92f89303bf 100644 --- a/src/panfrost/lib/pan_blit.c +++ b/src/panfrost/lib/pan_blit.c @@ -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 :