nvfx: so->RING_3D: vertprog
authorLuca Barbieri <luca@luca-barbieri.com>
Tue, 23 Feb 2010 14:52:24 +0000 (15:52 +0100)
committerLuca Barbieri <luca@luca-barbieri.com>
Mon, 12 Apr 2010 10:13:23 +0000 (12:13 +0200)
We could use an sb here instead, but there is no obvious performance
advantage, and perhaps there could be a disadvantage.

src/gallium/drivers/nvfx/nvfx_state.h
src/gallium/drivers/nvfx/nvfx_vertprog.c

index f1f9fb775b80bf1a926798045d20b651d78f27b6..555513a6428b135b310860696dd13a643bf5b9dd 100644 (file)
@@ -39,7 +39,6 @@ struct nvfx_vertex_program {
        uint32_t ir;
        uint32_t or;
        uint32_t clip_ctrl;
-       struct nouveau_stateobj *so;
 };
 
 struct nvfx_fragment_program_data {
index 78ba10c31c5fd7b1f0d01d4050f8b5b5167a7497..3d25ab761a3f0c35711248140bb0783469b2182f 100644 (file)
@@ -847,6 +847,7 @@ nvfx_vertprog_validate(struct nvfx_context *nvfx)
                vp = nvfx->vertprog;
                constbuf = nvfx->constbuf[PIPE_SHADER_VERTEX];
 
+               // TODO: ouch! can't we just use constant slots for these?!
                if ((nvfx->dirty & NVFX_NEW_UCP) ||
                    memcmp(&nvfx->clip, &vp->ucp, sizeof(vp->ucp))) {
                        nvfx_vertprog_destroy(nvfx, vp);
@@ -858,21 +859,19 @@ nvfx_vertprog_validate(struct nvfx_context *nvfx)
        }
 
        /* Translate TGSI shader into hw bytecode */
-       if (vp->translated)
-               goto check_gpu_resources;
-
-       nvfx->fallback_swtnl &= ~NVFX_NEW_VERTPROG;
+       if (!vp->translated)
+       {
+               nvfx->fallback_swtnl &= ~NVFX_NEW_VERTPROG;
                nvfx_vertprog_translate(nvfx, vp);
-       if (!vp->translated) {
-               nvfx->fallback_swtnl |= NVFX_NEW_VERTPROG;
+               if (!vp->translated) {
+                       nvfx->fallback_swtnl |= NVFX_NEW_VERTPROG;
                        return FALSE;
+               }
        }
 
-check_gpu_resources:
        /* Allocate hw vtxprog exec slots */
        if (!vp->exec) {
                struct nouveau_resource *heap = nvfx->screen->vp_exec_heap;
-               struct nouveau_stateobj *so;
                uint vplen = vp->nr_insns;
 
                if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) {
@@ -887,19 +886,6 @@ check_gpu_resources:
                                assert(0);
                }
 
-               so = so_new(3, 4, 0);
-               so_method(so, eng3d, NV34TCL_VP_START_FROM_ID, 1);
-               so_data  (so, vp->exec->start);
-               if(nvfx->is_nv4x) {
-                       so_method(so, eng3d, NV40TCL_VP_ATTRIB_EN, 2);
-                       so_data  (so, vp->ir);
-                       so_data  (so, vp->or);
-               }
-               so_method(so, eng3d,  NV34TCL_VP_CLIP_PLANES_ENABLE, 1);
-               so_data  (so, vp->clip_ctrl);
-               so_ref(so, &vp->so);
-               so_ref(NULL, &so);
-
                upload_code = TRUE;
        }
 
@@ -1007,9 +993,18 @@ check_gpu_resources:
                }
        }
 
-       if (vp->so != nvfx->state.hw[NVFX_STATE_VERTPROG]) {
-               so_ref(vp->so, &nvfx->state.hw[NVFX_STATE_VERTPROG]);
-               return TRUE;
+       if(nvfx->dirty & (NVFX_NEW_VERTPROG | NVFX_NEW_UCP))
+       {
+               WAIT_RING(chan, 7);
+               OUT_RING(chan, RING_3D(NV34TCL_VP_START_FROM_ID, 1));
+               OUT_RING(chan, vp->exec->start);
+               if(nvfx->is_nv4x) {
+                       OUT_RING(chan, RING_3D(NV40TCL_VP_ATTRIB_EN, 2));
+                       OUT_RING(chan, vp->ir);
+                       OUT_RING(chan, vp->or);
+               }
+               OUT_RING(chan, RING_3D(NV34TCL_VP_CLIP_PLANES_ENABLE, 1));
+               OUT_RING(chan, vp->clip_ctrl);
        }
 
        return FALSE;
@@ -1039,13 +1034,11 @@ nvfx_vertprog_destroy(struct nvfx_context *nvfx, struct nvfx_vertex_program *vp)
        vp->data_start_min = 0;
 
        vp->ir = vp->or = vp->clip_ctrl = 0;
-       so_ref(NULL, &vp->so);
 }
 
 struct nvfx_state_entry nvfx_state_vertprog = {
        .validate = nvfx_vertprog_validate,
        .dirty = {
                .pipe = NVFX_NEW_VERTPROG | NVFX_NEW_UCP,
-               .hw = NVFX_STATE_VERTPROG,
        }
 };