From f8e1cdd315f79ab8ed9f913397ac9374eca8a9c7 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 29 Nov 2022 21:55:18 +0100 Subject: [PATCH] Move number of properties to shared constant --- .../Shaders/Interop/D2D1PixelShaderEffect.cs | 6 +++--- .../Shaders/Interop/D2D1PixelShaderEffectProperty.cs | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs index 8d60b8fd..b0b63c86 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs @@ -151,7 +151,7 @@ public static unsafe class D2D1PixelShaderEffect fixed (char* pTransformMapperPropertyName = nameof(D2D1PixelShaderEffectProperty.TransformMapper)) { // Prepare the effect binding functions - D2D1_PROPERTY_BINDING* d2D1PropertyBinding = stackalloc D2D1_PROPERTY_BINDING[18]; + D2D1_PROPERTY_BINDING* d2D1PropertyBinding = stackalloc D2D1_PROPERTY_BINDING[(int)D2D1PixelShaderEffectProperty.NumberOfProperties]; // Property names d2D1PropertyBinding[0].propertyName = (ushort*)pBufferPropertyName; @@ -220,7 +220,7 @@ public static unsafe class D2D1PixelShaderEffect classId: pGuid, propertyXml: (ushort*)pXml, bindings: d2D1PropertyBinding, - bindingsCount: 18, + bindingsCount: D2D1PixelShaderEffectProperty.NumberOfProperties, effectFactory: PixelShaderEffect.For.Instance.Factory).Assert(); } @@ -372,7 +372,7 @@ public static unsafe class D2D1PixelShaderEffect writer.WriteRaw((byte)'\0'); // Bindings - writer.WriteRaw(18); + writer.WriteRaw(D2D1PixelShaderEffectProperty.NumberOfProperties); writer.WriteRaw("ConstantBuffer"u8); writer.WriteRaw((byte)'\0'); writer.WriteRaw((nint)PixelShaderEffect.GetConstantBuffer); diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffectProperty.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffectProperty.cs index 3b4b80ac..440b0951 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffectProperty.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffectProperty.cs @@ -122,4 +122,10 @@ public static class D2D1PixelShaderEffectProperty /// For more info, see . /// public const uint TransformMapper = 17; + + /// + /// The total number of properties. + /// + /// This should always be the value of the last property above, plus 1. + internal const uint NumberOfProperties = 18; } \ No newline at end of file