nv40: move some things around
authorBen Skeggs <skeggsb@gmail.com>
Mon, 18 Feb 2008 05:38:27 +0000 (16:38 +1100)
committerBen Skeggs <skeggsb@gmail.com>
Mon, 18 Feb 2008 05:38:27 +0000 (16:38 +1100)
src/gallium/drivers/nv40/Makefile
src/gallium/drivers/nv40/nv40_context.h
src/gallium/drivers/nv40/nv40_state_clip.c [new file with mode: 0644]
src/gallium/drivers/nv40/nv40_state_emit.c
src/gallium/drivers/nv40/nv40_state_scissor.c [new file with mode: 0644]
src/gallium/drivers/nv40/nv40_state_stipple.c [new file with mode: 0644]

index 2a9de4a2dcb7f0367daa34342c1c75111c1d41c5..12b8eef2590dca138e20fd2c170ec28dd82f6072 100644 (file)
@@ -13,6 +13,9 @@ DRIVER_SOURCES = \
        nv40_query.c \
        nv40_state.c \
        nv40_state_emit.c \
+       nv40_state_clip.c \
+       nv40_state_scissor.c \
+       nv40_state_stipple.c \
        nv40_surface.c \
        nv40_vbo.c \
        nv40_vertprog.c
index e9ed7ea3fb482ca4a08a3d45c573fed534c48e58..432204b825270b3d27fedf9a0d35dc28bc6bcaab 100644 (file)
@@ -174,6 +174,9 @@ extern void nv40_fragtex_bind(struct nv40_context *);
 /* nv40_state.c and friends */
 extern void nv40_emit_hw_state(struct nv40_context *nv40);
 extern void nv40_state_tex_update(struct nv40_context *nv40);
+extern struct nv40_state_entry nv40_state_clip;
+extern struct nv40_state_entry nv40_state_scissor;
+extern struct nv40_state_entry nv40_state_stipple;
 
 /* nv40_vbo.c */
 extern boolean nv40_draw_arrays(struct pipe_context *, unsigned mode,
diff --git a/src/gallium/drivers/nv40/nv40_state_clip.c b/src/gallium/drivers/nv40/nv40_state_clip.c
new file mode 100644 (file)
index 0000000..19f1c3b
--- /dev/null
@@ -0,0 +1,18 @@
+#include "nv40_context.h"
+
+static boolean
+nv40_state_clip_validate(struct nv40_context *nv40)
+{
+       if (nv40->pipe_state.clip.nr)
+               nv40->fallback |= NV40_FALLBACK_TNL;
+
+       return FALSE;
+}
+
+struct nv40_state_entry nv40_state_clip = {
+       .validate = nv40_state_clip_validate,
+       .dirty = {
+               .pipe = NV40_NEW_UCP,
+               .hw = 0
+       }
+};
index ce52a3863e7ff869c07d92c7af9e4d2e51910f76..b5d0d68d6b167ca93941abee796e606f86f418df 100644 (file)
@@ -22,63 +22,6 @@ nv40_state_emit_dummy_relocs(struct nv40_context *nv40)
        so_emit_reloc_markers(nv40->nvws, nv40->fragprog.active->so);
 }
 
-static boolean
-nv40_state_scissor_validate(struct nv40_context *nv40)
-{
-       struct pipe_rasterizer_state *rast = &nv40->rasterizer->pipe;
-       struct pipe_scissor_state *s = &nv40->pipe_state.scissor;
-       struct nouveau_stateobj *so;
-
-       if (nv40->state.scissor.so &&
-           (rast->scissor == 0 && nv40->state.scissor.enabled == 0))
-               return FALSE;
-
-       so = so_new(3, 0);
-       so_method(so, nv40->hw->curie, NV40TCL_SCISSOR_HORIZ, 2);
-       if (rast->scissor) {
-               so_data  (so, ((s->maxx - s->minx) << 16) | s->minx);
-               so_data  (so, ((s->maxy - s->miny) << 16) | s->miny);
-       } else {
-               so_data  (so, 4096 << 16);
-               so_data  (so, 4096 << 16);
-       }
-
-       so_ref(so, &nv40->state.scissor.so);
-       so_ref(NULL, &so);
-       return TRUE;
-}
-
-static boolean
-nv40_state_stipple_validate(struct nv40_context *nv40)
-{
-       struct pipe_rasterizer_state *rast = &nv40->rasterizer->pipe;
-       struct nouveau_grobj *curie = nv40->hw->curie;
-       struct nouveau_stateobj *so;
-
-       if (nv40->state.stipple.so && (rast->poly_stipple_enable == 0 &&
-                                      nv40->state.stipple.enabled == 0))
-               return FALSE;
-
-       if (rast->poly_stipple_enable) {
-               unsigned i;
-
-               so = so_new(35, 0);
-               so_method(so, curie, NV40TCL_POLYGON_STIPPLE_ENABLE, 1);
-               so_data  (so, 1);
-               so_method(so, curie, NV40TCL_POLYGON_STIPPLE_PATTERN(0), 32);
-               for (i = 0; i < 32; i++)
-                       so_data(so, nv40->pipe_state.stipple[i]);
-       } else {
-               so = so_new(2, 0);
-               so_method(so, curie, NV40TCL_POLYGON_STIPPLE_ENABLE, 1);
-               so_data  (so, 0);
-       }
-
-       so_ref(so, &nv40->state.stipple.so);
-       so_ref(NULL, &so);
-       return TRUE;
-}
-
 static boolean
 nv40_state_clip_validate(struct nv40_context *nv40)
 {
@@ -87,43 +30,31 @@ nv40_state_clip_validate(struct nv40_context *nv40)
        return FALSE;
 }
 
