nouveau: make stateobjs start off with refcount of 1
authorBen Skeggs <bskeggs@redhat.com>
Sat, 7 Mar 2009 07:14:24 +0000 (17:14 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Sat, 7 Mar 2009 07:49:09 +0000 (17:49 +1000)
26 files changed:
src/gallium/drivers/nouveau/nouveau_stateobj.h
src/gallium/drivers/nv30/nv30_fragprog.c
src/gallium/drivers/nv30/nv30_fragtex.c
src/gallium/drivers/nv30/nv30_state.c
src/gallium/drivers/nv30/nv30_state_blend.c
src/gallium/drivers/nv30/nv30_state_fb.c
src/gallium/drivers/nv30/nv30_state_scissor.c
src/gallium/drivers/nv30/nv30_state_stipple.c
src/gallium/drivers/nv30/nv30_state_viewport.c
src/gallium/drivers/nv30/nv30_vbo.c
src/gallium/drivers/nv30/nv30_vertprog.c
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_viewport.c
src/gallium/drivers/nv40/nv40_vbo.c
src/gallium/drivers/nv40/nv40_vertprog.c
src/gallium/drivers/nv50/nv50_program.c
src/gallium/drivers/nv50/nv50_screen.c
src/gallium/drivers/nv50/nv50_state.c
src/gallium/drivers/nv50/nv50_state_validate.c
src/gallium/drivers/nv50/nv50_tex.c
src/gallium/drivers/nv50/nv50_vbo.c

index 666e061..9785911 100644 (file)
@@ -32,7 +32,7 @@ so_new(unsigned push, unsigned reloc)
        struct nouveau_stateobj *so;
 
        so = MALLOC(sizeof(struct nouveau_stateobj));
-       pipe_reference_init(&so->reference, 0);
+       pipe_reference_init(&so->reference, 1);
        so->push = MALLOC(sizeof(unsigned) * push);
        so->reloc = MALLOC(sizeof(struct nouveau_stateobj_reloc) * reloc);
 
index 0da392f..bdfe142 100644 (file)
@@ -865,6 +865,7 @@ nv30_fragprog_validate(struct nv30_context *nv30)
        so_method(so, nv30->screen->rankine, NV34TCL_TX_UNITS_ENABLE, 1);
        so_data  (so, fp->samplers);
        so_ref(so, &fp->so);
+       so_ref(NULL, &so);
 
 update_constants:
        if (fp->nr_consts) {
index b1d2663..8b6ab99 100644 (file)
@@ -137,6 +137,7 @@ nv30_fragtex_validate(struct nv30_context *nv30)
                so_method(so, nv30->screen->rankine, NV34TCL_TX_ENABLE(unit), 1);
                so_data  (so, 0);
                so_ref(so, &nv30->state.hw[NV30_STATE_FRAGTEX0 + unit]);
+               so_ref(NULL, &so);
                state->dirty |= (1ULL << (NV30_STATE_FRAGTEX0 + unit));
        }
 
@@ -147,6 +148,7 @@ nv30_fragtex_validate(struct nv30_context *nv30)
 
                so = nv30_fragtex_build(nv30, unit);
                so_ref(so, &nv30->state.hw[NV30_STATE_FRAGTEX0 + unit]);
+               so_ref(NULL, &so);
                state->dirty |= (1ULL << (NV30_STATE_FRAGTEX0 + unit));
        }
 
index 2614756..b91e972 100644 (file)
@@ -51,6 +51,7 @@ nv30_blend_state_create(struct pipe_context *pipe,
        so_data  (so, cso->dither ? 1 : 0);
 
        so_ref(so, &bso->so);
+       so_ref(NULL, &so);
        bso->pipe = *cso;
        return (void *)bso;
 }
@@ -404,6 +405,7 @@ nv30_rasterizer_state_create(struct pipe_context *pipe,
        }
 
        so_ref(so, &rsso->so);
+       so_ref(NULL, &so);
        rsso->pipe = *cso;
        return (void *)rsso;
 }
@@ -477,6 +479,7 @@ nv30_depth_stencil_alpha_state_create(struct pipe_context *pipe,
        }
 
        so_ref(so, &zsaso->so);
+       so_ref(NULL, &so);
        zsaso->pipe = *cso;
        return (void *)zsaso;
 }
index 44d43e1..64cf9ae 100644 (file)
@@ -28,6 +28,7 @@ nv30_state_blend_colour_validate(struct nv30_context *nv30)
                       (float_to_ubyte(bcol->color[2]) <<  0)));
 
        so_ref(so, &nv30->state.hw[NV30_STATE_BCOL]);
+       so_ref(NULL, &so);
        return TRUE;
 }
 
index ee03260..fdc1cad 100644 (file)
@@ -132,6 +132,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
        so_data  (so, 0);
 
        so_ref(so, &nv30->state.hw[NV30_STATE_FB]);
+       so_ref(NULL, &so);
        return TRUE;
 }
 
index 1db9bc1..3ac7a84 100644 (file)
@@ -23,6 +23,7 @@ nv30_state_scissor_validate(struct nv30_context *nv30)
        }
 
        so_ref(so, &nv30->state.hw[NV30_STATE_SCISSOR]);
+       so_ref(NULL, &so);
        return TRUE;
 }
 
index 41b4281..d0c791a 100644 (file)
@@ -27,6 +27,7 @@ nv30_state_stipple_validate(struct nv30_context *nv30)
        }
 
        so_ref(so, &nv30->state.hw[NV30_STATE_STIPPLE]);
+       so_ref(NULL, &so);
        return TRUE;
 }
 
index 951d40e..4b8300d 100644 (file)
@@ -58,6 +58,7 @@ nv30_state_viewport_validate(struct nv30_context *nv30)
        so_data  (so, 1);
 
        so_ref(so, &nv30->state.hw[NV30_STATE_VIEWPORT]);
+       so_ref(NULL, &so);
        return TRUE;
 }
 
index 2d6d48a..990a876 100644 (file)
@@ -539,10 +539,13 @@ nv30_vbo_validate(struct nv30_context *nv30)
        so_data  (vtxbuf, 0);
 
        so_ref(vtxbuf, &nv30->state.hw[NV30_STATE_VTXBUF]);
+       so_ref(NULL, &vtxbuf);
        nv30->state.dirty |= (1ULL << NV30_STATE_VTXBUF);
        so_ref(vtxfmt, &nv30->state.hw[NV30_STATE_VTXFMT]);
+       so_ref(NULL, &vtxfmt);
        nv30->state.dirty |= (1ULL << NV30_STATE_VTXFMT);
        so_ref(sattr, &nv30->state.hw[NV30_STATE_VTXATTR]);
+       so_ref(NULL, &sattr);
        nv30->state.dirty |= (1ULL << NV30_STATE_VTXATTR);
        return FALSE;
 }
index d262725..eaf543b 100644 (file)
@@ -685,6 +685,7 @@ nv30_vertprog_validate(struct nv30_context *nv30)
                so_method(so, rankine, NV34TCL_VP_START_FROM_ID, 1);
                so_data  (so, vp->exec->start);
                so_ref(so, &vp->so);
+               so_ref(NULL, &so);
 
                upload_code = TRUE;
        }
index 1031e87..16e4088 100644 (file)
@@ -944,6 +944,7 @@ nv40_fragprog_validate(struct nv40_context *nv40)
        so_method(so, nv40->screen->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 0227d22..eb3002d 100644 (file)
@@ -151,6 +151,7 @@ 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 |= (1ULL << (NV40_STATE_FRAGTEX0 + unit));
        }
 
index 2eff25a..c3ee4d2 100644 (file)
@@ -52,6 +52,7 @@ nv40_blend_state_create(struct pipe_context *pipe,
        so_data  (so, cso->dither ? 1 : 0);
 
        so_ref(so, &bso->so);
+       so_ref(NULL, &so);
        bso->pipe = *cso;
        return (void *)bso;
 }
@@ -414,6 +415,7 @@ nv40_rasterizer_state_create(struct pipe_context *pipe,
        }
 
        so_ref(so, &rsso->so);
+       so_ref(NULL, &so);
        rsso->pipe = *cso;
        return (void *)rsso;
 }
@@ -487,6 +489,7 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe,
        }
 
        so_ref(so, &zsaso->so);
+       so_ref(NULL, &so);
        zsaso->pipe = *cso;
        return (void *)zsaso;
 }
index 95e6d73..8cd05ce 100644 (file)
@@ -28,6 +28,7 @@ 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 5ebd3a1..be618a3 100644 (file)
@@ -150,6 +150,7 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
        so_data  (so, (1 << 12) | h);
 
        so_ref(so, &nv40->state.hw[NV40_STATE_FB]);
+       so_ref(NULL, &so);
        return TRUE;
 }
 
index 285239e..cf58d33 100644 (file)
@@ -23,6 +23,7 @@ nv40_state_scissor_validate(struct nv40_context *nv40)
        }
 
        so_ref(so, &nv40->state.hw[NV40_STATE_SCISSOR]);
+       so_ref(NULL, &so);
        return TRUE;
 }
 
index 869a55b..3d14d20 100644 (file)
@@ -55,6 +55,7 @@ nv40_state_viewport_validate(struct nv40_context *nv40)
        }
 
        so_ref(so, &nv40->state.hw[NV40_STATE_VIEWPORT]);
+       so_ref(NULL, &so);
        return TRUE;
 }
 
index 8f18346..f3518b2 100644 (file)
@@ -537,10 +537,13 @@ nv40_vbo_validate(struct nv40_context *nv40)
        so_data  (vtxbuf, 0);
 
        so_ref(vtxbuf, &nv40->state.hw[NV40_STATE_VTXBUF]);
+       so_ref(NULL, &vtxbuf);
        nv40->state.dirty |= (1ULL << NV40_STATE_VTXBUF);
        so_ref(vtxfmt, &nv40->state.hw[NV40_STATE_VTXFMT]);
+       so_ref(NULL, &vtxfmt);
        nv40->state.dirty |= (1ULL << NV40_STATE_VTXFMT);
        so_ref(sattr, &nv40->state.hw[NV40_STATE_VTXATTR]);
