<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Apr 12, 2017 at 6:14 AM, Boyan Ding <span dir="ltr"><<a href="mailto:boyan.j.ding@gmail.com" target="_blank">boyan.j.ding@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This fixes the following error when using ARB_shader_clock on i965:<br>
vec1 32 ssa_0 = intrinsic shader_clock () () ()<br>
intrinsic store_var (ssa_0) (clock_retval) (3) /* wrmask=xy */<br>
error: src->ssa->num_components == num_components (nir/nir_validate.c:204)<br>
<br>
Cc: <a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.freedesktop.<wbr>org</a><br>
Signed-off-by: Boyan Ding <<a href="mailto:boyan.j.ding@gmail.com">boyan.j.ding@gmail.com</a>><br>
---<br>
src/compiler/glsl/glsl_to_nir.<wbr>cpp | 3 ++-<br>
src/compiler/nir/nir_<wbr>intrinsics.h | 2 +-<br>
2 files changed, 3 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/compiler/glsl/glsl_to_<wbr>nir.cpp b/src/compiler/glsl/glsl_to_<wbr>nir.cpp<br>
index f0557f985b..870d457681 100644<br>
--- a/src/compiler/glsl/glsl_to_<wbr>nir.cpp<br>
+++ b/src/compiler/glsl/glsl_to_<wbr>nir.cpp<br>
@@ -930,7 +930,8 @@ nir_visitor::visit(ir_call *ir)<br>
nir_builder_instr_insert(&b, &instr->instr);<br>
break;<br>
case nir_intrinsic_shader_clock:<br>
- nir_ssa_dest_init(&instr-><wbr>instr, &instr->dest, 1, 32, NULL);<br>
+ nir_ssa_dest_init(&instr-><wbr>instr, &instr->dest, 2, 32, NULL);<br>
+ instr->num_components = 2;<br></blockquote><div><br></div><div>This made me go look at the spec, and things get a bit more subtle... In particular, ARB_shader_clock specifies two builtin functions:<br><pre> uvec2 clock2x32ARB(void);
uint64_t clockARB(void);</pre></div><div> Where the second one only exists if you support int64. On gen8+, we do support int64...<br><br></div><div>My feeling is that the correct way to implement this is to make the NIR intrinsic return a 64bit value and wrap it in a nir_unpack_64_2x32 if the client asks for the 2x32 version. If that's too much refactoring for you, then this patch is probably sufficient to solve the issue today.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
nir_builder_instr_insert(&b, &instr->instr);<br>
break;<br>
case nir_intrinsic_store_ssbo: {<br>
diff --git a/src/compiler/nir/nir_<wbr>intrinsics.h b/src/compiler/nir/nir_<wbr>intrinsics.h<br>
index 105c56f759..3a519a73dd 100644<br>
--- a/src/compiler/nir/nir_<wbr>intrinsics.h<br>
+++ b/src/compiler/nir/nir_<wbr>intrinsics.h<br>
@@ -91,7 +91,7 @@ BARRIER(memory_barrier)<br>
* The latter can be used as code motion barrier, which is currently not<br>
* feasible with NIR.<br>
*/<br>
-INTRINSIC(shader_clock, 0, ARR(0), true, 1, 0, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)<br>
+INTRINSIC(shader_clock, 0, ARR(0), true, 2, 0, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)<br>
<br>
/*<br>
* Memory barrier with semantics analogous to the compute shader<br>
<span class="gmail-HOEnZb"><font color="#888888">--<br>
2.12.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>