Mesa (10.2): linker: Fix consumer_inputs_with_locations indexing

Ian Romanick idr at kemper.freedesktop.org
Wed May 7 16:51:05 UTC 2014


Module: Mesa
Branch: 10.2
Commit: d26b59ec27ed7c85f3af17397a9e8325cf854420
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d26b59ec27ed7c85f3af17397a9e8325cf854420

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Mon May  5 10:39:26 2014 -0700

linker: Fix consumer_inputs_with_locations indexing

In an earlier incarnation of populate_consumer_input_sets and
get_matching_input, the consumer_inputs_with_locations array was indexed
using the user-specified location.  In that version, only user-defined
varyings were included in the array.

In the current incarnation, the Mesa location is used to index the
array, and built-in varyings are included.

This change fixes the unit test to exepect gl_ClipDistance in the array,
and it resizes the arrays to actually be big enough.  It's just dumb
luck that the existing piglit tests use small enough locations to not
stomp the stack. :(

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78258
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Cc: "10.2" <mesa-stable at lists.freedesktop.org>
Cc: Vinson Lee <vlee at freedesktop.org>
(cherry picked from commit f7bf37cb13ff4e727d640a3bd02980aba0c0b4ce)

---

 src/glsl/link_varyings.cpp       |    8 ++++----
 src/glsl/tests/varyings_test.cpp |   11 +++++------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index 45f1b10..ac38a2f 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -1092,11 +1092,11 @@ bool
 populate_consumer_input_sets(void *mem_ctx, exec_list *ir,
                              hash_table *consumer_inputs,
                              hash_table *consumer_interface_inputs,
-                             ir_variable *consumer_inputs_with_locations[MAX_VARYING])
+                             ir_variable *consumer_inputs_with_locations[VARYING_SLOT_MAX])
 {
    memset(consumer_inputs_with_locations,
           0,
-          sizeof(consumer_inputs_with_locations[0]) * MAX_VARYING);
+          sizeof(consumer_inputs_with_locations[0]) * VARYING_SLOT_MAX);
 
    foreach_list(node, ir) {
       ir_variable *const input_var = ((ir_instruction *) node)->as_variable();
@@ -1152,7 +1152,7 @@ get_matching_input(void *mem_ctx,
                    const ir_variable *output_var,
                    hash_table *consumer_inputs,
                    hash_table *consumer_interface_inputs,
-                   ir_variable *consumer_inputs_with_locations[MAX_VARYING])
+                   ir_variable *consumer_inputs_with_locations[VARYING_SLOT_MAX])
 {
    ir_variable *input_var;
 
@@ -1277,7 +1277,7 @@ assign_varying_locations(struct gl_context *ctx,
       = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare);
    hash_table *consumer_interface_inputs
       = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare);
-   ir_variable *consumer_inputs_with_locations[MAX_VARYING] = {
+   ir_variable *consumer_inputs_with_locations[VARYING_SLOT_MAX] = {
       NULL,
    };
 
diff --git a/src/glsl/tests/varyings_test.cpp b/src/glsl/tests/varyings_test.cpp
index 8a188a7..662fc0e 100644
--- a/src/glsl/tests/varyings_test.cpp
+++ b/src/glsl/tests/varyings_test.cpp
@@ -39,14 +39,14 @@ bool
 populate_consumer_input_sets(void *mem_ctx, exec_list *ir,
                              hash_table *consumer_inputs,
                              hash_table *consumer_interface_inputs,
-                             ir_variable *consumer_inputs_with_locations[MAX_VARYING]);
+                             ir_variable *consumer_inputs_with_locations[VARYING_SLOT_MAX]);
 
 ir_variable *
 get_matching_input(void *mem_ctx,
                    const ir_variable *output_var,
                    hash_table *consumer_inputs,
                    hash_table *consumer_interface_inputs,
-                   ir_variable *consumer_inputs_with_locations[MAX_VARYING]);
+                   ir_variable *consumer_inputs_with_locations[VARYING_SLOT_MAX]);
 }
 
 class link_varyings : public ::testing::Test {
@@ -70,7 +70,7 @@ public:
    hash_table *consumer_interface_inputs;
 
    const glsl_type *simple_interface;
-   ir_variable *junk[MAX_VARYING];
+   ir_variable *junk[VARYING_SLOT_MAX];
 };
 
 link_varyings::link_varyings()
@@ -197,9 +197,8 @@ TEST_F(link_varyings, gl_ClipDistance)
                                                     consumer_interface_inputs,
                                                     junk));
 
-   EXPECT_EQ((void *) clipdistance,
-             hash_table_find(consumer_inputs, "gl_ClipDistance"));
-   EXPECT_EQ(1u, num_elements(consumer_inputs));
+   EXPECT_EQ(clipdistance, junk[VARYING_SLOT_CLIP_DIST0]);
+   EXPECT_TRUE(is_empty(consumer_inputs));
    EXPECT_TRUE(is_empty(consumer_interface_inputs));
 }
 




More information about the mesa-commit mailing list