+       so_ref(NULL, &sattr);
        nv40->state.dirty |= (1ULL << NV40_STATE_VTXATTR);
        return FALSE;
 }
index 0862386..7df9a4d 100644 (file)
@@ -916,6 +916,7 @@ check_gpu_resources:
                so_method(so, curie,  NV40TCL_CLIP_PLANE_ENABLE, 1);
                so_data  (so, vp->clip_ctrl);
                so_ref(so, &vp->so);
+               so_ref(NULL, &so);
 
                upload_code = TRUE;
        }
index 308eb34..2d15868 100644 (file)
@@ -1719,6 +1719,7 @@ nv50_vertprog_validate(struct nv50_context *nv50)
        so_method(so, tesla, 0x140c, 1);
        so_data  (so, 0); /* program start offset */
        so_ref(so, &nv50->state.vertprog);
+       so_ref(NULL, &so);
 }
 
 void
@@ -1758,6 +1759,7 @@ nv50_fragprog_validate(struct nv50_context *nv50)
        so_method(so, tesla, 0x1414, 1);
        so_data  (so, 0); /* program start offset */
        so_ref(so, &nv50->state.fragprog);
+       so_ref(NULL, &so);
 }
 
 void
index 9bf5e8c..d0348ec 100644 (file)
@@ -366,7 +366,8 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
        so_data  (so, 1);
 
        so_emit(nvws, so);
-       so_ref(so, &screen->static_init);
+       so_ref (so, &screen->static_init);
+       so_ref (NULL, &so);
        nvws->push_flush(nvws, 0, NULL);
 
        return &screen->pipe;
index 787ff95..ba85219 100644 (file)
@@ -85,6 +85,7 @@ nv50_blend_state_create(struct pipe_context *pipe,
 
        bso->pipe = *cso;
        so_ref(so, &bso->so);
+       so_ref(NULL, &so);
        return (void *)bso;
 }
 
@@ -352,6 +353,7 @@ nv50_rasterizer_state_create(struct pipe_context *pipe,
 
        rso->pipe = *cso;
        so_ref(so, &rso->so);
+       so_ref(NULL, &so);
        return (void *)rso;
 }
 
@@ -438,6 +440,7 @@ nv50_depth_stencil_alpha_state_create(struct pipe_context *pipe,
 
        zsa->pipe = *cso;
        so_ref(so, &zsa->so);
+       so_ref(NULL, &so);
        return (void *)zsa;
 }
 
index 948112f..b7958f1 100644 (file)
@@ -124,6 +124,7 @@ nv50_state_validate_fb(struct nv50_context *nv50)
        so_data  (so, h);
 
        so_ref(so, &nv50->state.fb);
+       so_ref(NULL, &so);
 }
 
 static void
@@ -214,6 +215,7 @@ nv50_state_validate(struct nv50_context *nv50)
                so_data  (so, fui(nv50->blend_colour.color[2]));
                so_data  (so, fui(nv50->blend_colour.color[3]));
                so_ref(so, &nv50->state.blend_colour);
+               so_ref(NULL, &so);
        }
 
        if (nv50->dirty & NV50_NEW_STIPPLE) {
@@ -222,6 +224,7 @@ nv50_state_validate(struct nv50_context *nv50)
                for (i = 0; i < 32; i++)
                        so_data(so, nv50->stipple.stipple[i]);
                so_ref(so, &nv50->state.stipple);
+               so_ref(NULL, &so);
        }
 
        if (nv50->dirty & (NV50_NEW_SCISSOR | NV50_NEW_RASTERIZER)) {
@@ -243,6 +246,7 @@ nv50_state_validate(struct nv50_context *nv50)
                        so_data(so, (8192 << 16));
                }
                so_ref(so, &nv50->state.scissor);
+               so_ref(NULL, &so);
                nv50->state.dirty |= NV50_NEW_SCISSOR;
        }
 scissor_uptodate:
@@ -283,6 +287,7 @@ scissor_uptodate:
                }
 
                so_ref(so, &nv50->state.viewport);
+               so_ref(NULL, &so);
        }
 viewport_uptodate:
 
@@ -296,6 +301,7 @@ viewport_uptodate:
                for (i = 0; i < nv50->sampler_nr; i++)
                        so_datap (so, nv50->sampler[i], 8);
                so_ref(so, &nv50->state.tsc_upload);
+               so_ref(NULL, &so);
        }
 
        if (nv50->dirty & NV50_NEW_TEXTURE)
index 31bf596..223c8a3 100644 (file)
@@ -152,5 +152,6 @@ nv50_tex_validate(struct nv50_context *nv50)
        }
 
        so_ref(so, &nv50->state.tic_upload);
+       so_ref(NULL, &so);
 }
 
index 08d751d..0749c90 100644 (file)
@@ -250,5 +250,7 @@ nv50_vbo_validate(struct nv50_context *nv50)
 
        so_ref (vtxfmt, &nv50->state.vtxfmt);
        so_ref (vtxbuf, &nv50->state.vtxbuf);
+       so_ref (NULL, &vtxbuf);
+       so_ref (NULL, &vtxfmt);
 }