Mesa (9.0): i965: Lower textureGrad() with samplerCubeShadow.

Kenneth Graunke kwg at kemper.freedesktop.org
Thu Jan 31 00:22:15 UTC 2013


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Wed Jan 16 11:14:14 2013 -0800

i965: Lower textureGrad() with samplerCubeShadow.

We weren't lowering textureGrad() with samplerCubeShadow because I
couldn't figure out the LOD calculations.  It turns out they're easy:
you just have to use 1 for the depth.  This causes it to pass
oglconform's four tests.

(cherry picked from commit 613e64060c2bc58c3920c3c6ff77291642ba0e23)

When cherry-picking this to stable, I've reordered this before the
Haswell commit that would have introduced a regression.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Tested-by: Anuj Phogat <anuj.phogat at gmail.com> (original)
Tested-by: Ian Romanick <idr at freedesktop.org> (original)

---

 .../dri/i965/brw_lower_texture_gradients.cpp       |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_lower_texture_gradients.cpp b/src/mesa/drivers/dri/i965/brw_lower_texture_gradients.cpp
index dfbb983..9e661a1 100644
--- a/src/mesa/drivers/dri/i965/brw_lower_texture_gradients.cpp
+++ b/src/mesa/drivers/dri/i965/brw_lower_texture_gradients.cpp
@@ -27,6 +27,7 @@
 
 #include "glsl/ir.h"
 #include "glsl/ir_builder.h"
+#include "program/prog_instruction.h"
 
 using namespace ir_builder;
 
@@ -89,10 +90,6 @@ lower_texture_grad_visitor::visit_leave(ir_texture *ir)
    if (ir->op != ir_txd || !ir->shadow_comparitor)
       return visit_continue;
 
-   /* Cubes are broken.  Avoid assertion failures when swizzling. */
-   if (ir->sampler->type->sampler_dimensionality == GLSL_SAMPLER_DIM_CUBE)
-      return visit_continue;
-
    void *mem_ctx = ralloc_parent(ir);
 
    const glsl_type *grad_type = ir->lod_info.grad.dPdx->type;
@@ -106,8 +103,14 @@ lower_texture_grad_visitor::visit_leave(ir_texture *ir)
    txs->lod_info.lod = new(mem_ctx) ir_constant(0);
    ir_variable *size =
       new(mem_ctx) ir_variable(grad_type, "size", ir_var_temporary);
-   emit(size, expr(ir_unop_i2f,
-		   swizzle_for_size(txs, grad_type->vector_elements)));
+   if (ir->sampler->type->sampler_dimensionality == GLSL_SAMPLER_DIM_CUBE) {
+      base_ir->insert_before(size);
+      base_ir->insert_before(assign(size, expr(ir_unop_i2f, txs), WRITEMASK_XY));
+      base_ir->insert_before(assign(size, new(mem_ctx) ir_constant(1.0f), WRITEMASK_Z));
+   } else {
+      emit(size, expr(ir_unop_i2f,
+                      swizzle_for_size(txs, grad_type->vector_elements)));
+   }
 
    /* Scale the gradients by width and height.  Effectively, the incoming
     * gradients are s'(x,y), t'(x,y), and r'(x,y) from equation 3.19 in the




More information about the mesa-commit mailing list