Fixes many of the fbo-blending-formats tests.
struct pipe_stencil_ref stencil_ref;
unsigned sample_mask;
struct pipe_framebuffer_state framebuffer;
+
+ /* Per render target, whether we should swap the R and B fields in the
+ * shader's color output and in blending. If render targets disagree
+ * on the R/B swap and use the constant color, then we would need to
+ * fall back to in-shader blending.
+ */
+ uint8_t swap_color_rb;
+
struct pipe_poly_stipple stipple;
struct pipe_clip_state clip;
struct pipe_viewport_state viewport;
if (vc5->dirty & VC5_DIRTY_BLEND_COLOR) {
cl_emit(&job->bcl, BLEND_CONSTANT_COLOUR, colour) {
- /* XXX: format-dependent swizzling */
- colour.red_f16 = vc5->blend_color.hf[2];
+ colour.red_f16 = (vc5->swap_color_rb ?
+ vc5->blend_color.hf[2] :
+ vc5->blend_color.hf[0]);
colour.green_f16 = vc5->blend_color.hf[1];
- colour.blue_f16 = vc5->blend_color.hf[0];
+ colour.blue_f16 = (vc5->swap_color_rb ?
+ vc5->blend_color.hf[0] :
+ vc5->blend_color.hf[2]);
colour.alpha_f16 = vc5->blend_color.hf[3];
}
}
* there are means that the buffer count needs to be in the key.
*/
key->nr_cbufs = vc5->framebuffer.nr_cbufs;
+ key->swap_color_rb = vc5->swap_color_rb;
for (int i = 0; i < key->nr_cbufs; i++) {
struct pipe_surface *cbuf = vc5->framebuffer.cbufs[i];
const struct util_format_description *desc =
util_format_description(cbuf->format);
- /* For BGRA8 formats (DRI window system default format), we
- * need to swap R and B, since the HW's format is RGBA8.
- */
- if (desc->swizzle[0] == PIPE_SWIZZLE_Z &&
- cbuf->format != PIPE_FORMAT_B5G6R5_UNORM) {
- key->swap_color_rb |= 1 << i;
- }
-
if (desc->channel[0].type == UTIL_FORMAT_TYPE_FLOAT &&
desc->channel[0].size == 32) {
key->f32_color_rb |= 1 << i;
cso->width = framebuffer->width;
cso->height = framebuffer->height;
+ vc5->swap_color_rb = 0;
+ for (int i = 0; i < vc5->framebuffer.nr_cbufs; i++) {
+ struct pipe_surface *cbuf = vc5->framebuffer.cbufs[i];
+ const struct util_format_description *desc =
+ util_format_description(cbuf->format);
+
+ /* For BGRA8 formats (DRI window system default format), we
+ * need to swap R and B, since the HW's format is RGBA8.
+ */
+ if (desc->swizzle[0] == PIPE_SWIZZLE_Z &&
+ cbuf->format != PIPE_FORMAT_B5G6R5_UNORM) {
+ vc5->swap_color_rb |= 1 << i;
+ }
+ }
+
vc5->dirty |= VC5_DIRTY_FRAMEBUFFER;
}