summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Berry <stereotype441@gmail.com>2013-02-17 08:05:52 -0800
committerPaul Berry <stereotype441@gmail.com>2013-04-11 09:25:25 -0700
commit42a3d63dd4470be73b92b5d87daa32a9c293f127 (patch)
treee9aa51b5f74cb2e044386bb27f4909a21db27ffe
parent8941f73c7ccb3c6cfa965a19f346e4b6ead6abdb (diff)
i965/vs: Add virtual function make_reg_for_system_value().
The system values handled by vec4_visitor::visit(ir_variable *) are VS-specific (vertex ID and instance ID). This patch moves the handling of those values into a new virtual function, make_reg_for_system_value(), so that this VS-specific code won't be inherited by geomtry shaders. Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4.h2
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp46
-rw-r--r--src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp6
3 files changed, 36 insertions, 18 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index cd3b6e70305..6bc0d304f12 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -482,6 +482,7 @@ public:
void dump_instructions();
protected:
+ virtual dst_reg *make_reg_for_system_value(ir_variable *ir) = 0;
virtual int setup_attributes(int payload_reg) = 0;
virtual void emit_prolog() = 0;
virtual void emit_program_code() = 0;
@@ -499,6 +500,7 @@ public:
void *mem_ctx);
protected:
+ virtual dst_reg *make_reg_for_system_value(ir_variable *ir);
virtual int setup_attributes(int payload_reg);
virtual void emit_prolog();
virtual void emit_program_code();
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 407c9e7100b..41d41e17366 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -1015,6 +1015,33 @@ vec4_vs_visitor::emit_prolog()
}
}
+
+dst_reg *
+vec4_vs_visitor::make_reg_for_system_value(ir_variable *ir)
+{
+ /* VertexID is stored by the VF as the last vertex element, but
+ * we don't represent it with a flag in inputs_read, so we call
+ * it VERT_ATTRIB_MAX, which setup_attributes() picks up on.
+ */
+ dst_reg *reg = new(mem_ctx) dst_reg(ATTR, VERT_ATTRIB_MAX);
+ prog_data->uses_vertexid = true;
+
+ switch (ir->location) {
+ case SYSTEM_VALUE_VERTEX_ID:
+ reg->writemask = WRITEMASK_X;
+ break;
+ case SYSTEM_VALUE_INSTANCE_ID:
+ reg->writemask = WRITEMASK_Y;
+ break;
+ default:
+ assert(!"not reached");
+ break;
+ }
+
+ return reg;
+}
+
+
void
vec4_visitor::visit(ir_variable *ir)
{
@@ -1068,24 +1095,7 @@ vec4_visitor::visit(ir_variable *ir)
break;
case ir_var_system_value:
- /* VertexID is stored by the VF as the last vertex element, but
- * we don't represent it with a flag in inputs_read, so we call
- * it VERT_ATTRIB_MAX, which setup_attributes() picks up on.
- */
- reg = new(mem_ctx) dst_reg(ATTR, VERT_ATTRIB_MAX);
- prog_data->uses_vertexid = true;
-
- switch (ir->location) {
- case SYSTEM_VALUE_VERTEX_ID:
- reg->writemask = WRITEMASK_X;
- break;
- case SYSTEM_VALUE_INSTANCE_ID:
- reg->writemask = WRITEMASK_Y;
- break;
- default:
- assert(!"not reached");
- break;
- }
+ reg = make_reg_for_system_value(ir);
break;
default:
diff --git a/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp b/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp
index 60a993e105b..7c507f86d02 100644
--- a/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp
+++ b/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp
@@ -54,6 +54,12 @@ public:
}
protected:
+ virtual dst_reg *make_reg_for_system_value(ir_variable *ir)
+ {
+ assert(!"Not reached");
+ return NULL;
+ }
+
virtual int setup_attributes(int payload_reg)
{
assert(!"Not reached");