Skip to content

Commit

Permalink
Merge pull request #574 from Sergio0694/dev/constant-buffer-type-layout
Browse files Browse the repository at this point in the history
Generate constant buffer layout type for marshalling
  • Loading branch information
Sergio0694 authored Sep 28, 2023
2 parents 33b8503 + 856475d commit 44e36eb
Show file tree
Hide file tree
Showing 19 changed files with 521 additions and 308 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ private static float2x2 Rotate2x2(in float a)
return new(c, -s, s, c);
}

// IQ's float2 to float hash.
private static float Hash21(float2 p)
{
return Hlsl.Frac(Hlsl.Sin(Hlsl.Dot(p, new float2(27.619f, 57.583f))) * 43758.5453f);
}

// float2 to float2 hash.
private float2 Hash22(float2 p)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ private static float2x2 Rotate2x2(in float a)
return new(c, -s, s, c);
}

// IQ's float2 to float hash.
private static float Hash21(float2 p)
{
return Hlsl.Frac(Hlsl.Sin(Hlsl.Dot(p, new float2(27.619f, 57.583f))) * 43758.5453f);
}

// float2 to float2 hash.
private float2 Hash22(float2 p)
{
Expand Down
64 changes: 32 additions & 32 deletions src/ComputeSharp.Core/Primitives/Bool/BoolMxN.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public Bool1x1(bool m11)
/// <param name="row">The row to access.</param>
/// <remarks>
/// <para>Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// <para>Invoking this method with an invalid row argument results in undefined behavior.</para>
/// </remarks>
[UnscopedRef]
public ref bool this[int row] => ref *(bool*)UndefinedData;
public ref bool this[int row] => ref Unsafe.As<int, bool>(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(bool) * row)));

/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="Bool1x1"/> instance.
Expand Down Expand Up @@ -184,10 +184,10 @@ public Bool1x2(bool m11, bool m12)
/// <param name="row">The row to access.</param>
/// <remarks>
/// <para>Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// <para>Invoking this method with an invalid row argument results in undefined behavior.</para>
/// </remarks>
[UnscopedRef]
public ref Bool2 this[int row] => ref *(Bool2*)UndefinedData;
public ref Bool2 this[int row] => ref Unsafe.As<int, Bool2>(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool2) * row)));

/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="Bool1x2"/> instance.
Expand Down Expand Up @@ -350,10 +350,10 @@ public Bool1x3(bool m11, bool m12, bool m13)
/// <param name="row">The row to access.</param>
/// <remarks>
/// <para>Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// <para>Invoking this method with an invalid row argument results in undefined behavior.</para>
/// </remarks>
[UnscopedRef]
public ref Bool3 this[int row] => ref *(Bool3*)UndefinedData;
public ref Bool3 this[int row] => ref Unsafe.As<int, Bool3>(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool3) * row)));

/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="Bool1x3"/> instance.
Expand Down Expand Up @@ -528,10 +528,10 @@ public Bool1x4(bool m11, bool m12, bool m13, bool m14)
/// <param name="row">The row to access.</param>
/// <remarks>
/// <para>Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// <para>Invoking this method with an invalid row argument results in undefined behavior.</para>
/// </remarks>
[UnscopedRef]
public ref Bool4 this[int row] => ref *(Bool4*)UndefinedData;
public ref Bool4 this[int row] => ref Unsafe.As<int, Bool4>(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool4) * row)));

/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="Bool1x4"/> instance.
Expand Down Expand Up @@ -703,10 +703,10 @@ public Bool2x1(bool m11, bool m21)
/// <param name="row">The row to access.</param>
/// <remarks>
/// <para>Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// <para>Invoking this method with an invalid row argument results in undefined behavior.</para>
/// </remarks>
[UnscopedRef]
public ref bool this[int row] => ref *(bool*)UndefinedData;
public ref bool this[int row] => ref Unsafe.As<int, bool>(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(bool) * row)));

/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="Bool2x1"/> instance.
Expand Down Expand Up @@ -887,10 +887,10 @@ public Bool2x2(Bool2 row1, Bool2 row2)
/// <param name="row">The row to access.</param>
/// <remarks>
/// <para>Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// <para>Invoking this method with an invalid row argument results in undefined behavior.</para>
/// </remarks>
[UnscopedRef]
public ref Bool2 this[int row] => ref *(Bool2*)UndefinedData;
public ref Bool2 this[int row] => ref Unsafe.As<int, Bool2>(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool2) * row)));

/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="Bool2x2"/> instance.
Expand Down Expand Up @@ -1091,10 +1091,10 @@ public Bool2x3(Bool3 row1, Bool3 row2)
/// <param name="row">The row to access.</param>
/// <remarks>
/// <para>Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// <para>Invoking this method with an invalid row argument results in undefined behavior.</para>
/// </remarks>
[UnscopedRef]
public ref Bool3 this[int row] => ref *(Bool3*)UndefinedData;
public ref Bool3 this[int row] => ref Unsafe.As<int, Bool3>(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool3) * row)));

/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="Bool2x3"/> instance.
Expand Down Expand Up @@ -1321,10 +1321,10 @@ public Bool2x4(Bool4 row1, Bool4 row2)
/// <param name="row">The row to access.</param>
/// <remarks>
/// <para>Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// <para>Invoking this method with an invalid row argument results in undefined behavior.</para>
/// </remarks>
[UnscopedRef]
public ref Bool4 this[int row] => ref *(Bool4*)UndefinedData;
public ref Bool4 this[int row] => ref Unsafe.As<int, Bool4>(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool4) * row)));

