summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Barbieri <[email protected]>2010-02-21 15:07:17 +0100
committerYounes Manton <[email protected]>2010-03-15 00:03:03 -0400
commit5bb68e5d174afa7a177c5e972fa80bf66e37f6ab (patch)
tree4eb91cc5e90ee1e1e2f4f4ab34f4845315ded497
parentda5103c3b382ca08368a19a195a24278596db4cb (diff)
nv30, nv40: partially non-trivially unify nv[34]0_fragtex.c
The bulk files cannot be unified, but the frontend can and allows to share some code and simplify state_emit.c
-rw-r--r--src/gallium/drivers/nv30/nv30_fragtex.c45
-rw-r--r--src/gallium/drivers/nv40/nv40_fragtex.c46
-rw-r--r--src/gallium/drivers/nvfx/Makefile1
-rw-r--r--src/gallium/drivers/nvfx/nvfx_context.h7
-rw-r--r--src/gallium/drivers/nvfx/nvfx_fragtex.c49
-rw-r--r--src/gallium/drivers/nvfx/nvfx_state_emit.c22
6 files changed, 64 insertions, 106 deletions
diff --git a/src/gallium/drivers/nv30/nv30_fragtex.c b/src/gallium/drivers/nv30/nv30_fragtex.c
index ab39dedae6b..52f7c52a9b1 100644
--- a/src/gallium/drivers/nv30/nv30_fragtex.c
+++ b/src/gallium/drivers/nv30/nv30_fragtex.c
@@ -57,7 +57,7 @@ nv30_fragtex_format(uint pipe_format)
}
-static struct nouveau_stateobj *
+struct nouveau_stateobj *
nv30_fragtex_build(struct nvfx_context *nvfx, int unit)
{
struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit];
@@ -116,46 +116,3 @@ nv30_fragtex_build(struct nvfx_context *nvfx, int unit)
return so;
}
-static boolean
-nv30_fragtex_validate(struct nvfx_context *nvfx)
-{
- struct nvfx_fragment_program *fp = nvfx->fragprog;
- struct nvfx_state *state = &nvfx->state;
- struct nouveau_stateobj *so;
- unsigned samplers, unit;
-
- samplers = state->fp_samplers & ~fp->samplers;
- 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));
- }
-
- samplers = nvfx->dirty_samplers & fp->samplers;
- while (samplers) {
- unit = ffs(samplers) - 1;
- samplers &= ~(1 << unit);
-
- so = nv30_fragtex_build(nvfx, unit);
- so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
- so_ref(NULL, &so);
- state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
- }
-
- nvfx->state.fp_samplers = fp->samplers;
- return FALSE;
-}
-
-struct nvfx_state_entry nv30_state_fragtex = {
- .validate = nv30_fragtex_validate,
- .dirty = {
- .pipe = NVFX_NEW_SAMPLER | NVFX_NEW_FRAGPROG,
- .hw = 0
- }
-};
diff --git a/src/gallium/drivers/nv40/nv40_fragtex.c b/src/gallium/drivers/nv40/nv40_fragtex.c
index 29257173b82..76150950259 100644
--- a/src/gallium/drivers/nv40/nv40_fragtex.c
+++ b/src/gallium/drivers/nv40/nv40_fragtex.c
@@ -59,7 +59,7 @@ nv40_fragtex_format(uint pipe_format)
}
-static struct nouveau_stateobj *
+struct nouveau_stateobj *
nv40_fragtex_build(struct nvfx_context *nvfx, int unit)
{
struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit];
@@ -126,47 +126,3 @@ nv40_fragtex_build(struct nvfx_context *nvfx, int unit)
return so;
}
-
-static boolean
-nv40_fragtex_validate(struct nvfx_context *nvfx)
-{
- struct nvfx_fragment_program *fp = nvfx->fragprog;
- struct nvfx_state *state = &nvfx->state;
- struct nouveau_stateobj *so;
- unsigned samplers, unit;
-
- samplers = state->fp_samplers & ~fp->samplers;
- 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]);
- state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
- }
-
- samplers = nvfx->dirty_samplers & fp->samplers;
- while (samplers) {
- unit = ffs(samplers) - 1;
- samplers &= ~(1 << unit);
-
- so = nv40_fragtex_build(nvfx, unit);
- so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
- so_ref(NULL, &so);
- state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
- }
-
- nvfx->state.fp_samplers = fp->samplers;
- return FALSE;
-}
-
-struct nvfx_state_entry nv40_state_fragtex = {
- .validate = nv40_fragtex_validate,
- .dirty = {
- .pipe = NVFX_NEW_SAMPLER | NVFX_NEW_FRAGPROG,
- .hw = 0
- }
-};
-
diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
index aa03a155e32..51fa34cfad2 100644
--- a/src/gallium/drivers/nvfx/Makefile
+++ b/src/gallium/drivers/nvfx/Makefile
@@ -8,6 +8,7 @@ C_SOURCES = \
nvfx_clear.c \
nvfx_draw.c \
nvfx_fragprog.c \
+ nvfx_fragtex.c \
nvfx_miptree.c \
nvfx_query.c \
nvfx_screen.c \
diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
index 0bd37a7ae83..e5389042981 100644
--- a/src/gallium/drivers/nvfx/nvfx_context.h
+++ b/src/gallium/drivers/nvfx/nvfx_context.h
@@ -184,6 +184,7 @@ struct nvfx_state_entry {
extern struct nvfx_state_entry nvfx_state_blend;
extern struct nvfx_state_entry nvfx_state_blend_colour;
extern struct nvfx_state_entry nvfx_state_fragprog;
+extern struct nvfx_state_entry nvfx_state_fragtex;
extern struct nvfx_state_entry nvfx_state_framebuffer;
extern struct nvfx_state_entry nvfx_state_rasterizer;
extern struct nvfx_state_entry nvfx_state_scissor;
@@ -220,12 +221,14 @@ extern void nvfx_fragprog_destroy(struct nvfx_context *,
/* nv30_fragtex.c */
extern void nv30_init_sampler_functions(struct nvfx_context *nvfx);
extern void nv30_fragtex_bind(struct nvfx_context *);
-extern struct nvfx_state_entry nv30_state_fragtex;
+extern struct nouveau_stateobj *
+nv30_fragtex_build(struct nvfx_context *nvfx, int unit);
/* nv40_fragtex.c */
extern void nv40_init_sampler_functions(struct nvfx_context *nvfx);
extern void nv40_fragtex_bind(struct nvfx_context *);
-extern struct nvfx_state_entry nv40_state_fragtex;
+extern struct nouveau_stateobj *
+nv40_fragtex_build(struct nvfx_context *nvfx, int unit);
/* nvfx_state.c */
extern void nvfx_init_state_functions(struct nvfx_context *nvfx);
diff --git a/src/gallium/drivers/nvfx/nvfx_fragtex.c b/src/gallium/drivers/nvfx/nvfx_fragtex.c
new file mode 100644
index 00000000000..84e4eb10042
--- /dev/null
+++ b/src/gallium/drivers/nvfx/nvfx_fragtex.c
@@ -0,0 +1,49 @@
+#include "nvfx_context.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;
+ unsigned samplers, unit;
+
+ samplers = state->fp_samplers & ~fp->samplers;
+ 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));
+ }
+
+ samplers = nvfx->dirty_samplers & fp->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);
+
+ so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
+ so_ref(NULL, &so);
+ state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
+ }
+
+ nvfx->state.fp_samplers = fp->samplers;
+ return FALSE;
+}
+
+struct nvfx_state_entry nvfx_state_fragtex = {
+ .validate = nvfx_fragtex_validate,
+ .dirty = {
+ .pipe = NVFX_NEW_SAMPLER | NVFX_NEW_FRAGPROG,
+ .hw = 0
+ }
+};
diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c
index 9d28b590746..72537388ea4 100644
--- a/src/gallium/drivers/nvfx/nvfx_state_emit.c
+++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c
@@ -2,14 +2,14 @@
#include "nvfx_state.h"
#include "draw/draw_context.h"
-#define RENDER_STATES(name, nvxx, vbo) \
-static struct nvfx_state_entry *name##_render_states[] = { \
+#define RENDER_STATES(name, vbo) \
+static struct nvfx_state_entry *name##render_states[] = { \
&nvfx_state_framebuffer, \
&nvfx_state_rasterizer, \
&nvfx_state_scissor, \
&nvfx_state_stipple, \
&nvfx_state_fragprog, \
- &nvxx##_state_fragtex, \
+ &nvfx_state_fragtex, \
&nvfx_state_vertprog, \
&nvfx_state_blend, \
&nvfx_state_blend_colour, \
@@ -20,10 +20,8 @@ static struct nvfx_state_entry *name##_render_states[] = { \
NULL \
}
-RENDER_STATES(nv30, nv30, vbo);
-RENDER_STATES(nv30_swtnl, nv30, vtxfmt);
-RENDER_STATES(nv40, nv40, vbo);
-RENDER_STATES(nv40_swtnl, nv40, vtxfmt);
+RENDER_STATES(, vbo);
+RENDER_STATES(swtnl_, vtxfmt);
static void
nvfx_state_do_validate(struct nvfx_context *nvfx,
@@ -126,10 +124,7 @@ nvfx_state_validate(struct nvfx_context *nvfx)
nvfx->render_mode = HW;
}
- if(!nvfx->is_nv4x)
- nvfx_state_do_validate(nvfx, nv30_render_states);
- else
- nvfx_state_do_validate(nvfx, nv40_render_states);
+ nvfx_state_do_validate(nvfx, render_states);
if (nvfx->fallback_swtnl || nvfx->fallback_swrast)
return FALSE;
@@ -172,10 +167,7 @@ nvfx_state_validate_swtnl(struct nvfx_context *nvfx)
draw_set_vertex_elements(draw, nvfx->vtxelt->num_elements, nvfx->vtxelt->pipe);
}
- if(!nvfx->is_nv4x)
- nvfx_state_do_validate(nvfx, nv30_swtnl_render_states);
- else
- nvfx_state_do_validate(nvfx, nv40_swtnl_render_states);
+ nvfx_state_do_validate(nvfx, swtnl_render_states);
if (nvfx->fallback_swrast) {
NOUVEAU_ERR("swtnl->swrast 0x%08x\n", nvfx->fallback_swrast);