summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nv30
diff options
context:
space:
mode:
authorPatrice Mandin <pmandin@caramail.com>2008-07-03 21:48:18 +0200
committerPatrice Mandin <pmandin@caramail.com>2008-07-03 21:48:18 +0200
commit360f7a3e239553fc0e1aff3b38c06c2e3d0a698c (patch)
treed4b4aafb667e2327754bddbd872df7d63ed9f570 /src/gallium/drivers/nv30
parentc0e9eb3b095c9769d3deacf4ad4470bd155acdcd (diff)
nv30: Emit rasterizer state using state objects
Diffstat (limited to 'src/gallium/drivers/nv30')
-rw-r--r--src/gallium/drivers/nv30/nv30_context.h6
-rw-r--r--src/gallium/drivers/nv30/nv30_state.c177
-rw-r--r--src/gallium/drivers/nv30/nv30_state.h23
-rw-r--r--src/gallium/drivers/nv30/nv30_state_emit.c1
4 files changed, 98 insertions, 109 deletions
diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
index eedebc91b2..692d8dd523 100644
--- a/src/gallium/drivers/nv30/nv30_context.h
+++ b/src/gallium/drivers/nv30/nv30_context.h
@@ -76,8 +76,7 @@ enum nv30_state_index {
#define NV30_NEW_ARRAYS (1 << 11)
#define NV30_NEW_UCP (1 << 12)
-/* TODO: rename when removing the old state emitter */
-struct nv30_rasterizer_state_new {
+struct nv30_rasterizer_state {
struct pipe_rasterizer_state pipe;
struct nouveau_stateobj *so;
};
@@ -124,11 +123,11 @@ struct nv30_context {
unsigned vp_samplers;
/* Context state */
+ struct nv30_rasterizer_state *rasterizer;
struct nv30_blend_state *blend;
struct pipe_blend_color blend_colour;
struct pipe_viewport_state viewport;
struct pipe_framebuffer_state framebuffer;
- struct nv30_rasterizer_state_new *rasterizer;
struct nv30_zsa_state *zsa;
unsigned stipple[32];
@@ -211,6 +210,7 @@ extern void nv30_fragtex_bind(struct nv30_context *);
extern boolean nv30_state_validate(struct nv30_context *nv30);
extern void nv30_emit_hw_state(struct nv30_context *nv30);
extern void nv30_state_tex_update(struct nv30_context *nv30);
+extern struct nv30_state_entry nv30_state_rasterizer;
extern struct nv30_state_entry nv30_state_blend;
extern struct nv30_state_entry nv30_state_blend_colour;
extern struct nv30_state_entry nv30_state_framebuffer;
diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c
index cf46dcef93..8c7a902e28 100644
--- a/src/gallium/drivers/nv30/nv30_state.c
+++ b/src/gallium/drivers/nv30/nv30_state.c
@@ -275,123 +275,134 @@ static void *
nv30_rasterizer_state_create(struct pipe_context *pipe,
const struct pipe_rasterizer_state *cso)
{
- struct nv30_rasterizer_state *rs;
- int i;
+ struct nv30_context *nv30 = nv30_context(pipe);
+ struct nv30_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso));
+ struct nouveau_stateobj *so = so_new(32, 0);
+ struct nouveau_grobj *rankine = nv30->screen->rankine;
/*XXX: ignored:
* light_twoside
- * offset_cw/ccw -nohw
- * scissor
* point_smooth -nohw
* multisample
- * offset_units / offset_scale
*/
- rs = malloc(sizeof(struct nv30_rasterizer_state));
-
- rs->shade_model = cso->flatshade ? 0x1d00 : 0x1d01;
- rs->line_width = (unsigned char)(cso->line_width * 8.0) & 0xff;
- rs->line_smooth_en = cso->line_smooth ? 1 : 0;
- rs->line_stipple_en = cso->line_stipple_enable ? 1 : 0;
- rs->line_stipple = (cso->line_stipple_pattern << 16) |
- cso->line_stipple_factor;
+ so_method(so, rankine, NV34TCL_SHADE_MODEL, 1);
+ so_data (so, cso->flatshade ? NV34TCL_SHADE_MODEL_FLAT :
+ NV34TCL_SHADE_MODEL_SMOOTH);
- rs->point_size = *(uint32_t*)&cso->point_size;
+ so_method(so, rankine, NV34TCL_LINE_WIDTH, 2);
+ so_data (so, (unsigned char)(cso->line_width * 8.0) & 0xff);
+ so_data (so, cso->line_smooth ? 1 : 0);
+ so_method(so, rankine, NV34TCL_LINE_STIPPLE_ENABLE, 2);
+ so_data (so, cso->line_stipple_enable ? 1 : 0);
+ so_data (so, (cso->line_stipple_pattern << 16) |
+ cso->line_stipple_factor);
- rs->poly_smooth_en = cso->poly_smooth ? 1 : 0;
- rs->poly_stipple_en = cso->poly_stipple_enable ? 1 : 0;
+ so_method(so, rankine, NV34TCL_POINT_SIZE, 1);
+ so_data (so, fui(cso->point_size));
+ so_method(so, rankine, NV34TCL_POLYGON_MODE_FRONT, 6);
if (cso->front_winding == PIPE_WINDING_CCW) {
- rs->front_face = NV34TCL_FRONT_FACE_CCW;
- rs->poly_mode_front = nvgl_polygon_mode(cso->fill_ccw);
- rs->poly_mode_back = nvgl_polygon_mode(cso->fill_cw);
+ so_data(so, nvgl_polygon_mode(cso->fill_ccw));
+ so_data(so, nvgl_polygon_mode(cso->fill_cw));
+ switch (cso->cull_mode) {
+ case PIPE_WINDING_CCW:
+ so_data(so, NV34TCL_CULL_FACE_FRONT);
+ break;
+ case PIPE_WINDING_CW:
+ so_data(so, NV34TCL_CULL_FACE_BACK);
+ break;
+ case PIPE_WINDING_BOTH:
+ so_data(so, NV34TCL_CULL_FACE_FRONT_AND_BACK);
+ break;
+ default:
+ so_data(so, NV34TCL_CULL_FACE_BACK);
+ break;
+ }
+ so_data(so, NV34TCL_FRONT_FACE_CCW);
} else {
- rs->front_face = NV34TCL_FRONT_FACE_CW;
- rs->poly_mode_front = nvgl_polygon_mode(cso->fill_cw);
- rs->poly_mode_back = nvgl_polygon_mode(cso->fill_ccw);
+ so_data(so, nvgl_polygon_mode(cso->fill_cw));
+ so_data(so, nvgl_polygon_mode(cso->fill_ccw));
+ switch (cso->cull_mode) {
+ case PIPE_WINDING_CCW:
+ so_data(so, NV34TCL_CULL_FACE_BACK);
+ break;
+ case PIPE_WINDING_CW:
+ so_data(so, NV34TCL_CULL_FACE_FRONT);
+ break;
+ case PIPE_WINDING_BOTH:
+ so_data(so, NV34TCL_CULL_FACE_FRONT_AND_BACK);
+ break;
+ default:
+ so_data(so, NV34TCL_CULL_FACE_BACK);
+ break;
+ }
+ so_data(so, NV34TCL_FRONT_FACE_CW);
}
-
- switch (cso->cull_mode) {
- case PIPE_WINDING_CCW:
- rs->cull_face_en = 1;
- if (cso->front_winding == PIPE_WINDING_CCW)
- rs->cull_face = NV34TCL_CULL_FACE_FRONT;
- else
- rs->cull_face = NV34TCL_CULL_FACE_BACK;
- break;
- case PIPE_WINDING_CW:
- rs->cull_face_en = 1;
- if (cso->front_winding == PIPE_WINDING_CW)
- rs->cull_face = NV34TCL_CULL_FACE_FRONT;
- else
- rs->cull_face = NV34TCL_CULL_FACE_BACK;
- break;
- case PIPE_WINDING_BOTH:
- rs->cull_face_en = 1;
- rs->cull_face = NV34TCL_CULL_FACE_FRONT_AND_BACK;
- break;
- case PIPE_WINDING_NONE:
- default:
- rs->cull_face_en = 0;
- rs->cull_face = 0;
- break;
+ so_data(so, cso->poly_smooth ? 1 : 0);
+ so_data(so, (cso->cull_mode != PIPE_WINDING_NONE) ? 1 : 0);
+
+ so_method(so, rankine, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
+ so_data (so, cso->poly_stipple_enable ? 1 : 0);
+
+ so_method(so, rankine, NV34TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
+ if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_POINT) ||
+ (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_POINT))
+ so_data(so, 1);
+ else
+ so_data(so, 0);
+ if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_LINE) ||
+ (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_LINE))
+ so_data(so, 1);
+ else
+ so_data(so, 0);
+ if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_FILL) ||
+ (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_FILL))
+ so_data(so, 1);
+ else
+ so_data(so, 0);
+ if (cso->offset_cw || cso->offset_ccw) {
+ so_method(so, rankine, NV34TCL_POLYGON_OFFSET_FACTOR, 2);
+ so_data (so, fui(cso->offset_scale));
+ so_data (so, fui(cso->offset_units * 2));
}
+ so_method(so, rankine, NV34TCL_POINT_SPRITE, 1);
if (cso->point_sprite) {
- rs->point_sprite = (1 << 0);
+ unsigned psctl = (1 << 0), i;
+
for (i = 0; i < 8; i++) {
if (cso->sprite_coord_mode[i] != PIPE_SPRITE_COORD_NONE)
- rs->point_sprite |= (1 << (8 + i));
+ psctl |= (1 << (8 + i));
}
+
+ so_data(so, psctl);
} else {
- rs->point_sprite = 0;
+ so_data(so, 0);
}
- return (void *)rs;
+ so_ref(so, &rsso->so);
+ rsso->pipe = *cso;
+ return (void *)rsso;
}
static void
nv30_rasterizer_state_bind(struct pipe_context *pipe, void *hwcso)
{
struct nv30_context *nv30 = nv30_context(pipe);
- struct nv30_rasterizer_state *rs = hwcso;
- if (!hwcso) {
- return;
- }
-
- BEGIN_RING(rankine, NV34TCL_SHADE_MODEL, 1);
- OUT_RING (rs->shade_model);
-
- BEGIN_RING(rankine, NV34TCL_LINE_WIDTH, 2);
- OUT_RING (rs->line_width);
- OUT_RING (rs->line_smooth_en);
- BEGIN_RING(rankine, NV34TCL_LINE_STIPPLE_ENABLE, 2);
- OUT_RING (rs->line_stipple_en);
- OUT_RING (rs->line_stipple);
-
- BEGIN_RING(rankine, NV34TCL_POINT_SIZE, 1);
- OUT_RING (rs->point_size);
-
- BEGIN_RING(rankine, NV34TCL_POLYGON_MODE_FRONT, 6);
- OUT_RING (rs->poly_mode_front);
- OUT_RING (rs->poly_mode_back);
- OUT_RING (rs->cull_face);
- OUT_RING (rs->front_face);
- OUT_RING (rs->poly_smooth_en);
- OUT_RING (rs->cull_face_en);
-
- BEGIN_RING(rankine, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
- OUT_RING (rs->poly_stipple_en);
-
- BEGIN_RING(rankine, NV34TCL_POINT_SPRITE, 1);
- OUT_RING (rs->point_sprite);
+ nv30->rasterizer = hwcso;
+ nv30->dirty |= NV30_NEW_RAST;
+ /*nv30->draw_dirty |= NV30_NEW_RAST;*/
}
static void
nv30_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso)
{
- free(hwcso);
+ struct nv30_rasterizer_state *rsso = hwcso;
+
+ so_ref(NULL, &rsso->so);
+ FREE(rsso);
}
static void
diff --git a/src/gallium/drivers/nv30/nv30_state.h b/src/gallium/drivers/nv30/nv30_state.h
index 8489b7b796..b33075aceb 100644
--- a/src/gallium/drivers/nv30/nv30_state.h
+++ b/src/gallium/drivers/nv30/nv30_state.h
@@ -11,29 +11,6 @@ struct nv30_sampler_state {
uint32_t bcol;
};
-struct nv30_rasterizer_state {
- uint32_t shade_model;
-
- uint32_t line_width;
- uint32_t line_smooth_en;
- uint32_t line_stipple_en;
- uint32_t line_stipple;
-
- uint32_t point_size;
-
- uint32_t poly_smooth_en;
- uint32_t poly_stipple_en;
-
- uint32_t poly_mode_front;
- uint32_t poly_mode_back;
-
- uint32_t front_face;
- uint32_t cull_face;
- uint32_t cull_face_en;
-
- uint32_t point_sprite;
-};
-
struct nv30_vertex_program_exec {
uint32_t data[4];
boolean has_branch_offset;
diff --git a/src/gallium/drivers/nv30/nv30_state_emit.c b/src/gallium/drivers/nv30/nv30_state_emit.c
index 492f411011..7d77adbfdf 100644
--- a/src/gallium/drivers/nv30/nv30_state_emit.c
+++ b/src/gallium/drivers/nv30/nv30_state_emit.c
@@ -3,6 +3,7 @@
static struct nv30_state_entry *render_states[] = {
&nv30_state_framebuffer,
+ &nv30_state_rasterizer,
&nv30_state_blend,
&nv30_state_blend_colour,
NULL