summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nvfx/nvfx_fragtex.c
diff options
context:
space:
mode:
authorLuca Barbieri <luca@luca-barbieri.com>2010-03-14 20:50:03 +0100
committerLuca Barbieri <luca@luca-barbieri.com>2010-04-12 12:13:16 +0200
commit631f6f56168888290baf1ccd4f5c9c275ebcb295 (patch)
tree1b95b479b0d51cde8d475960c462eb17494ea8b5 /src/gallium/drivers/nvfx/nvfx_fragtex.c
parentf5b6cc669961176d6464d20d27d842eda1844164 (diff)
nvfx: so->RING_3D: fragtex
Diffstat (limited to 'src/gallium/drivers/nvfx/nvfx_fragtex.c')
-rw-r--r--src/gallium/drivers/nvfx/nvfx_fragtex.c57
1 files changed, 36 insertions, 21 deletions
diff --git a/src/gallium/drivers/nvfx/nvfx_fragtex.c b/src/gallium/drivers/nvfx/nvfx_fragtex.c
index 84e4eb1004..e239235c3f 100644
--- a/src/gallium/drivers/nvfx/nvfx_fragtex.c
+++ b/src/gallium/drivers/nvfx/nvfx_fragtex.c
@@ -1,43 +1,58 @@
#include "nvfx_context.h"
+#include "nvfx_resource.h"
static boolean
nvfx_fragtex_validate(struct nvfx_context *nvfx)
{
- struct nvfx_fragment_program *fp = nvfx->fragprog;
- struct nvfx_state *state = &nvfx->state;
- struct nouveau_stateobj *so;
+ struct nouveau_channel* chan = nvfx->screen->base.channel;
unsigned samplers, unit;
- samplers = state->fp_samplers & ~fp->samplers;
+ samplers = nvfx->dirty_samplers;
+ if(!samplers)
+ return FALSE;
+
while (samplers) {
unit = ffs(samplers) - 1;
samplers &= ~(1 << unit);
- so = so_new(1, 1, 0);
- so_method(so, nvfx->screen->eng3d, NV34TCL_TX_ENABLE(unit), 1);
- so_data (so, 0);
- so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
- so_ref(NULL, &so);
- state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
+ if(nvfx->fragment_sampler_views[unit] && nvfx->tex_sampler[unit]) {
+ if(!nvfx->is_nv4x)
+ nv30_fragtex_set(nvfx, unit);
+ else
+ nv40_fragtex_set(nvfx, unit);
+ } else {
+ WAIT_RING(chan, 2);
+ /* this is OK for nv40 too */
+ OUT_RING(chan, RING_3D(NV34TCL_TX_ENABLE(unit), 1));
+ OUT_RING(chan, 0);
+ nvfx->hw_samplers &= ~(1 << unit);
+ }
}
+ nvfx->dirty_samplers = 0;
+ return FALSE;
+}
+
+void
+nvfx_fragtex_relocate(struct nvfx_context *nvfx)
+{
+ struct nouveau_channel* chan = nvfx->screen->base.channel;
+ unsigned samplers, unit;
+ unsigned tex_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
- samplers = nvfx->dirty_samplers & fp->samplers;
+ samplers = nvfx->hw_samplers;
while (samplers) {
unit = ffs(samplers) - 1;
samplers &= ~(1 << unit);
- if(!nvfx->is_nv4x)
- so = nv30_fragtex_build(nvfx, unit);
- else
- so = nv40_fragtex_build(nvfx, unit);
+ struct nvfx_miptree* mt = (struct nvfx_miptree*)nvfx->fragment_sampler_views[unit]->texture;
+ struct nouveau_bo *bo = mt->base.bo;
- so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
- so_ref(NULL, &so);
- state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
+ MARK_RING(chan, 3, 3);
+ OUT_RELOC(chan, bo, RING_3D(NV34TCL_TX_OFFSET(unit), 2), tex_flags | NOUVEAU_BO_DUMMY, 0, 0);
+ OUT_RELOC(chan, bo, 0, tex_flags | NOUVEAU_BO_LOW | NOUVEAU_BO_DUMMY, 0, 0);
+ OUT_RELOC(chan, bo, nvfx->hw_txf[unit], tex_flags | NOUVEAU_BO_OR | NOUVEAU_BO_DUMMY,
+ NV34TCL_TX_FORMAT_DMA0, NV34TCL_TX_FORMAT_DMA1);
}
-
- nvfx->state.fp_samplers = fp->samplers;
- return FALSE;
}
struct nvfx_state_entry nvfx_state_fragtex = {