summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2007-06-01 13:29:45 +0100
committerKeith Whitwell <keith@tungstengraphics.com>2007-06-01 13:29:45 +0100
commit346688a23eb6118c2888b1c4f5e250768fd29161 (patch)
treec7b9deee00ca0859208055ff188454765b69136b
parent6c6f861d14a478df5dc24430bf63f7a999605071 (diff)
Move scissor state to dynamic indirect.
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_context.h6
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_state.c1
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_state.h1
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_state_dynamic.c78
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_state_static.c59
5 files changed, 89 insertions, 56 deletions
diff --git a/src/mesa/drivers/dri/i915tex/i915_context.h b/src/mesa/drivers/dri/i915tex/i915_context.h
index e4c4a319f4..b5b97f7e1f 100644
--- a/src/mesa/drivers/dri/i915tex/i915_context.h
+++ b/src/mesa/drivers/dri/i915tex/i915_context.h
@@ -97,7 +97,11 @@ struct i915_fragment_program
#define I915_DYNAMIC_BFO_1 7
#define I915_DYNAMIC_STP_0 8
#define I915_DYNAMIC_STP_1 9
-#define I915_MAX_DYNAMIC 10
+#define I915_DYNAMIC_SC_0 10
+#define I915_DYNAMIC_SC_1 11
+#define I915_DYNAMIC_SC_2 12
+#define I915_DYNAMIC_SC_3 13
+#define I915_MAX_DYNAMIC 14
#define I915_IMMEDIATE_S0 0
diff --git a/src/mesa/drivers/dri/i915tex/i915_state.c b/src/mesa/drivers/dri/i915tex/i915_state.c
index 1595ecfe71..e068e29774 100644
--- a/src/mesa/drivers/dri/i915tex/i915_state.c
+++ b/src/mesa/drivers/dri/i915tex/i915_state.c
@@ -79,6 +79,7 @@ const struct intel_tracked_state *atoms[] =
&i915_upload_DEPTHSCALE,
&i915_upload_IAB,
&i915_upload_MODES4,
+ &i915_upload_SCISSOR,
&i915_upload_dynamic_indirect,
/* Other indirect state. Also includes program state, above.
diff --git a/src/mesa/drivers/dri/i915tex/i915_state.h b/src/mesa/drivers/dri/i915tex/i915_state.h
index f18ced5dfd..07fa0455c0 100644
--- a/src/mesa/drivers/dri/i915tex/i915_state.h
+++ b/src/mesa/drivers/dri/i915tex/i915_state.h
@@ -65,6 +65,7 @@ const struct intel_tracked_state i915_upload_FOGMODE;
const struct intel_tracked_state i915_upload_IAB;
const struct intel_tracked_state i915_upload_MODES4;
const struct intel_tracked_state i915_upload_STIPPLE;
+const struct intel_tracked_state i915_upload_SCISSOR;
const struct intel_tracked_state i915_upload_dynamic_indirect;
/* Other indirect:
diff --git a/src/mesa/drivers/dri/i915tex/i915_state_dynamic.c b/src/mesa/drivers/dri/i915tex/i915_state_dynamic.c
index 7af93a0d86..24e07e2810 100644
--- a/src/mesa/drivers/dri/i915tex/i915_state_dynamic.c
+++ b/src/mesa/drivers/dri/i915tex/i915_state_dynamic.c
@@ -103,6 +103,7 @@ static void emit_dynamic_indirect( struct intel_context *intel)
CHECK( I915_DYNAMIC_BC_0, 2 );
CHECK( I915_DYNAMIC_BFO_0, 2 );
CHECK( I915_DYNAMIC_STP_0, 2 );
+ CHECK( I915_DYNAMIC_SC_0, 4 );
if (!dirty)
return;
@@ -503,3 +504,80 @@ const struct intel_tracked_state i915_upload_STIPPLE = {
},
.update = upload_STIPPLE
};
+
+
+
+/***********************************************************************
+ * Scissor.
+ *
+ * Is it static or dynamic??? It is not understood by the hardware
+ * binner, so if we ever implement HWZ, it would be static under that
+ * scheme, or somehow not handled, or perhaps we would have to
+ * manually clip primitives to the scissor region. For now, we call
+ * it static.
+ */
+static void upload_SCISSOR( struct intel_context *intel )
+{
+ GLuint sc[4];
+
+ GLboolean scissor = (intel->state.Scissor->Enabled &&
+ intel->state.DrawBuffer);
+
+ /* _NEW_SCISSOR, _NEW_BUFFERS
+ */
+ if (scissor)
+ sc[0] = _3DSTATE_SCISSOR_ENABLE_CMD | ENABLE_SCISSOR_RECT;
+ else
+ sc[0] = _3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT;
+
+ {
+ GLint x = intel->state.Scissor->X;
+ GLint y = intel->state.Scissor->Y;
+ GLint w = intel->state.Scissor->Width;
+ GLint h = intel->state.Scissor->Height;
+
+ GLint x1, y1, x2, y2;
+
+ if (intel->state.DrawBuffer->Name == 0) {
+ x1 = x;
+ y1 = intel->state.DrawBuffer->Height - (y + h);
+ x2 = x + w - 1;
+ y2 = y1 + h - 1;
+ }
+ else {
+ /* FBO - not inverted
+ */
+ x1 = x;
+ y1 = y;
+ x2 = x + w - 1;
+ y2 = y + h - 1;
+ }
+
+ x1 = CLAMP(x1, 0, intel->state.DrawBuffer->Width - 1);
+ y1 = CLAMP(y1, 0, intel->state.DrawBuffer->Height - 1);
+ x2 = CLAMP(x2, 0, intel->state.DrawBuffer->Width - 1);
+ y2 = CLAMP(y2, 0, intel->state.DrawBuffer->Height - 1);
+
+ sc[1] = _3DSTATE_SCISSOR_RECT_0_CMD;
+ sc[2] = (y1 << 16) | (x1 & 0xffff);
+ sc[3] = (y2 << 16) | (x2 & 0xffff);
+ }
+
+ /* XXX: For hwz, we would need to flush and restart when this
+ * changes, according to docs at least.
+ */
+ set_dynamic_indirect( intel,
+ I915_DYNAMIC_SC_0,
+ &sc[0],
+ 4 );
+}
+
+
+const struct intel_tracked_state i915_upload_SCISSOR = {
+ .dirty = {
+ .mesa = _NEW_SCISSOR | _NEW_BUFFERS,
+ .intel = 0,
+ .extra = 0
+ },
+ .update = upload_SCISSOR
+};
diff --git a/src/mesa/drivers/dri/i915tex/i915_state_static.c b/src/mesa/drivers/dri/i915tex/i915_state_static.c
index f1f5a1248c..91cd43a059 100644
--- a/src/mesa/drivers/dri/i915tex/i915_state_static.c
+++ b/src/mesa/drivers/dri/i915tex/i915_state_static.c
@@ -124,15 +124,12 @@ static void upload_static(struct intel_context *intel)
struct intel_region *color_region = intel->state.draw_region;
struct intel_region *depth_region = intel->state.depth_region;
struct i915_cache_packet packet;
- GLboolean scissor = (intel->state.Scissor->Enabled &&
- intel->state.DrawBuffer);
GLuint clearparams = intel->state.clearparams;
GLuint i;
GLuint dwords = ((color_region ? 3 : 0) +
(depth_region ? 3 : 0) +
2 + /* DV */
- (scissor ? 4 : 1) +
(clearparams ? 14 : 0) +
Elements(invarient_state));
@@ -143,7 +140,9 @@ static void upload_static(struct intel_context *intel)
packet_init( &packet, I915_CACHE_STATIC, dwords, relocs );
/***********************************************************************
- * Misc invarient state packets
+ * Misc invarient state packets. These are maybe special and
+ * should just be handled as a batchbufffer preamble like they used
+ * to be.
*/
for (i = 0; i < Elements(invarient_state); i++)
packet_dword( &packet, invarient_state[i] );
@@ -198,56 +197,6 @@ static void upload_static(struct intel_context *intel)
: DEPTH_FRMT_16_FIXED)) );
- /***********************************************************************
- * Scissor.
- *
- * Is it static or dynamic??? It is not understood by the hardware
- * binner, so if we ever implement HWZ, it would be static under that
- * scheme, or somehow not handled, or perhaps we would have to
- * manually clip primitives to the scissor region. For now, we call
- * it static.
- */
-
- /* _NEW_SCISSOR, _NEW_BUFFERS
- */
- if (scissor) {
-
- GLint x = intel->state.Scissor->X;
- GLint y = intel->state.Scissor->Y;
- GLint w = intel->state.Scissor->Width;
- GLint h = intel->state.Scissor->Height;
-
- GLint x1, y1, x2, y2;
-
- if (intel->state.DrawBuffer->Name == 0) {
- x1 = x;
- y1 = intel->state.DrawBuffer->Height - (y + h);
- x2 = x + w - 1;
- y2 = y1 + h - 1;
- }
- else {
- /* FBO - not inverted
- */
- x1 = x;
- y1 = y;
- x2 = x + w - 1;
- y2 = y + h - 1;
- }
-
- x1 = CLAMP(x1, 0, intel->state.DrawBuffer->Width - 1);
- y1 = CLAMP(y1, 0, intel->state.DrawBuffer->Height - 1);
- x2 = CLAMP(x2, 0, intel->state.DrawBuffer->Width - 1);
- y2 = CLAMP(y2, 0, intel->state.DrawBuffer->Height - 1);
-
- packet_dword( &packet,_3DSTATE_SCISSOR_ENABLE_CMD | ENABLE_SCISSOR_RECT);
- packet_dword( &packet,_3DSTATE_SCISSOR_RECT_0_CMD);
- packet_dword( &packet,(y1 << 16) | (x1 & 0xffff));
- packet_dword( &packet,(y2 << 16) | (x2 & 0xffff));
- }
- else {
- packet_dword( &packet,_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT);
- }
-
/* INTEL_NEW_CLEAR_PARAMS, _NEW_DEPTH
*/
@@ -310,7 +259,7 @@ static void upload_static(struct intel_context *intel)
const struct intel_tracked_state i915_upload_static = {
.dirty = {
- .mesa = _NEW_SCISSOR | _NEW_BUFFERS | _NEW_COLOR | _NEW_DEPTH | _NEW_STENCIL,
+ .mesa = _NEW_COLOR | _NEW_DEPTH | _NEW_STENCIL,
.intel = INTEL_NEW_CBUF | INTEL_NEW_ZBUF | INTEL_NEW_FENCE | INTEL_NEW_CLEAR_PARAMS,
.extra = 0
},