shader-slang / slang

Making it easier to work with shaders
MIT License
1.78k stars 158 forks source link

Post-op multiplication results in ambiguous call #4414

Closed chaoticbob closed 6 days ago

chaoticbob commented 1 week ago

The shader below is generating a baffling error message for a post-op multiplication expression:

error 39999: ambiguous call to 'mul' with arguments of type (matrix<int,2,2>, vector<int,2>)
  b.zw = mul(a, b.yx);
            ^
hlsl.meta.slang(10850): note 39999: candidate: func mul<int, 2, 2>(int2x2, int2) -> int2
hlsl.meta.slang(10826): note 39999: candidate: func mul<int, 2, 2>(int2x2, int2) -> int2

As far as I can tell this is a int2x2 * int2 which should work?

CMD

slangc.exe -target spirv -lang slang -D__spirv__ -emit-spirv-directly -profile ps_6_0 -entry main shader.slang

Shader

void main() {
  int2x2 a;
  int4 b;

  b.zw = mul(a, b.yx);
}
jkwak-work commented 1 week ago

The error message means that Slang found two functions matching to the given expression and it cannot decide which one to use. Most likely it is a bug in our Slang stdlib. I will take a look at it tomorrow.