summaryrefslogtreecommitdiffstats
path: root/src/glsl/link_varyings.cpp
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2013-10-02 15:39:45 -0700
committerIan Romanick <[email protected]>2014-05-02 07:19:39 -0700
commit8f5852bd2b91df7b259e5aeafb6a62a4268ca4c4 (patch)
treea8349665eaa28b9940dc900916bf6dd034e030a6 /src/glsl/link_varyings.cpp
parentca21cffebd063354291d561eadc2ded8795a5333 (diff)
linker: Refactor code that builds hash tables of varyings during linking
I want to make some changes to this code, but first I want to make some unit tests for it... so that I can capture the pre- and post-invariants. Pulling the code out into its own function in a non-anonymous namespace enables that. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/glsl/link_varyings.cpp')
-rw-r--r--src/glsl/link_varyings.cpp53
1 files changed, 33 insertions, 20 deletions
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index adb23593b65..3a6dfc87148 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -1036,6 +1036,34 @@ private:
};
+namespace linker {
+
+void
+populate_consumer_input_sets(void *mem_ctx, exec_list *ir,
+ hash_table *consumer_inputs,
+ hash_table *consumer_interface_inputs)
+{
+ foreach_list(node, ir) {
+ ir_variable *const input_var = ((ir_instruction *) node)->as_variable();
+
+ if ((input_var != NULL) && (input_var->data.mode == ir_var_shader_in)) {
+ if (input_var->get_interface_type() != NULL) {
+ char *const iface_field_name =
+ ralloc_asprintf(mem_ctx, "%s.%s",
+ input_var->get_interface_type()->name,
+ input_var->name);
+ hash_table_insert(consumer_interface_inputs, input_var,
+ iface_field_name);
+ } else {
+ hash_table_insert(consumer_inputs, input_var,
+ ralloc_strdup(mem_ctx, input_var->name));
+ }
+ }
+ }
+}
+
+}
+
/**
* Assign locations for all variables that are produced in one pipeline stage
* (the "producer") and consumed in the next stage (the "consumer").
@@ -1088,26 +1116,11 @@ assign_varying_locations(struct gl_context *ctx,
* not being inputs. This lets the optimizer eliminate them.
*/
- if (consumer) {
- foreach_list(node, consumer->ir) {
- ir_variable *const input_var =
- ((ir_instruction *) node)->as_variable();
-
- if ((input_var != NULL) && (input_var->data.mode == ir_var_shader_in)) {
- if (input_var->get_interface_type() != NULL) {
- char *const iface_field_name =
- ralloc_asprintf(mem_ctx, "%s.%s",
- input_var->get_interface_type()->name,
- input_var->name);
- hash_table_insert(consumer_interface_inputs, input_var,
- iface_field_name);
- } else {
- hash_table_insert(consumer_inputs, input_var,
- ralloc_strdup(mem_ctx, input_var->name));
- }
- }
- }
- }
+ if (consumer)
+ linker::populate_consumer_input_sets(mem_ctx,
+ consumer->ir,
+ consumer_inputs,
+ consumer_interface_inputs);
foreach_list(node, producer->ir) {
ir_variable *const output_var = ((ir_instruction *) node)->as_variable();