struct nv40_state state;
unsigned fallback;
- struct nouveau_stateobj *so_fragtex[16];
struct nouveau_stateobj *so_vtxbuf;
struct pipe_vertex_buffer vtxbuf[PIPE_ATTRIB_MAX];
extern struct nv40_state_entry nv40_state_zsa;
extern struct nv40_state_entry nv40_state_viewport;
extern struct nv40_state_entry nv40_state_framebuffer;
+extern struct nv40_state_entry nv40_state_fragtex;
/* nv40_vbo.c */
extern boolean nv40_draw_arrays(struct pipe_context *, unsigned mode,
}
-static void
+static struct nouveau_stateobj *
nv40_fragtex_build(struct nv40_context *nv40, int unit)
{
struct nv40_sampler_state *ps = nv40->tex_sampler[unit];
break;
default:
NOUVEAU_ERR("Unknown target %d\n", pt->target);
- return;
+ return NULL;
}
if (swizzled) {
so_method(so, nv40->hw->curie, NV40TCL_TEX_SIZE1(unit), 1);
so_data (so, (pt->depth[0] << NV40TCL_TEX_SIZE1_DEPTH_SHIFT) | txp);
- so_emit(nv40->nvws, so);
- so_ref (so, &nv40->so_fragtex[unit]);
- so_ref (NULL, &so);
+ return so;
}
-void
-nv40_fragtex_bind(struct nv40_context *nv40)
+static boolean
+nv40_fragtex_validate(struct nv40_context *nv40)
{
struct nv40_fragment_program *fp = nv40->pipe_state.fragprog;
+ struct nouveau_stateobj *so;
unsigned samplers, unit;
samplers = nv40->fp_samplers & ~fp->samplers;
unit = ffs(samplers) - 1;
samplers &= ~(1 << unit);
- so_ref(NULL, &nv40->so_fragtex[unit]);
- BEGIN_RING(curie, NV40TCL_TEX_ENABLE(unit), 1);
- OUT_RING (0);
+ so = so_new(2, 0);
+ so_method(so, nv40->hw->curie, NV40TCL_TEX_ENABLE(unit), 1);
+ so_data (so, 0);
+ so_ref(so, &nv40->state.hw[NV40_STATE_FRAGTEX0 + unit]);
+ so_ref(NULL, &so);
+ nv40->hw_dirty |= (1 << (NV40_STATE_FRAGTEX0 + unit));
}
samplers = nv40->dirty_samplers & fp->samplers;
unit = ffs(samplers) - 1;
samplers &= ~(1 << unit);
- nv40_fragtex_build(nv40, unit);
+ so = nv40_fragtex_build(nv40, unit);
+ so_ref(so, &nv40->state.hw[NV40_STATE_FRAGTEX0 + unit]);
+ so_ref(NULL, &so);
+ nv40->hw_dirty |= (1 << (NV40_STATE_FRAGTEX0 + unit));
}
nv40->fp_samplers = fp->samplers;
+ return FALSE;
}
+struct nv40_state_entry nv40_state_fragtex = {
+ .validate = nv40_fragtex_validate,
+ .dirty = {
+ .pipe = NV40_NEW_SAMPLER | NV40_NEW_FRAGPROG,
+ .hw = 0
+ }
+};
+
&nv40_state_scissor,
&nv40_state_stipple,
&nv40_state_fragprog,
+ &nv40_state_fragtex,
&nv40_state_vertprog,
&nv40_state_blend,
&nv40_state_blend_colour,
states++;
}
+ nv40->dirty = 0;
if (nv40->fallback & NV40_FALLBACK_TNL &&
!(last_fallback & NV40_FALLBACK_TNL)) {
for (i = 0; i < 16; i++) {
if (!(nv40->fp_samplers & (1 << i)))
continue;
- so_emit_reloc_markers(nv40->nvws, nv40->so_fragtex[i]);
+ so_emit_reloc_markers(nv40->nvws,
+ nv40->state.hw[NV40_STATE_FRAGTEX0+i]);
}
so_emit_reloc_markers(nv40->nvws, nv40->state.hw[NV40_STATE_FRAGPROG]);
}
nv40_emit_hw_state(struct nv40_context *nv40)
{
nv40_state_validate(nv40);
-
- if (nv40->dirty_samplers || (nv40->dirty & NV40_NEW_FRAGPROG)) {
- nv40_fragtex_bind(nv40);
-
- BEGIN_RING(curie, NV40TCL_TEX_CACHE_CTL, 1);
- OUT_RING (2);
- BEGIN_RING(curie, NV40TCL_TEX_CACHE_CTL, 1);
- OUT_RING (1);
- nv40->dirty &= ~NV40_NEW_FRAGPROG;
- }
-
nv40_state_emit(nv40);
- nv40->dirty_samplers = 0;
- nv40->dirty = 0;
+ BEGIN_RING(curie, NV40TCL_TEX_CACHE_CTL, 1);
+ OUT_RING (2);
+ BEGIN_RING(curie, NV40TCL_TEX_CACHE_CTL, 1);
+ OUT_RING (1);
}