diff --git a/src/ComputeSharp/Core/Primitives/Bool/Bool.cs b/src/ComputeSharp/Core/Primitives/Bool/Bool.cs
index 8af16442..58b539b4 100644
--- a/src/ComputeSharp/Core/Primitives/Bool/Bool.cs
+++ b/src/ComputeSharp/Core/Primitives/Bool/Bool.cs
@@ -1,12 +1,10 @@
-using System.Diagnostics;
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
namespace ComputeSharp
{
///
/// A that can be used in place of the type in HLSL shaders.
///
- [DebuggerDisplay("{Value}")]
[StructLayout(LayoutKind.Explicit, Size = sizeof(int), Pack = 4)]
public readonly struct Bool
{
diff --git a/src/ComputeSharp/Core/Primitives/Bool/Bool2.cs b/src/ComputeSharp/Core/Primitives/Bool/Bool2.cs
index ad578a8a..95729603 100644
--- a/src/ComputeSharp/Core/Primitives/Bool/Bool2.cs
+++ b/src/ComputeSharp/Core/Primitives/Bool/Bool2.cs
@@ -1,11 +1,8 @@
-using System.Diagnostics;
-
-namespace ComputeSharp
+namespace ComputeSharp
{
///
/// A that maps the HLSL type.
///
- [DebuggerDisplay("({X}, {Y})")]
public partial struct Bool2
{
///
diff --git a/src/ComputeSharp/Core/Primitives/Bool/Bool2.g.cs b/src/ComputeSharp/Core/Primitives/Bool/Bool2.g.cs
index be78cec9..c5935638 100644
--- a/src/ComputeSharp/Core/Primitives/Bool/Bool2.g.cs
+++ b/src/ComputeSharp/Core/Primitives/Bool/Bool2.g.cs
@@ -1,10 +1,15 @@
-using System.Runtime.CompilerServices;
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Text;
#if !NET5_0
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
#endif
+#nullable enable
+
namespace ComputeSharp
{
///
@@ -96,5 +101,19 @@ namespace ComputeSharp
///
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public readonly ref readonly Bool2 GG => ref *(Bool2*)UndefinedData;
+
+ ///
+ public override readonly string ToString()
+ {
+ StringBuilder sb = new();
+
+ sb.Append('<');
+ sb.Append(this.x);
+ sb.Append(", ");
+ sb.Append(this.y);
+ sb.Append('>');
+
+ return sb.ToString();
+ }
}
}
diff --git a/src/ComputeSharp/Core/Primitives/Bool/Bool3.cs b/src/ComputeSharp/Core/Primitives/Bool/Bool3.cs
index c52d99d2..0cef513a 100644
--- a/src/ComputeSharp/Core/Primitives/Bool/Bool3.cs
+++ b/src/ComputeSharp/Core/Primitives/Bool/Bool3.cs
@@ -1,11 +1,8 @@
-using System.Diagnostics;
-
-namespace ComputeSharp
+namespace ComputeSharp
{
///
/// A that maps the HLSL type.
///
- [DebuggerDisplay("({X}, {Y}, {Z})")]
public partial struct Bool3
{
///
diff --git a/src/ComputeSharp/Core/Primitives/Bool/Bool3.g.cs b/src/ComputeSharp/Core/Primitives/Bool/Bool3.g.cs
index f4c603be..42a59fa3 100644
--- a/src/ComputeSharp/Core/Primitives/Bool/Bool3.g.cs
+++ b/src/ComputeSharp/Core/Primitives/Bool/Bool3.g.cs
@@ -1,10 +1,15 @@
-using System.Runtime.CompilerServices;
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Text;
#if !NET5_0
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
#endif
+#nullable enable
+
namespace ComputeSharp
{
///
@@ -493,5 +498,21 @@ namespace ComputeSharp
///
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public readonly ref readonly Bool3 BBB => ref *(Bool3*)UndefinedData;
+
+ ///
+ public override readonly string ToString()
+ {
+ StringBuilder sb = new();
+
+ sb.Append('<');
+ sb.Append(this.x);
+ sb.Append(", ");
+ sb.Append(this.y);
+ sb.Append(", ");
+ sb.Append(this.z);
+ sb.Append('>');
+
+ return sb.ToString();
+ }
}
}
diff --git a/src/ComputeSharp/Core/Primitives/Bool/Bool4.cs b/src/ComputeSharp/Core/Primitives/Bool/Bool4.cs
index 305cc760..7323ed77 100644
--- a/src/ComputeSharp/Core/Primitives/Bool/Bool4.cs
+++ b/src/ComputeSharp/Core/Primitives/Bool/Bool4.cs
@@ -1,11 +1,8 @@
-using System.Diagnostics;
-
-namespace ComputeSharp
+namespace ComputeSharp
{
///
/// A that maps the HLSL type.
///
- [DebuggerDisplay("({X}, {Y}, {Z}, {W})")]
public partial struct Bool4
{
///
diff --git a/src/ComputeSharp/Core/Primitives/Bool/Bool4.g.cs b/src/ComputeSharp/Core/Primitives/Bool/Bool4.g.cs
index d93c7839..f54edec5 100644
--- a/src/ComputeSharp/Core/Primitives/Bool/Bool4.g.cs
+++ b/src/ComputeSharp/Core/Primitives/Bool/Bool4.g.cs
@@ -1,10 +1,15 @@
-using System.Runtime.CompilerServices;
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Text;
#if !NET5_0
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
#endif
+#nullable enable
+
namespace ComputeSharp
{
///
@@ -4106,5 +4111,23 @@ namespace ComputeSharp
///
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public readonly ref readonly Bool4 AAAA => ref *(Bool4*)UndefinedData;
+
+ ///
+ public override readonly string ToString()
+ {
+ StringBuilder sb = new();
+
+ sb.Append('<');
+ sb.Append(this.x);
+ sb.Append(", ");
+ sb.Append(this.y);
+ sb.Append(", ");
+ sb.Append(this.z);
+ sb.Append(", ");
+ sb.Append(this.w);
+ sb.Append('>');
+
+ return sb.ToString();
+ }
}
}
diff --git a/src/ComputeSharp/Core/Primitives/Double/Double2.cs b/src/ComputeSharp/Core/Primitives/Double/Double2.cs
index 45b9cafc..d18591e1 100644
--- a/src/ComputeSharp/Core/Primitives/Double/Double2.cs
+++ b/src/ComputeSharp/Core/Primitives/Double/Double2.cs
@@ -1,11 +1,8 @@
-using System.Diagnostics;
-
-namespace ComputeSharp
+namespace ComputeSharp
{
///
/// A that maps the HLSL type.
///
- [DebuggerDisplay("({X}, {Y})")]
public partial struct Double2
{
///
diff --git a/src/ComputeSharp/Core/Primitives/Double/Double2.g.cs b/src/ComputeSharp/Core/Primitives/Double/Double2.g.cs
index b1b6a5ae..739973c1 100644
--- a/src/ComputeSharp/Core/Primitives/Double/Double2.g.cs
+++ b/src/ComputeSharp/Core/Primitives/Double/Double2.g.cs
@@ -1,15 +1,20 @@
-using System.Runtime.CompilerServices;
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Text;
#if !NET5_0
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
#endif
+#nullable enable
+
namespace ComputeSharp
{
///
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 8)]
- public unsafe partial struct Double2
+ public unsafe partial struct Double2 : IFormattable
{
///
/// A private buffer to which the undefined properties will point to.
@@ -97,6 +102,29 @@ namespace ComputeSharp
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public readonly ref readonly Double2 GG => ref *(Double2*)UndefinedData;
+ ///
+ public override readonly string ToString()
+ {
+ return ToString("G", CultureInfo.CurrentCulture);
+ }
+
+ ///
+ public readonly string ToString(string? format, IFormatProvider? formatProvider)
+ {
+ StringBuilder sb = new();
+
+ string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
+
+ sb.Append('<');
+ sb.Append(this.x.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.y.ToString(format, formatProvider));
+ sb.Append('>');
+
+ return sb.ToString();
+ }
+
///
/// Negates a value.
///
diff --git a/src/ComputeSharp/Core/Primitives/Double/Double3.cs b/src/ComputeSharp/Core/Primitives/Double/Double3.cs
index 508e6c09..b5ef0088 100644
--- a/src/ComputeSharp/Core/Primitives/Double/Double3.cs
+++ b/src/ComputeSharp/Core/Primitives/Double/Double3.cs
@@ -1,11 +1,8 @@
-using System.Diagnostics;
-
-namespace ComputeSharp
+namespace ComputeSharp
{
///
/// A that maps the HLSL type.
///
- [DebuggerDisplay("({X}, {Y}, {Z})")]
public partial struct Double3
{
///
diff --git a/src/ComputeSharp/Core/Primitives/Double/Double3.g.cs b/src/ComputeSharp/Core/Primitives/Double/Double3.g.cs
index 1637c7fa..00d65371 100644
--- a/src/ComputeSharp/Core/Primitives/Double/Double3.g.cs
+++ b/src/ComputeSharp/Core/Primitives/Double/Double3.g.cs
@@ -1,15 +1,20 @@
-using System.Runtime.CompilerServices;
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Text;
#if !NET5_0
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
#endif
+#nullable enable
+
namespace ComputeSharp
{
///
[StructLayout(LayoutKind.Explicit, Size = 24, Pack = 8)]
- public unsafe partial struct Double3
+ public unsafe partial struct Double3 : IFormattable
{
///
/// A private buffer to which the undefined properties will point to.
@@ -494,6 +499,32 @@ namespace ComputeSharp
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public readonly ref readonly Double3 BBB => ref *(Double3*)UndefinedData;
+ ///
+ public override readonly string ToString()
+ {
+ return ToString("G", CultureInfo.CurrentCulture);
+ }
+
+ ///
+ public readonly string ToString(string? format, IFormatProvider? formatProvider)
+ {
+ StringBuilder sb = new();
+
+ string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
+
+ sb.Append('<');
+ sb.Append(this.x.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.y.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.z.ToString(format, formatProvider));
+ sb.Append('>');
+
+ return sb.ToString();
+ }
+
///
/// Negates a value.
///
diff --git a/src/ComputeSharp/Core/Primitives/Double/Double4.cs b/src/ComputeSharp/Core/Primitives/Double/Double4.cs
index c4e231bd..371f3ada 100644
--- a/src/ComputeSharp/Core/Primitives/Double/Double4.cs
+++ b/src/ComputeSharp/Core/Primitives/Double/Double4.cs
@@ -1,11 +1,8 @@
-using System.Diagnostics;
-
-namespace ComputeSharp
+namespace ComputeSharp
{
///
/// A that maps the HLSL type.
///
- [DebuggerDisplay("({X}, {Y}, {Z}, {W})")]
public partial struct Double4
{
///
diff --git a/src/ComputeSharp/Core/Primitives/Double/Double4.g.cs b/src/ComputeSharp/Core/Primitives/Double/Double4.g.cs
index e5172ae9..02f44345 100644
--- a/src/ComputeSharp/Core/Primitives/Double/Double4.g.cs
+++ b/src/ComputeSharp/Core/Primitives/Double/Double4.g.cs
@@ -1,15 +1,20 @@
-using System.Runtime.CompilerServices;
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Text;
#if !NET5_0
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
#endif
+#nullable enable
+
namespace ComputeSharp
{
///
[StructLayout(LayoutKind.Explicit, Size = 32, Pack = 8)]
- public unsafe partial struct Double4
+ public unsafe partial struct Double4 : IFormattable
{
///
/// A private buffer to which the undefined properties will point to.
@@ -4107,6 +4112,35 @@ namespace ComputeSharp
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public readonly ref readonly Double4 AAAA => ref *(Double4*)UndefinedData;
+ ///
+ public override readonly string ToString()
+ {
+ return ToString("G", CultureInfo.CurrentCulture);
+ }
+
+ ///
+ public readonly string ToString(string? format, IFormatProvider? formatProvider)
+ {
+ StringBuilder sb = new();
+
+ string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
+
+ sb.Append('<');
+ sb.Append(this.x.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.y.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.z.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.w.ToString(format, formatProvider));
+ sb.Append('>');
+
+ return sb.ToString();
+ }
+
///
/// Negates a value.
///
diff --git a/src/ComputeSharp/Core/Primitives/Float/Float2.cs b/src/ComputeSharp/Core/Primitives/Float/Float2.cs
index 50eaaa9d..5360d172 100644
--- a/src/ComputeSharp/Core/Primitives/Float/Float2.cs
+++ b/src/ComputeSharp/Core/Primitives/Float/Float2.cs
@@ -1,12 +1,10 @@
-using System.Diagnostics;
-using System.Numerics;
+using System.Numerics;
namespace ComputeSharp
{
///
/// A that maps the HLSL type.
///
- [DebuggerDisplay("({X}, {Y})")]
public partial struct Float2
{
///
diff --git a/src/ComputeSharp/Core/Primitives/Float/Float2.g.cs b/src/ComputeSharp/Core/Primitives/Float/Float2.g.cs
index 408fc21f..7a7e7372 100644
--- a/src/ComputeSharp/Core/Primitives/Float/Float2.g.cs
+++ b/src/ComputeSharp/Core/Primitives/Float/Float2.g.cs
@@ -1,15 +1,20 @@
-using System.Runtime.CompilerServices;
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Text;
#if !NET5_0
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
#endif
+#nullable enable
+
namespace ComputeSharp
{
///
[StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)]
- public unsafe partial struct Float2
+ public unsafe partial struct Float2 : IFormattable
{
///
/// A private buffer to which the undefined properties will point to.
@@ -97,6 +102,29 @@ namespace ComputeSharp
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public readonly ref readonly Float2 GG => ref *(Float2*)UndefinedData;
+ ///
+ public override readonly string ToString()
+ {
+ return ToString("G", CultureInfo.CurrentCulture);
+ }
+
+ ///
+ public readonly string ToString(string? format, IFormatProvider? formatProvider)
+ {
+ StringBuilder sb = new();
+
+ string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
+
+ sb.Append('<');
+ sb.Append(this.x.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.y.ToString(format, formatProvider));
+ sb.Append('>');
+
+ return sb.ToString();
+ }
+
///
/// Negates a value.
///
diff --git a/src/ComputeSharp/Core/Primitives/Float/Float3.cs b/src/ComputeSharp/Core/Primitives/Float/Float3.cs
index 5ecfbf25..15af02b1 100644
--- a/src/ComputeSharp/Core/Primitives/Float/Float3.cs
+++ b/src/ComputeSharp/Core/Primitives/Float/Float3.cs
@@ -1,12 +1,10 @@
-using System.Diagnostics;
-using System.Numerics;
+using System.Numerics;
namespace ComputeSharp
{
///
/// A that maps the HLSL type.
///
- [DebuggerDisplay("({X}, {Y}, {Z})")]
public partial struct Float3
{
///
diff --git a/src/ComputeSharp/Core/Primitives/Float/Float3.g.cs b/src/ComputeSharp/Core/Primitives/Float/Float3.g.cs
index 048a9f2c..d7fa7980 100644
--- a/src/ComputeSharp/Core/Primitives/Float/Float3.g.cs
+++ b/src/ComputeSharp/Core/Primitives/Float/Float3.g.cs
@@ -1,15 +1,20 @@
-using System.Runtime.CompilerServices;
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Text;
#if !NET5_0
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
#endif
+#nullable enable
+
namespace ComputeSharp
{
///
[StructLayout(LayoutKind.Explicit, Size = 12, Pack = 4)]
- public unsafe partial struct Float3
+ public unsafe partial struct Float3 : IFormattable
{
///
/// A private buffer to which the undefined properties will point to.
@@ -494,6 +499,32 @@ namespace ComputeSharp
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public readonly ref readonly Float3 BBB => ref *(Float3*)UndefinedData;
+ ///
+ public override readonly string ToString()
+ {
+ return ToString("G", CultureInfo.CurrentCulture);
+ }
+
+ ///
+ public readonly string ToString(string? format, IFormatProvider? formatProvider)
+ {
+ StringBuilder sb = new();
+
+ string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
+
+ sb.Append('<');
+ sb.Append(this.x.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.y.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.z.ToString(format, formatProvider));
+ sb.Append('>');
+
+ return sb.ToString();
+ }
+
///
/// Negates a value.
///
diff --git a/src/ComputeSharp/Core/Primitives/Float/Float4.cs b/src/ComputeSharp/Core/Primitives/Float/Float4.cs
index 44916723..65476089 100644
--- a/src/ComputeSharp/Core/Primitives/Float/Float4.cs
+++ b/src/ComputeSharp/Core/Primitives/Float/Float4.cs
@@ -1,12 +1,10 @@
-using System.Diagnostics;
-using System.Numerics;
+using System.Numerics;
namespace ComputeSharp
{
///
/// A that maps the HLSL type.
///
- [DebuggerDisplay("({X}, {Y}, {Z}, {W})")]
public partial struct Float4
{
///
diff --git a/src/ComputeSharp/Core/Primitives/Float/Float4.g.cs b/src/ComputeSharp/Core/Primitives/Float/Float4.g.cs
index c997359c..4055e29f 100644
--- a/src/ComputeSharp/Core/Primitives/Float/Float4.g.cs
+++ b/src/ComputeSharp/Core/Primitives/Float/Float4.g.cs
@@ -1,15 +1,20 @@
-using System.Runtime.CompilerServices;
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Text;
#if !NET5_0
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
#endif
+#nullable enable
+
namespace ComputeSharp
{
///
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 4)]
- public unsafe partial struct Float4
+ public unsafe partial struct Float4 : IFormattable
{
///
/// A private buffer to which the undefined properties will point to.
@@ -4107,6 +4112,35 @@ namespace ComputeSharp
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public readonly ref readonly Float4 AAAA => ref *(Float4*)UndefinedData;
+ ///
+ public override readonly string ToString()
+ {
+ return ToString("G", CultureInfo.CurrentCulture);
+ }
+
+ ///
+ public readonly string ToString(string? format, IFormatProvider? formatProvider)
+ {
+ StringBuilder sb = new();
+
+ string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
+
+ sb.Append('<');
+ sb.Append(this.x.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.y.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.z.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.w.ToString(format, formatProvider));
+ sb.Append('>');
+
+ return sb.ToString();
+ }
+
///
/// Negates a value.
///
diff --git a/src/ComputeSharp/Core/Primitives/Int/Int2.cs b/src/ComputeSharp/Core/Primitives/Int/Int2.cs
index ef13a36f..a65bd6d9 100644
--- a/src/ComputeSharp/Core/Primitives/Int/Int2.cs
+++ b/src/ComputeSharp/Core/Primitives/Int/Int2.cs
@@ -1,11 +1,8 @@
-using System.Diagnostics;
-
-namespace ComputeSharp
+namespace ComputeSharp
{
///
/// A that maps the HLSL type.
///
- [DebuggerDisplay("({X}, {Y})")]
public partial struct Int2
{
///
diff --git a/src/ComputeSharp/Core/Primitives/Int/Int2.g.cs b/src/ComputeSharp/Core/Primitives/Int/Int2.g.cs
index e98ecaf1..b62a0ff5 100644
--- a/src/ComputeSharp/Core/Primitives/Int/Int2.g.cs
+++ b/src/ComputeSharp/Core/Primitives/Int/Int2.g.cs
@@ -1,15 +1,20 @@
-using System.Runtime.CompilerServices;
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Text;
#if !NET5_0
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
#endif
+#nullable enable
+
namespace ComputeSharp
{
///
[StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)]
- public unsafe partial struct Int2
+ public unsafe partial struct Int2 : IFormattable
{
///
/// A private buffer to which the undefined properties will point to.
@@ -97,6 +102,29 @@ namespace ComputeSharp
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public readonly ref readonly Int2 GG => ref *(Int2*)UndefinedData;
+ ///
+ public override readonly string ToString()
+ {
+ return ToString("G", CultureInfo.CurrentCulture);
+ }
+
+ ///
+ public readonly string ToString(string? format, IFormatProvider? formatProvider)
+ {
+ StringBuilder sb = new();
+
+ string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
+
+ sb.Append('<');
+ sb.Append(this.x.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.y.ToString(format, formatProvider));
+ sb.Append('>');
+
+ return sb.ToString();
+ }
+
///
/// Negates a value.
///
diff --git a/src/ComputeSharp/Core/Primitives/Int/Int3.cs b/src/ComputeSharp/Core/Primitives/Int/Int3.cs
index 8690c048..25839169 100644
--- a/src/ComputeSharp/Core/Primitives/Int/Int3.cs
+++ b/src/ComputeSharp/Core/Primitives/Int/Int3.cs
@@ -1,11 +1,8 @@
-using System.Diagnostics;
-
-namespace ComputeSharp
+namespace ComputeSharp
{
///
/// A that maps the HLSL type.
///
- [DebuggerDisplay("({X}, {Y}, {Z})")]
public partial struct Int3
{
///
diff --git a/src/ComputeSharp/Core/Primitives/Int/Int3.g.cs b/src/ComputeSharp/Core/Primitives/Int/Int3.g.cs
index a30b25cb..dfcf3b7f 100644
--- a/src/ComputeSharp/Core/Primitives/Int/Int3.g.cs
+++ b/src/ComputeSharp/Core/Primitives/Int/Int3.g.cs
@@ -1,15 +1,20 @@
-using System.Runtime.CompilerServices;
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Text;
#if !NET5_0
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
#endif
+#nullable enable
+
namespace ComputeSharp
{
///
[StructLayout(LayoutKind.Explicit, Size = 12, Pack = 4)]
- public unsafe partial struct Int3
+ public unsafe partial struct Int3 : IFormattable
{
///
/// A private buffer to which the undefined properties will point to.
@@ -494,6 +499,32 @@ namespace ComputeSharp
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public readonly ref readonly Int3 BBB => ref *(Int3*)UndefinedData;
+ ///
+ public override readonly string ToString()
+ {
+ return ToString("G", CultureInfo.CurrentCulture);
+ }
+
+ ///
+ public readonly string ToString(string? format, IFormatProvider? formatProvider)
+ {
+ StringBuilder sb = new();
+
+ string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
+
+ sb.Append('<');
+ sb.Append(this.x.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.y.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.z.ToString(format, formatProvider));
+ sb.Append('>');
+
+ return sb.ToString();
+ }
+
///
/// Negates a value.
///
diff --git a/src/ComputeSharp/Core/Primitives/Int/Int4.cs b/src/ComputeSharp/Core/Primitives/Int/Int4.cs
index 2b87778e..ad3712fd 100644
--- a/src/ComputeSharp/Core/Primitives/Int/Int4.cs
+++ b/src/ComputeSharp/Core/Primitives/Int/Int4.cs
@@ -1,11 +1,8 @@
-using System.Diagnostics;
-
-namespace ComputeSharp
+namespace ComputeSharp
{
///
/// A that maps the HLSL type.
///
- [DebuggerDisplay("({X}, {Y}, {Z}, {W})")]
public partial struct Int4
{
///
diff --git a/src/ComputeSharp/Core/Primitives/Int/Int4.g.cs b/src/ComputeSharp/Core/Primitives/Int/Int4.g.cs
index 747fbcbf..2f898b7f 100644
--- a/src/ComputeSharp/Core/Primitives/Int/Int4.g.cs
+++ b/src/ComputeSharp/Core/Primitives/Int/Int4.g.cs
@@ -1,15 +1,20 @@
-using System.Runtime.CompilerServices;
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Text;
#if !NET5_0
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
#endif
+#nullable enable
+
namespace ComputeSharp
{
///
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 4)]
- public unsafe partial struct Int4
+ public unsafe partial struct Int4 : IFormattable
{
///
/// A private buffer to which the undefined properties will point to.
@@ -4107,6 +4112,35 @@ namespace ComputeSharp
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public readonly ref readonly Int4 AAAA => ref *(Int4*)UndefinedData;
+ ///
+ public override readonly string ToString()
+ {
+ return ToString("G", CultureInfo.CurrentCulture);
+ }
+
+ ///
+ public readonly string ToString(string? format, IFormatProvider? formatProvider)
+ {
+ StringBuilder sb = new();
+
+ string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
+
+ sb.Append('<');
+ sb.Append(this.x.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.y.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.z.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.w.ToString(format, formatProvider));
+ sb.Append('>');
+
+ return sb.ToString();
+ }
+
///
/// Negates a value.
///
diff --git a/src/ComputeSharp/Core/Primitives/UInt/UInt2.cs b/src/ComputeSharp/Core/Primitives/UInt/UInt2.cs
index 6db3e55f..b9aa527c 100644
--- a/src/ComputeSharp/Core/Primitives/UInt/UInt2.cs
+++ b/src/ComputeSharp/Core/Primitives/UInt/UInt2.cs
@@ -1,11 +1,8 @@
-using System.Diagnostics;
-
-namespace ComputeSharp
+namespace ComputeSharp
{
///
/// A that maps the HLSL type.
///
- [DebuggerDisplay("({X}, {Y})")]
public partial struct UInt2
{
///
diff --git a/src/ComputeSharp/Core/Primitives/UInt/UInt2.g.cs b/src/ComputeSharp/Core/Primitives/UInt/UInt2.g.cs
index 04b0c531..a14245f5 100644
--- a/src/ComputeSharp/Core/Primitives/UInt/UInt2.g.cs
+++ b/src/ComputeSharp/Core/Primitives/UInt/UInt2.g.cs
@@ -1,15 +1,20 @@
-using System.Runtime.CompilerServices;
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Text;
#if !NET5_0
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
#endif
+#nullable enable
+
namespace ComputeSharp
{
///
[StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)]
- public unsafe partial struct UInt2
+ public unsafe partial struct UInt2 : IFormattable
{
///
/// A private buffer to which the undefined properties will point to.
@@ -97,6 +102,29 @@ namespace ComputeSharp
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public readonly ref readonly UInt2 GG => ref *(UInt2*)UndefinedData;
+ ///
+ public override readonly string ToString()
+ {
+ return ToString("G", CultureInfo.CurrentCulture);
+ }
+
+ ///
+ public readonly string ToString(string? format, IFormatProvider? formatProvider)
+ {
+ StringBuilder sb = new();
+
+ string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
+
+ sb.Append('<');
+ sb.Append(this.x.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.y.ToString(format, formatProvider));
+ sb.Append('>');
+
+ return sb.ToString();
+ }
+
///
/// Sums two values.
///
diff --git a/src/ComputeSharp/Core/Primitives/UInt/UInt3.cs b/src/ComputeSharp/Core/Primitives/UInt/UInt3.cs
index 2b04f6ab..0fec29a5 100644
--- a/src/ComputeSharp/Core/Primitives/UInt/UInt3.cs
+++ b/src/ComputeSharp/Core/Primitives/UInt/UInt3.cs
@@ -1,11 +1,8 @@
-using System.Diagnostics;
-
-namespace ComputeSharp
+namespace ComputeSharp
{
///
/// A that maps the HLSL type.
///
- [DebuggerDisplay("({X}, {Y}, {Z})")]
public partial struct UInt3
{
///
diff --git a/src/ComputeSharp/Core/Primitives/UInt/UInt3.g.cs b/src/ComputeSharp/Core/Primitives/UInt/UInt3.g.cs
index fa6414df..034a57f4 100644
--- a/src/ComputeSharp/Core/Primitives/UInt/UInt3.g.cs
+++ b/src/ComputeSharp/Core/Primitives/UInt/UInt3.g.cs
@@ -1,15 +1,20 @@
-using System.Runtime.CompilerServices;
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Text;
#if !NET5_0
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
#endif
+#nullable enable
+
namespace ComputeSharp
{
///
[StructLayout(LayoutKind.Explicit, Size = 12, Pack = 4)]
- public unsafe partial struct UInt3
+ public unsafe partial struct UInt3 : IFormattable
{
///
/// A private buffer to which the undefined properties will point to.
@@ -494,6 +499,32 @@ namespace ComputeSharp
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public readonly ref readonly UInt3 BBB => ref *(UInt3*)UndefinedData;
+ ///
+ public override readonly string ToString()
+ {
+ return ToString("G", CultureInfo.CurrentCulture);
+ }
+
+ ///
+ public readonly string ToString(string? format, IFormatProvider? formatProvider)
+ {
+ StringBuilder sb = new();
+
+ string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
+
+ sb.Append('<');
+ sb.Append(this.x.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.y.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.z.ToString(format, formatProvider));
+ sb.Append('>');
+
+ return sb.ToString();
+ }
+
///
/// Sums two values.
///
diff --git a/src/ComputeSharp/Core/Primitives/UInt/UInt4.cs b/src/ComputeSharp/Core/Primitives/UInt/UInt4.cs
index a4ac74d8..6b76e874 100644
--- a/src/ComputeSharp/Core/Primitives/UInt/UInt4.cs
+++ b/src/ComputeSharp/Core/Primitives/UInt/UInt4.cs
@@ -1,11 +1,8 @@
-using System.Diagnostics;
-
-namespace ComputeSharp
+namespace ComputeSharp
{
///
/// A that maps the HLSL type.
///
- [DebuggerDisplay("({X}, {Y}, {Z}, {W})")]
public partial struct UInt4
{
///
diff --git a/src/ComputeSharp/Core/Primitives/UInt/UInt4.g.cs b/src/ComputeSharp/Core/Primitives/UInt/UInt4.g.cs
index 8fddc481..6c7126dc 100644
--- a/src/ComputeSharp/Core/Primitives/UInt/UInt4.g.cs
+++ b/src/ComputeSharp/Core/Primitives/UInt/UInt4.g.cs
@@ -1,15 +1,20 @@
-using System.Runtime.CompilerServices;
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Text;
#if !NET5_0
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
#endif
+#nullable enable
+
namespace ComputeSharp
{
///
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 4)]
- public unsafe partial struct UInt4
+ public unsafe partial struct UInt4 : IFormattable
{
///
/// A private buffer to which the undefined properties will point to.
@@ -4107,6 +4112,35 @@ namespace ComputeSharp
/// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public readonly ref readonly UInt4 AAAA => ref *(UInt4*)UndefinedData;
+ ///
+ public override readonly string ToString()
+ {
+ return ToString("G", CultureInfo.CurrentCulture);
+ }
+
+ ///
+ public readonly string ToString(string? format, IFormatProvider? formatProvider)
+ {
+ StringBuilder sb = new();
+
+ string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
+
+ sb.Append('<');
+ sb.Append(this.x.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.y.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.z.ToString(format, formatProvider));
+ sb.Append(separator);
+ sb.Append(' ');
+ sb.Append(this.w.ToString(format, formatProvider));
+ sb.Append('>');
+
+ return sb.ToString();
+ }
+
///
/// Sums two values.
///
diff --git a/src/ComputeSharp/Core/Primitives/VectorType.ttinclude b/src/ComputeSharp/Core/Primitives/VectorType.ttinclude
index 42046416..c248b560 100644
--- a/src/ComputeSharp/Core/Primitives/VectorType.ttinclude
+++ b/src/ComputeSharp/Core/Primitives/VectorType.ttinclude
@@ -65,19 +65,25 @@ void GenerateVectorProperties(string typeName, int elementSize)
string elementTypeName = Regex.Match(typeName, @"^[A-Za-z]+").Value;
string hlslElementTypeName = elementTypeName.ToLower();
int i = int.Parse(Regex.Match(typeName, @"\d+$").Value);
+ string formattable = elementTypeName == "Bool" ? "" : " : IFormattable";
#>
+using System;
+using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Text;
#if !NET5_0
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
#endif
+#nullable enable
+
namespace ComputeSharp
{
///
[StructLayout(LayoutKind.Explicit, Size = <#=(elementSize * i)#>, Pack = <#=elementSize#>)]
- public unsafe partial struct <#=typeName#>
+ public unsafe partial struct <#=typeName#><#=formattable#>
{
///
/// A private buffer to which the undefined properties will point to.
@@ -155,6 +161,85 @@ namespace ComputeSharp
PopIndent();
PopIndent();
+ WriteLine("");
+
+ if (elementTypeName == "Bool")
+ {
+#>
+ ///
+ public override readonly string ToString()
+ {
+ StringBuilder sb = new();
+
+ sb.Append('<');
+<#
+ PushIndent(" ");
+ PushIndent(" ");
+ PushIndent(" ");
+
+ for (int j = 0; j < i; j++)
+ {
+ WriteLine($"sb.Append(this.{"xyzw"[j]});");
+
+ if (j < i - 1)
+ {
+ WriteLine("sb.Append(\", \");");
+ }
+ }
+
+ PopIndent();
+ PopIndent();
+ PopIndent();
+#>
+ sb.Append('>');
+
+ return sb.ToString();
+ }
+<#
+ }
+ else
+ {
+#>
+ ///
+ public override readonly string ToString()
+ {
+ return ToString("G", CultureInfo.CurrentCulture);
+ }
+
+ ///
+ public readonly string ToString(string? format, IFormatProvider? formatProvider)
+ {
+ StringBuilder sb = new();
+
+ string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
+
+ sb.Append('<');
+<#
+ PushIndent(" ");
+ PushIndent(" ");
+ PushIndent(" ");
+
+ for (int j = 0; j < i; j++)
+ {
+ WriteLine($"sb.Append(this.{"xyzw"[j]}.ToString(format, formatProvider));");
+
+ if (j < i - 1)
+ {
+ WriteLine("sb.Append(separator);");
+ WriteLine("sb.Append(' ');");
+ }
+ }
+
+ PopIndent();
+ PopIndent();
+ PopIndent();
+#>
+ sb.Append('>');
+
+ return sb.ToString();
+ }
+<#
+ }
// Generate the negation operator
if (elementTypeName != "Bool" && elementTypeName != "UInt")