From ecb28e23826be0cf4467d6b52f3021771192631c Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 16 Aug 2022 13:55:38 +0200 Subject: [PATCH] Add missing validation when initializing managers --- .../Interop/Effects/PixelShaderEffect.Properties.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.cs index 78d6c48f..fb5c9f63 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.cs @@ -225,7 +225,17 @@ unsafe partial struct PixelShaderEffect // Initialize the resource texture manager, if an effect context is available if (this.d2D1EffectContext is not null) { - resourceTextureManagerInternal.Get()->Initialize(this.d2D1EffectContext, &dimensions); + result = resourceTextureManagerInternal.Get()->Initialize(this.d2D1EffectContext, &dimensions); + + // ID2D1ResourceTextureManager::Initialize should generally return either S_OK for first + // initialization, S_FALSE if an ID2D1EffectContext is already present (which is allowed, to + // enable sharing resource texture managers across different source textures and effects), or + // E_INVALIDARG if the manager has already been initialized through the public interface, + // and the stored dimensions for that don't match the ones for this resource texture index. + if (!Windows.SUCCEEDED(result)) + { + return result; + } } // Store the resource texture manager into the buffer