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 bc610451b403d6bae828856d613880106daa623a..603a46ed242a1ec80c5810fa5ef5009cc12372dd 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 d01d962c9f200852ea5e57098feb733904a48d56..38ac9753c8cbc433d95eb8c59188d55de536e3a9 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 3624b3af9211b77ec0ec2114af91e5b7f83fc888..6834f7cd3dc60fb2e868651c7dab809990c37305 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 860d0aeb8f5f6d0631854f58a6fa8d4979d7219d..d008063d3c45bcb6549100d67dd4891541830be2 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 d662712533b8bd641b59398ce224119135f2e57f..cefd6c6fba8494ec4d2ce481baaf9f1e385fc12d 100644 (file)
@@ -133,6 +133,9 @@ nv10_emit_frag(GLcontext *ctx, int emit);
 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);
 
index 02a5ca797ae0cce44f6c485871fe37269af7e88f..92148722af719235d57eb879e656b62e33ae8c05 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 db39ef70750cb3b81878631e29abd26bcf428963..99df34716fcaddd06a3af45a309b14a542126e2e 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 18574e9be6413073ecb72fec22706dae1174f7e5..05770b2d6cfd736dd7d8bc793a3255c5281bdf1b 100644 (file)
@@ -67,6 +67,9 @@ void
 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);
 
index 92870105f96beac422c1a74578b04e90ad05cb43..d7ac4c57bce2e75d9fc06a10b38679bee5058619 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)
 {