Mesa (master): glsl: Fix incorrect pattern matching in ir_set_program_inouts

Paul Berry stereotype441 at kemper.freedesktop.org
Wed Aug 14 18:11:23 UTC 2013


Module: Mesa
Branch: master
Commit: 98d2498404ba69a3efc1c765b1a1885d151181ed
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=98d2498404ba69a3efc1c765b1a1885d151181ed

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Fri Aug  9 07:58:43 2013 -0700

glsl: Fix incorrect pattern matching in ir_set_program_inouts

In commit 8fc41df (glsl: Modify ir_set_program_inouts to handle
geometry shaders), when attempting to pattern match the "foo" part of
expressions such as:

   foo[i][j]
   foo[i]

I incorrectly called as_dereference_variable() on the subexpression
foo[i] instead of foo.  As a result, the pattern never matched, so
ir_set_program_inouts would fall back on marking the entire variable
as used, rather than just the portion indexed by the array.

This didn't result in incorrect behaviour, but it could have resulted
in inefficiency by causing the back-end to allocate resources for
unused parts of an input or output array.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/glsl/ir_set_program_inouts.cpp |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/glsl/ir_set_program_inouts.cpp b/src/glsl/ir_set_program_inouts.cpp
index c6abc82..6196d6a 100644
--- a/src/glsl/ir_set_program_inouts.cpp
+++ b/src/glsl/ir_set_program_inouts.cpp
@@ -235,7 +235,7 @@ ir_set_program_inouts_visitor::visit_enter(ir_dereference_array *ir)
        * inner_array => foo[i]
        */
       if (ir_dereference_variable * const deref_var =
-          inner_array->as_dereference_variable()) {
+          inner_array->array->as_dereference_variable()) {
          if (this->shader_type == GL_GEOMETRY_SHADER &&
              deref_var->var->mode == ir_var_shader_in) {
             /* foo is a geometry shader input, so i is the vertex, and j the
@@ -253,7 +253,7 @@ ir_set_program_inouts_visitor::visit_enter(ir_dereference_array *ir)
          }
       }
    } else if (ir_dereference_variable * const deref_var =
-              ir->as_dereference_variable()) {
+              ir->array->as_dereference_variable()) {
       /* ir => foo[i], where foo is a variable. */
       if (this->shader_type == GL_GEOMETRY_SHADER &&
           deref_var->var->mode == ir_var_shader_in) {




More information about the mesa-commit mailing list