-static struct nv40_state_entry states[] = {
-       {
-               .validate = nv40_state_scissor_validate,
-               .dirty = {
-                       .pipe = NV40_NEW_SCISSOR | NV40_NEW_RAST,
-                       .hw = NV40_NEW_SCISSOR,
-               }
-       },
-       {
-               .validate = nv40_state_stipple_validate,
-               .dirty = {
-                       .pipe = NV40_NEW_STIPPLE | NV40_NEW_RAST,
-                       .hw = NV40_NEW_STIPPLE,
-               }
-       },
-       {
-               .validate = nv40_state_clip_validate,
-               .dirty = {
-                       .pipe = NV40_NEW_UCP,
-                       .hw = 0,
-               }
-       }
+static struct nv40_state_entry *render_states[] = {
+       &nv40_state_clip,
+       &nv40_state_scissor,
+       &nv40_state_stipple,
+       NULL
 };
 
 static void
 nv40_state_validate(struct nv40_context *nv40)
 {
-       unsigned i, last_fallback;
+       struct nv40_state_entry **states = render_states;
+       unsigned last_fallback;
 
        last_fallback = nv40->fallback;
        nv40->fallback = 0;
 
-       for (i = 0; i < sizeof(states) / sizeof(states[0]); i++) {
-               if (nv40->dirty & states[i].dirty.pipe) {
-                       if (states[i].validate(nv40))
-                               nv40->hw_dirty |= states[i].dirty.hw;
+       while (*states) {
+               struct nv40_state_entry *e = *states;
+
+               if (nv40->dirty & e->dirty.pipe) {
+                       if (e->validate(nv40))
+                               nv40->hw_dirty |= e->dirty.hw;
                }
+
+               states++;
        }
 
        if (nv40->fallback & NV40_FALLBACK_TNL &&
diff --git a/src/gallium/drivers/nv40/nv40_state_scissor.c b/src/gallium/drivers/nv40/nv40_state_scissor.c
new file mode 100644 (file)
index 0000000..556b820
--- /dev/null
@@ -0,0 +1,35 @@
+#include "nv40_context.h"
+
+static boolean
+nv40_state_scissor_validate(struct nv40_context *nv40)
+{
+       struct pipe_rasterizer_state *rast = &nv40->rasterizer->pipe;
+       struct pipe_scissor_state *s = &nv40->pipe_state.scissor;
+       struct nouveau_stateobj *so;
+
+       if (nv40->state.scissor.so &&
+           (rast->scissor == 0 && nv40->state.scissor.enabled == 0))
+               return FALSE;
+
+       so = so_new(3, 0);
+       so_method(so, nv40->hw->curie, NV40TCL_SCISSOR_HORIZ, 2);
+       if (rast->scissor) {
+               so_data  (so, ((s->maxx - s->minx) << 16) | s->minx);
+               so_data  (so, ((s->maxy - s->miny) << 16) | s->miny);
+       } else {
+               so_data  (so, 4096 << 16);
+               so_data  (so, 4096 << 16);
+       }
+
+       so_ref(so, &nv40->state.scissor.so);
+       so_ref(NULL, &so);
+       return TRUE;
+}
+
+struct nv40_state_entry nv40_state_scissor = {
+       .validate = nv40_state_scissor_validate,
+       .dirty = {
+               .pipe = NV40_NEW_SCISSOR | NV40_NEW_RAST,
+               .hw = NV40_NEW_SCISSOR
+       }
+};
diff --git a/src/gallium/drivers/nv40/nv40_state_stipple.c b/src/gallium/drivers/nv40/nv40_state_stipple.c
new file mode 100644 (file)
index 0000000..52462a0
--- /dev/null
@@ -0,0 +1,40 @@
+#include "nv40_context.h"
+
+static boolean
+nv40_state_stipple_validate(struct nv40_context *nv40)
+{
+       struct pipe_rasterizer_state *rast = &nv40->rasterizer->pipe;
+       struct nouveau_grobj *curie = nv40->hw->curie;
+       struct nouveau_stateobj *so;
+
+       if (nv40->state.stipple.so && (rast->poly_stipple_enable == 0 &&
+                                      nv40->state.stipple.enabled == 0))
+               return FALSE;
+
+       if (rast->poly_stipple_enable) {
+               unsigned i;
+
+               so = so_new(35, 0);
+               so_method(so, curie, NV40TCL_POLYGON_STIPPLE_ENABLE, 1);
+               so_data  (so, 1);
+               so_method(so, curie, NV40TCL_POLYGON_STIPPLE_PATTERN(0), 32);
+               for (i = 0; i < 32; i++)
+                       so_data(so, nv40->pipe_state.stipple[i]);
+       } else {
+               so = so_new(2, 0);
+               so_method(so, curie, NV40TCL_POLYGON_STIPPLE_ENABLE, 1);
+               so_data  (so, 0);
+       }
+
+       so_ref(so, &nv40->state.stipple.so);
+       so_ref(NULL, &so);
+       return TRUE;
+}
+
+struct nv40_state_entry nv40_state_stipple = {
+       .validate = nv40_state_stipple_validate,
+       .dirty = {
+               .pipe = NV40_NEW_STIPPLE | NV40_NEW_RAST,
+               .hw = NV40_NEW_STIPPLE
+       }
+};