Mesa (master): virgl: Use alpha_src_factor to store blend_equation_advenced value
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jul 17 06:37:07 UTC 2020
Module: Mesa
Branch: master
Commit: a026364b55ea4c804d1a725ed4d2028d0f616a37
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a026364b55ea4c804d1a725ed4d2028d0f616a37
Author: Elie Tournier <tournier.elie at gmail.com>
Date: Wed Jun 24 21:43:40 2020 +0100
virgl: Use alpha_src_factor to store blend_equation_advenced value
Signed-off-by: Elie Tournier <elie.tournier at collabora.com>
Reviewed-by: Gert Wollny <gert.wollny at collabora.com>
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5516>
---
src/gallium/drivers/virgl/virgl_encode.c | 8 +++++++-
src/gallium/include/pipe/p_state.h | 1 +
src/mesa/state_tracker/st_atom_blend.c | 4 ++++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c
index 292cc2bb0d6..8e65a90d40d 100644
--- a/src/gallium/drivers/virgl/virgl_encode.c
+++ b/src/gallium/drivers/virgl/virgl_encode.c
@@ -338,13 +338,19 @@ int virgl_encode_blend_state(struct virgl_context *ctx,
virgl_encoder_write_dword(ctx->cbuf, tmp);
for (i = 0; i < VIRGL_MAX_COLOR_BUFS; i++) {
+ /* We use alpha src factor to pass the advanced blend equation value
+ * to the host. By doing so, we don't have to change the protocol.
+ */
+ uint32_t alpha = (i == 0 && blend_state->advanced_blend_func)
+ ? blend_state->advanced_blend_func
+ : blend_state->rt[i].alpha_src_factor;
tmp =
VIRGL_OBJ_BLEND_S2_RT_BLEND_ENABLE(blend_state->rt[i].blend_enable) |
VIRGL_OBJ_BLEND_S2_RT_RGB_FUNC(blend_state->rt[i].rgb_func) |
VIRGL_OBJ_BLEND_S2_RT_RGB_SRC_FACTOR(blend_state->rt[i].rgb_src_factor) |
VIRGL_OBJ_BLEND_S2_RT_RGB_DST_FACTOR(blend_state->rt[i].rgb_dst_factor)|
VIRGL_OBJ_BLEND_S2_RT_ALPHA_FUNC(blend_state->rt[i].alpha_func) |
- VIRGL_OBJ_BLEND_S2_RT_ALPHA_SRC_FACTOR(blend_state->rt[i].alpha_src_factor) |
+ VIRGL_OBJ_BLEND_S2_RT_ALPHA_SRC_FACTOR(alpha) |
VIRGL_OBJ_BLEND_S2_RT_ALPHA_DST_FACTOR(blend_state->rt[i].alpha_dst_factor) |
VIRGL_OBJ_BLEND_S2_RT_COLORMASK(blend_state->rt[i].colormask);
virgl_encoder_write_dword(ctx->cbuf, tmp);
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index b75906d148f..6f1d4c6309c 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -365,6 +365,7 @@ struct pipe_blend_state
unsigned alpha_to_coverage_dither:1;
unsigned alpha_to_one:1;
unsigned max_rt:3; /* index of max rt, Ie. # of cbufs minus 1 */
+ unsigned advanced_blend_func:4;
struct pipe_rt_blend_state rt[PIPE_MAX_COLOR_BUFS];
};
diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c
index 1c53e34588f..9aefd6aa5d8 100644
--- a/src/mesa/state_tracker/st_atom_blend.c
+++ b/src/mesa/state_tracker/st_atom_blend.c
@@ -217,6 +217,10 @@ st_update_blend( struct st_context *st )
blend->logicop_enable = 1;
blend->logicop_func = ctx->Color._LogicOp;
}
+ else if (ctx->Color.BlendEnabled &&
+ ctx->Color._AdvancedBlendMode != BLEND_NONE) {
+ blend->advanced_blend_func = ctx->Color._AdvancedBlendMode;
+ }
else if (ctx->Color.BlendEnabled &&
ctx->Color._AdvancedBlendMode == BLEND_NONE) {
/* blending enabled */
More information about the mesa-commit
mailing list