diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs index e83187bb..cd73c442 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs @@ -104,8 +104,8 @@ public static unsafe class D2D1PixelShaderEffect {effectInputsBuilder} - - + + @@ -158,7 +158,7 @@ public static unsafe class D2D1PixelShaderEffect "; fixed (char* pXml = xml) - fixed (char* pBufferPropertyName = "Buffer") + fixed (char* pBufferPropertyName = "ConstantBuffer") fixed (char* pResourceTextureManager0PropertyName = "ResourceTextureManager0") fixed (char* pResourceTextureManager1PropertyName = "ResourceTextureManager1") fixed (char* pResourceTextureManager2PropertyName = "ResourceTextureManager2") @@ -360,8 +360,8 @@ public static unsafe class D2D1PixelShaderEffect // Write the last part of the XML (including the buffer property) writer.WriteAsUtf8(@" - - + + @@ -418,7 +418,7 @@ public static unsafe class D2D1PixelShaderEffect // Bindings writer.Write(17); - writer.WriteAsUtf8("Buffer"); + writer.WriteAsUtf8("ConstantBuffer"); writer.Write((byte)'\0'); writer.Write((nint)PixelShaderEffect.GetConstantBuffer); writer.Write((nint)PixelShaderEffect.SetConstantBuffer); diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1EffectRegistrationDataTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1EffectRegistrationDataTests.cs new file mode 100644 index 00000000..6e63f1a8 --- /dev/null +++ b/tests/ComputeSharp.D2D1.Tests/D2D1EffectRegistrationDataTests.cs @@ -0,0 +1,120 @@ +using System; +using ComputeSharp.D2D1.Interop; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace ComputeSharp.D2D1.Tests; + +[TestClass] +[TestCategory("D2D1EffectRegistrationData")] +public partial class D2D1EffectRegistrationDataTests +{ + [TestMethod] + public unsafe void EffectRegistrationData_Validate() + { + ReadOnlyMemory blob = D2D1PixelShaderEffect.GetRegistrationBlob(out Guid effectId); + D2D1EffectRegistrationData.V1 data = D2D1EffectRegistrationData.V1.Load(blob); + + Assert.AreEqual(effectId, data.ClassId); + Assert.AreEqual(2, data.NumberOfInputs); + Assert.IsTrue(data.EffectFactory is not null); + Assert.AreEqual(17, data.PropertyBindings.Length); + Assert.AreEqual(nameof(D2D1PixelShaderEffectProperty.ConstantBuffer), data.PropertyBindings.Span[0].PropertyName); + Assert.AreEqual(nameof(D2D1PixelShaderEffectProperty.ResourceTextureManager0), data.PropertyBindings.Span[1].PropertyName); + Assert.AreEqual(nameof(D2D1PixelShaderEffectProperty.ResourceTextureManager1), data.PropertyBindings.Span[2].PropertyName); + Assert.AreEqual(nameof(D2D1PixelShaderEffectProperty.ResourceTextureManager2), data.PropertyBindings.Span[3].PropertyName); + Assert.AreEqual(nameof(D2D1PixelShaderEffectProperty.ResourceTextureManager3), data.PropertyBindings.Span[4].PropertyName); + Assert.AreEqual(nameof(D2D1PixelShaderEffectProperty.ResourceTextureManager4), data.PropertyBindings.Span[5].PropertyName); + Assert.AreEqual(nameof(D2D1PixelShaderEffectProperty.ResourceTextureManager5), data.PropertyBindings.Span[6].PropertyName); + Assert.AreEqual(nameof(D2D1PixelShaderEffectProperty.ResourceTextureManager6), data.PropertyBindings.Span[7].PropertyName); + Assert.AreEqual(nameof(D2D1PixelShaderEffectProperty.ResourceTextureManager7), data.PropertyBindings.Span[8].PropertyName); + Assert.AreEqual(nameof(D2D1PixelShaderEffectProperty.ResourceTextureManager8), data.PropertyBindings.Span[9].PropertyName); + Assert.AreEqual(nameof(D2D1PixelShaderEffectProperty.ResourceTextureManager9), data.PropertyBindings.Span[10].PropertyName); + Assert.AreEqual(nameof(D2D1PixelShaderEffectProperty.ResourceTextureManager10), data.PropertyBindings.Span[11].PropertyName); + Assert.AreEqual(nameof(D2D1PixelShaderEffectProperty.ResourceTextureManager11), data.PropertyBindings.Span[12].PropertyName); + Assert.AreEqual(nameof(D2D1PixelShaderEffectProperty.ResourceTextureManager12), data.PropertyBindings.Span[13].PropertyName); + Assert.AreEqual(nameof(D2D1PixelShaderEffectProperty.ResourceTextureManager13), data.PropertyBindings.Span[14].PropertyName); + Assert.AreEqual(nameof(D2D1PixelShaderEffectProperty.ResourceTextureManager14), data.PropertyBindings.Span[15].PropertyName); + Assert.AreEqual(nameof(D2D1PixelShaderEffectProperty.ResourceTextureManager15), data.PropertyBindings.Span[16].PropertyName); + + foreach (ref readonly D2D1PropertyBinding propertyBinding in data.PropertyBindings.Span) + { + Assert.IsTrue(propertyBinding.SetFunction is not null); + Assert.IsTrue(propertyBinding.GetFunction is not null); + } + + Assert.AreEqual(@" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +", data.PropertyXml); + } + + [D2DInputCount(2)] + [D2DRequiresScenePosition] + [AutoConstructor] + private partial struct TestRegistrationBlobShader : ID2D1PixelShader + { + private float a; + + public float4 Execute() + { + return a; + } + } +} \ No newline at end of file