diff --git a/src/ComputeSharp.Core/Primitives/Bool/BoolMxN.g.cs b/src/ComputeSharp.Core/Primitives/Bool/BoolMxN.g.cs
index 2d09df216..b173a1474 100644
--- a/src/ComputeSharp.Core/Primitives/Bool/BoolMxN.g.cs
+++ b/src/ComputeSharp.Core/Primitives/Bool/BoolMxN.g.cs
@@ -36,10 +36,10 @@ public Bool1x1(bool m11)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref bool this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(bool) * row)));
+ public ref bool this[int row] => ref *(bool*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -184,10 +184,10 @@ public Bool1x2(bool m11, bool m12)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Bool2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool2) * row)));
+ public ref Bool2 this[int row] => ref *(Bool2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -350,10 +350,10 @@ public Bool1x3(bool m11, bool m12, bool m13)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Bool3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool3) * row)));
+ public ref Bool3 this[int row] => ref *(Bool3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -528,10 +528,10 @@ public Bool1x4(bool m11, bool m12, bool m13, bool m14)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Bool4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool4) * row)));
+ public ref Bool4 this[int row] => ref *(Bool4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -703,10 +703,10 @@ public Bool2x1(bool m11, bool m21)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref bool this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(bool) * row)));
+ public ref bool this[int row] => ref *(bool*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -887,10 +887,10 @@ public Bool2x2(Bool2 row1, Bool2 row2)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Bool2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool2) * row)));
+ public ref Bool2 this[int row] => ref *(Bool2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -1091,10 +1091,10 @@ public Bool2x3(Bool3 row1, Bool3 row2)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Bool3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool3) * row)));
+ public ref Bool3 this[int row] => ref *(Bool3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -1321,10 +1321,10 @@ public Bool2x4(Bool4 row1, Bool4 row2)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Bool4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool4) * row)));
+ public ref Bool4 this[int row] => ref *(Bool4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -1523,10 +1523,10 @@ public Bool3x1(bool m11, bool m21, bool m31)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref bool this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(bool) * row)));
+ public ref bool this[int row] => ref *(bool*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -1727,10 +1727,10 @@ public Bool3x2(Bool2 row1, Bool2 row2, Bool2 row3)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Bool2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool2) * row)));
+ public ref Bool2 this[int row] => ref *(Bool2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -1964,10 +1964,10 @@ public Bool3x3(Bool3 row1, Bool3 row2, Bool3 row3)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Bool3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool3) * row)));
+ public ref Bool3 this[int row] => ref *(Bool3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -2240,10 +2240,10 @@ public Bool3x4(Bool4 row1, Bool4 row2, Bool4 row3)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Bool4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool4) * row)));
+ public ref Bool4 this[int row] => ref *(Bool4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -2475,10 +2475,10 @@ public Bool4x1(bool m11, bool m21, bool m31, bool m41)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref bool this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(bool) * row)));
+ public ref bool this[int row] => ref *(bool*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -2699,10 +2699,10 @@ public Bool4x2(Bool2 row1, Bool2 row2, Bool2 row3, Bool2 row4)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Bool2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool2) * row)));
+ public ref Bool2 this[int row] => ref *(Bool2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -2969,10 +2969,10 @@ public Bool4x3(Bool3 row1, Bool3 row2, Bool3 row3, Bool3 row4)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Bool3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool3) * row)));
+ public ref Bool3 this[int row] => ref *(Bool3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -3291,10 +3291,10 @@ public Bool4x4(Bool4 row1, Bool4 row2, Bool4 row3, Bool4 row4)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Bool4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool4) * row)));
+ public ref Bool4 this[int row] => ref *(Bool4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
diff --git a/src/ComputeSharp.Core/Primitives/Double/DoubleMxN.g.cs b/src/ComputeSharp.Core/Primitives/Double/DoubleMxN.g.cs
index 5657f6e26..f946b9c5e 100644
--- a/src/ComputeSharp.Core/Primitives/Double/DoubleMxN.g.cs
+++ b/src/ComputeSharp.Core/Primitives/Double/DoubleMxN.g.cs
@@ -36,10 +36,10 @@ public Double1x1(double m11)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref double this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(double) * row)));
+ public ref double this[int row] => ref *(double*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -238,10 +238,10 @@ public Double1x2(double m11, double m12)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Double2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Double2) * row)));
+ public ref Double2 this[int row] => ref *(Double2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -458,10 +458,10 @@ public Double1x3(double m11, double m12, double m13)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Double3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Double3) * row)));
+ public ref Double3 this[int row] => ref *(Double3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -690,10 +690,10 @@ public Double1x4(double m11, double m12, double m13, double m14)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Double4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Double4) * row)));
+ public ref Double4 this[int row] => ref *(Double4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -919,10 +919,10 @@ public Double2x1(double m11, double m21)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref double this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(double) * row)));
+ public ref double this[int row] => ref *(double*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -1157,10 +1157,10 @@ public Double2x2(Double2 row1, Double2 row2)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Double2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Double2) * row)));
+ public ref Double2 this[int row] => ref *(Double2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -1415,10 +1415,10 @@ public Double2x3(Double3 row1, Double3 row2)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Double3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Double3) * row)));
+ public ref Double3 this[int row] => ref *(Double3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -1699,10 +1699,10 @@ public Double2x4(Double4 row1, Double4 row2)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Double4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Double4) * row)));
+ public ref Double4 this[int row] => ref *(Double4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -1955,10 +1955,10 @@ public Double3x1(double m11, double m21, double m31)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref double this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(double) * row)));
+ public ref double this[int row] => ref *(double*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -2213,10 +2213,10 @@ public Double3x2(Double2 row1, Double2 row2, Double2 row3)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Double2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Double2) * row)));
+ public ref Double2 this[int row] => ref *(Double2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -2504,10 +2504,10 @@ public Double3x3(Double3 row1, Double3 row2, Double3 row3)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Double3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Double3) * row)));
+ public ref Double3 this[int row] => ref *(Double3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -2834,10 +2834,10 @@ public Double3x4(Double4 row1, Double4 row2, Double4 row3)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Double4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Double4) * row)));
+ public ref Double4 this[int row] => ref *(Double4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -3123,10 +3123,10 @@ public Double4x1(double m11, double m21, double m31, double m41)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref double this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(double) * row)));
+ public ref double this[int row] => ref *(double*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -3401,10 +3401,10 @@ public Double4x2(Double2 row1, Double2 row2, Double2 row3, Double2 row4)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Double2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Double2) * row)));
+ public ref Double2 this[int row] => ref *(Double2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -3725,10 +3725,10 @@ public Double4x3(Double3 row1, Double3 row2, Double3 row3, Double3 row4)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Double3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Double3) * row)));
+ public ref Double3 this[int row] => ref *(Double3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -4101,10 +4101,10 @@ public Double4x4(Double4 row1, Double4 row2, Double4 row3, Double4 row4)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Double4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Double4) * row)));
+ public ref Double4 this[int row] => ref *(Double4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
diff --git a/src/ComputeSharp.Core/Primitives/Float/FloatMxN.g.cs b/src/ComputeSharp.Core/Primitives/Float/FloatMxN.g.cs
index d0585c39b..33554337e 100644
--- a/src/ComputeSharp.Core/Primitives/Float/FloatMxN.g.cs
+++ b/src/ComputeSharp.Core/Primitives/Float/FloatMxN.g.cs
@@ -37,10 +37,10 @@ public Float1x1(float m11)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref float this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(float) * row)));
+ public ref float this[int row] => ref *(float*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -257,10 +257,10 @@ public Float1x2(float m11, float m12)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Float2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Float2) * row)));
+ public ref Float2 this[int row] => ref *(Float2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -579,10 +579,10 @@ public Float1x3(float m11, float m12, float m13)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Float3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Float3) * row)));
+ public ref Float3 this[int row] => ref *(Float3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -913,10 +913,10 @@ public Float1x4(float m11, float m12, float m13, float m14)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Float4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Float4) * row)));
+ public ref Float4 this[int row] => ref *(Float4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -1244,10 +1244,10 @@ public Float2x1(float m11, float m21)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref float this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(float) * row)));
+ public ref float this[int row] => ref *(float*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -1570,10 +1570,10 @@ public Float2x2(Float2 row1, Float2 row2)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Float2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Float2) * row)));
+ public ref Float2 this[int row] => ref *(Float2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -1846,10 +1846,10 @@ public Float2x3(Float3 row1, Float3 row2)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Float3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Float3) * row)));
+ public ref Float3 this[int row] => ref *(Float3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -2232,10 +2232,10 @@ public Float2x4(Float4 row1, Float4 row2)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Float4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Float4) * row)));
+ public ref Float4 this[int row] => ref *(Float4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -2590,10 +2590,10 @@ public Float3x1(float m11, float m21, float m31)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref float this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(float) * row)));
+ public ref float this[int row] => ref *(float*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -2936,10 +2936,10 @@ public Float3x2(Float2 row1, Float2 row2, Float2 row3)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Float2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Float2) * row)));
+ public ref Float2 this[int row] => ref *(Float2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -3329,10 +3329,10 @@ public Float3x3(Float3 row1, Float3 row2, Float3 row3)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Float3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Float3) * row)));
+ public ref Float3 this[int row] => ref *(Float3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -3677,10 +3677,10 @@ public Float3x4(Float4 row1, Float4 row2, Float4 row3)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Float4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Float4) * row)));
+ public ref Float4 this[int row] => ref *(Float4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -4068,10 +4068,10 @@ public Float4x1(float m11, float m21, float m31, float m41)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref float this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(float) * row)));
+ public ref float this[int row] => ref *(float*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -4434,10 +4434,10 @@ public Float4x2(Float2 row1, Float2 row2, Float2 row3, Float2 row4)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Float2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Float2) * row)));
+ public ref Float2 this[int row] => ref *(Float2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -4860,10 +4860,10 @@ public Float4x3(Float3 row1, Float3 row2, Float3 row3, Float3 row4)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Float3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Float3) * row)));
+ public ref Float3 this[int row] => ref *(Float3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -5338,10 +5338,10 @@ public Float4x4(Float4 row1, Float4 row2, Float4 row3, Float4 row4)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Float4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Float4) * row)));
+ public ref Float4 this[int row] => ref *(Float4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
diff --git a/src/ComputeSharp.Core/Primitives/Int/IntMxN.g.cs b/src/ComputeSharp.Core/Primitives/Int/IntMxN.g.cs
index 3a0bed1a6..a092d2b5b 100644
--- a/src/ComputeSharp.Core/Primitives/Int/IntMxN.g.cs
+++ b/src/ComputeSharp.Core/Primitives/Int/IntMxN.g.cs
@@ -37,10 +37,10 @@ public Int1x1(int m11)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref int this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(int) * row)));
+ public ref int this[int row] => ref *(int*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -355,10 +355,10 @@ public Int1x2(int m11, int m12)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Int2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Int2) * row)));
+ public ref Int2 this[int row] => ref *(Int2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -775,10 +775,10 @@ public Int1x3(int m11, int m12, int m13)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Int3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Int3) * row)));
+ public ref Int3 this[int row] => ref *(Int3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -1207,10 +1207,10 @@ public Int1x4(int m11, int m12, int m13, int m14)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Int4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Int4) * row)));
+ public ref Int4 this[int row] => ref *(Int4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -1636,10 +1636,10 @@ public Int2x1(int m11, int m21)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref int this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(int) * row)));
+ public ref int this[int row] => ref *(int*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -2060,10 +2060,10 @@ public Int2x2(Int2 row1, Int2 row2)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Int2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Int2) * row)));
+ public ref Int2 this[int row] => ref *(Int2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -2434,10 +2434,10 @@ public Int2x3(Int3 row1, Int3 row2)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Int3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Int3) * row)));
+ public ref Int3 this[int row] => ref *(Int3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -2918,10 +2918,10 @@ public Int2x4(Int4 row1, Int4 row2)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Int4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Int4) * row)));
+ public ref Int4 this[int row] => ref *(Int4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -3374,10 +3374,10 @@ public Int3x1(int m11, int m21, int m31)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref int this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(int) * row)));
+ public ref int this[int row] => ref *(int*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -3818,10 +3818,10 @@ public Int3x2(Int2 row1, Int2 row2, Int2 row3)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Int2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Int2) * row)));
+ public ref Int2 this[int row] => ref *(Int2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -4309,10 +4309,10 @@ public Int3x3(Int3 row1, Int3 row2, Int3 row3)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Int3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Int3) * row)));
+ public ref Int3 this[int row] => ref *(Int3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -4755,10 +4755,10 @@ public Int3x4(Int4 row1, Int4 row2, Int4 row3)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Int4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Int4) * row)));
+ public ref Int4 this[int row] => ref *(Int4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -5244,10 +5244,10 @@ public Int4x1(int m11, int m21, int m31, int m41)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref int this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(int) * row)));
+ public ref int this[int row] => ref *(int*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -5708,10 +5708,10 @@ public Int4x2(Int2 row1, Int2 row2, Int2 row3, Int2 row4)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Int2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Int2) * row)));
+ public ref Int2 this[int row] => ref *(Int2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -6232,10 +6232,10 @@ public Int4x3(Int3 row1, Int3 row2, Int3 row3, Int3 row4)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Int3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Int3) * row)));
+ public ref Int3 this[int row] => ref *(Int3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -6808,10 +6808,10 @@ public Int4x4(Int4 row1, Int4 row2, Int4 row3, Int4 row4)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref Int4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Int4) * row)));
+ public ref Int4 this[int row] => ref *(Int4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
diff --git a/src/ComputeSharp.Core/Primitives/MatrixType.ttinclude b/src/ComputeSharp.Core/Primitives/MatrixType.ttinclude
index 9c5a9d0ae..ab58fef34 100644
--- a/src/ComputeSharp.Core/Primitives/MatrixType.ttinclude
+++ b/src/ComputeSharp.Core/Primitives/MatrixType.ttinclude
@@ -152,10 +152,10 @@ public unsafe partial struct <#=fullTypeName#>
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref <#=rowTypeName#> this[int row] => ref Unsafe.As<<#=fieldElementTypeName#>, <#=rowTypeName#>>(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(<#=rowTypeName#>) * row)));
+ public ref <#=rowTypeName#> this[int row] => ref *(<#=rowTypeName#>*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
diff --git a/src/ComputeSharp.Core/Primitives/UInt/UIntMxN.g.cs b/src/ComputeSharp.Core/Primitives/UInt/UIntMxN.g.cs
index 7f1a728cc..14df1cf2f 100644
--- a/src/ComputeSharp.Core/Primitives/UInt/UIntMxN.g.cs
+++ b/src/ComputeSharp.Core/Primitives/UInt/UIntMxN.g.cs
@@ -36,10 +36,10 @@ public UInt1x1(uint m11)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref uint this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(uint) * row)));
+ public ref uint this[int row] => ref *(uint*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -329,10 +329,10 @@ public UInt1x2(uint m11, uint m12)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref UInt2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(UInt2) * row)));
+ public ref UInt2 this[int row] => ref *(UInt2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -640,10 +640,10 @@ public UInt1x3(uint m11, uint m12, uint m13)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref UInt3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(UInt3) * row)));
+ public ref UInt3 this[int row] => ref *(UInt3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -963,10 +963,10 @@ public UInt1x4(uint m11, uint m12, uint m13, uint m14)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref UInt4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(UInt4) * row)));
+ public ref UInt4 this[int row] => ref *(UInt4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -1283,10 +1283,10 @@ public UInt2x1(uint m11, uint m21)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref uint this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(uint) * row)));
+ public ref uint this[int row] => ref *(uint*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -1612,10 +1612,10 @@ public UInt2x2(UInt2 row1, UInt2 row2)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref UInt2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(UInt2) * row)));
+ public ref UInt2 this[int row] => ref *(UInt2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -1961,10 +1961,10 @@ public UInt2x3(UInt3 row1, UInt3 row2)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref UInt3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(UInt3) * row)));
+ public ref UInt3 this[int row] => ref *(UInt3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -2336,10 +2336,10 @@ public UInt2x4(UInt4 row1, UInt4 row2)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref UInt4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(UInt4) * row)));
+ public ref UInt4 this[int row] => ref *(UInt4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -2683,10 +2683,10 @@ public UInt3x1(uint m11, uint m21, uint m31)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref uint this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(uint) * row)));
+ public ref uint this[int row] => ref *(uint*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -3032,10 +3032,10 @@ public UInt3x2(UInt2 row1, UInt2 row2, UInt2 row3)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref UInt2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(UInt2) * row)));
+ public ref UInt2 this[int row] => ref *(UInt2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -3414,10 +3414,10 @@ public UInt3x3(UInt3 row1, UInt3 row2, UInt3 row3)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref UInt3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(UInt3) * row)));
+ public ref UInt3 this[int row] => ref *(UInt3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -3835,10 +3835,10 @@ public UInt3x4(UInt4 row1, UInt4 row2, UInt4 row3)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref UInt4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(UInt4) * row)));
+ public ref UInt4 this[int row] => ref *(UInt4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -4215,10 +4215,10 @@ public UInt4x1(uint m11, uint m21, uint m31, uint m41)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref uint this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(uint) * row)));
+ public ref uint this[int row] => ref *(uint*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -4584,10 +4584,10 @@ public UInt4x2(UInt2 row1, UInt2 row2, UInt2 row3, UInt2 row4)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref UInt2 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(UInt2) * row)));
+ public ref UInt2 this[int row] => ref *(UInt2*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -4999,10 +4999,10 @@ public UInt4x3(UInt3 row1, UInt3 row2, UInt3 row3, UInt3 row4)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref UInt3 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(UInt3) * row)));
+ public ref UInt3 this[int row] => ref *(UInt3*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
@@ -5466,10 +5466,10 @@ public UInt4x4(UInt4 row1, UInt4 row2, UInt4 row3, UInt4 row4)
/// The row to access.
///
/// Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.
- /// Invoking this method with an invalid row argument results in undefined behavior.
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
///
[UnscopedRef]
- public ref UInt4 this[int row] => ref Unsafe.As(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(UInt4) * row)));
+ public ref UInt4 this[int row] => ref *(UInt4*)UndefinedData;
///
/// Gets a swizzled reference to a specific sequence of items in the current instance.
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateCreateFromConstantBufferMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateCreateFromConstantBufferMethod.Syntax.cs
index 66084b044..aa1be8d8b 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateCreateFromConstantBufferMethod.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateCreateFromConstantBufferMethod.Syntax.cs
@@ -1,6 +1,7 @@
using ComputeSharp.D2D1.SourceGenerators.Models;
using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
+using ComputeSharp.SourceGeneration.Mappings;
namespace ComputeSharp.D2D1.SourceGenerators;
@@ -52,18 +53,20 @@ public static void WriteSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
break;
case FieldInfo.NonLinearMatrix matrix:
+ string primitiveTypeName = matrix.ElementName.ToLowerInvariant();
+ string rowTypeName = HlslKnownTypes.GetMappedName($"ComputeSharp.{matrix.ElementName}{matrix.Columns}");
string fieldPath = string.Join(".", matrix.FieldPath);
string fieldNamePrefix = string.Join("_", matrix.FieldPath);
// Read all rows of a given matrix type:
//
- // (*&shader.)[0] = buffer.;
- // (*&shader.)[1] = buffer.;
+ // Unsafe.As<, >(ref (*&shader.).M11) = buffer.;
+ // Unsafe.As<, >(ref (*&shader.).M21) = buffer.;
// ...
- // (*&shader.)[N] = buffer.;
+ // Unsafe.As<, >(ref (*&shader.).MN1) = buffer.;
for (int j = 0; j < matrix.Rows; j++)
{
- writer.WriteLine($"(*&shader.{fieldPath})[{j}] = buffer.{fieldNamePrefix}_{j};");
+ writer.WriteLine($"global::System.Runtime.CompilerServices.Unsafe.As<{primitiveTypeName}, {rowTypeName}>(ref (*&shader.{fieldPath}).M{j + 1}1) = buffer.{fieldNamePrefix}_{j};");
}
break;
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadConstantBufferMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadConstantBufferMethod.Syntax.cs
index f5e58d3ea..04fa769a2 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadConstantBufferMethod.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadConstantBufferMethod.Syntax.cs
@@ -45,22 +45,24 @@ public static void WriteSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
case FieldInfo.Primitive primitive:
// Assign a primitive value
- writer.WriteLine($"buffer.{string.Join("_", primitive.FieldPath)} = this.{string.Join(".", primitive.FieldPath)};");
+ writer.WriteLine($"buffer.{string.Join("_", primitive.FieldPath)} = shader.{string.Join(".", primitive.FieldPath)};");
break;
case FieldInfo.NonLinearMatrix matrix:
+ string primitiveTypeName = matrix.ElementName.ToLowerInvariant();
+ string rowTypeName = HlslKnownTypes.GetMappedName($"ComputeSharp.{matrix.ElementName}{matrix.Columns}");
string fieldPath = string.Join(".", matrix.FieldPath);
string fieldNamePrefix = string.Join("_", matrix.FieldPath);
// Assign all rows of a given matrix type:
//
- // buffer. = this.[0];
- // buffer. = this.[1];
+ // buffer. = Unsafe.As<, >(ref Unsafe.AsRef(in shader.).M11);
+ // buffer. = Unsafe.As<, >(ref Unsafe.AsRef(in shader.).M21);
// ...
- // buffer. = this.[N];
+ // buffer. = Unsafe.As<, >(ref Unsafe.AsRef(in shader.).MN1);
for (int j = 0; j < matrix.Rows; j++)
{
- writer.WriteLine($"buffer.{fieldNamePrefix}_{j} = this.{fieldPath}[{j}];");
+ writer.WriteLine($"buffer.{fieldNamePrefix}_{j} = global::System.Runtime.CompilerServices.Unsafe.As<{primitiveTypeName}, {rowTypeName}>(ref global::System.Runtime.CompilerServices.Unsafe.AsRef(in shader.{fieldPath}).M{j + 1}1);");
}
break;
diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShader.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShader.cs
index 2122a91d7..53e0b7a17 100644
--- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShader.cs
+++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShader.cs
@@ -13,6 +13,123 @@ namespace ComputeSharp.D2D1.Interop;
///
public static class D2D1PixelShader
{
+ ///
+ /// Gets the size of the constant buffer for a D2D1 pixel shader of a specified type.
+ ///
+ /// The type of D2D1 pixel shader to retrieve info for.
+ /// The size of the constant buffer for a D2D1 pixel shader of type .
+ public static int GetConstantBufferSize()
+ where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
+ {
+ Unsafe.SkipInit(out T shader);
+
+ return shader.ConstantBufferSize;
+ }
+
+ ///
+ /// Gets the number of inputs from an input D2D1 pixel shader.
+ ///
+ /// The type of D2D1 pixel shader to get the input count for.
+ /// The number of inputs for the D2D1 pixel shader of type .
+ public static int GetInputCount()
+ where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
+ {
+ Unsafe.SkipInit(out T shader);
+
+ return shader.InputCount;
+ }
+
+ ///
+ /// Gets the number of resource textures for a D2D1 pixel shader.
+ ///
+ /// The type of D2D1 pixel shader to get the resource texture count for.
+ /// The number of resource texture for the D2D1 pixel shader of type .
+ public static int GetResourceTextureCount()
+ where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
+ {
+ Unsafe.SkipInit(out T shader);
+
+ return shader.ResourceTextureCount;
+ }
+
+ ///
+ /// Gets the input types for a D2D1 pixel shader.
+ ///
+ /// The type of D2D1 pixel shader to get the input types for.
+ /// The input types of the target D2D1 pixel shader.
+ public static ReadOnlyMemory GetInputTypes()
+ where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
+ {
+ Unsafe.SkipInit(out T shader);
+
+ return shader.InputTypes;
+ }
+
+ ///
+ /// Gets the available input descriptions for a D2D1 pixel shader.
+ ///
+ /// The type of D2D1 pixel shader to get the input descriptions for.
+ /// A with the available input descriptions for the shader.
+ public static ReadOnlyMemory GetInputDescriptions()
+ where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
+ {
+ Unsafe.SkipInit(out T shader);
+
+ return shader.InputDescriptions;
+ }
+
+ ///
+ /// Gets the available resource texture descriptions for a D2D1 pixel shader.
+ ///
+ /// The type of D2D1 pixel shader to get the resource texture descriptions for.
+ /// A with the available resource texture descriptions for the shader.
+ public static ReadOnlyMemory GetResourceTextureDescriptions()
+ where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
+ {
+ Unsafe.SkipInit(out T shader);
+
+ return shader.ResourceTextureDescriptions;
+ }
+
+ ///
+ /// Gets the pixel options from an input D2D1 pixel shader.
+ ///
+ /// The type of D2D1 pixel shader to get the pixel options for.
+ /// The pixel options for the D2D1 pixel shader of type .
+ public static D2D1PixelOptions GetPixelOptions()
+ where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
+ {
+ Unsafe.SkipInit(out T shader);
+
+ return shader.PixelOptions;
+ }
+
+ ///
+ /// Gets the buffer precision for the output buffer of a D2D1 pixel shader.
+ ///
+ /// The type of D2D1 pixel shader to get the output buffer precision for.
+ /// The output buffer precision for the D2D1 pixel shader of type .
+ public static D2D1BufferPrecision GetOutputBufferPrecision()
+ where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
+ {
+ Unsafe.SkipInit(out T shader);
+
+ return shader.BufferPrecision;
+ }
+
+ ///
+ /// Gets the channel depth for the output buffer of a D2D1 pixel shader.
+ ///
+ /// The type of D2D1 pixel shader to get the output buffer channel depth for.
+ /// The output buffer channel depth for the D2D1 pixel shader of type .
+ public static D2D1ChannelDepth GetOutputBufferChannelDepth()
+ where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
+ {
+ Unsafe.SkipInit(out T shader);
+
+ return shader.ChannelDepth;
+ }
+
///
/// Loads the bytecode from an input D2D1 pixel shader.
///
@@ -268,110 +385,6 @@ private static unsafe ReadOnlyMemory LoadOrCompileBytecode(
return CompileBytecode(requestedShaderProfile, requestedCompileOptions, out effectiveShaderProfile, out effectiveCompileOptions);
}
- ///
- /// Gets the pixel options from an input D2D1 pixel shader.
- ///
- /// The type of D2D1 pixel shader to get the pixel options for.
- /// The pixel options for the D2D1 pixel shader of type .
- public static D2D1PixelOptions GetPixelOptions()
- where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
- {
- Unsafe.SkipInit(out T shader);
-
- return shader.PixelOptions;
- }
-
- ///
- /// Gets the number of inputs from an input D2D1 pixel shader.
- ///
- /// The type of D2D1 pixel shader to get the input count for.
- /// The number of inputs for the D2D1 pixel shader of type .
- public static int GetInputCount()
- where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
- {
- Unsafe.SkipInit(out T shader);
-
- return shader.InputCount;
- }
-
- ///
- /// Gets the number of resource textures for a D2D1 pixel shader.
- ///
- /// The type of D2D1 pixel shader to get the resource texture count for.
- /// The number of resource texture for the D2D1 pixel shader of type .
- public static int GetResourceTextureCount()
- where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
- {
- Unsafe.SkipInit(out T shader);
-
- return shader.ResourceTextureCount;
- }
-
- ///
- /// Gets the input types for a D2D1 pixel shader.
- ///
- /// The type of D2D1 pixel shader to get the input types for.
- /// The input types of the target D2D1 pixel shader.
- public static ReadOnlyMemory GetInputTypes()
- where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
- {
- Unsafe.SkipInit(out T shader);
-
- return shader.InputTypes;
- }
-
- ///
- /// Gets the available input descriptions for a D2D1 pixel shader.
- ///
- /// The type of D2D1 pixel shader to get the input descriptions for.
- /// A with the available input descriptions for the shader.
- public static ReadOnlyMemory GetInputDescriptions()
- where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
- {
- Unsafe.SkipInit(out T shader);
-
- return shader.InputDescriptions;
- }
-
- ///
- /// Gets the available resource texture descriptions for a D2D1 pixel shader.
- ///
- /// The type of D2D1 pixel shader to get the resource texture descriptions for.
- /// A with the available resource texture descriptions for the shader.
- public static ReadOnlyMemory GetResourceTextureDescriptions()
- where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
- {
- Unsafe.SkipInit(out T shader);
-
- return shader.ResourceTextureDescriptions;
- }
-
- ///
- /// Gets the buffer precision for the output buffer of a D2D1 pixel shader.
- ///
- /// The type of D2D1 pixel shader to get the output buffer precision for.
- /// The output buffer precision for the D2D1 pixel shader of type .
- public static D2D1BufferPrecision GetOutputBufferPrecision()
- where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
- {
- Unsafe.SkipInit(out T shader);
-
- return shader.BufferPrecision;
- }
-
- ///
- /// Gets the channel depth for the output buffer of a D2D1 pixel shader.
- ///
- /// The type of D2D1 pixel shader to get the output buffer channel depth for.
- /// The output buffer channel depth for the D2D1 pixel shader of type .
- public static D2D1ChannelDepth GetOutputBufferChannelDepth()
- where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
- {
- Unsafe.SkipInit(out T shader);
-
- return shader.ChannelDepth;
- }
-
///
/// Gets the constant buffer from an input D2D1 pixel shader.
///
@@ -391,19 +404,6 @@ public static ReadOnlyMemory GetConstantBuffer(in T shader)
return dataLoader.GetResultingDispatchData();
}
- ///
- /// Gets the size of the constant buffer for a D2D1 pixel shader of a specified type.
- ///
- /// The type of D2D1 pixel shader to retrieve info for.
- /// The size of the constant buffer for a D2D1 pixel shader of type .
- public static int GetConstantBufferSize()
- where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor
- {
- Unsafe.SkipInit(out T shader);
-
- return shader.ConstantBufferSize;
- }
-
///
/// Gets the constant buffer from an input D2D1 pixel shader.
///
diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs
index 5dfd26399..3a985d2b8 100644
--- a/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs
+++ b/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs
@@ -731,4 +731,95 @@ public unsafe void SetConstantBufferForD2D1DrawInfo_NullD2D1DrawInfo()
{
D2D1PixelShader.SetConstantBufferForD2D1DrawInfo(null, default);
}
+
+ [TestMethod]
+ public unsafe void GetConstantBufferSize_WithNestedStructs()
+ {
+ Assert.AreEqual(156, D2D1PixelShader.GetConstantBufferSize());
+
+ ReadOnlyMemory memory = D2D1PixelShader.GetConstantBuffer(new ShaderWithScalarVectorAndMatrixTypesInNestedStructs(
+ x: 111,
+ y: 222,
+ container2: new FieldsContainer2(
+ z: 333,
+ f2x3: new(55, 44, 888, 111, 222, 333),
+ a: 22,
+ container3: new FieldsContainer3(
+ i1x3: new(1, 2, 3),
+ d2: new(3.14, 6.28))),
+ c: 42,
+ container1: new FieldsContainer1(
+ i1x2: new(111, 222),
+ i2x2: new(11, 22, 33, 44),
+ d: 9999)));
+
+ Assert.AreEqual(156, memory.Length);
+
+ fixed (byte* buffer = memory.Span)
+ {
+ Assert.AreEqual(111, *(int*)&buffer[0]);
+ Assert.AreEqual(222, *(int*)&buffer[4]);
+ Assert.AreEqual(333, *(int*)&buffer[16]);
+ Assert.AreEqual(55, *(float*)&buffer[32]);
+ Assert.AreEqual(44, *(float*)&buffer[36]);
+ Assert.AreEqual(888, *(float*)&buffer[40]);
+ Assert.AreEqual(111, *(float*)&buffer[48]);
+ Assert.AreEqual(222, *(float*)&buffer[52]);
+ Assert.AreEqual(333, *(float*)&buffer[56]);
+ Assert.AreEqual(22, *(int*)&buffer[60]);
+ Assert.AreEqual(1, *(int*)&buffer[64]);
+ Assert.AreEqual(2, *(int*)&buffer[68]);
+ Assert.AreEqual(3, *(int*)&buffer[72]);
+ Assert.AreEqual(3.14, *(double*)&buffer[80]);
+ Assert.AreEqual(6.28, *(double*)&buffer[88]);
+ Assert.AreEqual(42, *(int*)&buffer[96]);
+ Assert.AreEqual(111, *(int*)&buffer[112]);
+ Assert.AreEqual(222, *(int*)&buffer[116]);
+ Assert.AreEqual(11, *(int*)&buffer[128]);
+ Assert.AreEqual(22, *(int*)&buffer[132]);
+ Assert.AreEqual(33, *(int*)&buffer[144]);
+ Assert.AreEqual(44, *(int*)&buffer[148]);
+ Assert.AreEqual(9999, *(int*)&buffer[152]);
+ }
+ }
+
+ [AutoConstructor]
+ public readonly partial struct FieldsContainer1
+ {
+ public readonly Int1x2 i1x2;
+ public readonly int2x2 i2x2;
+ public readonly int d;
+ }
+
+ [AutoConstructor]
+ public readonly partial struct FieldsContainer2
+ {
+ public readonly int z;
+ public readonly float2x3 f2x3;
+ public readonly int a;
+ public readonly FieldsContainer3 container3;
+ }
+
+ [AutoConstructor]
+ public readonly partial struct FieldsContainer3
+ {
+ public readonly Int1x3 i1x3;
+ public readonly double2 d2;
+ }
+
+ [D2DInputCount(0)]
+ [AutoConstructor]
+ private readonly partial struct ShaderWithScalarVectorAndMatrixTypesInNestedStructs : ID2D1PixelShader
+ {
+ public readonly int x;
+ public readonly int y;
+ public readonly FieldsContainer2 container2;
+ public readonly int c;
+ public readonly FieldsContainer1 container1;
+
+ public float4 Execute()
+ {
+ return 0;
+ }
+ }
}
\ No newline at end of file