dri/nv10-nv20: Add support for NV_texture_env_combine4.
authorFrancisco Jerez <currojerez@riseup.net>
Thu, 9 Sep 2010 12:14:48 +0000 (14:14 +0200)
committerFrancisco Jerez <currojerez@riseup.net>
Thu, 9 Sep 2010 12:19:35 +0000 (14:19 +0200)
src/mesa/drivers/dri/nouveau/nouveau_context.c
src/mesa/drivers/dri/nouveau/nv10_state_frag.c

index b1d415257da64676ee96be4fe946e44256aa7d34..287f77d96c25f3113308cebbe2c943ef8a9fbb30 100644 (file)
@@ -60,6 +60,7 @@ static const struct dri_extension nouveau_extensions[] = {
        { "GL_EXT_stencil_wrap",        NULL },
        { "GL_EXT_texture_lod_bias",    NULL },
        { "GL_NV_blend_square",         NULL },
+       { "GL_NV_texture_env_combine4", NULL },
        { "GL_SGIS_generate_mipmap",    NULL },
        { NULL,                         NULL }
 };
index 76b95fdd518094e37ee0814c0b75f6279aa9f703..ab713f9dbf5f64be46a8e485faf3d6c8fafb7ee7 100644 (file)
@@ -63,6 +63,7 @@
 struct combiner_state {
        GLcontext *ctx;
        int unit;
+       GLboolean premodulate;
 
        /* GL state */
        GLenum mode;
@@ -82,6 +83,7 @@ struct combiner_state {
                        ctx->Texture.Unit[i]._CurrentCombine;   \
                (rc)->ctx = ctx;                                \
                (rc)->unit = i;                                 \
+               (rc)->premodulate = c->_NumArgs##chan == 4;     \
                (rc)->mode = c->Mode##chan;                     \
                (rc)->source = c->Source##chan;                 \
                (rc)->operand = c->Operand##chan;               \
@@ -95,6 +97,9 @@ static uint32_t
 get_input_source(struct combiner_state *rc, int source)
 {
        switch (source) {
+       case GL_ZERO:
+               return RC_IN_SOURCE(ZERO);
+
        case GL_TEXTURE:
                return RC_IN_SOURCE(TEXTURE0) + rc->unit;
 
@@ -228,21 +233,21 @@ setup_combiner(struct combiner_state *rc)
                break;
 
        case GL_ADD:
-               INPUT_ARG(rc, A, 0, 0);
-               INPUT_ONE(rc, B, 0);
-               INPUT_ARG(rc, C, 1, 0);
-               INPUT_ONE(rc, D, 0);
-
-               rc->out = RC_OUT_SUM;
-               break;
-
        case GL_ADD_SIGNED:
-               INPUT_ARG(rc, A, 0, 0);
-               INPUT_ONE(rc, B, 0);
-               INPUT_ARG(rc, C, 1, 0);
-               INPUT_ONE(rc, D, 0);
+               if (rc->premodulate) {
+                       INPUT_ARG(rc, A, 0, 0);
+                       INPUT_ARG(rc, B, 1, 0);
+                       INPUT_ARG(rc, C, 2, 0);
+                       INPUT_ARG(rc, D, 3, 0);
+               } else {
+                       INPUT_ARG(rc, A, 0, 0);
+                       INPUT_ONE(rc, B, 0);
+                       INPUT_ARG(rc, C, 1, 0);
+                       INPUT_ONE(rc, D, 0);
+               }
 
-               rc->out = RC_OUT_SUM | RC_OUT_BIAS;
+               rc->out = RC_OUT_SUM |
+                       (rc->mode == GL_ADD_SIGNED ? RC_OUT_BIAS : 0);
                break;
 
        case GL_INTERPOLATE: