diff --git a/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs b/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs index c2df970b..810cb67d 100644 --- a/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs +++ b/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs @@ -303,6 +303,8 @@ public sealed partial class BokehBlurEffect using ComPtr gammaExposureEffect = default; using ComPtr inverseGammaExposureEffect = default; using ComPtr compositeEffect = default; + using ComPtr borderEffect = default; + Span> verticalConvolutionEffectsForReals = stackalloc ComPtr[numberOfComponents]; Span> verticalConvolutionEffectsForImaginaries = stackalloc ComPtr[numberOfComponents]; Span> horizontalConvolutionEffects = stackalloc ComPtr[numberOfComponents]; @@ -320,6 +322,17 @@ public sealed partial class BokehBlurEffect D2D1PixelShaderEffect.CreateFromD2D1DeviceContext(d2D1DeviceContext.Get(), (void**)horizontalConvolutionEffects[i].GetAddressOf()); } + // Create the border effect to clamp the input image + d2D1DeviceContext.Get()->CreateEffect( + effectId: (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in CLSID.CLSID_D2D1Border)), + effect: borderEffect.GetAddressOf()).Assert(); + + D2D1_BORDER_EDGE_MODE d2D1BorderEdgeMode = D2D1_BORDER_EDGE_MODE.D2D1_BORDER_EDGE_MODE_CLAMP; + + // Set the border mode to clamp on both axes + borderEffect.Get()->SetValue((uint)D2D1_BORDER_PROP.D2D1_BORDER_PROP_EDGE_MODE_X, (byte*)&d2D1BorderEdgeMode, sizeof(D2D1_BORDER_EDGE_MODE)).Assert(); + borderEffect.Get()->SetValue((uint)D2D1_BORDER_PROP.D2D1_BORDER_PROP_EDGE_MODE_Y, (byte*)&d2D1BorderEdgeMode, sizeof(D2D1_BORDER_EDGE_MODE)).Assert(); + // If partials need to be summed, also create the composite effect if (numberOfComponents > 1) { @@ -391,13 +404,15 @@ public sealed partial class BokehBlurEffect // Build the effect graph: // - // [INPUT] ---> [GAMMA EXPOSURE] ---> [VERTICAL REAL] ------ - // \ \ - // -----------> [VERTICAL IMAGINARY] ----> [HORIZONTAL] ---> [INVERSE GAMMA EXPOSURE] ---> [OUTPUT] + // [INPUT] ---> [BORDER] --> [GAMMA EXPOSURE] ---> [VERTICAL REAL] ---- + // \ \ + // -----> [VERTICAL IMAGINARY] ----> [HORIZONTAL] ---> [INVERSE GAMMA EXPOSURE] ---> [OUTPUT] + borderEffect.Get()->SetInputEffect(0, gammaExposureEffect.Get()); + for (int i = 0; i < numberOfComponents; i++) { - verticalConvolutionEffectsForReals[i].Get()->SetInputEffect(0, gammaExposureEffect.Get()); - verticalConvolutionEffectsForImaginaries[i].Get()->SetInputEffect(0, gammaExposureEffect.Get()); + verticalConvolutionEffectsForReals[i].Get()->SetInputEffect(0, borderEffect.Get()); + verticalConvolutionEffectsForImaginaries[i].Get()->SetInputEffect(0, borderEffect.Get()); horizontalConvolutionEffects[i].Get()->SetInputEffect(0, verticalConvolutionEffectsForReals[i].Get()); horizontalConvolutionEffects[i].Get()->SetInputEffect(1, verticalConvolutionEffectsForImaginaries[i].Get()); }