diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c index 818e94261b6..e0e36fb6f54 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.c +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c @@ -302,8 +302,10 @@ etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info, .sprite_coord_yinvert = !!ctx->rasterizer->sprite_coord_mode, }; - if (pfb->cbufs[0]) - key.frag_rb_swap = !!translate_pe_format_rb_swap(pfb->cbufs[0]->format); + for (i = 0; i < pfb->nr_cbufs; i++) { + if (pfb->cbufs[i]) + key.frag_rb_swap |= !!translate_pe_format_rb_swap(pfb->cbufs[i]->format) << i; + } if (!etna_get_vs(ctx, &key) || !etna_get_fs(ctx, &key)) { BUG("compiled shaders are not okay"); diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c b/src/gallium/drivers/etnaviv/etnaviv_nir.c index 672cfe5f475..11a35f06c61 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_nir.c +++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c @@ -26,6 +26,18 @@ #include "etnaviv_nir.h" +static inline int +color_index_for_location(unsigned location) +{ + assert(location != FRAG_RESULT_COLOR && + "gl_FragColor must be lowered before nir_lower_blend"); + + if (location < FRAG_RESULT_DATA0) + return -1; + else + return location - FRAG_RESULT_DATA0; +} + /* io related lowering * run after lower_int_to_float because it adds i2f/f2i ops */ @@ -64,8 +76,12 @@ etna_lower_io(nir_shader *shader, struct etna_shader_variant *v) assert(deref->deref_type == nir_deref_type_var); - if (deref->var->data.location != FRAG_RESULT_DATA0) - break; + int rt = color_index_for_location(deref->var->data.location); + if (rt == -1) + break; + + if (!(v->key.frag_rb_swap & (1 << rt))) + break; b.cursor = nir_before_instr(instr); diff --git a/src/gallium/drivers/etnaviv/etnaviv_shader.h b/src/gallium/drivers/etnaviv/etnaviv_shader.h index bc8ae52cab6..ac48f0b7538 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_shader.h +++ b/src/gallium/drivers/etnaviv/etnaviv_shader.h @@ -46,8 +46,8 @@ struct etna_shader_key * Combined Vertex/Fragment shader parameters: */ - /* do we need to swap rb in frag color? */ - unsigned frag_rb_swap : 1; + /* do we need to swap rb in frag colors? */ + unsigned frag_rb_swap : PIPE_MAX_COLOR_BUFS; /* do we need to invert front facing value? */ unsigned front_ccw : 1; /* do we need to replace glTexCoord.xy ? */