From d832e33574ed772db1fa9b7ba184b37d0e3704cf Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Mon, 24 Jun 2024 09:45:21 -0400 Subject: Added float2x2 cast to float4 (and vise versa) (#4432) * added float4x4<->float4 casting (and related) Note: not adding `matrix<1,N>` and `matrix` translations since this will bloat stdlib with many expensive to process `extension` operations. `matrix` is already planned to be treated as vectors (which should solve this problem by proxy). * address review * explicit cast mat to vec --- source/slang/core.meta.slang | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source') diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang index 3f396b864..6b396a621 100644 --- a/source/slang/core.meta.slang +++ b/source/slang/core.meta.slang @@ -1210,6 +1210,31 @@ extension matrix __init(int value) { this = matrix(T(value)); } } +__intrinsic_op(makeVector) +__generic +vector __makeVector(vector vec1, vector vec2); + +__generic +extension vector +{ + __generic + [__unsafeForceInlineEarly] + __init(matrix value) + { + this = __makeVector(value[0], value[1]); + } +} +__generic +extension matrix +{ + [__unsafeForceInlineEarly] + __init(vector value) + { + this[0] = value.xy; + this[1] = value.zw; + } +} + ${{{{ static const struct { char const* name; -- cgit v1.2.3