shader-slang / slang

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

Added float2x2 cast to float4 (and vise versa) #4432

Closed ArielG-NV closed 4 days ago

ArielG-NV commented 1 week ago

fixes: #4415

Note: not adding matrix<1,N> and matrix<N,1> translations since this will bloat stdlib with many expensive to process extension operations. matrix<N,1> is already planned to be treated as vectors (which should solve this problem by proxy).

csyonghe commented 1 week ago

I really don't think we should allow implicit cast from float2x2 to float4 because they are fundamentally different types. This is not the same as 1-vector and scalar.

csyonghe commented 1 week ago

Why do we need this?

ArielG-NV commented 1 week ago

Why do we need this?

HLSL has the feature, Hai requested it. https://github.com/shader-slang/slang/issues/4415

csyonghe commented 1 week ago

I don't think we should provide everything HLSL has. And I think this is one of the bad things we shouldn't be adding to our language.

csyonghe commented 1 week ago

We can add an explicit conversion between float2x2 and float4, but we shouldn't make them implicit.