Mesa (master): i965: Fix cube array coordinate normalization

Chris Forbes chrisf at kemper.freedesktop.org
Thu Sep 26 06:20:12 UTC 2013


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

Author: Chris Forbes <chrisf at ijw.co.nz>
Date:   Sun Sep 15 22:25:45 2013 +1200

i965: Fix cube array coordinate normalization

Hardware requires the magnitude of the largest component to not exceed
1; brw_cubemap_normalize ensures that this is the case.

Unfortunately, we would previously multiply the array index for cube
arrays by the normalization factor. The incorrect array index would then
cause the sampler to attempt to access either the wrong cube, or memory
outside the cube surface entirely, resulting in garbage rendering or in
the worst case, hangs.

Alter the normalization pass to only multiply the .xyz components.

Fixes broken rendering in the arb_texture_cube_map_array-cubemap piglit,
which was recently adjusted to provoke this behavior.

V2: Fix indent.

Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
Cc: "9.2" mesa-stable at lists.freedesktop.org
Reviewed-by: Eric Anholt <eric at anholt.net>

---

 .../drivers/dri/i965/brw_cubemap_normalize.cpp     |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_cubemap_normalize.cpp b/src/mesa/drivers/dri/i965/brw_cubemap_normalize.cpp
index 9e149f9..46155fb 100644
--- a/src/mesa/drivers/dri/i965/brw_cubemap_normalize.cpp
+++ b/src/mesa/drivers/dri/i965/brw_cubemap_normalize.cpp
@@ -32,6 +32,7 @@
 
 #include "glsl/glsl_types.h"
 #include "glsl/ir.h"
+#include "program/prog_instruction.h" /* For WRITEMASK_* */
 
 class brw_cubemap_normalize_visitor : public ir_hierarchical_visitor {
 public:
@@ -88,11 +89,16 @@ brw_cubemap_normalize_visitor::visit_leave(ir_texture *ir)
 				     glsl_type::float_type,
 				     expr, NULL);
 
-   deref = new(mem_ctx) ir_dereference_variable(var);
-   ir->coordinate = new(mem_ctx) ir_expression(ir_binop_mul,
-					       ir->coordinate->type,
-					       deref,
-					       expr);
+   /* coordinate.xyz *= expr */
+   assign = new(mem_ctx) ir_assignment(
+      new(mem_ctx) ir_dereference_variable(var),
+      new(mem_ctx) ir_expression(ir_binop_mul,
+                                 ir->coordinate->type,
+                                 new(mem_ctx) ir_dereference_variable(var),
+                                 expr));
+   assign->write_mask = WRITEMASK_XYZ;
+   base_ir->insert_before(assign);
+   ir->coordinate = new(mem_ctx) ir_dereference_variable(var);
 
    progress = true;
    return visit_continue;




More information about the mesa-commit mailing list