summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/svga/svga_pipe_blend.c
diff options
context:
space:
mode:
authorCharmaine Lee <charmainel@vmware.com>2017-10-04 11:05:58 -0600
committerBrian Paul <brianp@vmware.com>2018-09-10 13:07:30 -0600
commit3c3fc7154e50e8ef4d81fef1d6b12d1ce57326a7 (patch)
tree872d01d6efeb9b12d22f86bd6dcf83e3b8f49f28 /src/gallium/drivers/svga/svga_pipe_blend.c
parent5512f943b87c2ebe01c410cf3af9af8eb31dcb17 (diff)
svga: add support for independent blend function per render target
This patch adds support for GL_ARB_draw_buffers_blend extension for SM4_1 device. Fixes piglit test fbo-draw-buffers-blend. This patch is squashed with a subsequent patch which fixed a regression. Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Neha Bhende <bhenden@vmware.com> Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Diffstat (limited to 'src/gallium/drivers/svga/svga_pipe_blend.c')
-rw-r--r--src/gallium/drivers/svga/svga_pipe_blend.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/gallium/drivers/svga/svga_pipe_blend.c b/src/gallium/drivers/svga/svga_pipe_blend.c
index 6bb9d94369b..b5557d31f44 100644
--- a/src/gallium/drivers/svga/svga_pipe_blend.c
+++ b/src/gallium/drivers/svga/svga_pipe_blend.c
@@ -118,7 +118,6 @@ define_blend_state_object(struct svga_context *svga,
perRT[i].renderTargetWriteMask = bs->rt[i].writemask;
perRT[i].logicOpEnable = 0;
perRT[i].logicOp = SVGA3D_LOGICOP_COPY;
- assert(perRT[i].srcBlend == perRT[0].srcBlend);
}
/* Loop in case command buffer is full and we need to flush and retry */
@@ -148,10 +147,10 @@ svga_create_blend_state(struct pipe_context *pipe,
if (!blend)
return NULL;
- /* Find index of first target with blending enabled. -1 means blending
- * is not enabled at all.
+ /* Find index of first target with blending enabled. If no blending is
+ * enabled at all, first_enabled will be zero.
*/
- int first_enabled = -1;
+ unsigned first_enabled = 0;
for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
if (templ->rt[i].blend_enable) {
first_enabled = i;
@@ -271,26 +270,26 @@ svga_create_blend_state(struct pipe_context *pipe,
}
}
else {
- /* Note: the vgpu10 device does not yet support independent blend
- * terms per render target. When blending is enabled, the blend
- * terms must match for all targets.
+ /* Note: per-target blend terms are only supported for sm4_1
+ * device. For vgpu10 device, the blending terms must be identical
+ * for all targets (this is why we need the first_enabled index).
*/
- if (first_enabled >= 0) {
- /* use first enabled target's blending terms */
- const struct pipe_rt_blend_state *rt = &templ->rt[first_enabled];
-
+ const unsigned j =
+ svga_have_sm4_1(svga) && templ->independent_blend_enable
+ ? i : first_enabled;
+ if (templ->independent_blend_enable || templ->rt[j].blend_enable) {
blend->rt[i].srcblend =
- svga_translate_blend_factor(svga, rt->rgb_src_factor);
+ svga_translate_blend_factor(svga, templ->rt[j].rgb_src_factor);
blend->rt[i].dstblend =
- svga_translate_blend_factor(svga, rt->rgb_dst_factor);
+ svga_translate_blend_factor(svga, templ->rt[j].rgb_dst_factor);
blend->rt[i].blendeq =
- svga_translate_blend_func(rt->rgb_func);
+ svga_translate_blend_func(templ->rt[j].rgb_func);
blend->rt[i].srcblend_alpha =
- svga_translate_blend_factor(svga, rt->alpha_src_factor);
+ svga_translate_blend_factor(svga, templ->rt[j].alpha_src_factor);
blend->rt[i].dstblend_alpha =
- svga_translate_blend_factor(svga, rt->alpha_dst_factor);
+ svga_translate_blend_factor(svga, templ->rt[j].alpha_dst_factor);
blend->rt[i].blendeq_alpha =
- svga_translate_blend_func(rt->alpha_func);
+ svga_translate_blend_func(templ->rt[j].alpha_func);
if (blend->rt[i].srcblend_alpha != blend->rt[i].srcblend ||
blend->rt[i].dstblend_alpha != blend->rt[i].dstblend ||