etnaviv: fix shader register control with MSAA
authorLucas Stach <l.stach@pengutronix.de>
Mon, 7 Nov 2022 15:12:52 +0000 (16:12 +0100)
committerMarge Bot <emma+marge@anholt.net>
Tue, 15 Nov 2022 09:07:40 +0000 (09:07 +0000)
Apparently MSAA doesn't only add another input, but it also increases
required temporaries by one. Simple programs where the register demand
is given by the number of inputs did work fine, while more complex ones,
where register demand is given by the number of temporaries exhibit
rendering issues without this fix.

Cc: 22.3 mesa-stable
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19582>

src/gallium/drivers/etnaviv/etnaviv_shader.c

index e24c3f1..8a8cf53 100644 (file)
@@ -215,11 +215,13 @@ etna_link_shaders(struct etna_context *ctx, struct compiled_shader_state *cs,
 
    /* Precompute PS_INPUT_COUNT and TEMP_REGISTER_CONTROL in the case of MSAA
     * mode, avoids some fumbling in sync_context. */
+   /* MSAA adds another input */
    cs->PS_INPUT_COUNT_MSAA =
-      VIVS_PS_INPUT_COUNT_COUNT(link.num_varyings + 2) | /* MSAA adds another input */
+      VIVS_PS_INPUT_COUNT_COUNT(link.num_varyings + 2) |
       VIVS_PS_INPUT_COUNT_UNK8(fs->input_count_unk8);
+   /* MSAA adds another temp */
    cs->PS_TEMP_REGISTER_CONTROL_MSAA =
-      VIVS_PS_TEMP_REGISTER_CONTROL_NUM_TEMPS(MAX2(fs->num_temps, link.num_varyings + 2));
+      VIVS_PS_TEMP_REGISTER_CONTROL_NUM_TEMPS(MAX2(fs->num_temps + 1, link.num_varyings + 2));
 
    uint32_t total_components = 0;
    DEFINE_ETNA_BITARRAY(num_components, ETNA_NUM_VARYINGS, 4) = {0};