nv40: only update draw module state when using swtnl

This commit is contained in:
Ben Skeggs 2008-04-02 13:04:06 +10:00
parent bdf5b23bfd
commit ae87909d0d
3 changed files with 34 additions and 14 deletions

View file

@ -133,7 +133,7 @@ struct nv40_context {
unsigned fallback_swrast;
/* Context state */
unsigned dirty;
unsigned dirty, draw_dirty;
struct pipe_scissor_state scissor;
unsigned stipple[32];
struct pipe_clip_state clip;
@ -153,8 +153,10 @@ struct nv40_context {
unsigned nr_samplers;
unsigned nr_textures;
unsigned dirty_samplers;
struct pipe_vertex_buffer vtxbuf[PIPE_ATTRIB_MAX];
struct pipe_vertex_buffer vtxbuf[PIPE_ATTRIB_MAX];
unsigned vtxbuf_nr;
struct pipe_vertex_element vtxelt[PIPE_ATTRIB_MAX];
unsigned vtxelt_nr;
};
static INLINE struct nv40_context *

View file

@ -423,10 +423,9 @@ nv40_rasterizer_state_bind(struct pipe_context *pipe, void *hwcso)
struct nv40_context *nv40 = nv40_context(pipe);
struct nv40_rasterizer_state *rsso = hwcso;
draw_set_rasterizer_state(nv40->draw, &rsso->pipe);
nv40->rasterizer = hwcso;
nv40->dirty |= NV40_NEW_RAST;
nv40->draw_dirty |= NV40_NEW_RAST;
}
static void
@ -530,10 +529,9 @@ nv40_vp_state_bind(struct pipe_context *pipe, void *hwcso)
struct nv40_context *nv40 = nv40_context(pipe);
struct nv40_vertex_program *vp = hwcso;
draw_bind_vertex_shader(nv40->draw, vp ? vp->draw : NULL);
nv40->vertprog = hwcso;
nv40->dirty |= NV40_NEW_VERTPROG;
nv40->draw_dirty |= NV40_NEW_VERTPROG;
}
static void
@ -596,10 +594,9 @@ nv40_set_clip_state(struct pipe_context *pipe,
{
struct nv40_context *nv40 = nv40_context(pipe);
draw_set_clip_state(nv40->draw, clip);
nv40->clip = *clip;
nv40->dirty |= NV40_NEW_UCP;
nv40->draw_dirty |= NV40_NEW_UCP;
}
static void
@ -654,10 +651,9 @@ nv40_set_viewport_state(struct pipe_context *pipe,
{
struct nv40_context *nv40 = nv40_context(pipe);
draw_set_viewport_state(nv40->draw, vpt);
nv40->viewport = *vpt;
nv40->dirty |= NV40_NEW_VIEWPORT;
nv40->draw_dirty |= NV40_NEW_VIEWPORT;
}
static void
@ -666,10 +662,11 @@ nv40_set_vertex_buffers(struct pipe_context *pipe, unsigned count,
{
struct nv40_context *nv40 = nv40_context(pipe);
draw_set_vertex_buffers(nv40->draw, count, vb);
memcpy(nv40->vtxbuf, vb, sizeof(*vb) * count);
nv40->vtxbuf_nr = count;
nv40->dirty |= NV40_NEW_ARRAYS;
nv40->draw_dirty |= NV40_NEW_ARRAYS;
}
static void
@ -678,10 +675,11 @@ nv40_set_vertex_elements(struct pipe_context *pipe, unsigned count,
{
struct nv40_context *nv40 = nv40_context(pipe);
draw_set_vertex_elements(nv40->draw, count, ve);
memcpy(nv40->vtxelt, ve, sizeof(*ve) * count);
nv40->vtxelt_nr = count;
nv40->dirty |= NV40_NEW_ARRAYS;
nv40->draw_dirty |= NV40_NEW_ARRAYS;
}
void

View file

@ -144,6 +144,8 @@ nv40_state_validate(struct nv40_context *nv40)
boolean
nv40_state_validate_swtnl(struct nv40_context *nv40)
{
struct draw_context *draw = nv40->draw;
/* Setup for swtnl */
if (nv40->render_mode == HW) {
NOUVEAU_ERR("hw->swtnl 0x%08x\n", nv40->fallback_swtnl);
@ -155,12 +157,30 @@ nv40_state_validate_swtnl(struct nv40_context *nv40)
nv40->render_mode = SWTNL;
}
if (nv40->draw_dirty & NV40_NEW_VERTPROG)
draw_bind_vertex_shader(draw, nv40->vertprog->draw);
if (nv40->draw_dirty & NV40_NEW_RAST)
draw_set_rasterizer_state(draw, &nv40->rasterizer->pipe);
if (nv40->draw_dirty & NV40_NEW_UCP)
draw_set_clip_state(draw, &nv40->clip);
if (nv40->draw_dirty & NV40_NEW_VIEWPORT)
draw_set_viewport_state(draw, &nv40->viewport);
if (nv40->draw_dirty & NV40_NEW_ARRAYS) {
draw_set_vertex_buffers(draw, nv40->vtxbuf_nr, nv40->vtxbuf);
draw_set_vertex_elements(draw, nv40->vtxelt_nr, nv40->vtxelt);
}
nv40_state_do_validate(nv40, swtnl_states);
if (nv40->fallback_swrast) {
NOUVEAU_ERR("swtnl->swrast 0x%08x\n", nv40->fallback_swrast);
return FALSE;
}
nv40->draw_dirty = 0;
return TRUE;
}