nouveau: cleanups + fixes
authorBen Skeggs <skeggsb@gmail.com>
Mon, 18 Feb 2008 07:23:12 +0000 (18:23 +1100)
committerBen Skeggs <skeggsb@gmail.com>
Mon, 18 Feb 2008 07:23:12 +0000 (18:23 +1100)
src/gallium/drivers/nouveau/nouveau_stateobj.h
src/gallium/drivers/nv40/nv40_state_emit.c

index 07c31b014a5bccd99c1d8889792df791a1a3fd2d..459cc7d77ae6d01d4c1e6e3fe4b18f4dcf99c07a 100644 (file)
@@ -45,22 +45,19 @@ so_new(unsigned push, unsigned reloc)
 static INLINE void
 so_ref(struct nouveau_stateobj *ref, struct nouveau_stateobj **pso)
 {
-       struct nouveau_stateobj *so;
-
-       so = *pso;
-       if (so) {
-               if (--so->refcount <= 0) {
-                       free(so->push);
-                       free(so->reloc);
-                       free(so);
-               }
-               *pso = NULL;
-       }
+       struct nouveau_stateobj *so = *pso;
 
        if (ref) {
                ref->refcount++;
-               *pso = ref;
        }
+
+       if (so && --so->refcount <= 0) {
+               free(so->push);
+               free(so->reloc);
+               free(so);
+       }
+
+       *pso = ref;
 }
 
 static INLINE void
index e702b1032363449e9a2f383947feababce8ac8f3..e8230111bb4893e81f15a133af60690bd77b872f 100644 (file)
@@ -103,8 +103,10 @@ nv40_emit_hw_state(struct nv40_context *nv40)
                nv40->hw_dirty &= ~NV40_NEW_STIPPLE;
        }
 
-       if (nv40->hw_dirty & NV40_NEW_FRAGPROG)
+       if (nv40->hw_dirty & NV40_NEW_FRAGPROG) {
                so_emit(nv40->nvws, nv40->state.fragprog);
+               nv40->hw_dirty &= ~NV40_NEW_FRAGPROG;
+       }
 
        if (nv40->dirty_samplers || (nv40->dirty & NV40_NEW_FRAGPROG)) {
                nv40_fragtex_bind(nv40);
@@ -116,9 +118,9 @@ nv40_emit_hw_state(struct nv40_context *nv40)
                nv40->dirty &= ~NV40_NEW_FRAGPROG;
        }
 
-       if (nv40->dirty & NV40_NEW_VERTPROG) {
+       if (nv40->hw_dirty & NV40_NEW_VERTPROG) {
                so_emit(nv40->nvws, nv40->state.vertprog);
-               nv40->dirty &= ~NV40_NEW_VERTPROG;
+               nv40->hw_dirty &= ~NV40_NEW_VERTPROG;
        }
 
        nv40->dirty_samplers = 0;