Mesa (master): i965/vec4: Initialize LOD to 0.0f for textureQueryLevels() and texture().

Matt Turner mattst88 at kemper.freedesktop.org
Thu Oct 22 17:22:04 UTC 2015


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

Author: Matt Turner <mattst88 at gmail.com>
Date:   Mon Oct 19 10:51:42 2015 -0700

i965/vec4: Initialize LOD to 0.0f for textureQueryLevels() and texture().

We implement textureQueryLevels (which takes no arguments, save the
sampler) using the resinfo message (which takes an argument of LOD).
Without initializing it, we'd generate a MOV from the null register to
load the LOD argument.

Essentially the same logic applies to texture. A vertex shader cannot
compute derivatives and so cannot produce an LOD, so TXL with an LOD of
0.0 is used.

Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>

---

 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index c39f97e..b8f90f2 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -882,6 +882,18 @@ vec4_visitor::emit_texture(ir_texture_opcode op,
                            uint32_t sampler,
                            src_reg sampler_reg)
 {
+   /* The sampler can only meaningfully compute LOD for fragment shader
+    * messages. For all other stages, we change the opcode to TXL and hardcode
+    * the LOD to 0.
+    *
+    * textureQueryLevels() is implemented in terms of TXS so we need to pass a
+    * valid LOD argument.
+    */
+   if (op == ir_tex || op == ir_query_levels) {
+      assert(lod.file == BAD_FILE);
+      lod = src_reg(0.0f);
+   }
+
    enum opcode opcode;
    switch (op) {
    case ir_tex: opcode = SHADER_OPCODE_TXL; break;




More information about the mesa-commit mailing list