From f01fc0ebfba1ba93dd2d11b6ad63cd8a208cc5d0 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 22 Jan 2022 15:40:55 +0100 Subject: [PATCH] Update source generators for non-normalized texture interfaces --- .../Mappings/HlslKnownMembers.cs | 13 +++++++++++++ .../Mappings/HlslKnownTypes.cs | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownMembers.cs b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownMembers.cs index e66cab64..a3d99549 100644 --- a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownMembers.cs +++ b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownMembers.cs @@ -22,12 +22,16 @@ internal static class HlslKnownMembers [$"ComputeSharp.ReadOnlyTexture2D`2.this[{typeof(int).FullName}, {typeof(int).FullName}]"] = "int2", [$"ComputeSharp.ReadWriteTexture2D`1.this[{typeof(int).FullName}, {typeof(int).FullName}]"] = "int2", [$"ComputeSharp.ReadWriteTexture2D`2.this[{typeof(int).FullName}, {typeof(int).FullName}]"] = "int2", + [$"ComputeSharp.IReadOnlyTexture2D`1.this[{typeof(int).FullName}, {typeof(int).FullName}]"] = "int2", + [$"ComputeSharp.IReadWriteTexture2D`1.this[{typeof(int).FullName}, {typeof(int).FullName}]"] = "int2", [$"ComputeSharp.IReadOnlyNormalizedTexture2D`1.this[{typeof(int).FullName}, {typeof(int).FullName}]"] = "int2", [$"ComputeSharp.IReadWriteNormalizedTexture2D`1.this[{typeof(int).FullName}, {typeof(int).FullName}]"] = "int2", [$"ComputeSharp.ReadOnlyTexture3D`1.this[{typeof(int).FullName}, {typeof(int).FullName}, {typeof(int).FullName}]"] = "int3", [$"ComputeSharp.ReadOnlyTexture3D`2.this[{typeof(int).FullName}, {typeof(int).FullName}, {typeof(int).FullName}]"] = "int3", [$"ComputeSharp.ReadWriteTexture3D`1.this[{typeof(int).FullName}, {typeof(int).FullName}, {typeof(int).FullName}]"] = "int3", [$"ComputeSharp.ReadWriteTexture3D`2.this[{typeof(int).FullName}, {typeof(int).FullName}, {typeof(int).FullName}]"] = "int3", + [$"ComputeSharp.IReadOnlyTexture3D`1.this[{typeof(int).FullName}, {typeof(int).FullName}, {typeof(int).FullName}]"] = "int3", + [$"ComputeSharp.IReadWriteTexture3D`1.this[{typeof(int).FullName}, {typeof(int).FullName}, {typeof(int).FullName}]"] = "int3", [$"ComputeSharp.IReadOnlyNormalizedTexture3D`1.this[{typeof(int).FullName}, {typeof(int).FullName}, {typeof(int).FullName}]"] = "int3", [$"ComputeSharp.IReadWriteNormalizedTexture3D`1.this[{typeof(int).FullName}, {typeof(int).FullName}, {typeof(int).FullName}]"] = "int3" }; @@ -39,10 +43,14 @@ internal static class HlslKnownMembers { [$"ComputeSharp.ReadOnlyTexture2D`2.this[{typeof(float).FullName}, {typeof(float).FullName}]"] = "float2", [$"ComputeSharp.ReadOnlyTexture2D`2.this[{typeof(Float2).FullName}]"] = null, + [$"ComputeSharp.IReadOnlyTexture2D`1.this[{typeof(float).FullName}, {typeof(float).FullName}]"] = "float2", + [$"ComputeSharp.IReadOnlyTexture2D`1.this[{typeof(Float2).FullName}]"] = null, [$"ComputeSharp.IReadOnlyNormalizedTexture2D`1.this[{typeof(float).FullName}, {typeof(float).FullName}]"] = "float2", [$"ComputeSharp.IReadOnlyNormalizedTexture2D`1.this[{typeof(Float2).FullName}]"] = null, [$"ComputeSharp.ReadOnlyTexture3D`2.this[{typeof(float).FullName}, {typeof(float).FullName}, {typeof(float).FullName}]"] = "float3", [$"ComputeSharp.ReadOnlyTexture3D`2.this[{typeof(Float3).FullName}]"] = null, + [$"ComputeSharp.IReadOnlyTexture3D`1.this[{typeof(float).FullName}, {typeof(float).FullName}, {typeof(float).FullName}]"] = "float3", + [$"ComputeSharp.IReadOnlyTexture3D`1.this[{typeof(Float3).FullName}]"] = null, [$"ComputeSharp.IReadOnlyNormalizedTexture3D`1.this[{typeof(float).FullName}, {typeof(float).FullName}, {typeof(float).FullName}]"] = "float3", [$"ComputeSharp.IReadOnlyNormalizedTexture3D`1.this[{typeof(Float3).FullName}]"] = null }; @@ -58,6 +66,11 @@ internal static class HlslKnownMembers ["ComputeSharp.Resources.Texture3D`1.Width"] = (3, 0), ["ComputeSharp.Resources.Texture3D`1.Height"] = (3, 1), ["ComputeSharp.Resources.Texture3D`1.Depth"] = (3, 2), + ["ComputeSharp.IReadOnlyTexture2D`1.Width"] = (2, 0), + ["ComputeSharp.IReadOnlyTexture2D`1.Height"] = (2, 1), + ["ComputeSharp.IReadOnlyTexture3D`1.Width"] = (3, 0), + ["ComputeSharp.IReadOnlyTexture3D`1.Height"] = (3, 1), + ["ComputeSharp.IReadOnlyTexture3D`1.Depth"] = (3, 2), ["ComputeSharp.IReadOnlyNormalizedTexture2D`1.Width"] = (2, 0), ["ComputeSharp.IReadOnlyNormalizedTexture2D`1.Height"] = (2, 1), ["ComputeSharp.IReadOnlyNormalizedTexture3D`1.Width"] = (3, 0), diff --git a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs index 64defbab..2625d3f7 100644 --- a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs @@ -141,6 +141,8 @@ internal static class HlslKnownTypes "ComputeSharp.ReadOnlyTexture2D`2" or "ComputeSharp.ReadOnlyTexture3D`1" or "ComputeSharp.ReadOnlyTexture3D`2" or + "ComputeSharp.IReadOnlyTexture2D`1" or + "ComputeSharp.IReadOnlyTexture3D`1" => true, "ComputeSharp.IReadOnlyNormalizedTexture2D`1" or "ComputeSharp.IReadOnlyNormalizedTexture3D`1" => true, _ => false, @@ -187,6 +189,8 @@ internal static class HlslKnownTypes "ComputeSharp.ReadOnlyTexture3D`2" or "ComputeSharp.ReadWriteTexture3D`1" or "ComputeSharp.ReadWriteTexture3D`2" or + "ComputeSharp.IReadOnlyTexture2D`1" or + "ComputeSharp.IReadOnlyTexture3D`1" or "ComputeSharp.IReadOnlyNormalizedTexture2D`1" or "ComputeSharp.IReadWriteNormalizedTexture2D`1" or "ComputeSharp.IReadOnlyNormalizedTexture3D`1" or @@ -294,6 +298,8 @@ internal static class HlslKnownTypes "ComputeSharp.ReadOnlyTexture3D`2" => $"Texture3D", "ComputeSharp.ReadWriteTexture3D`1" => $"RWTexture3D<{mappedElementType}>", "ComputeSharp.ReadWriteTexture3D`2" => $"RWTexture3D", + "ComputeSharp.IReadOnlyTexture2D`1" => $"Texture2D<{mappedElementType}>", + "ComputeSharp.IReadOnlyTexture3D`1" => $"Texture3D<{mappedElementType}>", "ComputeSharp.IReadOnlyNormalizedTexture2D`1" => $"Texture2D", "ComputeSharp.IReadWriteNormalizedTexture2D`1" => $"RWTexture2D", "ComputeSharp.IReadOnlyNormalizedTexture3D`1" => $"Texture3D",