dri/nouveau: Implement texture matrices.
authorFrancisco Jerez <currojerez@riseup.net>
Thu, 18 Mar 2010 13:13:36 +0000 (14:13 +0100)
committerFrancisco Jerez <currojerez@riseup.net>
Thu, 18 Mar 2010 14:02:36 +0000 (15:02 +0100)
src/mesa/drivers/dri/nouveau/nouveau_state.c
src/mesa/drivers/dri/nouveau/nouveau_state.h
src/mesa/drivers/dri/nouveau/nv04_context.c
src/mesa/drivers/dri/nouveau/nv10_context.c
src/mesa/drivers/dri/nouveau/nv10_driver.h
src/mesa/drivers/dri/nouveau/nv10_state_tex.c
src/mesa/drivers/dri/nouveau/nv20_context.c
src/mesa/drivers/dri/nouveau/nv20_driver.h
src/mesa/drivers/dri/nouveau/nv20_state_tex.c

index bc61045..603a46e 100644 (file)
@@ -454,12 +454,19 @@ nouveau_state_emit(GLcontext *ctx)
 static void
 nouveau_update_state(GLcontext *ctx, GLbitfield new_state)
 {
+       int i;
+
        if (new_state & (_NEW_PROJECTION | _NEW_MODELVIEW))
                context_dirty(ctx, PROJECTION);
 
        if (new_state & _NEW_MODELVIEW)
                context_dirty(ctx, MODELVIEW);
 
+       if (new_state & _NEW_TEXTURE_MATRIX) {
+               for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)
+                       context_dirty_i(ctx, TEX_MAT, i);
+       }
+
        if (new_state & _NEW_CURRENT_ATTRIB &&
            new_state & _NEW_LIGHT) {
                context_dirty(ctx, MATERIAL_FRONT_AMBIENT);
index d01d962..38ac975 100644 (file)
@@ -89,6 +89,10 @@ enum {
        NOUVEAU_STATE_TEX_GEN1,
        NOUVEAU_STATE_TEX_GEN2,
        NOUVEAU_STATE_TEX_GEN3,
+       NOUVEAU_STATE_TEX_MAT0,
+       NOUVEAU_STATE_TEX_MAT1,
+       NOUVEAU_STATE_TEX_MAT2,
+       NOUVEAU_STATE_TEX_MAT3,
        NOUVEAU_STATE_TEX_OBJ0,
        NOUVEAU_STATE_TEX_OBJ1,
        NOUVEAU_STATE_TEX_OBJ2,
index 3624b3a..6834f7c 100644 (file)
@@ -276,6 +276,10 @@ const struct nouveau_driver nv04_driver = {
                nouveau_emit_nothing,
                nouveau_emit_nothing,
                nouveau_emit_nothing,
+               nouveau_emit_nothing,
+               nouveau_emit_nothing,
+               nouveau_emit_nothing,
+               nouveau_emit_nothing,
                nv04_emit_tex_obj,
                nv04_emit_tex_obj,
                nouveau_emit_nothing,
index 860d0ae..d008063 100644 (file)
@@ -412,6 +412,10 @@ const struct nouveau_driver nv10_driver = {
                nv10_emit_tex_gen,
                nouveau_emit_nothing,
                nouveau_emit_nothing,
+               nv10_emit_tex_mat,
+               nv10_emit_tex_mat,
+               nouveau_emit_nothing,
+               nouveau_emit_nothing,
                nv10_emit_tex_obj,
                nv10_emit_tex_obj,
                nouveau_emit_nothing,
index d662712..cefd6c6 100644 (file)
@@ -134,6 +134,9 @@ void
 nv10_emit_tex_gen(GLcontext *ctx, int emit);
 
 void
+nv10_emit_tex_mat(GLcontext *ctx, int emit);
+
+void
 nv10_emit_tex_obj(GLcontext *ctx, int emit);
 
 /* nv10_state_tnl.c */
index 02a5ca7..9214872 100644 (file)
 #include "nouveau_util.h"
 #include "nv10_driver.h"
 
+#define TX_MATRIX(i) (NV10TCL_TX0_MATRIX(0) + 64 * (i))
+
 void
 nv10_emit_tex_gen(GLcontext *ctx, int emit)
 {
 }
 
+void
+nv10_emit_tex_mat(GLcontext *ctx, int emit)
+{
+       const int i = emit - NOUVEAU_STATE_TEX_MAT0;
+       struct nouveau_context *nctx = to_nouveau_context(ctx);
+       struct nouveau_channel *chan = context_chan(ctx);
+       struct nouveau_grobj *celsius = context_eng3d(ctx);
+
+       if (nctx->fallback == HWTNL &&
+           ((ctx->Texture._TexMatEnabled & 1 << i) ||
+            ctx->Texture.Unit[i]._GenFlags)) {
+               BEGIN_RING(chan, celsius, NV10TCL_TX_MATRIX_ENABLE(i), 1);
+               OUT_RING(chan, 1);
+
+               BEGIN_RING(chan, celsius, TX_MATRIX(i), 16);
+               OUT_RINGm(chan, ctx->TextureMatrixStack[i].Top->m);
+
+       } else {
+               BEGIN_RING(chan, celsius, NV10TCL_TX_MATRIX_ENABLE(i), 1);
+               OUT_RING(chan, 0);
+       }
+}
+
 static uint32_t
 get_tex_format_pot(struct gl_texture_image *ti)
 {
index db39ef7..99df347 100644 (file)
@@ -501,6 +501,10 @@ const struct nouveau_driver nv20_driver = {
                nv10_emit_tex_gen,
                nv10_emit_tex_gen,
                nv10_emit_tex_gen,
+               nv20_emit_tex_mat,
+               nv20_emit_tex_mat,
+               nv20_emit_tex_mat,
+               nv20_emit_tex_mat,
                nv20_emit_tex_obj,
                nv20_emit_tex_obj,
                nv20_emit_tex_obj,
index 18574e9..05770b2 100644 (file)
@@ -68,6 +68,9 @@ nv20_emit_frag(GLcontext *ctx, int emit);
 
 /* nv20_state_tex.c */
 void
+nv20_emit_tex_mat(GLcontext *ctx, int emit);
+
+void
 nv20_emit_tex_obj(GLcontext *ctx, int emit);
 
 void
index 9287010..d7ac4c5 100644 (file)
 #include "nouveau_util.h"
 #include "nv20_driver.h"
 
+#define TX_MATRIX(i) (NV20TCL_TX0_MATRIX(0) + 64 * (i))
+
+void
+nv20_emit_tex_mat(GLcontext *ctx, int emit)
+{
+       const int i = emit - NOUVEAU_STATE_TEX_MAT0;
+       struct nouveau_context *nctx = to_nouveau_context(ctx);
+       struct nouveau_channel *chan = context_chan(ctx);
+       struct nouveau_grobj *kelvin = context_eng3d(ctx);
+
+       if (nctx->fallback == HWTNL &&
+           (ctx->Texture._TexMatEnabled & 1 << i)) {
+               BEGIN_RING(chan, kelvin, NV20TCL_TX_MATRIX_ENABLE(i), 1);
+               OUT_RING(chan, 1);
+
+               BEGIN_RING(chan, kelvin, TX_MATRIX(i), 16);
+               OUT_RINGm(chan, ctx->TextureMatrixStack[i].Top->m);
+
+       } else {
+               BEGIN_RING(chan, kelvin, NV20TCL_TX_MATRIX_ENABLE(i), 1);
+               OUT_RING(chan, 0);
+       }
+}
+
 static uint32_t
 get_tex_format_pot(struct gl_texture_image *ti)
 {