From 9a082ae142eed97f65ce6c15c3f6ac7163a93992 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Tue, 28 Nov 2023 15:04:24 +0100 Subject: [PATCH] etnaviv: shader: Apply output remapping The mapping between fragment shader output and and render target is not fixed and depends on the framebuffer state. Apply the mapping during the linking of the shaders. Signed-off-by: Christian Gmeiner Reviewed-by: Lucas Stach Part-of: --- src/gallium/drivers/etnaviv/etnaviv_shader.c | 22 +++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_shader.c b/src/gallium/drivers/etnaviv/etnaviv_shader.c index 9c8ebfc2a1b..1fc26adef51 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_shader.c +++ b/src/gallium/drivers/etnaviv/etnaviv_shader.c @@ -191,17 +191,23 @@ etna_link_shaders(struct etna_context *ctx, struct compiled_shader_state *cs, cs->PS_END_PC = fs->code_size / 4; + /* apply output remapping based on current framebuffer state */ + int ps_color_out_reg[PIPE_MAX_COLOR_BUFS]; + + for (unsigned i = 0; i < ARRAY_SIZE(ctx->framebuffer.ps_output_remap); i++) + ps_color_out_reg[i] = fs->ps_color_out_reg[ctx->framebuffer.ps_output_remap[i]]; + cs->PS_OUTPUT_REG[0] = - VIVS_PS_OUTPUT_REG_0(fs->ps_color_out_reg[0]) | - VIVS_PS_OUTPUT_REG_1(fs->ps_color_out_reg[1]) | - VIVS_PS_OUTPUT_REG_2(fs->ps_color_out_reg[2]) | - VIVS_PS_OUTPUT_REG_3(fs->ps_color_out_reg[3]); + VIVS_PS_OUTPUT_REG_0(ps_color_out_reg[0]) | + VIVS_PS_OUTPUT_REG_1(ps_color_out_reg[1]) | + VIVS_PS_OUTPUT_REG_2(ps_color_out_reg[2]) | + VIVS_PS_OUTPUT_REG_3(ps_color_out_reg[3]); cs->PS_OUTPUT_REG[1] = - VIVS_PS_OUTPUT_REG2_4(fs->ps_color_out_reg[4]) | - VIVS_PS_OUTPUT_REG2_5(fs->ps_color_out_reg[5]) | - VIVS_PS_OUTPUT_REG2_6(fs->ps_color_out_reg[6]) | - VIVS_PS_OUTPUT_REG2_7(fs->ps_color_out_reg[7]); + VIVS_PS_OUTPUT_REG2_4(ps_color_out_reg[4]) | + VIVS_PS_OUTPUT_REG2_5(ps_color_out_reg[5]) | + VIVS_PS_OUTPUT_REG2_6(ps_color_out_reg[6]) | + VIVS_PS_OUTPUT_REG2_7(ps_color_out_reg[7]); cs->PS_INPUT_COUNT = VIVS_PS_INPUT_COUNT_COUNT(link.num_varyings + 1) | /* Number of inputs plus position */