Mesa (master): dri/nv04: Add support for NV_texture_env_combine4.

Francisco Jerez currojerez at kemper.freedesktop.org
Thu Sep 9 12:21:36 UTC 2010


Module: Mesa
Branch: master
Commit: 699749cfeeea7d0a17ed5f94fd5fdbbe52f4ab2b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=699749cfeeea7d0a17ed5f94fd5fdbbe52f4ab2b

Author: Francisco Jerez <currojerez at riseup.net>
Date:   Thu Sep  9 14:14:14 2010 +0200

dri/nv04: Add support for NV_texture_env_combine4.

---

 src/mesa/drivers/dri/nouveau/nv04_context.c    |    1 +
 src/mesa/drivers/dri/nouveau/nv04_state_frag.c |   36 +++++++++++++++--------
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nv04_context.c b/src/mesa/drivers/dri/nouveau/nv04_context.c
index 6834f7c..1d34c86 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_context.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_context.c
@@ -39,6 +39,7 @@ nv04_context_engine(GLcontext *ctx)
 	struct nouveau_grobj *fahrenheit;
 
 	if (ctx->Texture.Unit[0].EnvMode == GL_COMBINE ||
+	    ctx->Texture.Unit[0].EnvMode == GL_COMBINE4_NV ||
 	    ctx->Texture.Unit[0].EnvMode == GL_BLEND ||
 	    ctx->Texture.Unit[0].EnvMode == GL_ADD ||
 	    ctx->Texture.Unit[1]._ReallyEnabled ||
diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
index d7c86d4..bb5d7dc 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
@@ -44,6 +44,7 @@ struct combiner_state {
 	GLcontext *ctx;
 	int unit;
 	GLboolean alpha;
+	GLboolean premodulate;
 
 	/* GL state */
 	GLenum mode;
@@ -66,6 +67,7 @@ struct combiner_state {
 		(rc)->ctx = ctx;				\
 		(rc)->unit = i;					\
 		(rc)->alpha = __INIT_COMBINER_ALPHA_##chan;	\
+		(rc)->premodulate = c->_NumArgs##chan == 4;	\
 		(rc)->mode = c->Mode##chan;			\
 		(rc)->source = c->Source##chan;			\
 		(rc)->operand = c->Operand##chan;		\
@@ -79,6 +81,9 @@ static uint32_t
 get_input_source(struct combiner_state *rc, int source)
 {
 	switch (source) {
+	case GL_ZERO:
+		return COMBINER_SOURCE(ZERO);
+
 	case GL_TEXTURE:
 		return rc->unit ? COMBINER_SOURCE(TEXTURE1) :
 			COMBINER_SOURCE(TEXTURE0);
@@ -195,11 +200,24 @@ setup_combiner(struct combiner_state *rc)
 		break;
 
 	case GL_ADD:
-		INPUT_ARG(rc, 0, 0, 0);
-		INPUT_SRC(rc, 1, ZERO, INVERT);
-		INPUT_ARG(rc, 2, 1, 0);
-		INPUT_SRC(rc, 3, ZERO, INVERT);
-		UNSIGNED_OP(rc);
+	case GL_ADD_SIGNED:
+		if (rc->premodulate) {
+			INPUT_ARG(rc, 0, 0, 0);
+			INPUT_ARG(rc, 1, 1, 0);
+			INPUT_ARG(rc, 2, 2, 0);
+			INPUT_ARG(rc, 3, 3, 0);
+		} else {
+			INPUT_ARG(rc, 0, 0, 0);
+			INPUT_SRC(rc, 1, ZERO, INVERT);
+			INPUT_ARG(rc, 2, 1, 0);
+			INPUT_SRC(rc, 3, ZERO, INVERT);
+		}
+
+		if (rc->mode == GL_ADD_SIGNED)
+			SIGNED_OP(rc);
+		else
+			UNSIGNED_OP(rc);
+
 		break;
 
 	case GL_INTERPOLATE:
@@ -210,14 +228,6 @@ setup_combiner(struct combiner_state *rc)
 		UNSIGNED_OP(rc);
 		break;
 
-	case GL_ADD_SIGNED:
-		INPUT_ARG(rc, 0, 0, 0);
-		INPUT_SRC(rc, 1, ZERO, INVERT);
-		INPUT_ARG(rc, 2, 1, 0);
-		INPUT_SRC(rc, 3, ZERO, INVERT);
-		SIGNED_OP(rc);
-		break;
-
 	default:
 		assert(0);
 	}




More information about the mesa-commit mailing list