diff options
author | Francisco Jerez <currojerez@riseup.net> | 2010-03-18 14:13:36 +0100 |
---|---|---|
committer | Francisco Jerez <currojerez@riseup.net> | 2010-03-18 15:02:36 +0100 |
commit | 1a812ab57a71d16e45ca44de7ae0570d2bd46674 (patch) | |
tree | ffadc077beccfc043366630e44b3aa4c342e9948 | |
parent | d475eae50b15646efd83fa7f73ad7f2b40dd5206 (diff) |
dri/nouveau: Implement texture matrices.
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nouveau_state.c | 7 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nouveau_state.h | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv04_context.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv10_context.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv10_driver.h | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv10_state_tex.c | 25 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv20_context.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv20_driver.h | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv20_state_tex.c | 24 |
9 files changed, 78 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c index bc610451b4..603a46ed24 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c @@ -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); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.h b/src/mesa/drivers/dri/nouveau/nouveau_state.h index d01d962c9f..38ac9753c8 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.h @@ -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, diff --git a/src/mesa/drivers/dri/nouveau/nv04_context.c b/src/mesa/drivers/dri/nouveau/nv04_context.c index 3624b3af92..6834f7cd3d 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_context.c +++ b/src/mesa/drivers/dri/nouveau/nv04_context.c @@ -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, diff --git a/src/mesa/drivers/dri/nouveau/nv10_context.c b/src/mesa/drivers/dri/nouveau/nv10_context.c index 860d0aeb8f..d008063d3c 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_context.c +++ b/src/mesa/drivers/dri/nouveau/nv10_context.c @@ -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, diff --git a/src/mesa/drivers/dri/nouveau/nv10_driver.h b/src/mesa/drivers/dri/nouveau/nv10_driver.h index d662712533..cefd6c6fba 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_driver.h +++ b/src/mesa/drivers/dri/nouveau/nv10_driver.h @@ -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 */ diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c index 02a5ca797a..92148722af 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c @@ -32,11 +32,36 @@ #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) { diff --git a/src/mesa/drivers/dri/nouveau/nv20_context.c b/src/mesa/drivers/dri/nouveau/nv20_context.c index db39ef7075..99df34716f 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_context.c +++ b/src/mesa/drivers/dri/nouveau/nv20_context.c @@ -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, diff --git a/src/mesa/drivers/dri/nouveau/nv20_driver.h b/src/mesa/drivers/dri/nouveau/nv20_driver.h index 18574e9be6..05770b2d6c 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_driver.h +++ b/src/mesa/drivers/dri/nouveau/nv20_driver.h @@ -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 diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c index 92870105f9..d7ac4c57bc 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c @@ -32,6 +32,30 @@ #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) { |