nv40: stateobj start out with 0 refcount
authorBen Skeggs <darktama@beleth.(none)>
Fri, 22 Feb 2008 03:46:48 +0000 (14:46 +1100)
committerBen Skeggs <darktama@beleth.(none)>
Fri, 22 Feb 2008 03:46:48 +0000 (14:46 +1100)
src/gallium/drivers/nouveau/nouveau_stateobj.h
src/gallium/drivers/nv40/nv40_fragprog.c
src/gallium/drivers/nv40/nv40_fragtex.c
src/gallium/drivers/nv40/nv40_state.c
src/gallium/drivers/nv40/nv40_state_blend.c
src/gallium/drivers/nv40/nv40_state_fb.c
src/gallium/drivers/nv40/nv40_state_scissor.c
src/gallium/drivers/nv40/nv40_state_stipple.c
src/gallium/drivers/nv40/nv40_state_viewport.c
src/gallium/drivers/nv40/nv40_vbo.c
src/gallium/drivers/nv40/nv40_vertprog.c

index 459cc7d..439c7e4 100644 (file)
@@ -32,7 +32,7 @@ so_new(unsigned push, unsigned reloc)
        struct nouveau_stateobj *so;
 
        so = MALLOC(sizeof(struct nouveau_stateobj));
-       so->refcount = 1;
+       so->refcount = 0;
        so->push = MALLOC(sizeof(unsigned) * push);
        so->reloc = MALLOC(sizeof(struct nouveau_stateobj_reloc) * reloc);
 
index db2613e..a4a1ea0 100644 (file)
@@ -817,7 +817,6 @@ nv40_fragprog_validate(struct nv40_context *nv40)
        so_method(so, nv40->hw->curie, NV40TCL_FP_CONTROL, 1);
        so_data  (so, fp->fp_control);
        so_ref(so, &fp->so);
-       so_ref(NULL, &so);
 
 update_constants:
        if (fp->nr_consts) {
index 3d27a9b..c8a8120 100644 (file)
@@ -137,7 +137,6 @@ nv40_fragtex_validate(struct nv40_context *nv40)
                so_method(so, nv40->hw->curie, NV40TCL_TEX_ENABLE(unit), 1);
                so_data  (so, 0);
                so_ref(so, &nv40->state.hw[NV40_STATE_FRAGTEX0 + unit]);
-               so_ref(NULL, &so);
                state->dirty |= (1 << (NV40_STATE_FRAGTEX0 + unit));
        }
 
@@ -148,7 +147,6 @@ 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);
                state->dirty |= (1 << (NV40_STATE_FRAGTEX0 + unit));
        }
 
index 74cbabb..107e60f 100644 (file)
@@ -11,7 +11,7 @@ nv40_blend_state_create(struct pipe_context *pipe,
 {
        struct nv40_context *nv40 = nv40_context(pipe);
        struct nouveau_grobj *curie = nv40->hw->curie;
-       struct nv40_blend_state *bso = MALLOC(sizeof(*bso));
+       struct nv40_blend_state *bso = CALLOC(1, sizeof(*bso));
        struct nouveau_stateobj *so = so_new(16, 0);
 
        if (cso->blend_enable) {
@@ -47,7 +47,7 @@ nv40_blend_state_create(struct pipe_context *pipe,
        so_method(so, curie, NV40TCL_DITHER_ENABLE, 1);
        so_data  (so, cso->dither ? 1 : 0);
 
-       bso->so = so;
+       so_ref(so, &bso->so);
        bso->pipe = *cso;
        return (void *)bso;
 }
@@ -284,7 +284,7 @@ nv40_rasterizer_state_create(struct pipe_context *pipe,
                             const struct pipe_rasterizer_state *cso)
 {
        struct nv40_context *nv40 = nv40_context(pipe);
-       struct nv40_rasterizer_state *rsso = MALLOC(sizeof(*rsso));
+       struct nv40_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso));
        struct nouveau_stateobj *so = so_new(32, 0);
        struct nouveau_grobj *curie = nv40->hw->curie;
 
@@ -389,7 +389,7 @@ nv40_rasterizer_state_create(struct pipe_context *pipe,
                so_data(so, 0);
        }
 
-       rsso->so = so;
+       so_ref(so, &rsso->so);
        rsso->pipe = *cso;
        return (void *)rsso;
 }
@@ -417,7 +417,7 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe,
                        const struct pipe_depth_stencil_alpha_state *cso)
 {
        struct nv40_context *nv40 = nv40_context(pipe);
-       struct nv40_zsa_state *zsaso = MALLOC(sizeof(*zsaso));
+       struct nv40_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso));
        struct nouveau_stateobj *so = so_new(32, 0);
 
        so_method(so, nv40->hw->curie, NV40TCL_DEPTH_FUNC, 3);
@@ -460,7 +460,7 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe,
                so_data  (so, 0);
        }
 
-       zsaso->so = so;
+       so_ref(so, &zsaso->so);
        zsaso->pipe = *cso;
        return (void *)zsaso;
 }
index b12f8b0..81b927a 100644 (file)
@@ -28,7 +28,6 @@ nv40_state_blend_colour_validate(struct nv40_context *nv40)
                       (float_to_ubyte(bcol->color[2]) <<  0)));
 
        so_ref(so, &nv40->state.hw[NV40_STATE_BCOL]);
-       so_ref(NULL, &so);
        return TRUE;
 }
 
index d3032f1..c3bf4d4 100644 (file)
@@ -143,7 +143,6 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
        so_data  (so, ((h - 1) << 16) | 0);
 
        so_ref(so, &nv40->state.hw[NV40_STATE_FB]);
-       so_ref(NULL, &so);
        return TRUE;
 }
 
index 2871fa2..ee79709 100644 (file)
@@ -22,7 +22,6 @@ nv40_state_scissor_validate(struct nv40_context *nv40)
        }
 
        so_ref(so, &nv40->state.hw[NV40_STATE_SCISSOR]);
-       so_ref(NULL, &so);
        return TRUE;
 }
 
index bd16358..aad4d17 100644 (file)
@@ -27,7 +27,6 @@ nv40_state_stipple_validate(struct nv40_context *nv40)
        }
 
        so_ref(so, &nv40->state.hw[NV40_STATE_STIPPLE]);
-       so_ref(NULL, &so);
        return TRUE;
 }
 
index 79fcc31..68820d3 100644 (file)
@@ -17,7 +17,6 @@ nv40_state_viewport_validate(struct nv40_context *nv40)
        so_data  (so, fui(vpt->scale[3]));
 
        so_ref(so, &nv40->state.hw[NV40_STATE_VIEWPORT]);
-       so_ref(NULL, &so);
        return TRUE;
 }
 
index 3bfcb26..5abe4c9 100644 (file)
@@ -159,7 +159,6 @@ nv40_vbo_arrays_update(struct nv40_context *nv40, struct pipe_buffer *ib,
        so_emit(nv40->nvws, vtxfmt);
        so_emit(nv40->nvws, vtxbuf);
        so_ref (vtxbuf, &nv40->so_vtxbuf);
-       so_ref (NULL, &vtxbuf);
        so_ref (NULL, &vtxfmt);
 }
 
index 8a2d233..c482964 100644 (file)
@@ -678,7 +678,6 @@ check_gpu_resources:
                so_data  (so, vp->ir);
                so_data  (so, vp->or);
                so_ref(so, &vp->so);
-               so_ref(NULL, &so);
 
                upload_code = TRUE;
        }