<div dir="ltr"><div><div>It turns out there's already a glslang bug for this and it was closed in March:<br><br><a href="https://github.com/KhronosGroup/glslang/issues/809">https://github.com/KhronosGroup/glslang/issues/809</a><br><br></div>Unfortunately, there are applications shipping with these shaders so failure isn't really an option.<br><br></div>--Jason<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 14, 2017 at 7:56 PM, Jason Ekstrand <span dir="ltr"><<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The Talos Principle contains shaders with an OpSelect between two<br>
vectors where the condition is a scalar boolean.  This is technically<br>
against the spec bout nir_builder gracefully handles it by splatting<br>
out the condition to all the channels.  So long as the condition is a<br>
boolean, just emit a warning instead of failing.<br>
<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=104246" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/<wbr>show_bug.cgi?id=104246</a><br>
---<br>
 src/compiler/spirv/spirv_to_<wbr>nir.c | 18 ++++++++++++++----<br>
 1 file changed, 14 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/src/compiler/spirv/spirv_to_<wbr>nir.c b/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
index 0493dd3..f0476b2 100644<br>
--- a/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
+++ b/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
@@ -3511,10 +3511,20 @@ vtn_handle_body_instruction(<wbr>struct vtn_builder *b, SpvOp opcode,<br>
          vtn_fail("Result type of OpSelect must be a scalar, vector, or pointer");<br>
       }<br>
<br>
-      vtn_fail_if(sel_val->type-><wbr>type != sel_type,<br>
-                  "Condition type of OpSelect must be a scalar or vector of "<br>
-                  "Boolean type. It must have the same number of components "<br>
-                  "as Result Type");<br>
+      if (unlikely(sel_val->type->type != sel_type)) {<br>
+         if (sel_val->type->type == glsl_bool_type()) {<br>
+            /* This case is illegal but some versions of GLSLang produce it.<br>
+             * That's fine, nir_builder will just splat the condition out<br>
+             * which is most likely what the client wanted anyway.<br>
+             */<br>
+            vtn_warn("Condition type of OpSelect must have the same number "<br>
+                     "of components as Result Type");<br>
+         } else {<br>
+            vtn_fail("Condition type of OpSelect must be a scalar or vector "<br>
+                     "of Boolean type. It must have the same number of "<br>
+                     "components as Result Type");<br>
+         }<br>
+      }<br>
<br>
       vtn_fail_if(obj1_val->type != res_val->type ||<br>
                   obj2_val->type != res_val->type,<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.0.400.gff86faf<br>
<br>
</font></span></blockquote></div><br></div>