diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.CreateFromConstantBuffer.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.CreateFromConstantBuffer.Syntax.cs index 14511432..00c2161f 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.CreateFromConstantBuffer.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.CreateFromConstantBuffer.Syntax.cs @@ -24,7 +24,7 @@ partial class D2DPixelShaderDescriptorGenerator writer.WriteLine("/// "); writer.WriteGeneratedAttributes(GeneratorName); writer.WriteLine("[global::System.Runtime.CompilerServices.SkipLocalsInit]"); - writer.WriteLine($"readonly unsafe {typeName} global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{typeName}>.CreateFromConstantBuffer(global::System.ReadOnlySpan data)"); + writer.WriteLine($"static unsafe {typeName} global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{typeName}>.CreateFromConstantBuffer(global::System.ReadOnlySpan data)"); using (writer.WriteBlock()) { diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.EffectId.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.EffectId.Syntax.cs index 7d4f8284..6c6c2fa8 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.EffectId.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.EffectId.Syntax.cs @@ -19,7 +19,7 @@ partial class D2DPixelShaderDescriptorGenerator { writer.WriteLine("/// "); writer.WriteGeneratedAttributes(GeneratorName); - writer.WriteLine($"readonly ref readonly global::System.Guid global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.EffectId"); + writer.WriteLine($"static ref readonly global::System.Guid global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.EffectId"); using (writer.WriteBlock()) { diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.EffectMetadata.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.EffectMetadata.Syntax.cs index 954b3166..83caf155 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.EffectMetadata.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.EffectMetadata.Syntax.cs @@ -61,7 +61,7 @@ partial class D2DPixelShaderDescriptorGenerator { writer.WriteLine("/// "); writer.WriteGeneratedAttributes(GeneratorName); - writer.Write($"readonly string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{qualifiedName}>.{propertyName} => "); + writer.Write($"static string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{qualifiedName}>.{propertyName} => "); // Append null or the metadata value as a string literal if (metadataValue is null) diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslBytecode.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslBytecode.Syntax.cs index 4dc54c8a..fe88365a 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslBytecode.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslBytecode.Syntax.cs @@ -22,7 +22,7 @@ partial class D2DPixelShaderDescriptorGenerator { writer.WriteLine("/// "); writer.WriteGeneratedAttributes(GeneratorName); - writer.WriteLine($"readonly ComputeSharp.D2D1.D2D1ShaderProfile global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ShaderProfile => global::ComputeSharp.D2D1.D2D1ShaderProfile.{info.HlslInfoKey.ShaderProfile};"); + writer.WriteLine($"static ComputeSharp.D2D1.D2D1ShaderProfile global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ShaderProfile => global::ComputeSharp.D2D1.D2D1ShaderProfile.{info.HlslInfoKey.ShaderProfile};"); } /// @@ -42,7 +42,7 @@ partial class D2DPixelShaderDescriptorGenerator writer.WriteLine("/// "); writer.WriteGeneratedAttributes(GeneratorName); - writer.WriteLine($"readonly ComputeSharp.D2D1.D2D1CompileOptions global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.CompileOptions => {compileOptionsExpression};"); + writer.WriteLine($"static ComputeSharp.D2D1.D2D1CompileOptions global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.CompileOptions => {compileOptionsExpression};"); } /// @@ -54,7 +54,7 @@ partial class D2DPixelShaderDescriptorGenerator { writer.WriteLine("/// "); writer.WriteGeneratedAttributes(GeneratorName); - writer.Write($"readonly global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.HlslBytecode => "); + writer.Write($"static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.HlslBytecode => "); // If there is no bytecode, just return a default expression. // Otherwise, return the memory manager backed memory instance. diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslSource.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslSource.Syntax.cs index b9650bea..9addce80 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslSource.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslSource.Syntax.cs @@ -19,7 +19,7 @@ partial class D2DPixelShaderDescriptorGenerator { writer.WriteLine("/// "); writer.WriteGeneratedAttributes(GeneratorName); - writer.WriteLine($"readonly string global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.HlslSource =>"); + writer.WriteLine($"static string global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.HlslSource =>"); writer.IncreaseIndent(); writer.WriteLine("\"\"\""); writer.Write(info.HlslInfoKey.HlslSource, isMultiline: true); diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.InputDescriptions.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.InputDescriptions.Syntax.cs index d1f19417..ce1f1096 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.InputDescriptions.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.InputDescriptions.Syntax.cs @@ -21,7 +21,7 @@ partial class D2DPixelShaderDescriptorGenerator { writer.WriteLine("/// "); writer.WriteGeneratedAttributes(GeneratorName); - writer.Write($"readonly global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.InputDescriptions => "); + writer.Write($"static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.InputDescriptions => "); // If there are no input descriptions, just return a default expression. // Otherwise, return the shared array with cached input descriptions. diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.InputTypes.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.InputTypes.Syntax.cs index f38586d1..0829cdc5 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.InputTypes.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.InputTypes.Syntax.cs @@ -19,7 +19,7 @@ partial class D2DPixelShaderDescriptorGenerator { writer.WriteLine("/// "); writer.WriteGeneratedAttributes(GeneratorName); - writer.Write($"readonly global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.InputTypes => "); + writer.Write($"static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.InputTypes => "); // If there are no inputs, simply return a default expression. Otherwise, create // a ReadOnlyMemory instance from the memory manager. diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.LoadConstantBuffer.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.LoadConstantBuffer.Syntax.cs index 42d8754b..4a7d6503 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.LoadConstantBuffer.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.LoadConstantBuffer.Syntax.cs @@ -24,7 +24,7 @@ partial class D2DPixelShaderDescriptorGenerator writer.WriteLine("/// "); writer.WriteGeneratedAttributes(GeneratorName); writer.WriteLine("[global::System.Runtime.CompilerServices.SkipLocalsInit]"); - writer.WriteLine($"readonly unsafe void global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{typeName}>.LoadConstantBuffer(in {typeName} shader, ref TLoader loader)"); + writer.WriteLine($"static unsafe void global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{typeName}>.LoadConstantBuffer(in {typeName} shader, ref TLoader loader)"); using (writer.WriteBlock()) { diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.NumericProperties.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.NumericProperties.Syntax.cs index 0efc43fd..332705c4 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.NumericProperties.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.NumericProperties.Syntax.cs @@ -21,7 +21,7 @@ partial class D2DPixelShaderDescriptorGenerator { writer.WriteLine("/// "); writer.WriteGeneratedAttributes(GeneratorName); - writer.WriteLine($"readonly int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ConstantBufferSize => {info.ConstantBufferSizeInBytes};"); + writer.WriteLine($"static int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ConstantBufferSize => {info.ConstantBufferSizeInBytes};"); } /// @@ -33,7 +33,7 @@ partial class D2DPixelShaderDescriptorGenerator { writer.WriteLine("/// "); writer.WriteGeneratedAttributes(GeneratorName); - writer.WriteLine($"readonly int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.InputCount => {info.InputTypes.Length};"); + writer.WriteLine($"static int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.InputCount => {info.InputTypes.Length};"); } /// @@ -45,7 +45,7 @@ partial class D2DPixelShaderDescriptorGenerator { writer.WriteLine("/// "); writer.WriteGeneratedAttributes(GeneratorName); - writer.WriteLine($"readonly int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ResourceTextureCount => {info.ResourceTextureDescriptions.Length};"); + writer.WriteLine($"static int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ResourceTextureCount => {info.ResourceTextureDescriptions.Length};"); } } } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.OutputBuffer.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.OutputBuffer.Syntax.cs index 3767bb78..5a860c53 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.OutputBuffer.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.OutputBuffer.Syntax.cs @@ -28,7 +28,7 @@ partial class D2DPixelShaderDescriptorGenerator writer.WriteLine("/// "); writer.WriteGeneratedAttributes(GeneratorName); - writer.WriteLine($"readonly ComputeSharp.D2D1.D2D1BufferPrecision global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.BufferPrecision => {bufferPrecisionExpression};"); + writer.WriteLine($"static ComputeSharp.D2D1.D2D1BufferPrecision global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.BufferPrecision => {bufferPrecisionExpression};"); } /// @@ -47,7 +47,7 @@ partial class D2DPixelShaderDescriptorGenerator writer.WriteLine("/// "); writer.WriteGeneratedAttributes(GeneratorName); - writer.WriteLine($"readonly ComputeSharp.D2D1.D2D1ChannelDepth global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ChannelDepth => {channelDepthExpression};"); + writer.WriteLine($"static ComputeSharp.D2D1.D2D1ChannelDepth global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ChannelDepth => {channelDepthExpression};"); } } } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.PixelOptions.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.PixelOptions.Syntax.cs index a469a342..6f0cf8b5 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.PixelOptions.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.PixelOptions.Syntax.cs @@ -26,7 +26,7 @@ partial class D2DPixelShaderDescriptorGenerator writer.WriteLine("/// "); writer.WriteGeneratedAttributes(GeneratorName); - writer.WriteLine($"readonly ComputeSharp.D2D1.D2D1PixelOptions global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.PixelOptions => {pixelOptionsExpression};"); + writer.WriteLine($"static ComputeSharp.D2D1.D2D1PixelOptions global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.PixelOptions => {pixelOptionsExpression};"); } } } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.ResourceTextureDescriptions.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.ResourceTextureDescriptions.Syntax.cs index d0bb8a8b..1ec6ee18 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.ResourceTextureDescriptions.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.ResourceTextureDescriptions.Syntax.cs @@ -21,7 +21,7 @@ partial class D2DPixelShaderDescriptorGenerator { writer.WriteLine("/// "); writer.WriteGeneratedAttributes(GeneratorName); - writer.Write($"readonly global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ResourceTextureDescriptions => "); + writer.Write($"static global::System.ReadOnlyMemory global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ResourceTextureDescriptions => "); // If there are no resource texture descriptions, just return a default expression. // Otherwise, return a memory instance from the generated static readonly array. diff --git a/src/ComputeSharp.D2D1.WinUI/Extensions/ID2D1EffectExtensions.cs b/src/ComputeSharp.D2D1.WinUI/Extensions/ID2D1EffectExtensions.cs index e7901037..28fa310d 100644 --- a/src/ComputeSharp.D2D1.WinUI/Extensions/ID2D1EffectExtensions.cs +++ b/src/ComputeSharp.D2D1.WinUI/Extensions/ID2D1EffectExtensions.cs @@ -25,7 +25,7 @@ internal static unsafe class ID2D1EffectExtensions public static T GetConstantBuffer(this ref ID2D1Effect d2D1Effect) where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - int constantBufferSize = D2D1PixelShader.GetConstantBufferSize(); + int constantBufferSize = T.ConstantBufferSize; // Special cases the constant buffer type being empty. If that's the case, there is no // need to try to retrieve the constant buffer from the underlying effect anyway, and @@ -67,7 +67,7 @@ internal static unsafe class ID2D1EffectExtensions // avoid crashing when someone's just setting an empty constant buffer, which is // unnecessary but still valid (eg. a stateless shader). This could be the case if // someone was eg. binding or using some other automated system to set constant buffer. - if (D2D1PixelShader.GetConstantBufferSize() == 0) + if (T.ConstantBufferSize == 0) { return; } diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs index b1ee3d9a..d1b23d9a 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs @@ -2,7 +2,6 @@ using System; using System.Runtime.CompilerServices; using ABI.Microsoft.Graphics.Canvas; using ComputeSharp.D2D1.Extensions; -using ComputeSharp.D2D1.Interop; using ComputeSharp.D2D1.WinUI.Extensions; using ComputeSharp.D2D1.WinUI.Helpers; using ComputeSharp.Win32; @@ -63,7 +62,7 @@ unsafe partial class PixelShaderEffect if (!this.isEffectFactoryRegistered) { ResourceManager.RegisterEffectFactory( - effectId: D2D1PixelShaderEffect.GetEffectId(), + effectId: T.EffectId, factory: new EffectFactory()); this.isEffectFactoryRegistered = true; diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasImageInterop.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasImageInterop.cs index df2a995a..0d729c98 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasImageInterop.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasImageInterop.cs @@ -250,7 +250,7 @@ unsafe partial class PixelShaderEffect { fixed (ID2D1Effect** d2D1Effect = this.d2D1Effect) { - Guid effectId = D2D1PixelShaderEffect.GetEffectId(); + Guid effectId = T.EffectId; using ComPtr d2D1DeviceContextEffective = default; using ComPtr d2D1DeviceContextLease = default; diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.ResourceTextureManagerCollection.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.ResourceTextureManagerCollection.cs index 3cd6822c..cfd1947b 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.ResourceTextureManagerCollection.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.ResourceTextureManagerCollection.cs @@ -223,11 +223,9 @@ partial class PixelShaderEffect /// The bitmask of indices for resource textures in the target shader. private static int GetIndexBitmask() { - Unsafe.SkipInit(out T shader); - int indexBitmask = 0; - foreach (ref readonly D2D1ResourceTextureDescription description in shader.ResourceTextureDescriptions.Span) + foreach (ref readonly D2D1ResourceTextureDescription description in T.ResourceTextureDescriptions.Span) { indexBitmask |= 1 << description.Index; } @@ -241,9 +239,7 @@ partial class PixelShaderEffect /// The collection of valid indices for the current effect. private static ImmutableArray GetIndices() { - Unsafe.SkipInit(out T shader); - - ReadOnlySpan descriptions = shader.ResourceTextureDescriptions.Span; + ReadOnlySpan descriptions = T.ResourceTextureDescriptions.Span; // Skip the array allocation if there are no resource texture descriptions if (descriptions.IsEmpty) diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.SourceCollection.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.SourceCollection.cs index 2b063129..688292de 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.SourceCollection.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.SourceCollection.cs @@ -3,7 +3,6 @@ using System.Collections; using System.Collections.Generic; using System.Collections.Immutable; using System.Runtime.CompilerServices; -using ComputeSharp.D2D1.Interop; using ComputeSharp.D2D1.WinUI.Buffers; using ComputeSharp.D2D1.WinUI.Collections; using Windows.Graphics.Effects; @@ -41,7 +40,7 @@ partial class PixelShaderEffect public int Count { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => D2D1PixelShader.GetInputCount(); + get => T.InputCount; } /// @@ -49,13 +48,13 @@ partial class PixelShaderEffect { get { - default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, D2D1PixelShader.GetInputCount(), nameof(index)); + default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, T.InputCount, nameof(index)); return Owner.GetSource(index); } set { - default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, D2D1PixelShader.GetInputCount(), nameof(index)); + default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, T.InputCount, nameof(index)); Owner.SetSource(value, index); } @@ -210,7 +209,7 @@ partial class PixelShaderEffect /// The collection of valid indices for the current effect. private static ImmutableArray GetIndices() { - int inputCount = D2D1PixelShader.GetInputCount(); + int inputCount = T.InputCount; if (inputCount == 0) { diff --git a/src/ComputeSharp.D2D1/Interfaces/Descriptors/ID2D1PixelShaderDescriptor{T}.cs b/src/ComputeSharp.D2D1/Interfaces/Descriptors/ID2D1PixelShaderDescriptor{T}.cs index ac06889c..fd010abc 100644 --- a/src/ComputeSharp.D2D1/Interfaces/Descriptors/ID2D1PixelShaderDescriptor{T}.cs +++ b/src/ComputeSharp.D2D1/Interfaces/Descriptors/ID2D1PixelShaderDescriptor{T}.cs @@ -18,7 +18,7 @@ public interface ID2D1PixelShaderDescriptor /// /// This only applies to effects created from . /// - ref readonly Guid EffectId { get; } + static abstract ref readonly Guid EffectId { get; } /// /// Gets the display name of the D2D effect using this shader, if specified. @@ -26,7 +26,7 @@ public interface ID2D1PixelShaderDescriptor /// /// This only applies to effects created from . /// - string? EffectDisplayName { get; } + static abstract string? EffectDisplayName { get; } /// /// Gets the description of the D2D effect using this shader, if specified. @@ -34,7 +34,7 @@ public interface ID2D1PixelShaderDescriptor /// /// This only applies to effects created from . /// - string? EffectDescription { get; } + static abstract string? EffectDescription { get; } /// /// Gets the category of the D2D effect using this shader, if specified. @@ -42,7 +42,7 @@ public interface ID2D1PixelShaderDescriptor /// /// This only applies to effects created from . /// - string? EffectCategory { get; } + static abstract string? EffectCategory { get; } /// /// Gets the author of the D2D effect using this shader, if specified. @@ -50,52 +50,52 @@ public interface ID2D1PixelShaderDescriptor /// /// This only applies to effects created from . /// - string? EffectAuthor { get; } + static abstract string? EffectAuthor { get; } /// /// Gets the size in bytes of the constant buffer for the current shader. /// - int ConstantBufferSize { get; } + static abstract int ConstantBufferSize { get; } /// /// Gets the number of inputs for the current shader. /// - int InputCount { get; } + static abstract int InputCount { get; } /// /// Gets the number of resource textures for the current shader. /// - int ResourceTextureCount { get; } + static abstract int ResourceTextureCount { get; } /// /// Gets the input types for the current shader. /// - ReadOnlyMemory InputTypes { get; } + static abstract ReadOnlyMemory InputTypes { get; } /// /// Gets the input descriptions for the current shader. /// - ReadOnlyMemory InputDescriptions { get; } + static abstract ReadOnlyMemory InputDescriptions { get; } /// /// Gets the resource texture descriptions for the shader. /// - ReadOnlyMemory ResourceTextureDescriptions { get; } + static abstract ReadOnlyMemory ResourceTextureDescriptions { get; } /// /// Gets the pixel options for the current shader. /// - D2D1PixelOptions PixelOptions { get; } + static abstract D2D1PixelOptions PixelOptions { get; } /// /// Gets the buffer precision for the shader. /// - D2D1BufferPrecision BufferPrecision { get; } + static abstract D2D1BufferPrecision BufferPrecision { get; } /// /// Gets the channel depth for the shader. /// - D2D1ChannelDepth ChannelDepth { get; } + static abstract D2D1ChannelDepth ChannelDepth { get; } /// /// Gets the shader profile for the current shader. @@ -103,7 +103,7 @@ public interface ID2D1PixelShaderDescriptor /// /// This shader profile is either explicitly set by users, or the default one for D2D1 shaders. /// - D2D1ShaderProfile ShaderProfile { get; } + static abstract D2D1ShaderProfile ShaderProfile { get; } /// /// Gets the compile options for the current shader. @@ -111,12 +111,12 @@ public interface ID2D1PixelShaderDescriptor /// /// This compile options are either explicitly set by users, or the default one for D2D1 shaders. /// - D2D1CompileOptions CompileOptions { get; } + static abstract D2D1CompileOptions CompileOptions { get; } /// /// Gets the HLSL source code for the current shader instance. /// - string HlslSource { get; } + static abstract string HlslSource { get; } /// /// Gets the HLSL bytecode for the current shader, if available. @@ -124,14 +124,14 @@ public interface ID2D1PixelShaderDescriptor /// /// If no precompiled HLSL bytecode is available, the returned instance will be empty. /// - ReadOnlyMemory HlslBytecode { get; } + static abstract ReadOnlyMemory HlslBytecode { get; } /// /// Creates a new shader instance from a constant buffer. /// /// The input constant buffer to read. /// The input buffer must be retrieved from . - T CreateFromConstantBuffer(ReadOnlySpan buffer); + static abstract T CreateFromConstantBuffer(ReadOnlySpan buffer); /// /// Loads the constant buffer of a given input shader. @@ -139,6 +139,6 @@ public interface ID2D1PixelShaderDescriptor /// The type of data loader being used. /// The input shader to load the constant buffer for. /// The instance to use to load the constant buffer. - void LoadConstantBuffer(in T shader, ref TLoader loader) + static abstract void LoadConstantBuffer(in T shader, ref TLoader loader) where TLoader : struct, ID2D1ConstantBufferLoader; } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1DrawInfoUpdateContext{T}.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1DrawInfoUpdateContext{T}.cs index a0064dae..58c5dda7 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1DrawInfoUpdateContext{T}.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1DrawInfoUpdateContext{T}.cs @@ -1,5 +1,4 @@ using System.Buffers; -using System.Runtime.CompilerServices; using ComputeSharp.D2D1.Descriptors; using ComputeSharp.D2D1.Extensions; using ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers; @@ -45,9 +44,7 @@ public readonly unsafe ref struct D2D1DrawInfoUpdateContext this.d2D1DrawInfoUpdateContext->GetConstantBuffer(pBuffer, constantBufferSize).Assert(); } - Unsafe.SkipInit(out T shader); - - shader = shader.CreateFromConstantBuffer(buffer); + T shader = T.CreateFromConstantBuffer(buffer); ArrayPool.Shared.Return(buffer); @@ -62,6 +59,6 @@ public readonly unsafe ref struct D2D1DrawInfoUpdateContext { D2D1DrawInfoUpdateContextConstantBufferLoader dataLoader = new(this.d2D1DrawInfoUpdateContext); - Unsafe.AsRef(in shader).LoadConstantBuffer(in shader, ref dataLoader); + T.LoadConstantBuffer(in shader, ref dataLoader); } } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShader.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShader.cs index f6e18354..b5d8b4c8 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShader.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShader.cs @@ -20,9 +20,7 @@ public static class D2D1PixelShader public static int GetConstantBufferSize() where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - - return shader.ConstantBufferSize; + return T.ConstantBufferSize; } /// @@ -33,9 +31,7 @@ public static class D2D1PixelShader public static int GetInputCount() where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - - return shader.InputCount; + return T.InputCount; } /// @@ -46,9 +42,7 @@ public static class D2D1PixelShader public static int GetResourceTextureCount() where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - - return shader.ResourceTextureCount; + return T.ResourceTextureCount; } /// @@ -59,9 +53,7 @@ public static class D2D1PixelShader public static ReadOnlyMemory GetInputTypes() where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - - return shader.InputTypes; + return T.InputTypes; } /// @@ -72,9 +64,7 @@ public static class D2D1PixelShader public static ReadOnlyMemory GetInputDescriptions() where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - - return shader.InputDescriptions; + return T.InputDescriptions; } /// @@ -85,9 +75,7 @@ public static class D2D1PixelShader public static ReadOnlyMemory GetResourceTextureDescriptions() where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - - return shader.ResourceTextureDescriptions; + return T.ResourceTextureDescriptions; } /// @@ -98,9 +86,7 @@ public static class D2D1PixelShader public static D2D1PixelOptions GetPixelOptions() where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - - return shader.PixelOptions; + return T.PixelOptions; } /// @@ -111,9 +97,7 @@ public static class D2D1PixelShader public static D2D1BufferPrecision GetOutputBufferPrecision() where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - - return shader.BufferPrecision; + return T.BufferPrecision; } /// @@ -124,9 +108,7 @@ public static class D2D1PixelShader public static D2D1ChannelDepth GetOutputBufferChannelDepth() where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - - return shader.ChannelDepth; + return T.ChannelDepth; } /// @@ -144,13 +126,11 @@ public static class D2D1PixelShader public static ReadOnlyMemory LoadBytecode() where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - // This method is the one used by the built-in ID2D1Effect, so it has special optimization // to help both performance and especially trimming. That is, we first check whether the // HLSL code is already available, which should get completely inlined when using the // generated code. This allows the entire fallback path below to be trimmed out. - if (shader.HlslBytecode is ReadOnlyMemory { Length: > 0 } hlslBytecode) + if (T.HlslBytecode is ReadOnlyMemory { Length: > 0 } hlslBytecode) { return hlslBytecode; } @@ -334,16 +314,12 @@ public static class D2D1PixelShader out D2D1CompileOptions effectiveCompileOptions) where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - - string hlslSource = shader.HlslSource; - // Set the effective profile and option to the requested ones or the default values - effectiveShaderProfile = requestedShaderProfile ?? shader.ShaderProfile; - effectiveCompileOptions = requestedCompileOptions ?? shader.CompileOptions; + effectiveShaderProfile = requestedShaderProfile ?? T.ShaderProfile; + effectiveCompileOptions = requestedCompileOptions ?? T.CompileOptions; // Compile the shader with the current settings - using ComPtr dynamicBytecode = D3DCompiler.Compile(hlslSource.AsSpan(), effectiveShaderProfile, effectiveCompileOptions); + using ComPtr dynamicBytecode = D3DCompiler.Compile(T.HlslSource, effectiveShaderProfile, effectiveCompileOptions); byte* bytecodePtr = (byte*)dynamicBytecode.Get()->GetBufferPointer(); int bytecodeSize = (int)dynamicBytecode.Get()->GetBufferSize(); @@ -367,15 +343,13 @@ public static class D2D1PixelShader out D2D1CompileOptions effectiveCompileOptions) where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - // Check whether there is precompiled bytecode we can use - if (shader.HlslBytecode is ReadOnlyMemory { Length: > 0 } hlslBytecode && - (requestedShaderProfile is null || shader.ShaderProfile == requestedShaderProfile.GetValueOrDefault()) && - (requestedCompileOptions is null || shader.CompileOptions == requestedCompileOptions.GetValueOrDefault())) + if (T.HlslBytecode is ReadOnlyMemory { Length: > 0 } hlslBytecode && + (requestedShaderProfile is null || T.ShaderProfile == requestedShaderProfile.GetValueOrDefault()) && + (requestedCompileOptions is null || T.CompileOptions == requestedCompileOptions.GetValueOrDefault())) { - effectiveShaderProfile = shader.ShaderProfile; - effectiveCompileOptions = shader.CompileOptions; + effectiveShaderProfile = T.ShaderProfile; + effectiveCompileOptions = T.CompileOptions; return hlslBytecode; } @@ -398,7 +372,7 @@ public static class D2D1PixelShader { D2D1ByteArrayConstantBufferLoader dataLoader = default; - Unsafe.AsRef(in shader).LoadConstantBuffer(in shader, ref dataLoader); + T.LoadConstantBuffer(in shader, ref dataLoader); return dataLoader.GetResultingDispatchData(); } @@ -437,7 +411,7 @@ public static class D2D1PixelShader { D2D1ByteBufferConstantBufferLoader dataLoader = new(buffer, span.Length); - Unsafe.AsRef(in shader).LoadConstantBuffer(in shader, ref dataLoader); + T.LoadConstantBuffer(in shader, ref dataLoader); return dataLoader.TryGetWrittenBytes(out bytesWritten); } @@ -458,7 +432,7 @@ public static class D2D1PixelShader D2D1DrawInfoConstantBufferLoader dataLoader = new((ID2D1DrawInfo*)d2D1DrawInfo); - Unsafe.AsRef(in shader).LoadConstantBuffer(in shader, ref dataLoader); + T.LoadConstantBuffer(in shader, ref dataLoader); } /// @@ -490,11 +464,9 @@ public static class D2D1PixelShader public static bool TryCreateFromConstantBuffer(ReadOnlySpan span, out T shader) where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out shader); - - if (span.Length >= shader.ConstantBufferSize) + if (span.Length >= T.ConstantBufferSize) { - shader = shader.CreateFromConstantBuffer(span); + shader = T.CreateFromConstantBuffer(span); return true; } diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs index 1edea605..efd78524 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs @@ -1,6 +1,5 @@ using System; using System.Buffers; -using System.Runtime.CompilerServices; using System.Text; using ComputeSharp.D2D1.Descriptors; using ComputeSharp.D2D1.Extensions; @@ -26,9 +25,7 @@ public static unsafe class D2D1PixelShaderEffect public static ref readonly Guid GetEffectId() where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - - return ref shader.EffectId; + return ref T.EffectId; } /// @@ -39,9 +36,7 @@ public static unsafe class D2D1PixelShaderEffect public static string? GetEffectDisplayName() where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - - return shader.EffectDisplayName; + return T.EffectDisplayName; } /// @@ -52,9 +47,7 @@ public static unsafe class D2D1PixelShaderEffect public static string? GetEffectDescription() where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - - return shader.EffectDescription; + return T.EffectDescription; } /// @@ -65,9 +58,7 @@ public static unsafe class D2D1PixelShaderEffect public static string? GetEffectCategory() where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - - return shader.EffectCategory; + return T.EffectCategory; } /// @@ -78,9 +69,7 @@ public static unsafe class D2D1PixelShaderEffect public static string? GetEffectAuthor() where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - - return shader.EffectAuthor; + return T.EffectAuthor; } /// @@ -194,7 +183,7 @@ public static unsafe class D2D1PixelShaderEffect classId: pGuid, propertyXml: (ushort*)pXml, bindings: d2D1PropertyBinding, - bindingsCount: (uint)(D2D1PixelShaderEffectProperty.NumberOfAlwaysAvailableProperties + D2D1PixelShader.GetResourceTextureCount()), + bindingsCount: (uint)(D2D1PixelShaderEffectProperty.NumberOfAlwaysAvailableProperties + T.ResourceTextureCount), effectFactory: PixelShaderEffect.Globals.Instance.Factory).Assert(); } @@ -249,8 +238,8 @@ public static unsafe class D2D1PixelShaderEffect writer.Write(D2D1EffectRegistrationData.V1.BlobId); // Effect id and number of inputs - writer.Write(GetEffectId()); - writer.Write(D2D1PixelShader.GetInputCount()); + writer.Write(T.EffectId); + writer.Write(T.InputCount); // Retrieve the effect XML and include it into the registration blob using (D2D1EffectXmlFactory.EffectXml effectXml = D2D1EffectXmlFactory.GetXmlBuffer()) @@ -272,7 +261,7 @@ public static unsafe class D2D1PixelShaderEffect } // Bindings - writer.Write(D2D1PixelShaderEffectProperty.NumberOfAlwaysAvailableProperties + D2D1PixelShader.GetResourceTextureCount()); + writer.Write(D2D1PixelShaderEffectProperty.NumberOfAlwaysAvailableProperties + T.ResourceTextureCount); writer.Write("ConstantBuffer"u8); writer.Write((byte)'\0'); writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetConstantBufferImpl); @@ -283,7 +272,7 @@ public static unsafe class D2D1PixelShaderEffect writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetTransformMapperImpl); // Add all resource texture manager property bindings - for (int i = 0; i < D2D1PixelShader.GetResourceTextureCount(); i++) + for (int i = 0; i < T.ResourceTextureCount; i++) { switch (i) { @@ -441,7 +430,7 @@ public static unsafe class D2D1PixelShaderEffect D2D1EffectConstantBufferLoader dataLoader = new((ID2D1Effect*)d2D1Effect); - Unsafe.AsRef(in shader).LoadConstantBuffer(in shader, ref dataLoader); + T.LoadConstantBuffer(in shader, ref dataLoader); } /// diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ReflectionServices.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ReflectionServices.cs index 29696e99..164b45f2 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ReflectionServices.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ReflectionServices.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.CompilerServices; using ComputeSharp.D2D1.Descriptors; using ComputeSharp.D2D1.Extensions; using ComputeSharp.Win32; @@ -27,8 +26,6 @@ public static class D2D1ReflectionServices public static unsafe D2D1ShaderInfo GetShaderInfo() where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { - Unsafe.SkipInit(out T shader); - ReadOnlyMemory hlslBytecode = D2D1PixelShader.LoadBytecode(); using ComPtr d3D11ShaderReflection = default; @@ -52,7 +49,7 @@ public static class D2D1ReflectionServices return new( CompilerVersion: new string(d3D11ShaderDescription.Creator), - HlslSource: shader.HlslSource, + HlslSource: T.HlslSource, HlslBytecode: hlslBytecode, ConstantBufferCount: d3D11ShaderDescription.ConstantBuffers, BoundResourceCount: d3D11ShaderDescription.BoundResources, diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Globals{T}.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Globals{T}.cs index 851056b1..008ca967 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Globals{T}.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Globals{T}.cs @@ -107,34 +107,34 @@ internal unsafe partial struct PixelShaderEffect public static Globals Instance { get; } = new(); /// - public override ref readonly Guid EffectId => ref D2D1PixelShaderEffect.GetEffectId(); + public override ref readonly Guid EffectId => ref T.EffectId; /// - public override int ConstantBufferSize => D2D1PixelShader.GetConstantBufferSize(); + public override int ConstantBufferSize => T.ConstantBufferSize; /// - public override int InputCount => D2D1PixelShader.GetInputCount(); + public override int InputCount => T.InputCount; /// - public override int ResourceTextureCount => D2D1PixelShader.GetResourceTextureCount(); + public override int ResourceTextureCount => T.ResourceTextureCount; /// - public override ReadOnlyMemory InputTypes => D2D1PixelShader.GetInputTypes(); + public override ReadOnlyMemory InputTypes => T.InputTypes; /// - public override ReadOnlyMemory InputDescriptions => D2D1PixelShader.GetInputDescriptions(); + public override ReadOnlyMemory InputDescriptions => T.InputDescriptions; /// - public override ReadOnlyMemory ResourceTextureDescriptions => D2D1PixelShader.GetResourceTextureDescriptions(); + public override ReadOnlyMemory ResourceTextureDescriptions => T.ResourceTextureDescriptions; /// - public override D2D1PixelOptions PixelOptions => D2D1PixelShader.GetPixelOptions(); + public override D2D1PixelOptions PixelOptions => T.PixelOptions; /// - public override D2D1BufferPrecision BufferPrecision => D2D1PixelShader.GetOutputBufferPrecision(); + public override D2D1BufferPrecision BufferPrecision => T.BufferPrecision; /// - public override D2D1ChannelDepth ChannelDepth => D2D1PixelShader.GetOutputBufferChannelDepth(); + public override D2D1ChannelDepth ChannelDepth => T.ChannelDepth; /// public override ReadOnlyMemory HlslBytecode diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/D2D1EffectXmlFactory.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/D2D1EffectXmlFactory.cs index 1e322f48..912c7553 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/D2D1EffectXmlFactory.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/D2D1EffectXmlFactory.cs @@ -26,12 +26,12 @@ internal static unsafe class D2D1EffectXmlFactory where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { // Compute all necessary values first, outside of the lock - string? displayName = D2D1PixelShaderEffect.GetEffectDisplayName(); - string? description = D2D1PixelShaderEffect.GetEffectDescription(); - string? category = D2D1PixelShaderEffect.GetEffectCategory(); - string? author = D2D1PixelShaderEffect.GetEffectAuthor(); - int inputCount = D2D1PixelShader.GetInputCount(); - int resourceTextureCount = D2D1PixelShader.GetResourceTextureCount(); + string? displayName = T.EffectDisplayName; + string? description = T.EffectDescription; + string? category = T.EffectCategory; + string? author = T.EffectAuthor; + int inputCount = T.InputCount; + int resourceTextureCount = T.ResourceTextureCount; StringBuilder builder = XmlBuilder;