From 1738f36455d6b03e618d71018896e64863cb6afa Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 18 Aug 2022 12:13:41 +0200 Subject: [PATCH] Rename [D2DEmbeddedBytecode] to [D2DShaderProfile] --- .../ComputeSharp.D2D1.SourceGenerators.csproj | 2 +- .../D2DPixelShaderSourceGenerator.Execute.cs | 4 ++-- ...D2D1ShaderGenerator.CreateLoadBytecodeMethod.cs | 4 ++-- .../Attributes/D2DCompileOptionsAttribute.cs | 2 +- .../Attributes/D2DPixelShaderSourceAttribute.cs | 2 +- ...deAttribute.cs => D2DShaderProfileAttribute.cs} | 14 +++++++------- .../Attributes/Enums/D2D1CompileOptions.cs | 2 +- .../Attributes/Enums/D2D1ShaderProfile.cs | 2 +- .../Shaders/Interop/D2D1ReflectionServices.cs | 2 +- .../D2D1PixelShaderTests.cs | 4 ++-- .../Properties/AssemblyInfo.cs | 2 +- .../D2D1PixelShaderTests.cs | 6 +++--- .../D2DPixelShaderSourceTests.cs | 2 +- .../Effects/CheckerboardClipEffect.cs | 2 +- .../Effects/InvertEffect.cs | 2 +- .../Effects/InvertWithThresholdEffect.cs | 2 +- .../Effects/PixelateEffect.cs | 2 +- .../Effects/ZonePlateEffect.cs | 2 +- 18 files changed, 29 insertions(+), 29 deletions(-) rename src/ComputeSharp.D2D1/Attributes/{D2DEmbeddedBytecodeAttribute.cs => D2DShaderProfileAttribute.cs} (68%) diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj b/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj index 6b89f4f1..2af1c50f 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj +++ b/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj @@ -72,7 +72,7 @@ - + diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.cs index 72624b15..decf1272 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.cs @@ -82,12 +82,12 @@ partial class D2DPixelShaderSourceGenerator /// The shader profile to use to compile the shader, if present. public static D2D1ShaderProfile GetShaderProfile(ImmutableArray.Builder diagnostics, IMethodSymbol methodSymbol) { - if (methodSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DEmbeddedBytecodeAttribute", out AttributeData? attributeData)) + if (methodSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DShaderProfileAttribute", out AttributeData? attributeData)) { return (D2D1ShaderProfile)attributeData!.ConstructorArguments[0].Value!; } - if (methodSymbol.ContainingAssembly.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DEmbeddedBytecodeAttribute", out attributeData)) + if (methodSymbol.ContainingAssembly.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DShaderProfileAttribute", out attributeData)) { return (D2D1ShaderProfile)attributeData!.ConstructorArguments[0].Value!; } diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.cs index 61313333..a8dd4db6 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.cs @@ -32,12 +32,12 @@ partial class ID2D1ShaderGenerator /// The shader profile to use to compile the shader, if present. public static D2D1ShaderProfile? GetShaderProfile(INamedTypeSymbol structDeclarationSymbol) { - if (structDeclarationSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DEmbeddedBytecodeAttribute", out AttributeData? attributeData)) + if (structDeclarationSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DShaderProfileAttribute", out AttributeData? attributeData)) { return (D2D1ShaderProfile)attributeData!.ConstructorArguments[0].Value!; } - if (structDeclarationSymbol.ContainingAssembly.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DEmbeddedBytecodeAttribute", out attributeData)) + if (structDeclarationSymbol.ContainingAssembly.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DShaderProfileAttribute", out attributeData)) { return (D2D1ShaderProfile)attributeData!.ConstructorArguments[0].Value!; } diff --git a/src/ComputeSharp.D2D1/Attributes/D2DCompileOptionsAttribute.cs b/src/ComputeSharp.D2D1/Attributes/D2DCompileOptionsAttribute.cs index 8f02de62..ba474e40 100644 --- a/src/ComputeSharp.D2D1/Attributes/D2DCompileOptionsAttribute.cs +++ b/src/ComputeSharp.D2D1/Attributes/D2DCompileOptionsAttribute.cs @@ -4,7 +4,7 @@ namespace ComputeSharp.D2D1; /// /// An attribute that indicates the compile options that should be used when compiling a given D2D1 shader. -/// This applies when the shader is precompiled (through ) as well. +/// This applies when the shader is precompiled (through ) as well. /// /// This attribute can be used to annotate shader types as follows: /// diff --git a/src/ComputeSharp.D2D1/Attributes/D2DPixelShaderSourceAttribute.cs b/src/ComputeSharp.D2D1/Attributes/D2DPixelShaderSourceAttribute.cs index f6c69899..00e23ace 100644 --- a/src/ComputeSharp.D2D1/Attributes/D2DPixelShaderSourceAttribute.cs +++ b/src/ComputeSharp.D2D1/Attributes/D2DPixelShaderSourceAttribute.cs @@ -28,7 +28,7 @@ namespace ComputeSharp.D2D1; /// /// /// -/// Methods can also be annotated with and +/// Methods can also be annotated with and /// to further customize the shader profile to use when compiling the HLSL source, and the compile options to use. /// /// diff --git a/src/ComputeSharp.D2D1/Attributes/D2DEmbeddedBytecodeAttribute.cs b/src/ComputeSharp.D2D1/Attributes/D2DShaderProfileAttribute.cs similarity index 68% rename from src/ComputeSharp.D2D1/Attributes/D2DEmbeddedBytecodeAttribute.cs rename to src/ComputeSharp.D2D1/Attributes/D2DShaderProfileAttribute.cs index aad92ca2..15ca30f8 100644 --- a/src/ComputeSharp.D2D1/Attributes/D2DEmbeddedBytecodeAttribute.cs +++ b/src/ComputeSharp.D2D1/Attributes/D2DShaderProfileAttribute.cs @@ -3,12 +3,12 @@ namespace ComputeSharp.D2D1; /// -/// An attribute that indicates that a given D2D1 shader should be precompiled at build time and embedded -/// directly into the containing assembly as static bytecode, to avoid compiling it at runtime. +/// An attribute that indicates that a given D2D1 shader should be precompiled at build time using a specific shader +/// profile and embedded directly into the containing assembly as static bytecode, to avoid compiling it at runtime. /// /// This attribute can be used to annotate shader types as follows: /// -/// [D2DEmbeddedBytecode(D2D1ShaderProfile.PixelShader50)] +/// [D2DShaderProfile(D2D1ShaderProfile.PixelShader50)] /// struct MyShader : ID2D1PixelShader /// { /// } @@ -25,19 +25,19 @@ namespace ComputeSharp.D2D1; /// /// [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Assembly | AttributeTargets.Method, AllowMultiple = false)] -public sealed class D2DEmbeddedBytecodeAttribute : Attribute +public sealed class D2DShaderProfileAttribute : Attribute { /// - /// Creates a new instance with the specified parameters. + /// Creates a new instance with the specified parameters. /// /// The target shader profile to use to compile the shader. - public D2DEmbeddedBytecodeAttribute(D2D1ShaderProfile shaderProfile) + public D2DShaderProfileAttribute(D2D1ShaderProfile shaderProfile) { ShaderProfile = shaderProfile; } /// - /// Gets the number of threads in each thread group for the X axis + /// The shader profile used to compile the annotated D2D1 pixel shader. /// public D2D1ShaderProfile ShaderProfile { get; } } diff --git a/src/ComputeSharp.D2D1/Attributes/Enums/D2D1CompileOptions.cs b/src/ComputeSharp.D2D1/Attributes/Enums/D2D1CompileOptions.cs index a0209386..5727953a 100644 --- a/src/ComputeSharp.D2D1/Attributes/Enums/D2D1CompileOptions.cs +++ b/src/ComputeSharp.D2D1/Attributes/Enums/D2D1CompileOptions.cs @@ -163,7 +163,7 @@ public enum D2D1CompileOptions /// /// The default options for shaders compiled by ComputeSharp.D2D1. Specifically, this combination - /// of options is the one used by precompiled shaders (ie. when using ), + /// of options is the one used by precompiled shaders (ie. when using ), /// and when using or any of the overloads. /// /// diff --git a/src/ComputeSharp.D2D1/Attributes/Enums/D2D1ShaderProfile.cs b/src/ComputeSharp.D2D1/Attributes/Enums/D2D1ShaderProfile.cs index 2580c5d2..e68a8aad 100644 --- a/src/ComputeSharp.D2D1/Attributes/Enums/D2D1ShaderProfile.cs +++ b/src/ComputeSharp.D2D1/Attributes/Enums/D2D1ShaderProfile.cs @@ -1,7 +1,7 @@ namespace ComputeSharp.D2D1; /// -/// A to be used with to indicate the shader profile to use to precompile a shader. +/// A to be used with to indicate the shader profile to use to precompile a shader. /// public enum D2D1ShaderProfile { diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ReflectionServices.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ReflectionServices.cs index 16aa8a6a..5acc5ac7 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ReflectionServices.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ReflectionServices.cs @@ -21,7 +21,7 @@ public static class D2D1ReflectionServices /// The type of D2D1 shader to retrieve info for. /// The resulting instance. /// - /// If the target shader type is precompiled (ie. it's annotated with ), that bytecode will + /// If the target shader type is precompiled (ie. it's annotated with ), that bytecode will /// be reused to reflect on the shader, so the same shader profile and compile options will be reused, which can make the returned metadata more accurate. /// /// If the shader is not precompiled, it will be compiled on the fly using the default settings for both the shader profile and the compile options. That is, diff --git a/tests/ComputeSharp.D2D1.Tests.AssemblyLevelAttributes/D2D1PixelShaderTests.cs b/tests/ComputeSharp.D2D1.Tests.AssemblyLevelAttributes/D2D1PixelShaderTests.cs index 62e052f6..481ff5d3 100644 --- a/tests/ComputeSharp.D2D1.Tests.AssemblyLevelAttributes/D2D1PixelShaderTests.cs +++ b/tests/ComputeSharp.D2D1.Tests.AssemblyLevelAttributes/D2D1PixelShaderTests.cs @@ -65,7 +65,7 @@ public partial class D2D1PixelShaderTests [D2DInputSimple(0)] [D2DInputSimple(1)] [D2DInputSimple(2)] - [D2DEmbeddedBytecode(D2D1ShaderProfile.PixelShader50)] + [D2DShaderProfile(D2D1ShaderProfile.PixelShader50)] private readonly partial struct ShaderWithOverriddenProfile : ID2D1PixelShader { public float4 Execute() @@ -133,7 +133,7 @@ public partial class D2D1PixelShaderTests [D2DInputSimple(0)] [D2DInputSimple(1)] [D2DInputSimple(2)] - [D2DEmbeddedBytecode(D2D1ShaderProfile.PixelShader50)] + [D2DShaderProfile(D2D1ShaderProfile.PixelShader50)] [D2DCompileOptions(D2D1CompileOptions.Debug | D2D1CompileOptions.AvoidFlowControl | D2D1CompileOptions.PartialPrecision)] private readonly partial struct ShaderWithOverriddenProfileAndOptions : ID2D1PixelShader { diff --git a/tests/ComputeSharp.D2D1.Tests.AssemblyLevelAttributes/Properties/AssemblyInfo.cs b/tests/ComputeSharp.D2D1.Tests.AssemblyLevelAttributes/Properties/AssemblyInfo.cs index 654a9470..24c73837 100644 --- a/tests/ComputeSharp.D2D1.Tests.AssemblyLevelAttributes/Properties/AssemblyInfo.cs +++ b/tests/ComputeSharp.D2D1.Tests.AssemblyLevelAttributes/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ using ComputeSharp.D2D1; -[assembly: D2DEmbeddedBytecode(D2D1ShaderProfile.PixelShader41)] +[assembly: D2DShaderProfile(D2D1ShaderProfile.PixelShader41)] [assembly: D2DCompileOptions(D2D1CompileOptions.IeeeStrictness | D2D1CompileOptions.OptimizationLevel2 | D2D1CompileOptions.PartialPrecision)] \ No newline at end of file diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs index a0375100..27fea62a 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs @@ -212,7 +212,7 @@ public partial class D2D1PixelShaderTests [D2DInputSimple(2)] [D2DInputComplex(1)] [D2DInputComplex(3)] - [D2DEmbeddedBytecode(D2D1ShaderProfile.PixelShader50)] + [D2DShaderProfile(D2D1ShaderProfile.PixelShader50)] [AutoConstructor] partial struct ShaderWithResourceTextures : ID2D1PixelShader { @@ -291,7 +291,7 @@ public partial class D2D1PixelShaderTests [D2DInputSimple(0)] [D2DInputSimple(1)] [D2DInputSimple(2)] - [D2DEmbeddedBytecode(D2D1ShaderProfile.PixelShader40Level91)] + [D2DShaderProfile(D2D1ShaderProfile.PixelShader40Level91)] private readonly partial struct ShaderWithEmbeddedBytecode : ID2D1PixelShader { public float4 Execute() @@ -337,7 +337,7 @@ public partial class D2D1PixelShaderTests [D2DInputSimple(0)] [D2DInputSimple(1)] [D2DInputSimple(2)] - [D2DEmbeddedBytecode(D2D1ShaderProfile.PixelShader40Level91)] + [D2DShaderProfile(D2D1ShaderProfile.PixelShader40Level91)] [D2DCompileOptions(D2D1CompileOptions.IeeeStrictness | D2D1CompileOptions.OptimizationLevel2)] private readonly partial struct ShaderWithEmbeddedBytecodeAndCompileOptions : ID2D1PixelShader { diff --git a/tests/ComputeSharp.D2D1.Tests/D2DPixelShaderSourceTests.cs b/tests/ComputeSharp.D2D1.Tests/D2DPixelShaderSourceTests.cs index 29852df5..3c891a8d 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2DPixelShaderSourceTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2DPixelShaderSourceTests.cs @@ -20,7 +20,7 @@ public partial class D2DPixelShaderSourceTests return float4(rgb, 1); } ")] - [D2DEmbeddedBytecode(D2D1ShaderProfile.PixelShader50)] + [D2DShaderProfile(D2D1ShaderProfile.PixelShader50)] [D2DCompileOptions(D2D1CompileOptions.OptimizationLevel0)] private static partial ReadOnlySpan InvertEffect(); diff --git a/tests/ComputeSharp.D2D1.Tests/Effects/CheckerboardClipEffect.cs b/tests/ComputeSharp.D2D1.Tests/Effects/CheckerboardClipEffect.cs index 028f59b6..b7a02601 100644 --- a/tests/ComputeSharp.D2D1.Tests/Effects/CheckerboardClipEffect.cs +++ b/tests/ComputeSharp.D2D1.Tests/Effects/CheckerboardClipEffect.cs @@ -3,7 +3,7 @@ [D2DInputCount(1)] [D2DInputSimple(0)] [D2DRequiresScenePosition] -[D2DEmbeddedBytecode(D2D1ShaderProfile.PixelShader50)] +[D2DShaderProfile(D2D1ShaderProfile.PixelShader50)] [AutoConstructor] public partial struct CheckerboardClipEffect : ID2D1PixelShader { diff --git a/tests/ComputeSharp.D2D1.Tests/Effects/InvertEffect.cs b/tests/ComputeSharp.D2D1.Tests/Effects/InvertEffect.cs index 277fcd82..dbf1dccf 100644 --- a/tests/ComputeSharp.D2D1.Tests/Effects/InvertEffect.cs +++ b/tests/ComputeSharp.D2D1.Tests/Effects/InvertEffect.cs @@ -2,7 +2,7 @@ [D2DInputCount(1)] [D2DInputSimple(0)] -[D2DEmbeddedBytecode(D2D1ShaderProfile.PixelShader50)] +[D2DShaderProfile(D2D1ShaderProfile.PixelShader50)] public partial struct InvertEffect : ID2D1PixelShader { /// diff --git a/tests/ComputeSharp.D2D1.Tests/Effects/InvertWithThresholdEffect.cs b/tests/ComputeSharp.D2D1.Tests/Effects/InvertWithThresholdEffect.cs index 6d98d350..6d0d9698 100644 --- a/tests/ComputeSharp.D2D1.Tests/Effects/InvertWithThresholdEffect.cs +++ b/tests/ComputeSharp.D2D1.Tests/Effects/InvertWithThresholdEffect.cs @@ -2,7 +2,7 @@ [D2DInputCount(1)] [D2DInputSimple(0)] -[D2DEmbeddedBytecode(D2D1ShaderProfile.PixelShader50)] +[D2DShaderProfile(D2D1ShaderProfile.PixelShader50)] [AutoConstructor] public partial struct InvertWithThresholdEffect : ID2D1PixelShader { diff --git a/tests/ComputeSharp.D2D1.Tests/Effects/PixelateEffect.cs b/tests/ComputeSharp.D2D1.Tests/Effects/PixelateEffect.cs index 898df187..84aa3544 100644 --- a/tests/ComputeSharp.D2D1.Tests/Effects/PixelateEffect.cs +++ b/tests/ComputeSharp.D2D1.Tests/Effects/PixelateEffect.cs @@ -27,7 +27,7 @@ public sealed partial class PixelateEffect : ID2D1TransformMapper