ThreadIds struct refactored
このコミットが含まれているのは:
1 親
67ff58d6de
コミット
639ae6520a
6ファイル変更
+31
-31
検索条件に一致するファイルはありません
@@ -19,7 +19,7 @@ namespace DirectX12ComputeShaderSample
|
||||
|
||||
public static class GraphicsDeviceExtensions
|
||||
{
|
||||
public static void For(this GraphicsDevice device, int n, Action<UInt3> shader)
|
||||
public static void For(this GraphicsDevice device, int n, Action<ThreadIds> shader)
|
||||
{
|
||||
// Generate the compute shadr
|
||||
ShaderGenerator shaderGenerator = new ShaderGenerator(shader);
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace DirectX12ComputeShaderSample
|
||||
var data = gpuBuffer.GetGpuResource();
|
||||
|
||||
// Shader body
|
||||
Action<UInt3> action = id =>
|
||||
Action<ThreadIds> action = id =>
|
||||
{
|
||||
data[id.X + id.Y * size] *= 2;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace DirectX12GameEngine.Shaders.Numerics
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that indicates the ids of a given GPU thread running a compute shader
|
||||
/// </summary>
|
||||
public readonly struct ThreadIds
|
||||
{
|
||||
/// <summary>
|
||||
/// The X id of the current thread
|
||||
/// </summary>
|
||||
public readonly uint X;
|
||||
|
||||
/// <summary>
|
||||
/// The Y id of the current thread
|
||||
/// </summary>
|
||||
public readonly uint Y;
|
||||
|
||||
/// <summary>
|
||||
/// The Z id of the current thread
|
||||
/// </summary>
|
||||
public readonly uint Z;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace DirectX12GameEngine.Shaders.Numerics
|
||||
{
|
||||
public struct UInt2
|
||||
{
|
||||
public uint X;
|
||||
|
||||
public uint Y;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace DirectX12GameEngine.Shaders.Numerics
|
||||
{
|
||||
public struct UInt3
|
||||
{
|
||||
public uint X;
|
||||
|
||||
public uint Y;
|
||||
|
||||
public uint Z;
|
||||
|
||||
public UInt2 XY => new UInt2 { X = X, Y = Y };
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ namespace DirectX12GameEngine.Shaders
|
||||
{
|
||||
if (result != null) return result;
|
||||
|
||||
if (!(shader is Action<UInt3> action)) throw new InvalidOperationException("Missing lambda shader");
|
||||
if (!(shader is Action<ThreadIds> action)) throw new InvalidOperationException("Missing lambda shader");
|
||||
|
||||
Type shaderType = action.Method.DeclaringType;
|
||||
object shaderInstance = action.Target;
|
||||
@@ -498,9 +498,8 @@ namespace DirectX12GameEngine.Shaders
|
||||
{ typeof(Vector2).FullName, "float2" },
|
||||
{ typeof(Vector3).FullName, "float3" },
|
||||
{ typeof(Vector4).FullName, "float4" },
|
||||
{ typeof(Numerics.UInt2).FullName, "uint2" },
|
||||
{ typeof(Numerics.UInt3).FullName, "uint3" },
|
||||
{ typeof(Matrix4x4).FullName, "float4x4" },
|
||||
{ typeof(ThreadIds).FullName, "uint3" },
|
||||
{ typeof(RWBufferResource<>).FullName, "RWBuffer" },
|
||||
};
|
||||
|
||||
@@ -562,10 +561,10 @@ namespace DirectX12GameEngine.Shaders
|
||||
{ "DirectX12GameEngine.Shaders.Numerics.UInt2.X", ".x" },
|
||||
{ "DirectX12GameEngine.Shaders.Numerics.UInt2.Y", ".y" },
|
||||
|
||||
{ "DirectX12GameEngine.Shaders.Numerics.UInt3.X", ".x" },
|
||||
{ "DirectX12GameEngine.Shaders.Numerics.UInt3.Y", ".y" },
|
||||
{ "DirectX12GameEngine.Shaders.Numerics.UInt3.Z", ".z" },
|
||||
{ "DirectX12GameEngine.Shaders.Numerics.UInt3.XY", ".xy" },
|
||||
{ "DirectX12GameEngine.Shaders.Numerics.ThreadIds.X", ".x" },
|
||||
{ "DirectX12GameEngine.Shaders.Numerics.ThreadIds.Y", ".y" },
|
||||
{ "DirectX12GameEngine.Shaders.Numerics.ThreadIds.Z", ".z" },
|
||||
{ "DirectX12GameEngine.Shaders.Numerics.ThreadIds.XY", ".xy" },
|
||||
|
||||
{ "System.Numerics.Vector3.X", ".x" },
|
||||
{ "System.Numerics.Vector3.Y", ".y" },
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする