summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nv30
diff options
context:
space:
mode:
authorLuca Barbieri <luca@luca-barbieri.com>2010-02-21 11:33:15 +0100
committerYounes Manton <younes.m@gmail.com>2010-03-15 00:03:01 -0400
commit778c64da97272e7508dbcdf0bffdb699d1b04ce0 (patch)
treefc28097f5b7b38f0d7c7ffaae8366af6fe4ee526 /src/gallium/drivers/nv30
parentd084d189d03dc89a3161a131f1b386840c06ad61 (diff)
nv30, nv40: non-trivially unify nv[34]0_state_emit.c
The files are the same except for swtnl support on nv40 and for texture cache flushing on nv40. Unify them, and use a macro to define 4 versions of render_states, for all combinations of nvfx and hwtnl/swtnl.
Diffstat (limited to 'src/gallium/drivers/nv30')
-rw-r--r--src/gallium/drivers/nv30/Makefile1
-rw-r--r--src/gallium/drivers/nv30/nv30_context.c2
-rw-r--r--src/gallium/drivers/nv30/nv30_context.h3
-rw-r--r--src/gallium/drivers/nv30/nv30_state_emit.c121
-rw-r--r--src/gallium/drivers/nv30/nv30_vbo.c14
5 files changed, 8 insertions, 133 deletions
diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
index f18295cefc..3067e45062 100644
--- a/src/gallium/drivers/nv30/Makefile
+++ b/src/gallium/drivers/nv30/Makefile
@@ -13,7 +13,6 @@ C_SOURCES = \
nv30_screen.c \
nv30_state.c \
nv30_state_blend.c \
- nv30_state_emit.c \
nv30_state_fb.c \
nv30_state_rasterizer.c \
nv30_state_scissor.c \
diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c
index ee2c465bc6..6fe8cb3e32 100644
--- a/src/gallium/drivers/nv30/nv30_context.c
+++ b/src/gallium/drivers/nv30/nv30_context.c
@@ -69,7 +69,7 @@ nv30_create(struct pipe_screen *pscreen, void *priv)
nvfx->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
screen->base.channel->user_private = nvfx;
- screen->base.channel->flush_notify = nv30_state_flush_notify;
+ screen->base.channel->flush_notify = nvfx_state_flush_notify;
nvfx->is_nv4x = screen->is_nv4x;
diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
index 9f28d49706..a6767da4dc 100644
--- a/src/gallium/drivers/nv30/nv30_context.h
+++ b/src/gallium/drivers/nv30/nv30_context.h
@@ -24,9 +24,6 @@ extern void nv30_fragprog_destroy(struct nvfx_context *,
extern void nv30_fragtex_bind(struct nvfx_context *);
/* nv30_state.c and friends */
-extern boolean nv30_state_validate(struct nvfx_context *nvfx);
-extern void nv30_state_emit(struct nvfx_context *nvfx);
-extern void nv30_state_flush_notify(struct nouveau_channel *chan);
extern struct nvfx_state_entry nv30_state_rasterizer;
extern struct nvfx_state_entry nv30_state_scissor;
extern struct nvfx_state_entry nv30_state_stipple;
diff --git a/src/gallium/drivers/nv30/nv30_state_emit.c b/src/gallium/drivers/nv30/nv30_state_emit.c
deleted file mode 100644
index 6df93618da..0000000000
--- a/src/gallium/drivers/nv30/nv30_state_emit.c
+++ /dev/null
@@ -1,121 +0,0 @@
-#include "nv30_context.h"
-#include "nvfx_state.h"
-
-static struct nvfx_state_entry *render_states[] = {
- &nv30_state_framebuffer,
- &nv30_state_rasterizer,
- &nv30_state_scissor,
- &nv30_state_stipple,
- &nv30_state_fragprog,
- &nv30_state_fragtex,
- &nv30_state_vertprog,
- &nv30_state_blend,
- &nv30_state_blend_colour,
- &nv30_state_zsa,
- &nv30_state_sr,
- &nv30_state_viewport,
- &nv30_state_vbo,
- NULL
-};
-
-static void
-nv30_state_do_validate(struct nvfx_context *nvfx,
- struct nvfx_state_entry **states)
-{
- while (*states) {
- struct nvfx_state_entry *e = *states;
-
- if (nvfx->dirty & e->dirty.pipe) {
- if (e->validate(nvfx))
- nvfx->state.dirty |= (1ULL << e->dirty.hw);
- }
-
- states++;
- }
- nvfx->dirty = 0;
-}
-
-void
-nv30_state_emit(struct nvfx_context *nvfx)
-{
- struct nouveau_channel *chan = nvfx->screen->base.channel;
- struct nvfx_state *state = &nvfx->state;
- struct nvfx_screen *screen = nvfx->screen;
- unsigned i;
- uint64_t states;
-
- /* XXX: racy!
- */
- if (nvfx != screen->cur_ctx) {
- for (i = 0; i < NVFX_STATE_MAX; i++) {
- if (state->hw[i] && screen->state[i] != state->hw[i])
- state->dirty |= (1ULL << i);
- }
-
- screen->cur_ctx = nvfx;
- }
-
- for (i = 0, states = state->dirty; states; i++) {
- if (!(states & (1ULL << i)))
- continue;
- so_ref (state->hw[i], &nvfx->screen->state[i]);
- if (state->hw[i])
- so_emit(chan, nvfx->screen->state[i]);
- states &= ~(1ULL << i);
- }
-
- state->dirty = 0;
-}
-
-void
-nv30_state_flush_notify(struct nouveau_channel *chan)
-{
- struct nvfx_context *nvfx = chan->user_private;
- struct nvfx_state *state = &nvfx->state;
- unsigned i, samplers;
-
- so_emit_reloc_markers(chan, state->hw[NVFX_STATE_FB]);
- for (i = 0, samplers = state->fp_samplers; i < 16 && samplers; i++) {
- if (!(samplers & (1 << i)))
- continue;
- so_emit_reloc_markers(chan,
- state->hw[NVFX_STATE_FRAGTEX0+i]);
- samplers &= ~(1ULL << i);
- }
- so_emit_reloc_markers(chan, state->hw[NVFX_STATE_FRAGPROG]);
- if (state->hw[NVFX_STATE_VTXBUF] /*&& nvfx->render_mode == HW*/)
- so_emit_reloc_markers(chan, state->hw[NVFX_STATE_VTXBUF]);
-}
-
-boolean
-nv30_state_validate(struct nvfx_context *nvfx)
-{
-#if 0
- boolean was_sw = nvfx->fallback_swtnl ? TRUE : FALSE;
-
- if (nvfx->render_mode != HW) {
- /* Don't even bother trying to go back to hw if none
- * of the states that caused swtnl previously have changed.
- */
- if ((nvfx->fallback_swtnl & nvfx->dirty)
- != nvfx->fallback_swtnl)
- return FALSE;
-
- /* Attempt to go to hwtnl again */
- nvfx->pipe.flush(&nvfx->pipe, 0, NULL);
- nvfx->dirty |= (NVFX_NEW_VIEWPORT |
- NVFX_NEW_VERTPROG |
- NVFX_NEW_ARRAYS);
- nvfx->render_mode = HW;
- }
-#endif
- nv30_state_do_validate(nvfx, render_states);
-#if 0
- if (nvfx->fallback_swtnl || nvfx->fallback_swrast)
- return FALSE;
-
- if (was_sw)
- NOUVEAU_ERR("swtnl->hw\n");
-#endif
- return TRUE;
-}
diff --git a/src/gallium/drivers/nv30/nv30_vbo.c b/src/gallium/drivers/nv30/nv30_vbo.c
index 119fa59890..2b4401e533 100644
--- a/src/gallium/drivers/nv30/nv30_vbo.c
+++ b/src/gallium/drivers/nv30/nv30_vbo.c
@@ -175,7 +175,7 @@ nv30_draw_arrays(struct pipe_context *pipe,
unsigned restart = 0;
nv30_vbo_set_idxbuf(nvfx, NULL, 0);
- if (FORCE_SWTNL || !nv30_state_validate(nvfx)) {
+ if (FORCE_SWTNL || !nvfx_state_validate(nvfx)) {
/*return nv30_draw_elements_swtnl(pipe, NULL, 0,
mode, start, count);*/
return;
@@ -184,7 +184,7 @@ nv30_draw_arrays(struct pipe_context *pipe,
while (count) {
unsigned vc, nr;
- nv30_state_emit(nvfx);
+ nvfx_state_emit(nvfx);
vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
mode, start, count, &restart);
@@ -238,7 +238,7 @@ nv30_draw_elements_u08(struct nvfx_context *nvfx, void *ib,
uint8_t *elts = (uint8_t *)ib + start;
unsigned vc, push, restart = 0;
- nv30_state_emit(nvfx);
+ nvfx_state_emit(nvfx);
vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
mode, start, count, &restart);
@@ -289,7 +289,7 @@ nv30_draw_elements_u16(struct nvfx_context *nvfx, void *ib,
uint16_t *elts = (uint16_t *)ib + start;
unsigned vc, push, restart = 0;
- nv30_state_emit(nvfx);
+ nvfx_state_emit(nvfx);
vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
mode, start, count, &restart);
@@ -340,7 +340,7 @@ nv30_draw_elements_u32(struct nvfx_context *nvfx, void *ib,
uint32_t *elts = (uint32_t *)ib + start;
unsigned vc, push, restart = 0;
- nv30_state_emit(nvfx);
+ nvfx_state_emit(nvfx);
vc = nouveau_vbuf_split(AVAIL_RING(chan), 5, 1,
mode, start, count, &restart);
@@ -416,7 +416,7 @@ nv30_draw_elements_vbo(struct pipe_context *pipe,
while (count) {
unsigned nr, vc;
- nv30_state_emit(nvfx);
+ nvfx_state_emit(nvfx);
vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
mode, start, count, &restart);
@@ -465,7 +465,7 @@ nv30_draw_elements(struct pipe_context *pipe,
boolean idxbuf;
idxbuf = nv30_vbo_set_idxbuf(nvfx, indexBuffer, indexSize);
- if (FORCE_SWTNL || !nv30_state_validate(nvfx)) {
+ if (FORCE_SWTNL || !nvfx_state_validate(nvfx)) {
/*return nv30_draw_elements_swtnl(pipe, NULL, 0,
mode, start, count);*/
return;