/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="Bool2x4"/> instance.
Expand Down Expand Up @@ -1523,10 +1523,10 @@ public Bool3x1(bool m11, bool m21, bool m31)
/// <param name="row">The row to access.</param>
/// <remarks>
/// <para>Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// <para>Invoking this method with an invalid row argument results in undefined behavior.</para>
/// </remarks>
[UnscopedRef]
public ref bool this[int row] => ref *(bool*)UndefinedData;
public ref bool this[int row] => ref Unsafe.As<int, bool>(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(bool) * row)));

/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="Bool3x1"/> instance.
Expand Down Expand Up @@ -1727,10 +1727,10 @@ public Bool3x2(Bool2 row1, Bool2 row2, Bool2 row3)
/// <param name="row">The row to access.</param>
/// <remarks>
/// <para>Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// <para>Invoking this method with an invalid row argument results in undefined behavior.</para>
/// </remarks>
[UnscopedRef]
public ref Bool2 this[int row] => ref *(Bool2*)UndefinedData;
public ref Bool2 this[int row] => ref Unsafe.As<int, Bool2>(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool2) * row)));

/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="Bool3x2"/> instance.
Expand Down Expand Up @@ -1964,10 +1964,10 @@ public Bool3x3(Bool3 row1, Bool3 row2, Bool3 row3)
/// <param name="row">The row to access.</param>
/// <remarks>
/// <para>Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// <para>Invoking this method with an invalid row argument results in undefined behavior.</para>
/// </remarks>
[UnscopedRef]
public ref Bool3 this[int row] => ref *(Bool3*)UndefinedData;
public ref Bool3 this[int row] => ref Unsafe.As<int, Bool3>(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool3) * row)));

/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="Bool3x3"/> instance.
Expand Down Expand Up @@ -2240,10 +2240,10 @@ public Bool3x4(Bool4 row1, Bool4 row2, Bool4 row3)
/// <param name="row">The row to access.</param>
/// <remarks>
/// <para>Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// <para>Invoking this method with an invalid row argument results in undefined behavior.</para>
/// </remarks>
[UnscopedRef]
public ref Bool4 this[int row] => ref *(Bool4*)UndefinedData;
public ref Bool4 this[int row] => ref Unsafe.As<int, Bool4>(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool4) * row)));

/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="Bool3x4"/> instance.
Expand Down Expand Up @@ -2475,10 +2475,10 @@ public Bool4x1(bool m11, bool m21, bool m31, bool m41)
/// <param name="row">The row to access.</param>
/// <remarks>
/// <para>Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// <para>Invoking this method with an invalid row argument results in undefined behavior.</para>
/// </remarks>
[UnscopedRef]
public ref bool this[int row] => ref *(bool*)UndefinedData;
public ref bool this[int row] => ref Unsafe.As<int, bool>(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(bool) * row)));

/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="Bool4x1"/> instance.
Expand Down Expand Up @@ -2699,10 +2699,10 @@ public Bool4x2(Bool2 row1, Bool2 row2, Bool2 row3, Bool2 row4)
/// <param name="row">The row to access.</param>
/// <remarks>
/// <para>Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// <para>Invoking this method with an invalid row argument results in undefined behavior.</para>
/// </remarks>
[UnscopedRef]
public ref Bool2 this[int row] => ref *(Bool2*)UndefinedData;
public ref Bool2 this[int row] => ref Unsafe.As<int, Bool2>(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool2) * row)));

/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="Bool4x2"/> instance.
Expand Down Expand Up @@ -2969,10 +2969,10 @@ public Bool4x3(Bool3 row1, Bool3 row2, Bool3 row3, Bool3 row4)
/// <param name="row">The row to access.</param>
/// <remarks>
/// <para>Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// <para>Invoking this method with an invalid row argument results in undefined behavior.</para>
/// </remarks>
[UnscopedRef]
public ref Bool3 this[int row] => ref *(Bool3*)UndefinedData;
public ref Bool3 this[int row] => ref Unsafe.As<int, Bool3>(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool3) * row)));

/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="Bool4x3"/> instance.
Expand Down Expand Up @@ -3291,10 +3291,10 @@ public Bool4x4(Bool4 row1, Bool4 row2, Bool4 row3, Bool4 row4)
/// <param name="row">The row to access.</param>
/// <remarks>
/// <para>Unlike with vector types, these properties cannot validate in advance which combinations are writeable, so callers should ensure proper use.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// <para>Invoking this method with an invalid row argument results in undefined behavior.</para>
/// </remarks>
[UnscopedRef]
public ref Bool4 this[int row] => ref *(Bool4*)UndefinedData;
public ref Bool4 this[int row] => ref Unsafe.As<int, Bool4>(ref Unsafe.AddByteOffset(ref this.m11, (nint)(uint)(sizeof(Bool4) * row)));

/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="Bool4x4"/> instance.
Expand Down
2 changes: 1 addition & 1 deletion src/ComputeSharp.Core/Primitives/Bool/BoolMxN.tt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#@include file="..\MatrixType.ttinclude" #>
<#@include file="..\MatrixType.ttinclude" #>
<#
GenerateAllMatrixProperties("Bool", sizeof(int));
#>
Loading

0 comments on commit 44e36eb

Please sign in to comment.