freedreno/a4xx: fix dst_alpha blend for RGBX render targets
There are not native RGBX render formats, so we must manually force dst_alpha to be one, same as for a3xx. Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
*/
|
||||
|
||||
#include "pipe/p_state.h"
|
||||
#include "util/u_blend.h"
|
||||
#include "util/u_string.h"
|
||||
#include "util/u_memory.h"
|
||||
|
||||
@@ -98,14 +99,22 @@ fd4_blend_state_create(struct pipe_context *pctx,
|
||||
else
|
||||
rt = &cso->rt[0];
|
||||
|
||||
so->rb_mrt[i].blend_control =
|
||||
so->rb_mrt[i].blend_control_rgb =
|
||||
A4XX_RB_MRT_BLEND_CONTROL_RGB_SRC_FACTOR(fd_blend_factor(rt->rgb_src_factor)) |
|
||||
A4XX_RB_MRT_BLEND_CONTROL_RGB_BLEND_OPCODE(blend_func(rt->rgb_func)) |
|
||||
A4XX_RB_MRT_BLEND_CONTROL_RGB_DEST_FACTOR(fd_blend_factor(rt->rgb_dst_factor)) |
|
||||
A4XX_RB_MRT_BLEND_CONTROL_RGB_DEST_FACTOR(fd_blend_factor(rt->rgb_dst_factor));
|
||||
|
||||
so->rb_mrt[i].blend_control_alpha =
|
||||
A4XX_RB_MRT_BLEND_CONTROL_ALPHA_SRC_FACTOR(fd_blend_factor(rt->alpha_src_factor)) |
|
||||
A4XX_RB_MRT_BLEND_CONTROL_ALPHA_BLEND_OPCODE(blend_func(rt->alpha_func)) |
|
||||
A4XX_RB_MRT_BLEND_CONTROL_ALPHA_DEST_FACTOR(fd_blend_factor(rt->alpha_dst_factor));
|
||||
|
||||
so->rb_mrt[i].blend_control_no_alpha_rgb =
|
||||
A4XX_RB_MRT_BLEND_CONTROL_RGB_SRC_FACTOR(fd_blend_factor(util_blend_dst_alpha_to_one(rt->rgb_src_factor))) |
|
||||
A4XX_RB_MRT_BLEND_CONTROL_RGB_BLEND_OPCODE(blend_func(rt->rgb_func)) |
|
||||
A4XX_RB_MRT_BLEND_CONTROL_RGB_DEST_FACTOR(fd_blend_factor(util_blend_dst_alpha_to_one(rt->rgb_dst_factor)));
|
||||
|
||||
|
||||
so->rb_mrt[i].control =
|
||||
0xc00 | /* XXX ROP_CODE ?? */
|
||||
A4XX_RB_MRT_CONTROL_COMPONENT_ENABLE(rt->colormask);
|
||||
|
||||
@@ -39,7 +39,12 @@ struct fd4_blend_stateobj {
|
||||
struct {
|
||||
uint32_t control;
|
||||
uint32_t buf_info;
|
||||
uint32_t blend_control;
|
||||
/* Blend control bits for color if there is an alpha channel */
|
||||
uint32_t blend_control_rgb;
|
||||
/* Blend control bits for color if there is no alpha channel */
|
||||
uint32_t blend_control_no_alpha_rgb;
|
||||
/* Blend control bits for alpha channel */
|
||||
uint32_t blend_control_alpha;
|
||||
} rb_mrt[A4XX_MAX_RENDER_TARGETS];
|
||||
uint32_t rb_fs_output;
|
||||
};
|
||||
|
||||
@@ -626,11 +626,24 @@ fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < A4XX_MAX_RENDER_TARGETS; i++) {
|
||||
enum pipe_format format = pipe_surface_format(
|
||||
ctx->framebuffer.cbufs[i]);
|
||||
bool has_alpha = util_format_has_alpha(format);
|
||||
uint32_t control = blend->rb_mrt[i].control;
|
||||
uint32_t blend_control = blend->rb_mrt[i].blend_control_alpha;
|
||||
|
||||
if (has_alpha) {
|
||||
blend_control |= blend->rb_mrt[i].blend_control_rgb;
|
||||
} else {
|
||||
blend_control |= blend->rb_mrt[i].blend_control_no_alpha_rgb;
|
||||
control &= ~A4XX_RB_MRT_CONTROL_BLEND2;
|
||||
}
|
||||
|
||||
OUT_PKT0(ring, REG_A4XX_RB_MRT_CONTROL(i), 1);
|
||||
OUT_RING(ring, blend->rb_mrt[i].control);
|
||||
OUT_RING(ring, control);
|
||||
|
||||
OUT_PKT0(ring, REG_A4XX_RB_MRT_BLEND_CONTROL(i), 1);
|
||||
OUT_RING(ring, blend->rb_mrt[i].blend_control);
|
||||
OUT_RING(ring, blend_control);
|
||||
}
|
||||
|
||||
OUT_PKT0(ring, REG_A4XX_RB_FS_OUTPUT, 1);
|
||||
|
||||
Reference in New Issue
Block a user