From 1b6e7d6a4ca7d9f318f953e747da74612ab0c40e Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 29 Aug 2019 02:11:11 +0200 Subject: [PATCH] Fixed Bool2 mappings --- .../Buffers/Extensions/BufferExtensions.cs | 1 - .../Mappings/HlslKnownMethods.cs | 6 +++++ .../Mappings/HlslKnownTypes.cs | 23 +++++++++++-------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs b/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs index 34fe732b..afa54b56 100644 --- a/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs +++ b/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs @@ -1,7 +1,6 @@ using System; using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; using ComputeSharp.Core; using ComputeSharp.Graphics; using ComputeSharp.Graphics.Buffers.Abstract; diff --git a/src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs b/src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs index 1f99defa..0dbcf371 100644 --- a/src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs +++ b/src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs @@ -128,6 +128,12 @@ namespace ComputeSharp.Shaders.Mappings ["System.Numerics.Vector4.Zero"] = "(float4)0", ["System.Numerics.Vector4.One"] = "float4(1.0f, 1.0f, 1.0f, 1.0f)", + // Bool2 + ["ComputeSharp.Bool2.False"] = "(bool2)0", + ["ComputeSharp.Bool2.True"] = "bool2(true, true)", + ["ComputeSharp.Bool2.TrueX"] = "bool2(true, false)", + ["ComputeSharp.Bool2.TrueY"] = "bool2(false, true)", + // Int2 ["ComputeSharp.Int2.Zero"] = "(int2)0", ["ComputeSharp.Int2.One"] = "int2(1, 1)", diff --git a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs index f83ff88e..739f77c3 100644 --- a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs @@ -17,26 +17,27 @@ namespace ComputeSharp.Shaders.Mappings private static readonly IReadOnlyDictionary KnownTypes = new Dictionary { [typeof(bool).FullName] = "bool", + [typeof(Bool2).FullName] = "bool2", [typeof(int).FullName] = "int", - [typeof(uint).FullName] = "uint", - [typeof(float).FullName] = "float", - [typeof(double).FullName] = "double", - [typeof(Vector2).FullName] = "float2", - [typeof(Vector3).FullName] = "float3", - [typeof(Vector4).FullName] = "float4", - [typeof(ThreadIds).FullName] = "uint3", [typeof(Int2).FullName] = "int2", [typeof(Int3).FullName] = "int3", [typeof(Int4).FullName] = "int4", + [typeof(uint).FullName] = "uint", [typeof(UInt2).FullName] = "uint2", [typeof(UInt3).FullName] = "uint3", [typeof(UInt4).FullName] = "uint4", + [typeof(float).FullName] = "float", [typeof(Float2).FullName] = "float2", [typeof(Float3).FullName] = "float3", [typeof(Float4).FullName] = "float4", + [typeof(Vector2).FullName] = "float2", + [typeof(Vector3).FullName] = "float3", + [typeof(Vector4).FullName] = "float4", + [typeof(double).FullName] = "double", [typeof(Double2).FullName] = "double2", [typeof(Double3).FullName] = "double3", [typeof(Double4).FullName] = "double4", + [typeof(ThreadIds).FullName] = "uint3", [typeof(ReadOnlyBuffer<>).FullName] = "StructuredBuffer", [typeof(ReadWriteBuffer<>).FullName] = "RWStructuredBuffer" }; @@ -46,6 +47,7 @@ namespace ComputeSharp.Shaders.Mappings /// public static IReadOnlyList KnownVectorTypes { get; } = new[] { + typeof(Bool2), typeof(Int2), typeof(Int3), typeof(Int4), typeof(UInt2), typeof(UInt3), typeof(UInt4), typeof(Float2), typeof(Float3), typeof(Float4), @@ -70,9 +72,7 @@ namespace ComputeSharp.Shaders.Mappings /// The input instance to check /// A indicating whether the input is in fact a known HLSL vector type [Pure] - public static bool IsKnownVectorType(Type type) => type == typeof(Vector2) || - type == typeof(Vector3) || - type == typeof(Vector4) || + public static bool IsKnownVectorType(Type type) => type == typeof(Bool2) || type == typeof(Int2) || type == typeof(Int3) || type == typeof(Int4) || @@ -82,6 +82,9 @@ namespace ComputeSharp.Shaders.Mappings type == typeof(Float2) || type == typeof(Float3) || type == typeof(Float4) || + type == typeof(Vector2) || + type == typeof(Vector3) || + type == typeof(Vector4) || type == typeof(Double2) || type == typeof(Double3) || type == typeof(Double4);