summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorbin Simpson <[email protected]>2009-01-14 00:49:48 -0800
committerCorbin Simpson <[email protected]>2009-02-01 23:30:22 -0800
commit28bb7f3206f023a9d3cfa020da344a57118a2efb (patch)
tree5bdb49d20441e9e16bf7c572c85a5fd4a78ab0b3
parent74288078eab1971cc6ce3ae00fa55eb917b5826a (diff)
r300: Add scissor state, fix build.
-rw-r--r--src/gallium/drivers/r300/r300_context.h10
-rw-r--r--src/gallium/drivers/r300/r300_state.c47
2 files changed, 56 insertions, 1 deletions
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index b9fff0deab9..6c64c9fa83d 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -34,7 +34,13 @@ struct r300_blend_state {
uint32_t dither; /* R300_RB3D_DITHER_CTL: 0x4e50 */
};
-#define R300_NEW_BLEND 0x1
+struct r300_scissor_state {
+ uint32_t scissor_top_left; /* R300_SC_SCISSORS_TL: 0x43e0 */
+ uint32_t scissor_bottom_right; /* R300_SC_SCISSORS_BR: 0x43e4 */
+};
+
+#define R300_NEW_BLEND 0x1
+#define R300_NEW_SCISSOR 0x2
struct r300_context {
/* Parent class */
@@ -48,6 +54,8 @@ struct r300_context {
/* Various CSO state objects. */
/* Blend state. */
struct r300_blend_state* blend_state;
+ /* Scissor state. */
+ struct r300_scissor_state* scissor_state;
/* Bitmask of dirty state objects. */
uint32_t dirty_state;
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 93441f624e9..2e19955454d 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -88,6 +88,9 @@ static uint32_t translate_blend_factor(int blend_fact) {
return 0;
}
+/* Create a new blend state based on the CSO blend state.
+ *
+ * This encompasses alpha blending, logic/raster ops, and blend dithering. */
static void* r300_create_blend_state(struct pipe_context* pipe,
struct pipe_blend_state* state)
{
@@ -128,6 +131,7 @@ static void* r300_create_blend_state(struct pipe_context* pipe,
return (void*)blend;
}
+/* Bind blend state. */
static void r300_bind_blend_state(struct pipe_context* pipe,
void* state)
{
@@ -137,12 +141,55 @@ static void r300_bind_blend_state(struct pipe_context* pipe,
r300->dirty_state |= R300_NEW_BLEND;
}
+/* Free blend state. */
static void r300_delete_blend_state(struct pipe_context* pipe,
void* state)
{
FREE(state);
}
+/* Create a new scissor state based on the CSO scissor state.
+ *
+ * This is only for the fragment scissors. */
+static void* r300_create_scissor_state(struct pipe_context* pipe,
+ struct pipe_scissor_state* state)
+{
+ uint32_t left, top, right, bottom;
+ struct r300_scissor_state* scissor = CALLOC_STRUCT(r300_scissor_state);
+
+ /* So, a bit of info. The scissors are offset by R300_SCISSORS_OFFSET in
+ * both directions for all values, and can only be 13 bits wide. Why?
+ * We may never know. */
+ left = (state->minx + R300_SCISSORS_OFFSET) & 0x1fff;
+ top = (state->miny + R300_SCISSORS_OFFSET) & 0x1fff;
+ right = (state->maxx + R300_SCISSORS_OFFSET) & 0x1fff;
+ bottom = (state->maxy + R300_SCISSORS_OFFSET) & 0x1fff;
+
+ scissor->scissor_top_left = (left << R300_SCISSORS_X_SHIFT) |
+ (top << R300_SCISSORS_Y_SHIFT);
+ scissor->scissor_bottom_right = (right << R300_SCISSORS_X_SHIFT) |
+ (bottom << R300_SCISSORS_Y_SHIFT);
+
+ return (void*)scissor;
+}
+
+/* Bind scissor state.*/
+static void r300_bind_scissor_state(struct pipe_context* pipe,
+ void* state)
+{
+ struct r300_context* r300 = r300_context(pipe);
+
+ r300->scissor_state = (struct r300_scissor_state*)state;
+ r300->dirty_state |= R300_NEW_SCISSOR;
+}
+
+/* Delete scissor state. */
+static void r300_delete_scissor_state(struct pipe_context* pipe,
+ void* state)
+{
+ FREE(state);
+}
+
static void* r300_create_vs_state(struct pipe_context* pipe,
struct pipe_shader_state* state)
{