diff --git a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.Shaders/Translation/Mappings/HlslKnownTypes.cs similarity index 91% rename from src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs rename to src/ComputeSharp.Shaders/Translation/Mappings/HlslKnownTypes.cs index 7ade5bc9..b3fe7b73 100644 --- a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.Shaders/Translation/Mappings/HlslKnownTypes.cs @@ -63,7 +63,7 @@ namespace ComputeSharp.Shaders.Mappings type.GetGenericTypeDefinition() == typeof(ConstantBuffer<>); /// - /// Checks whether or not the input type is a or value. + /// Checks whether or not the input type is a known readonly resource type (buffer or texture). /// /// The input instance to check. /// A indicating whether the input is a readonly resource type. @@ -76,11 +76,12 @@ namespace ComputeSharp.Shaders.Mappings return genericType == typeof(ReadOnlyBuffer<>) || - genericType == typeof(ReadOnlyTexture2D<>); + genericType == typeof(ReadOnlyTexture2D<>) || + genericType == typeof(ReadOnlyTexture3D<>); } /// - /// Checks whether or not the input type is a or value. + /// Checks whether or not the input type is a known writeable resource type (buffer or texture). /// /// The input instance to check. /// A indicating whether the input is a writeable resource type. @@ -93,7 +94,8 @@ namespace ComputeSharp.Shaders.Mappings return genericType == typeof(ReadWriteBuffer<>) || - genericType == typeof(ReadWriteTexture2D<>); + genericType == typeof(ReadWriteTexture2D<>) || + genericType == typeof(ReadWriteTexture3D<>); } } } diff --git a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs index 5b3b9299..bffcb65a 100644 --- a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs @@ -63,11 +63,17 @@ namespace ComputeSharp.SourceGenerators.Mappings /// Whether or not represents a typed resource type. public static bool IsTypedResourceType(string typeName) { - return - typeName == "ComputeSharp.ReadOnlyBuffer`1" || - typeName == "ComputeSharp.ReadWriteBuffer`1" || - typeName == "ComputeSharp.ReadOnlyTexture2D`1" || - typeName == "ComputeSharp.ReadWriteTexture2D`1"; + switch (typeName) + { + case "ComputeSharp.ReadOnlyBuffer`1": + case "ComputeSharp.ReadWriteBuffer`1": + case "ComputeSharp.ReadOnlyTexture2D`1": + case "ComputeSharp.ReadWriteTexture2D`1": + case "ComputeSharp.ReadOnlyTexture3D`1": + case "ComputeSharp.ReadWriteTexture3D`1": + return true; + default: return false; + }; } /// @@ -102,6 +108,8 @@ namespace ComputeSharp.SourceGenerators.Mappings "ComputeSharp.ReadWriteBuffer`1" => $"RWStructuredBuffer<{mapped}>", "ComputeSharp.ReadOnlyTexture2D`1" => $"Texture2D<{mapped}>", "ComputeSharp.ReadWriteTexture2D`1" => $"RWTexture2D<{mapped}>", + "ComputeSharp.ReadOnlyTexture3D`1" => $"Texture3D<{mapped}>", + "ComputeSharp.ReadWriteTexture3D`1" => $"RWTexture3D<{mapped}>", _ => throw new ArgumentException() }; }