<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Dec 7, 2017 at 11:54 AM, Michael Schellenberger Costa <span dir="ltr"><<a href="mailto:mschellenbergercosta@googlemail.com" target="_blank">mschellenbergercosta@<wbr>googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Jason,<span><br>
<br>
<br>
Am 07.12.2017 um 17:12 schrieb Jason Ekstrand:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
  src/compiler/spirv/vtn_variabl<wbr>es.c | 18 ++++++++++++++----<br>
  1 file changed, 14 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/src/compiler/spirv/vtn_varia<wbr>bles.c b/src/compiler/spirv/vtn_varia<wbr>bles.c<br>
index cf44ed3..8ce19ff 100644<br>
--- a/src/compiler/spirv/vtn_varia<wbr>bles.c<br>
+++ b/src/compiler/spirv/vtn_varia<wbr>bles.c<br>
@@ -1969,6 +1969,9 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,<br>
        struct vtn_value *dest = vtn_value(b, w[1], vtn_value_type_pointer);<br>
        struct vtn_value *src = vtn_value(b, w[2], vtn_value_type_pointer);<br>
  +      vtn_fail_if(dest->type->deref != src->type->deref,<br>
+                  "Result and pointer types of OpLoad do not match");<br>
</blockquote></span>
This should be OpCopyMemory?</blockquote><div><br></div><div>Oops.  Fixed locally.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> On a more general side: As you want to cover every OpCode, why not overload vtn_fail_if() so that it takes the OpCode and then prepends it to the error message, e.g.:<br>
<br>
vtn_fail_if(dest->type->deref != src->type->deref, opcode,"Result and pointer types of do not match");<br>
<br>
Would extend to<br>
<br>
"OpCodeMemory: Result and pointer types of do not match"<br>
<br>
That way there is no chance to really mess op the opcodes.<br></blockquote><div><br></div><div>I'm not sure what I think about that.  There may be cases where we want to use vtn_fail_if where we don't have ready access to the opcode.  One option would be to use spirv_opcode_to_string instead of putting it in the string but it may be hard to make that happen in such a way that we only call that function if the vtn_fail condition is true.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
All the best<span class="m_-5427107852966568026HOEnZb"><font color="#888888"><br>
Michael</font></span><div class="m_-5427107852966568026HOEnZb"><div class="m_-5427107852966568026h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
        vtn_variable_copy(b, dest->pointer, src->pointer);<br>
        break;<br>
     }<br>
@@ -1976,8 +1979,11 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,<br>
     case SpvOpLoad: {<br>
        struct vtn_type *res_type =<br>
           vtn_value(b, w[1], vtn_value_type_type)->type;<br>
-      struct vtn_pointer *src =<br>
-         vtn_value(b, w[3], vtn_value_type_pointer)->point<wbr>er;<br>
+      struct vtn_value *src_val = vtn_value(b, w[3], vtn_value_type_pointer);<br>
+      struct vtn_pointer *src = src_val->pointer;<br>
+<br>
+      vtn_fail_if(res_type != src_val->type->deref,<br>
+                  "Result and pointer types of OpLoad do not match");<br>
          if (src->mode == vtn_variable_mode_image ||<br>
            src->mode == vtn_variable_mode_sampler) {<br>
@@ -1990,8 +1996,12 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,<br>
     }<br>
       case SpvOpStore: {<br>
-      struct vtn_pointer *dest =<br>
-         vtn_value(b, w[1], vtn_value_type_pointer)->point<wbr>er;<br>
+      struct vtn_value *dest_val = vtn_value(b, w[1], vtn_value_type_pointer);<br>
+      struct vtn_pointer *dest = dest_val->pointer;<br>
+      struct vtn_value *src_val = vtn_untyped_value(b, w[2]);<br>
+<br>
+      vtn_fail_if(dest_val->type->de<wbr>ref != src_val->type,<br>
+                  "Value and pointer types of OpStore do not match");<br>
          if (glsl_type_is_sampler(dest->ty<wbr>pe->type)) {<br>
           vtn_warn("OpStore of a sampler detected.  Doing on-the-fly copy "<br>
</blockquote>
<br>
</div></div></blockquote></div><br></div></div>