Move known samplers to HlslKnownMethods type

このコミットが含まれているのは:
Sergio Pedri committed 2022-08-09 17:37:55 +02:00
1 親 6c75394e22
コミット 0dd0bd587a
6ファイル変更
+62 -55

検索条件に一致するファイルはありません

+13
ファイルの表示
@@ -37,4 +37,17 @@ partial class HlslKnownMethods
knownMethods.Add($"{typeof(D2D).FullName}{Type.Delimiter}{method.Name}", hlslName);
}
}
/// <inheritdoc/>
private static partial IReadOnlyDictionary<string, string?> BuildKnownResourceSamplers()
{
return new Dictionary<string, string?>
{
[$"ComputeSharp.D2D1.D2D1ResourceTexture1D.Sample({typeof(float).FullName})"] = null,
[$"ComputeSharp.D2D1.D2D1ResourceTexture2D.Sample({typeof(float).FullName}, {typeof(float).FullName})"] = "float2",
[$"ComputeSharp.D2D1.D2D1ResourceTexture2D.Sample({typeof(Float2).FullName})"] = null,
[$"ComputeSharp.D2D1.D2D1ResourceTexture3D.Sample({typeof(float).FullName}, {typeof(float).FullName}, {typeof(float).FullName})"] = "float3",
[$"ComputeSharp.D2D1.D2D1ResourceTexture3D.Sample({typeof(Float3).FullName})"] = null
};
}
}
-13
ファイルの表示
@@ -15,19 +15,6 @@ partial class HlslKnownProperties
};
}
/// <inheritdoc/>
private static partial IReadOnlyDictionary<string, string?> BuildKnownResourceSamplers()
{
return new Dictionary<string, string?>
{
[$"ComputeSharp.D2D1.D2D1ResourceTexture1D.this[{typeof(float).FullName}]"] = null,
[$"ComputeSharp.D2D1.D2D1ResourceTexture2D.this[{typeof(float).FullName}, {typeof(float).FullName}]"] = "float2",
[$"ComputeSharp.D2D1.D2D1ResourceTexture2D.this[{typeof(Float2).FullName}]"] = null,
[$"ComputeSharp.D2D1.D2D1ResourceTexture3D.this[{typeof(float).FullName}, {typeof(float).FullName}, {typeof(float).FullName}]"] = "float3",
[$"ComputeSharp.D2D1.D2D1ResourceTexture3D.this[{typeof(Float3).FullName}]"] = null
};
}
/// <inheritdoc/>
private static partial IReadOnlyDictionary<string, (int Rank, int Axis)> BuildKnownSizeAccessors()
{
+22
ファイルの表示
@@ -149,6 +149,28 @@ internal static partial class HlslKnownMethods
/// <param name="knownMethods">The mapping of known methods being built.</param>
static partial void AddKnownMethods(IDictionary<string, string> knownMethods);
/// <summary>
/// The mapping of supported known samplers to HLSL resource type names.
/// </summary>
private static readonly IReadOnlyDictionary<string, string?> KnownResourceSamplers = BuildKnownResourceSamplers();
/// <summary>
/// Builds the mapping of supported known samplers to HLSL resource type names.
/// </summary>
/// <returns>The mapping of supported known samplers to HLSL resource type names.</returns>
private static partial IReadOnlyDictionary<string, string?> BuildKnownResourceSamplers();
/// <summary>
/// Tries to get the mapped HLSL-compatible sampler resource type name for the input indexer name.
/// </summary>
/// <param name="name">The input fully qualified indexer name.</param>
/// <param name="mapped">The mapped type name, if one is found.</param>
/// <returns>The HLSL-compatible type name that can be used in an HLSL shader for the given sampler.</returns>
public static bool TryGetMappedResourceSamplerAccessType(string name, out string? mapped)
{
return KnownResourceSamplers.TryGetValue(name, out mapped);
}
/// <summary>
/// Tries to get the mapped HLSL-compatible method name for the input method name.
/// </summary>
-22
ファイルの表示
@@ -220,17 +220,6 @@ internal static partial class HlslKnownProperties
/// <returns>The mapping of supported known indexers to HLSL resource type names.</returns>
private static partial IReadOnlyDictionary<string, string> BuildKnownResourceIndexers();
/// <summary>
/// The mapping of supported known samplers to HLSL resource type names.
/// </summary>
private static readonly IReadOnlyDictionary<string, string?> KnownResourceSamplers = BuildKnownResourceSamplers();
/// <summary>
/// Builds the mapping of supported known samplers to HLSL resource type names.
/// </summary>
/// <returns>The mapping of supported known samplers to HLSL resource type names.</returns>
private static partial IReadOnlyDictionary<string, string?> BuildKnownResourceSamplers();
/// <summary>
/// The mapping of supported known size accessors for HLSL resource types.
/// </summary>
@@ -284,17 +273,6 @@ internal static partial class HlslKnownProperties
return KnownResourceIndexers.TryGetValue(name, out mapped);
}
/// <summary>
/// Tries to get the mapped HLSL-compatible sampler resource type name for the input indexer name.
/// </summary>
/// <param name="name">The input fully qualified indexer name.</param>
/// <param name="mapped">The mapped type name, if one is found.</param>
/// <returns>The HLSL-compatible type name that can be used in an HLSL shader for the given sampler.</returns>
public static bool TryGetMappedResourceSamplerAccessType(string name, out string? mapped)
{
return KnownResourceSamplers.TryGetValue(name, out mapped);
}
/// <summary>
/// Tries to get the mapped rank and axis for a given indexer name.
/// </summary>
+27
ファイルの表示
@@ -0,0 +1,27 @@
using System.Collections.Generic;
namespace ComputeSharp.SourceGeneration.Mappings;
/// <inheritdoc/>
partial class HlslKnownMethods
{
/// <inheritdoc/>
private static partial IReadOnlyDictionary<string, string?> BuildKnownResourceSamplers()
{
return new Dictionary<string, string?>
{
[$"ComputeSharp.ReadOnlyTexture2D`2.Sample({typeof(float).FullName}, {typeof(float).FullName})"] = "float2",
[$"ComputeSharp.ReadOnlyTexture2D`2.Sample({typeof(Float2).FullName})"] = null,
[$"ComputeSharp.IReadOnlyTexture2D`1.Sample({typeof(float).FullName}, {typeof(float).FullName})"] = "float2",
[$"ComputeSharp.IReadOnlyTexture2D`1.Sample({typeof(Float2).FullName})"] = null,
[$"ComputeSharp.IReadOnlyNormalizedTexture2D`1.Sample({typeof(float).FullName}, {typeof(float).FullName})"] = "float2",
[$"ComputeSharp.IReadOnlyNormalizedTexture2D`1.Sample({typeof(Float2).FullName})"] = null,
[$"ComputeSharp.ReadOnlyTexture3D`2.Sample({typeof(float).FullName}, {typeof(float).FullName}, {typeof(float).FullName})"] = "float3",
[$"ComputeSharp.ReadOnlyTexture3D`2.Sample({typeof(Float3).FullName})"] = null,
[$"ComputeSharp.IReadOnlyTexture3D`1.Sample({typeof(float).FullName}, {typeof(float).FullName}, {typeof(float).FullName})"] = "float3",
[$"ComputeSharp.IReadOnlyTexture3D`1.Sample({typeof(Float3).FullName})"] = null,
[$"ComputeSharp.IReadOnlyNormalizedTexture3D`1.Sample({typeof(float).FullName}, {typeof(float).FullName}, {typeof(float).FullName})"] = "float3",
[$"ComputeSharp.IReadOnlyNormalizedTexture3D`1.Sample({typeof(Float3).FullName})"] = null
};
}
}
-20
ファイルの表示
@@ -32,26 +32,6 @@ partial class HlslKnownProperties
};
}
/// <inheritdoc/>
private static partial IReadOnlyDictionary<string, string?> BuildKnownResourceSamplers()
{
return new Dictionary<string, string?>
{
[$"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
};
}
/// <inheritdoc/>
private static partial IReadOnlyDictionary<string, (int Rank, int Axis)> BuildKnownSizeAccessors()
{