summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2024-06-24 09:45:21 -0400
committerGitHub <noreply@github.com>2024-06-24 09:45:21 -0400
commitd832e33574ed772db1fa9b7ba184b37d0e3704cf (patch)
tree8a0a369757b7c7c37121d7d78bb870b10d6f6750 /source
parentcf8d1ceffcfbbb64734e6180a2c0cebd033f5b2e (diff)
Added float2x2 cast to float4 (and vise versa) (#4432)
* added float4x4<->float4 casting (and related) 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). * address review * explicit cast mat to vec
Diffstat (limited to 'source')
-rw-r--r--source/slang/core.meta.slang25
1 files changed, 25 insertions, 0 deletions
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<int16_t,R,C,L>
__init(int value) { this = matrix<T,R,C,L>(T(value)); }
}
+__intrinsic_op(makeVector)
+__generic<T, let N:int>
+vector<T,N*2> __makeVector(vector<T,N> vec1, vector<T,N> vec2);
+
+__generic<T>
+extension vector<T, 4>
+{
+ __generic<let L : int>
+ [__unsafeForceInlineEarly]
+ __init(matrix<T, 2, 2, L> value)
+ {
+ this = __makeVector(value[0], value[1]);
+ }
+}
+__generic<T, let L : int>
+extension matrix<T, 2, 2, L>
+{
+ [__unsafeForceInlineEarly]
+ __init(vector<T, 4> value)
+ {
+ this[0] = value.xy;
+ this[1] = value.zw;
+ }
+}
+
${{{{
static const struct {
char const* name;