<div dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 13, 2018 at 9:16 AM, Neil Roberts <span dir="ltr"><<a href="mailto:nroberts@igalia.com" target="_blank">nroberts@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The code to handle mat multipication by a scalar tries to pick either<br>
imul or fmul depending on whether the matrix is float or integer.<br>
However it was doing this by checking whether the base type is float.<br>
This was making it choose the int path for doubles (and presumably<br>
float16s).<br>
<br>
---<br>
<br>
This was discovered from running the arb_gpu_shader_fp64 tests through<br>
the GL_ARB_gl_spirv branch. For example:<br>
arb_gpu_shader_fp64@execution@<wbr>built-in-functions@vs-op-div-<wbr>dmat4-double.<br>
Note however these tests are hidden behind a glslang bug:<br>
<br>
<a href="https://github.com/KhronosGroup/glslang/issues/1278" rel="noreferrer" target="_blank">https://github.com/<wbr>KhronosGroup/glslang/issues/<wbr>1278</a><br>
<br>
The fix in that issue along with this patch makes them all pass.<br>
<br>
There’s also a little test case for this with VkRunner here:<br>
<br>
<a href="https://github.com/Igalia/vkrunner/blob/tests/examples/dmat-mul-scalar.shader_test" rel="noreferrer" target="_blank">https://github.com/Igalia/<wbr>vkrunner/blob/tests/examples/<wbr>dmat-mul-scalar.shader_test</a><br>
<br>
 src/compiler/spirv/vtn_alu.c | 6 +++---<br>
 1 file changed, 3 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/src/compiler/spirv/vtn_alu.c b/src/compiler/spirv/vtn_alu.c<br>
index d0c9e316935..110fcec2a60 100644<br>
--- a/src/compiler/spirv/vtn_alu.c<br>
+++ b/src/compiler/spirv/vtn_alu.c<br>
@@ -142,10 +142,10 @@ mat_times_scalar(struct vtn_builder *b,<br>
 {<br>
    struct vtn_ssa_value *dest = vtn_create_ssa_value(b, mat->type);<br>
    for (unsigned i = 0; i < glsl_get_matrix_columns(mat-><wbr>type); i++) {<br>
-      if (glsl_get_base_type(mat->type) == GLSL_TYPE_FLOAT)<br>
-         dest->elems[i]->def = nir_fmul(&b->nb, mat->elems[i]->def, scalar);<br>
-      else<br>
+      if (glsl_base_type_is_integer(<wbr>glsl_get_base_type(mat->type))<wbr>)<br>
          dest->elems[i]->def = nir_imul(&b->nb, mat->elems[i]->def, scalar);<br>
+      else<br>
+         dest->elems[i]->def = nir_fmul(&b->nb, mat->elems[i]->def, scalar);<br>
    }<br>
<br>
    return dest;<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.14.3<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></div></div>