r300: respect radeon common code fallbacks
[mesa.git] / src / gallium / drivers / nv40 / nv40_state_emit.c
index 52ec4c044b4c9d0be1e5bfdfe7f7092c33825e12..8990f303ce4e300d7465d5da6fe38571d2768270 100644 (file)
@@ -13,6 +13,7 @@ static struct nv40_state_entry *render_states[] = {
        &nv40_state_blend,
        &nv40_state_blend_colour,
        &nv40_state_zsa,
+       &nv40_state_sr,
        &nv40_state_viewport,
        &nv40_state_vbo,
        NULL
@@ -29,6 +30,7 @@ static struct nv40_state_entry *swtnl_states[] = {
        &nv40_state_blend,
        &nv40_state_blend_colour,
        &nv40_state_zsa,
+       &nv40_state_sr,
        &nv40_state_viewport,
        &nv40_state_vtxfmt,
        NULL
@@ -38,14 +40,6 @@ static void
 nv40_state_do_validate(struct nv40_context *nv40,
                       struct nv40_state_entry **states)
 {
-       const struct pipe_framebuffer_state *fb = &nv40->framebuffer;
-       unsigned i;
-
-       for (i = 0; i < fb->num_cbufs; i++)
-               fb->cbufs[i]->status = PIPE_SURFACE_STATUS_DEFINED;
-       if (fb->zsbuf)
-               fb->zsbuf->status = PIPE_SURFACE_STATUS_DEFINED;
-
        while (*states) {
                struct nv40_state_entry *e = *states;
 
@@ -64,16 +58,20 @@ nv40_state_emit(struct nv40_context *nv40)
 {
        struct nv40_state *state = &nv40->state;
        struct nv40_screen *screen = nv40->screen;
-       unsigned i, samplers;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *curie = screen->curie;
+       unsigned i;
        uint64_t states;
 
-       if (nv40->pctx_id != screen->cur_pctx) {
+       /* XXX: race conditions
+        */
+       if (nv40 != screen->cur_ctx) {
                for (i = 0; i < NV40_STATE_MAX; i++) {
                        if (state->hw[i] && screen->state[i] != state->hw[i])
                                state->dirty |= (1ULL << i);
                }
 
-               screen->cur_pctx = nv40->pctx_id;
+               screen->cur_ctx = nv40;
        }
 
        for (i = 0, states = state->dirty; states; i++) {
@@ -81,31 +79,39 @@ nv40_state_emit(struct nv40_context *nv40)
                        continue;
                so_ref (state->hw[i], &nv40->screen->state[i]);
                if (state->hw[i])
-                       so_emit(nv40->nvws, nv40->screen->state[i]);
+                       so_emit(chan, nv40->screen->state[i]);
                states &= ~(1ULL << i);
        }
 
        if (state->dirty & ((1ULL << NV40_STATE_FRAGPROG) |
                            (1ULL << NV40_STATE_FRAGTEX0))) {
-               BEGIN_RING(curie, NV40TCL_TEX_CACHE_CTL, 1);
-               OUT_RING  (2);
-               BEGIN_RING(curie, NV40TCL_TEX_CACHE_CTL, 1);
-               OUT_RING  (1);
+               BEGIN_RING(chan, curie, NV40TCL_TEX_CACHE_CTL, 1);
+               OUT_RING  (chan, 2);
+               BEGIN_RING(chan, curie, NV40TCL_TEX_CACHE_CTL, 1);
+               OUT_RING  (chan, 1);
        }
 
        state->dirty = 0;
+}
+
+void
+nv40_state_flush_notify(struct nouveau_channel *chan)
+{
+       struct nv40_context *nv40 = chan->user_private;
+       struct nv40_state *state = &nv40->state;
+       unsigned i, samplers;
 
-       so_emit_reloc_markers(nv40->nvws, state->hw[NV40_STATE_FB]);
+       so_emit_reloc_markers(chan, state->hw[NV40_STATE_FB]);
        for (i = 0, samplers = state->fp_samplers; i < 16 && samplers; i++) {
                if (!(samplers & (1 << i)))
                        continue;
-               so_emit_reloc_markers(nv40->nvws,
+               so_emit_reloc_markers(chan,
                                      state->hw[NV40_STATE_FRAGTEX0+i]);
                samplers &= ~(1ULL << i);
        }
-       so_emit_reloc_markers(nv40->nvws, state->hw[NV40_STATE_FRAGPROG]);
+       so_emit_reloc_markers(chan, state->hw[NV40_STATE_FRAGPROG]);
        if (state->hw[NV40_STATE_VTXBUF] && nv40->render_mode == HW)
-               so_emit_reloc_markers(nv40->nvws, state->hw[NV40_STATE_VTXBUF]);
+               so_emit_reloc_markers(chan, state->hw[NV40_STATE_VTXBUF]);
 }
 
 boolean
@@ -167,7 +173,6 @@ nv40_state_validate_swtnl(struct nv40_context *nv40)
                draw_set_viewport_state(draw, &nv40->viewport);
 
        if (nv40->draw_dirty & NV40_NEW_ARRAYS) {
-               draw_set_edgeflags(draw, nv40->edgeflags);
                draw_set_vertex_buffers(draw, nv40->vtxbuf_nr, nv40->vtxbuf);
                draw_set_vertex_elements(draw, nv40->vtxelt_nr, nv40->vtxelt);  
        }