mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-01 01:38:06 +02:00
broadcom/vc5: Do BGRA vs RGBA swapping for the BLEND_CONSTANT_COLOR.
Fixes many of the fbo-blending-formats tests.
This commit is contained in:
parent
2e3c7beb1e
commit
61bb0df60e
4 changed files with 30 additions and 11 deletions
|
|
@ -337,6 +337,14 @@ struct vc5_context {
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -360,10 +360,13 @@ vc5_emit_state(struct pipe_context *pctx)
|
|||
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -365,20 +365,13 @@ vc5_update_compiled_fs(struct vc5_context *vc5, uint8_t prim_mode)
|
|||
* 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;
|
||||
|
|
|
|||
|
|
@ -388,6 +388,21 @@ vc5_set_framebuffer_state(struct pipe_context *pctx,
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue