summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r300/r300_state.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2009-12-24 21:29:41 +0100
committerMarek Olšák <[email protected]>2010-03-19 01:18:18 +0100
commitcba6430524198a1bdcdeada03cbe946a454f3935 (patch)
tree5da7d19636e93028a6d9573e663e084be62d28d8 /src/gallium/drivers/r300/r300_state.c
parent8df65e98998b4c104db30cbba8a38be7eb2a9acd (diff)
r300g: add generating texture coordinates for point sprites (WIP)
Diffstat (limited to 'src/gallium/drivers/r300/r300_state.c')
-rw-r--r--src/gallium/drivers/r300/r300_state.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index d7d654dc315..db7844eef0e 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -715,6 +715,7 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
{
struct r300_screen* r300screen = r300_screen(pipe->screen);
struct r300_rs_state* rs = CALLOC_STRUCT(r300_rs_state);
+ unsigned coord_index;
/* Copy rasterizer state for Draw. */
rs->rs = *state;
@@ -807,6 +808,32 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
rs->color_control = R300_SHADE_MODEL_SMOOTH;
}
+ /* Point sprites */
+ if (state->sprite_coord_enable) {
+ coord_index = ffs(state->sprite_coord_enable)-1;
+
+ SCREEN_DBG(r300screen, DBG_DRAW,
+ "r300: point sprite: shader coord=%d\n", coord_index);
+
+ rs->stuffing_enable =
+ R300_GB_POINT_STUFF_ENABLE |
+ R300_GB_TEX_ST << (R300_GB_TEX0_SOURCE_SHIFT + (coord_index*2));
+
+ rs->point_texcoord_left = 0.0f;
+ rs->point_texcoord_right = 1.0f;
+
+ switch (state->sprite_coord_mode) {
+ case PIPE_SPRITE_COORD_UPPER_LEFT:
+ rs->point_texcoord_top = 0.0f;
+ rs->point_texcoord_bottom = 1.0f;
+ break;
+ case PIPE_SPRITE_COORD_LOWER_LEFT:
+ rs->point_texcoord_top = 1.0f;
+ rs->point_texcoord_bottom = 0.0f;
+ break;
+ }
+ }
+
return (void*)rs;
}
@@ -816,6 +843,7 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
struct r300_context* r300 = r300_context(pipe);
struct r300_rs_state* rs = (struct r300_rs_state*)state;
boolean scissor_was_enabled = r300->scissor_enabled;
+ int last_sprite_coord_index = r300->sprite_coord_index;
if (r300->draw) {
draw_flush(r300->draw);
@@ -825,17 +853,22 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
if (rs) {
r300->polygon_offset_enabled = rs->rs.offset_cw || rs->rs.offset_ccw;
r300->scissor_enabled = rs->rs.scissor;
+ r300->sprite_coord_index = ffs(rs->rs.sprite_coord_enable)-1;
} else {
r300->polygon_offset_enabled = FALSE;
r300->scissor_enabled = FALSE;
+ r300->sprite_coord_index = -1;
}
UPDATE_STATE(state, r300->rs_state);
- r300->rs_state.size = 17 + (r300->polygon_offset_enabled ? 5 : 0);
+ r300->rs_state.size = 24 + (r300->polygon_offset_enabled ? 5 : 0);
if (scissor_was_enabled != r300->scissor_enabled) {
r300->scissor_state.dirty = TRUE;
}
+ if (last_sprite_coord_index != r300->sprite_coord_index) {
+ r300->rs_block_state.dirty = TRUE;
+ }
}
/* Free rasterizer state. */