summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nvfx
diff options
context:
space:
mode:
authorLuca Barbieri <luca@luca-barbieri.com>2010-02-23 15:22:07 +0100
committerLuca Barbieri <luca@luca-barbieri.com>2010-04-12 12:13:17 +0200
commitcbe8ed435a6ea278b80ec8124a78475a25a57908 (patch)
tree30fe9bffead1d33e49522d65f73ccfe7a8f322c1 /src/gallium/drivers/nvfx
parentc8201c833c30434f9ac1fbe5451b7e074b01f826 (diff)
nvfx: so->sb: rasterizer
Diffstat (limited to 'src/gallium/drivers/nvfx')
-rw-r--r--src/gallium/drivers/nvfx/nvfx_context.h3
-rw-r--r--src/gallium/drivers/nvfx/nvfx_state.c92
-rw-r--r--src/gallium/drivers/nvfx/nvfx_state_rasterizer.c5
3 files changed, 48 insertions, 52 deletions
diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
index 371c61f54d..2aebea795e 100644
--- a/src/gallium/drivers/nvfx/nvfx_context.h
+++ b/src/gallium/drivers/nvfx/nvfx_context.h
@@ -83,7 +83,8 @@ enum nvfx_state_index {
struct nvfx_rasterizer_state {
struct pipe_rasterizer_state pipe;
- struct nouveau_stateobj *so;
+ unsigned sb_len;
+ uint32_t sb[30];
};
struct nvfx_zsa_state {
diff --git a/src/gallium/drivers/nvfx/nvfx_state.c b/src/gallium/drivers/nvfx/nvfx_state.c
index e11ab46c42..d91ea7dea9 100644
--- a/src/gallium/drivers/nvfx/nvfx_state.c
+++ b/src/gallium/drivers/nvfx/nvfx_state.c
@@ -192,10 +192,8 @@ static void *
nvfx_rasterizer_state_create(struct pipe_context *pipe,
const struct pipe_rasterizer_state *cso)
{
- struct nvfx_context *nvfx = nvfx_context(pipe);
struct nvfx_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso));
- struct nouveau_stateobj *so = so_new(9, 19, 0);
- struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
+ struct nouveau_statebuf_builder sb = sb_init(rsso->sb);
/*XXX: ignored:
* light_twoside
@@ -203,88 +201,88 @@ nvfx_rasterizer_state_create(struct pipe_context *pipe,
* multisample
*/
- so_method(so, eng3d, NV34TCL_SHADE_MODEL, 1);
- so_data (so, cso->flatshade ? NV34TCL_SHADE_MODEL_FLAT :
+ sb_method(sb, NV34TCL_SHADE_MODEL, 1);
+ sb_data(sb, cso->flatshade ? NV34TCL_SHADE_MODEL_FLAT :
NV34TCL_SHADE_MODEL_SMOOTH);
- so_method(so, eng3d, 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, eng3d, NV34TCL_LINE_STIPPLE_ENABLE, 2);
- so_data (so, cso->line_stipple_enable ? 1 : 0);
- so_data (so, (cso->line_stipple_pattern << 16) |
+ sb_method(sb, NV34TCL_LINE_WIDTH, 2);
+ sb_data(sb, (unsigned char)(cso->line_width * 8.0) & 0xff);
+ sb_data(sb, cso->line_smooth ? 1 : 0);
+ sb_method(sb, NV34TCL_LINE_STIPPLE_ENABLE, 2);
+ sb_data(sb, cso->line_stipple_enable ? 1 : 0);
+ sb_data(sb, (cso->line_stipple_pattern << 16) |
cso->line_stipple_factor);
- so_method(so, eng3d, NV34TCL_POINT_SIZE, 1);
- so_data (so, fui(cso->point_size));
+ sb_method(sb, NV34TCL_POINT_SIZE, 1);
+ sb_data(sb, fui(cso->point_size));
- so_method(so, eng3d, NV34TCL_POLYGON_MODE_FRONT, 6);
+ sb_method(sb, NV34TCL_POLYGON_MODE_FRONT, 6);
if (cso->front_winding == PIPE_WINDING_CCW) {
- so_data(so, nvgl_polygon_mode(cso->fill_ccw));
- so_data(so, nvgl_polygon_mode(cso->fill_cw));
+ sb_data(sb, nvgl_polygon_mode(cso->fill_ccw));
+ sb_data(sb, nvgl_polygon_mode(cso->fill_cw));
switch (cso->cull_mode) {
case PIPE_WINDING_CCW:
- so_data(so, NV34TCL_CULL_FACE_FRONT);
+ sb_data(sb, NV34TCL_CULL_FACE_FRONT);
break;
case PIPE_WINDING_CW:
- so_data(so, NV34TCL_CULL_FACE_BACK);
+ sb_data(sb, NV34TCL_CULL_FACE_BACK);
break;
case PIPE_WINDING_BOTH:
- so_data(so, NV34TCL_CULL_FACE_FRONT_AND_BACK);
+ sb_data(sb, NV34TCL_CULL_FACE_FRONT_AND_BACK);
break;
default:
- so_data(so, NV34TCL_CULL_FACE_BACK);
+ sb_data(sb, NV34TCL_CULL_FACE_BACK);
break;
}
- so_data(so, NV34TCL_FRONT_FACE_CCW);
+ sb_data(sb, NV34TCL_FRONT_FACE_CCW);
} else {
- so_data(so, nvgl_polygon_mode(cso->fill_cw));
- so_data(so, nvgl_polygon_mode(cso->fill_ccw));
+ sb_data(sb, nvgl_polygon_mode(cso->fill_cw));
+ sb_data(sb, nvgl_polygon_mode(cso->fill_ccw));
switch (cso->cull_mode) {
case PIPE_WINDING_CCW:
- so_data(so, NV34TCL_CULL_FACE_BACK);
+ sb_data(sb, NV34TCL_CULL_FACE_BACK);
break;
case PIPE_WINDING_CW:
- so_data(so, NV34TCL_CULL_FACE_FRONT);
+ sb_data(sb, NV34TCL_CULL_FACE_FRONT);
break;
case PIPE_WINDING_BOTH:
- so_data(so, NV34TCL_CULL_FACE_FRONT_AND_BACK);
+ sb_data(sb, NV34TCL_CULL_FACE_FRONT_AND_BACK);
break;
default:
- so_data(so, NV34TCL_CULL_FACE_BACK);
+ sb_data(sb, NV34TCL_CULL_FACE_BACK);
break;
}
- so_data(so, NV34TCL_FRONT_FACE_CW);
+ sb_data(sb, NV34TCL_FRONT_FACE_CW);
}
- so_data(so, cso->poly_smooth ? 1 : 0);
- so_data(so, (cso->cull_mode != PIPE_WINDING_NONE) ? 1 : 0);
+ sb_data(sb, cso->poly_smooth ? 1 : 0);
+ sb_data(sb, (cso->cull_mode != PIPE_WINDING_NONE) ? 1 : 0);
- so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
- so_data (so, cso->poly_stipple_enable ? 1 : 0);
+ sb_method(sb, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
+ sb_data(sb, cso->poly_stipple_enable ? 1 : 0);
- so_method(so, eng3d, NV34TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
+ sb_method(sb, 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);
+ sb_data(sb, 1);
else
- so_data(so, 0);
+ sb_data(sb, 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);
+ sb_data(sb, 1);
else
- so_data(so, 0);
+ sb_data(sb, 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);
+ sb_data(sb, 1);
else
- so_data(so, 0);
+ sb_data(sb, 0);
if (cso->offset_cw || cso->offset_ccw) {
- so_method(so, eng3d, NV34TCL_POLYGON_OFFSET_FACTOR, 2);
- so_data (so, fui(cso->offset_scale));
- so_data (so, fui(cso->offset_units * 2));
+ sb_method(sb, NV34TCL_POLYGON_OFFSET_FACTOR, 2);
+ sb_data(sb, fui(cso->offset_scale));
+ sb_data(sb, fui(cso->offset_units * 2));
}
- so_method(so, eng3d, NV34TCL_POINT_SPRITE, 1);
+ sb_method(sb, NV34TCL_POINT_SPRITE, 1);
if (cso->point_quad_rasterization) {
unsigned psctl = (1 << 0), i;
@@ -293,14 +291,13 @@ nvfx_rasterizer_state_create(struct pipe_context *pipe,
psctl |= (1 << (8 + i));
}
- so_data(so, psctl);
+ sb_data(sb, psctl);
} else {
- so_data(so, 0);
+ sb_data(sb, 0);
}
- so_ref(so, &rsso->so);
- so_ref(NULL, &so);
rsso->pipe = *cso;
+ rsso->sb_len = sb_len(sb, rsso->sb);
return (void *)rsso;
}
@@ -319,7 +316,6 @@ nvfx_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso)
{
struct nvfx_rasterizer_state *rsso = hwcso;
- so_ref(NULL, &rsso->so);
FREE(rsso);
}
diff --git a/src/gallium/drivers/nvfx/nvfx_state_rasterizer.c b/src/gallium/drivers/nvfx/nvfx_state_rasterizer.c
index 0d35ecbf20..a5d21e88b2 100644
--- a/src/gallium/drivers/nvfx/nvfx_state_rasterizer.c
+++ b/src/gallium/drivers/nvfx/nvfx_state_rasterizer.c
@@ -3,8 +3,8 @@
static boolean
nvfx_state_rasterizer_validate(struct nvfx_context *nvfx)
{
- so_ref(nvfx->rasterizer->so,
- &nvfx->state.hw[NVFX_STATE_RAST]);
+ struct nouveau_channel* chan = nvfx->screen->base.channel;
+ sb_emit(chan, nvfx->rasterizer->sb, nvfx->rasterizer->sb_len);
return TRUE;
}
@@ -12,6 +12,5 @@ struct nvfx_state_entry nvfx_state_rasterizer = {
.validate = nvfx_state_rasterizer_validate,
.dirty = {
.pipe = NVFX_NEW_RAST,
- .hw = NVFX_STATE_RAST
}
};