[Mesa-dev] [PATCH 59/78] i965/nir/vec4: Add utility method shader_opcode_for_nir_opcode()

Eduardo Lima Mitev elima at igalia.com
Fri Jun 26 01:07:15 PDT 2015


This is a helper method that returns a shader instruction opcode from the
corresponding NIR texture opcode. It will be used to keep code in
nir_emit_texture() clean.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89580
---
 src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 39 ++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
index 741b9af..6e9df99 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
@@ -1313,6 +1313,45 @@ vec4_visitor::nir_emit_jump(nir_jump_instr *instr)
    }
 }
 
+static enum opcode
+shader_opcode_for_nir_opcode(nir_texop nir_opcode)
+{
+  switch (nir_opcode) {
+   case nir_texop_query_levels:
+      return SHADER_OPCODE_TXS;
+
+   case nir_texop_tex:
+      return SHADER_OPCODE_TXL;
+
+   case nir_texop_tg4:
+      return SHADER_OPCODE_TG4;
+
+   case nir_texop_txd:
+     return SHADER_OPCODE_TXD;
+
+   case nir_texop_txf:
+     return SHADER_OPCODE_TXF;
+
+   case nir_texop_txf_ms:
+     return SHADER_OPCODE_TXF_CMS;
+
+   case nir_texop_txl:
+     return SHADER_OPCODE_TXL;
+
+   case nir_texop_txs:
+     return SHADER_OPCODE_TXS;
+
+   case nir_texop_txb:
+      unreachable("TXB (ie: texture() with bias on glsl) is not valid for vertex shaders.\n");
+
+   case nir_texop_lod:
+      unreachable("LOD (ie: textureQueryLOD on glsl) is not valid for vertex shaders.\n");
+
+   default:
+      unreachable("Unknown texture opcode");
+   }
+}
+
 void
 vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
 {
-- 
2.1.4



More information about the mesa-dev mailing list