[Mesa-dev] [PATCH 7/7] nouveau: allow blend_minmax_factor

Maxence Le Doré maxence.ledore at gmail.com
Thu Jan 2 17:18:26 PST 2014


Sound strange if nvidia would had chosen a different
implementation of min/max blending (where even
intel i830 allow factors with min/max blending).
Indeed, the driver doesn't set src and dst factors to ONE
when GL_MIN or GL_MAX are set as blend equation. Maybe
Francisco Jerez (going to ask him) simply forgot about
that and nv10-20 support it or nVIDIA had clearly opted
to another form of hardware implementation.
Anyway. Can't test this right now (lacks nv10 hw).
---
 src/mesa/drivers/dri/nouveau/nouveau_gldefs.h    |  2 ++
 src/mesa/drivers/dri/nouveau/nv10_context.c      |  1 +
 src/mesa/drivers/dri/nouveau/nv10_state_raster.c | 10 +++++++++-
 src/mesa/drivers/dri/nouveau/nv20_context.c      |  1 +
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_gldefs.h b/src/mesa/drivers/dri/nouveau/nouveau_gldefs.h
index 46ec14e..ba65dfd 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_gldefs.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_gldefs.h
@@ -73,8 +73,10 @@ nvgl_blend_eqn(unsigned eqn)
 	case GL_FUNC_ADD:
 		return 0x8006;
 	case GL_MIN:
+	case GL_FACTOR_MIN_AMD:
 		return 0x8007;
 	case GL_MAX:
+	case GL_FACTOR_MAX_AMD:
 		return 0x8008;
 	case GL_FUNC_SUBTRACT:
 		return 0x800a;
diff --git a/src/mesa/drivers/dri/nouveau/nv10_context.c b/src/mesa/drivers/dri/nouveau/nv10_context.c
index 1918f12..6f0e539 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_context.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_context.c
@@ -447,6 +447,7 @@ nv10_context_create(struct nouveau_screen *screen, const struct gl_config *visua
 	ctx->Extensions.ARB_texture_env_crossbar = true;
 	ctx->Extensions.ARB_texture_env_combine = true;
 	ctx->Extensions.ARB_texture_env_dot3 = true;
+	ctx->Extensions.AMD_blend_minmax_factor = true;
 	ctx->Extensions.NV_fog_distance = true;
 	ctx->Extensions.NV_texture_rectangle = true;
 	if (ctx->Mesa_DXTn) {
diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_raster.c b/src/mesa/drivers/dri/nouveau/nv10_state_raster.c
index bd4a78e..bcacae6 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_state_raster.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_state_raster.c
@@ -62,12 +62,20 @@ void
 nv10_emit_blend_equation(struct gl_context *ctx, int emit)
 {
 	struct nouveau_pushbuf *push = context_push(ctx);
+	unsigned eqn = ctx->Color.Blend[0].EquationRGB;
 
 	BEGIN_NV04(push, NV10_3D(BLEND_FUNC_ENABLE), 1);
 	PUSH_DATAb(push, ctx->Color.BlendEnabled);
 
 	BEGIN_NV04(push, NV10_3D(BLEND_EQUATION), 1);
-	PUSH_DATA (push, nvgl_blend_eqn(ctx->Color.Blend[0].EquationRGB));
+	PUSH_DATA (push, nvgl_blend_eqn(eqn));
+
+        if(eqn == GL_MIN || eqn == GL_MAX)
+        {
+	  BEGIN_NV04(push, NV10_3D(BLEND_FUNC_SRC), 2);
+	  PUSH_DATA (push, NV10_3D_BLEND_FUNC_SRC_ONE);
+	  PUSH_DATA (push, NV10_3D_BLEND_FUNC_DST_ONE);
+        }
 }
 
 void
diff --git a/src/mesa/drivers/dri/nouveau/nv20_context.c b/src/mesa/drivers/dri/nouveau/nv20_context.c
index 1d77132..b528798 100644
--- a/src/mesa/drivers/dri/nouveau/nv20_context.c
+++ b/src/mesa/drivers/dri/nouveau/nv20_context.c
@@ -458,6 +458,7 @@ nv20_context_create(struct nouveau_screen *screen, const struct gl_config *visua
 	ctx->Extensions.ARB_texture_env_crossbar = true;
 	ctx->Extensions.ARB_texture_env_combine = true;
 	ctx->Extensions.ARB_texture_env_dot3 = true;
+	ctx->Extensions.AMD_blend_minmax_factor = true;
 	ctx->Extensions.NV_fog_distance = true;
 	ctx->Extensions.NV_texture_rectangle = true;
 	if (ctx->Mesa_DXTn) {
-- 
1.8.5.2



More information about the mesa-dev mailing list