From 6dcb61ceb93a98c7ea459e2fedaf0e01755727f1 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 5 Jun 2022 12:48:09 +0200 Subject: [PATCH] Fix incorrect memory allocations in PixelShaderEffect --- .../Shaders/Interop/Effects/PixelShaderEffect.For{T}.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.For{T}.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.For{T}.cs index 26d86426..5098a14e 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.For{T}.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.For{T}.cs @@ -128,7 +128,7 @@ internal unsafe partial struct PixelShaderEffect // Prepare the inputs info int inputCount = D2D1PixelShader.GetInputCount(); - D2D1PixelShaderInputType* inputTypes = (D2D1PixelShaderInputType*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For), inputCount); + D2D1PixelShaderInputType* inputTypes = (D2D1PixelShaderInputType*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For), sizeof(D2D1PixelShaderInputType) * inputCount); for (int i = 0; i < inputCount; i++) { @@ -138,7 +138,7 @@ internal unsafe partial struct PixelShaderEffect // Prepare the input descriptions ReadOnlyMemory inputDescriptionsInfo = D2D1PixelShader.GetInputDescriptions(); int inputDescriptionCount = inputDescriptionsInfo.Length; - D2D1InputDescription* inputDescriptions = (D2D1InputDescription*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For), inputDescriptionCount); + D2D1InputDescription* inputDescriptions = (D2D1InputDescription*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For), sizeof(D2D1InputDescription) * inputDescriptionCount); inputDescriptionsInfo.Span.CopyTo(new Span(inputDescriptions, inputDescriptionCount));