From c554f56bfa40a73e83f8d0a6ed22092d3930e40d Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 7 May 2022 17:09:30 +0200 Subject: [PATCH] Add ID2D1Shader and D2D1PixelShader output buffer APIs --- .../Interfaces/__Internals/ID2D1Shader.cs | 9 ++++++ .../Shaders/Interop/D2D1PixelShader.cs | 30 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/ComputeSharp.D2D1/Interfaces/__Internals/ID2D1Shader.cs b/src/ComputeSharp.D2D1/Interfaces/__Internals/ID2D1Shader.cs index b9d2593a..035d7b52 100644 --- a/src/ComputeSharp.D2D1/Interfaces/__Internals/ID2D1Shader.cs +++ b/src/ComputeSharp.D2D1/Interfaces/__Internals/ID2D1Shader.cs @@ -37,6 +37,15 @@ public interface ID2D1Shader [Obsolete("This method is not intended to be used directly by user code")] uint GetInputType(uint index); + /// + /// Gets the output buffer precision and depth for the shader. + /// + /// The output buffer precision. + /// The output buffer channel depth. + [EditorBrowsable(EditorBrowsableState.Never)] + [Obsolete("This method is not intended to be used directly by user code")] + void GetOutputBuffer(out uint precision, out uint depth); + /// /// Loads the dispatch data for the shader. /// diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShader.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShader.cs index 54b4a683..1082ba7a 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShader.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShader.cs @@ -113,6 +113,36 @@ public static class D2D1PixelShader return (D2D1PixelShaderInputType)shader.GetInputType((uint)index); } + /// + /// Gets the buffer precision for the output buffer of a D2D1 pixel shader. + /// + /// The type of D2D1 pixel shader to get the output buffer precision for. + /// The output buffer precision for the D2D1 pixel shader of type . + public static D2D1BufferPrecision GetOutputBufferPrecision() + where T : unmanaged, ID2D1PixelShader + { + Unsafe.SkipInit(out T shader); + + shader.GetOutputBuffer(out uint precision, out _); + + return (D2D1BufferPrecision)precision; + } + + /// + /// Gets the channel depth for the output buffer of a D2D1 pixel shader. + /// + /// The type of D2D1 pixel shader to get the output buffer channel depth for. + /// The output buffer channel depth for the D2D1 pixel shader of type . + public static D2D1ChannelDepth GetOutputBufferChannelDepth() + where T : unmanaged, ID2D1PixelShader + { + Unsafe.SkipInit(out T shader); + + shader.GetOutputBuffer(out _, out uint depth); + + return (D2D1ChannelDepth)depth; + } + /// /// Gets the constant buffer from an input D2D1 pixel shader. ///