nv40: move hw_dirty
authorBen Skeggs <darktama@beleth.(none)>
Fri, 22 Feb 2008 02:55:18 +0000 (13:55 +1100)
committerBen Skeggs <darktama@beleth.(none)>
Fri, 22 Feb 2008 02:55:18 +0000 (13:55 +1100)
src/gallium/drivers/nv40/nv40_context.h
src/gallium/drivers/nv40/nv40_fragtex.c
src/gallium/drivers/nv40/nv40_state_emit.c

index cbc798fbd6eefe6c31adb1a64939861495275ac7..c533b9e0ef9d2e467206e46ac5b0a4f449640e2e 100644 (file)
@@ -115,7 +115,9 @@ struct nv40_blend_state {
 struct nv40_state {
        unsigned scissor_enabled;
        unsigned stipple_enabled;
+       unsigned fp_samplers;
 
+       unsigned dirty;
        struct nouveau_stateobj *hw[NV40_STATE_MAX];
 };
 
@@ -129,13 +131,10 @@ struct nv40_context {
        int chipset;
 
        unsigned dirty;
-       unsigned hw_dirty;
 
        struct nv40_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
        struct nv40_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
        unsigned dirty_samplers;
-       unsigned fp_samplers;
-       unsigned vp_samplers;
 
        struct {
                struct pipe_scissor_state scissor;
index 826d4a9478a9dfb973948bfb95c646db5eac5438..3d27a9bf13444af467ec1abcdc91943a98b8ab65 100644 (file)
@@ -124,10 +124,11 @@ static boolean
 nv40_fragtex_validate(struct nv40_context *nv40)
 {
        struct nv40_fragment_program *fp = nv40->pipe_state.fragprog;
+       struct nv40_state *state = &nv40->state;
        struct nouveau_stateobj *so;
        unsigned samplers, unit;
 
-       samplers = nv40->fp_samplers & ~fp->samplers;
+       samplers = state->fp_samplers & ~fp->samplers;
        while (samplers) {
                unit = ffs(samplers) - 1;
                samplers &= ~(1 << unit);
@@ -137,7 +138,7 @@ nv40_fragtex_validate(struct nv40_context *nv40)
                so_data  (so, 0);
                so_ref(so, &nv40->state.hw[NV40_STATE_FRAGTEX0 + unit]);
                so_ref(NULL, &so);
-               nv40->hw_dirty |= (1 << (NV40_STATE_FRAGTEX0 + unit));
+               state->dirty |= (1 << (NV40_STATE_FRAGTEX0 + unit));
        }
 
        samplers = nv40->dirty_samplers & fp->samplers;
@@ -148,10 +149,10 @@ nv40_fragtex_validate(struct nv40_context *nv40)
                so = nv40_fragtex_build(nv40, unit);
                so_ref(so, &nv40->state.hw[NV40_STATE_FRAGTEX0 + unit]);
                so_ref(NULL, &so);
-               nv40->hw_dirty |= (1 << (NV40_STATE_FRAGTEX0 + unit));
+               state->dirty |= (1 << (NV40_STATE_FRAGTEX0 + unit));
        }
 
-       nv40->fp_samplers = fp->samplers;
+       nv40->state.fp_samplers = fp->samplers;
        return FALSE;
 }
 
index 6d87b7b52b2583ee384eb72417f6350111e23e3c..af09ed47d6e354f6c1c91f4fd7cb42f4a2987aee 100644 (file)
@@ -31,7 +31,7 @@ nv40_state_validate(struct nv40_context *nv40)
 
                if (nv40->dirty & e->dirty.pipe) {
                        if (e->validate(nv40))
-                               nv40->hw_dirty |= (1 << e->dirty.hw);
+                               nv40->state.dirty |= (1 << e->dirty.hw);
                }
 
                states++;
@@ -60,24 +60,24 @@ nv40_state_validate(struct nv40_context *nv40)
 static void
 nv40_state_emit(struct nv40_context *nv40)
 {
-       unsigned i;
+       struct nv40_state *state = &nv40->state;
+       unsigned i, samplers;
 
-       while (nv40->hw_dirty) {
-               unsigned idx = ffs(nv40->hw_dirty) - 1;
-               nv40->hw_dirty &= ~(1 << idx);
+       while (state->dirty) {
+               unsigned idx = ffs(state->dirty) - 1;
 
-               so_ref (nv40->state.hw[idx], &nv40->hw->state[idx]);
+               so_ref (state->hw[idx], &nv40->hw->state[idx]);
                so_emit(nv40->nvws, nv40->hw->state[idx]);
+               state->dirty &= ~(1 << idx);
        }
 
-       so_emit_reloc_markers(nv40->nvws, nv40->state.hw[NV40_STATE_FB]);
-       for (i = 0; i < 16; i++) {
-               if (!(nv40->fp_samplers & (1 << i)))
-                       continue;
+       so_emit_reloc_markers(nv40->nvws, state->hw[NV40_STATE_FB]);
+       for (i = 0, samplers = state->fp_samplers; i < 16 && samplers; i++) {
                so_emit_reloc_markers(nv40->nvws,
-                                     nv40->state.hw[NV40_STATE_FRAGTEX0+i]);
+                                     state->hw[NV40_STATE_FRAGTEX0+i]);
+               samplers &= ~(1 << i);
        }
-       so_emit_reloc_markers(nv40->nvws, nv40->state.hw[NV40_STATE_FRAGPROG]);
+       so_emit_reloc_markers(nv40->nvws, state->hw[NV40_STATE_FRAGPROG]);
 }
 
 void