summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2011-02-26 16:54:14 +0100
committerDaniel Vetter <daniel.vetter@ffwll.ch>2011-02-26 22:25:08 +0100
commit5feb1a30440774f0ab30e9c3335c8d4bdb90eda2 (patch)
tree1ffe7e4f046978c68e01be368bafa7cdd107b1e1
parent5c9b1db2367effae51e10fba0eb8a069f8450397 (diff)
i915g: switch constants emission to hw_atom
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--src/gallium/drivers/i915/i915_state_emit.c93
1 files changed, 49 insertions, 44 deletions
diff --git a/src/gallium/drivers/i915/i915_state_emit.c b/src/gallium/drivers/i915/i915_state_emit.c
index 1eaba9c05f..27f50eb2da 100644
--- a/src/gallium/drivers/i915/i915_state_emit.c
+++ b/src/gallium/drivers/i915/i915_state_emit.c
@@ -290,6 +290,53 @@ emit_sampler(struct i915_context *i915)
}
}
+static void
+update_constants(struct i915_context *i915, unsigned *batch_space)
+{
+ *batch_space = i915->fs->num_constants ?
+ 2 + 4*i915->fs->num_constants : 0;
+}
+
+static void
+emit_constants(struct i915_context *i915)
+{
+ /* Collate the user-defined constants with the fragment shader's
+ * immediates according to the constant_flags[] array.
+ */
+ const uint nr = i915->fs->num_constants;
+ if (nr) {
+ uint i;
+
+ OUT_BATCH( _3DSTATE_PIXEL_SHADER_CONSTANTS | (nr * 4) );
+ OUT_BATCH((1 << nr) - 1);
+
+ for (i = 0; i < nr; i++) {
+ const uint *c;
+ if (i915->fs->constant_flags[i] == I915_CONSTFLAG_USER) {
+ /* grab user-defined constant */
+ c = (uint *) i915_buffer(i915->constants[PIPE_SHADER_FRAGMENT])->data;
+ c += 4 * i;
+ }
+ else {
+ /* emit program constant */
+ c = (uint *) i915->fs->constants[i];
+ }
+#if 0 /* debug */
+ {
+ float *f = (float *) c;
+ printf("Const %2d: %f %f %f %f %s\n", i, f[0], f[1], f[2], f[3],
+ (i915->fs->constant_flags[i] == I915_CONSTFLAG_USER
+ ? "user" : "immediate"));
+ }
+#endif
+ OUT_BATCH(*c++);
+ OUT_BATCH(*c++);
+ OUT_BATCH(*c++);
+ OUT_BATCH(*c++);
+ }
+ }
+}
+
const static struct i915_tracked_hw_state hw_atoms[] = {
{ "flush", update_flush, emit_flush, I915_HW_FLUSH },
{ "invariant", NULL, emit_invariant,
@@ -298,7 +345,8 @@ const static struct i915_tracked_hw_state hw_atoms[] = {
{ "dynamic", update_dynamic, emit_dynamic, I915_HW_DYNAMIC },
{ "static", update_static, emit_static, I915_HW_STATIC },
{ "map", update_map, emit_map, I915_HW_MAP },
- { "sampler", update_sampler, emit_sampler, I915_HW_SAMPLER }
+ { "sampler", update_sampler, emit_sampler, I915_HW_SAMPLER },
+ { "constants", update_constants, emit_constants, I915_HW_CONSTANTS }
};
static boolean
@@ -387,49 +435,6 @@ i915_emit_hardware_state(struct i915_context *i915 )
emit_state(i915);
#if 01
- /* constants */
- /* 2 + I915_MAX_CONSTANT*4 dwords, 0 relocs */
- if (i915->hardware_dirty & I915_HW_CONSTANTS)
- {
- /* Collate the user-defined constants with the fragment shader's
- * immediates according to the constant_flags[] array.
- */
- const uint nr = i915->fs->num_constants;
- if (nr) {
- uint i;
-
- OUT_BATCH( _3DSTATE_PIXEL_SHADER_CONSTANTS | (nr * 4) );
- OUT_BATCH((1 << nr) - 1);
-
- for (i = 0; i < nr; i++) {
- const uint *c;
- if (i915->fs->constant_flags[i] == I915_CONSTFLAG_USER) {
- /* grab user-defined constant */
- c = (uint *) i915_buffer(i915->constants[PIPE_SHADER_FRAGMENT])->data;
- c += 4 * i;
- }
- else {
- /* emit program constant */
- c = (uint *) i915->fs->constants[i];
- }
-#if 0 /* debug */
- {
- float *f = (float *) c;
- printf("Const %2d: %f %f %f %f %s\n", i, f[0], f[1], f[2], f[3],
- (i915->fs->constant_flags[i] == I915_CONSTFLAG_USER
- ? "user" : "immediate"));
- }
-#endif
- OUT_BATCH(*c++);
- OUT_BATCH(*c++);
- OUT_BATCH(*c++);
- OUT_BATCH(*c++);
- }
- }
- }
-#endif
-
-#if 01
/* Fragment program */
/* i915->current.program_len dwords, 0 relocs */
if (i915->hardware_dirty & I915_HW_PROGRAM)