Re: [Mesa-dev] [PATCH 4/4] glsl: Generated masked write instead of vector array index for UBO lowering

2013-03-27 Thread Kenneth Graunke

On 03/27/2013 09:30 AM, Ian Romanick wrote:

From: Ian Romanick 

When reading a column from a row-major matrix, we would slot the single
value read into the vector using an ir_dereference_array of the vector
with a constant index.  This will (eventually) get optimized to a
masked-write, so just generate the masked write in the first place.

Signed-off-by: Ian Romanick 
Cc: Eric Anholt 
---
  src/glsl/lower_ubo_reference.cpp | 9 +++--
  1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/glsl/lower_ubo_reference.cpp b/src/glsl/lower_ubo_reference.cpp
index 026197d..9e5e951 100644
--- a/src/glsl/lower_ubo_reference.cpp
+++ b/src/glsl/lower_ubo_reference.cpp
@@ -357,17 +357,14 @@ 
lower_ubo_reference_visitor::emit_ubo_loads(ir_dereference *deref,

for (unsigned i = 0; i < deref->type->vector_elements; i++) {
 ir_rvalue *chan = new(mem_ctx) ir_constant((int)i);


lower_ubo_reference.cpp:359:14: warning: unused variable 'chan' 
[-Wunused-variable]


You should delete this too.  Otherwise,

For the series:
Reviewed-by: Kenneth Graunke 


-ir_dereference *deref_chan =
-   new(mem_ctx) ir_dereference_array(deref->clone(mem_ctx, NULL),
- chan);
-
 ir_rvalue *chan_offset =
add(base_offset,
new(mem_ctx) ir_constant(deref_offset + i * matrix_stride));

-base_ir->insert_before(assign(deref_chan,
+base_ir->insert_before(assign(deref->clone(mem_ctx, NULL),
   ubo_load(glsl_type::float_type,
-   chan_offset)));
+   chan_offset),
+  (1U << i)));
}
 }
  }



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 4/4] glsl: Generated masked write instead of vector array index for UBO lowering

2013-03-27 Thread Ian Romanick
From: Ian Romanick 

When reading a column from a row-major matrix, we would slot the single
value read into the vector using an ir_dereference_array of the vector
with a constant index.  This will (eventually) get optimized to a
masked-write, so just generate the masked write in the first place.

Signed-off-by: Ian Romanick 
Cc: Eric Anholt 
---
 src/glsl/lower_ubo_reference.cpp | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/glsl/lower_ubo_reference.cpp b/src/glsl/lower_ubo_reference.cpp
index 026197d..9e5e951 100644
--- a/src/glsl/lower_ubo_reference.cpp
+++ b/src/glsl/lower_ubo_reference.cpp
@@ -357,17 +357,14 @@ 
lower_ubo_reference_visitor::emit_ubo_loads(ir_dereference *deref,
 
   for (unsigned i = 0; i < deref->type->vector_elements; i++) {
 ir_rvalue *chan = new(mem_ctx) ir_constant((int)i);
-ir_dereference *deref_chan =
-   new(mem_ctx) ir_dereference_array(deref->clone(mem_ctx, NULL),
- chan);
-
 ir_rvalue *chan_offset =
add(base_offset,
new(mem_ctx) ir_constant(deref_offset + i * matrix_stride));
 
-base_ir->insert_before(assign(deref_chan,
+base_ir->insert_before(assign(deref->clone(mem_ctx, NULL),
   ubo_load(glsl_type::float_type,
-   chan_offset)));
+   chan_offset),
+  (1U << i)));
   }
}
 }
-- 
1.8.1.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev