diff --git a/src/ComputeSharp.D2D1Interop/Interfaces/ID2D1PixelShader.cs b/src/ComputeSharp.D2D1Interop/Interfaces/ID2D1PixelShader.cs new file mode 100644 index 00000000..eba1c46b --- /dev/null +++ b/src/ComputeSharp.D2D1Interop/Interfaces/ID2D1PixelShader.cs @@ -0,0 +1,18 @@ +using ComputeSharp.D2D1Interop.__Internals; + +#pragma warning disable CS0618 + +namespace ComputeSharp.D2D1Interop; + +/// +/// An representing a pixel shader. +/// +public interface IPixelShader : ID2D1Shader + where TPixel : unmanaged +{ + /// + /// Executes the current pixel shader. + /// + /// The pixel value for the current invocation. + TPixel Execute(); +} \ No newline at end of file diff --git a/src/ComputeSharp.D2D1Interop/Interfaces/__Internals/ID2D1BytecodeLoader.cs b/src/ComputeSharp.D2D1Interop/Interfaces/__Internals/ID2D1BytecodeLoader.cs new file mode 100644 index 00000000..ad75568d --- /dev/null +++ b/src/ComputeSharp.D2D1Interop/Interfaces/__Internals/ID2D1BytecodeLoader.cs @@ -0,0 +1,26 @@ +using System; +using System.ComponentModel; + +namespace ComputeSharp.__Internals; + +/// +/// A base representing a bytecode loader for a D2D1 shader. +/// +[EditorBrowsable(EditorBrowsableState.Never)] +[Obsolete("This interface is not intended to be used directly by user code")] +public interface ID2D1BytecodeLoader +{ + /// + /// Loads a dynamic shader bytecode. + /// + /// An opaque handle to the shader bytecode. + /// Thrown if the shader has already been initialized. + void LoadDynamicBytecode(IntPtr handle); + + /// + /// Loads the embedded shader bytecode for the shader. + /// + /// The shader bytecode. + /// Thrown if the shader has already been initialized. + void LoadEmbeddedBytecode(ReadOnlySpan bytecode); +} diff --git a/src/ComputeSharp.D2D1Interop/Interfaces/__Internals/ID2D1DispatchDataLoader.cs b/src/ComputeSharp.D2D1Interop/Interfaces/__Internals/ID2D1DispatchDataLoader.cs new file mode 100644 index 00000000..22e4c8c6 --- /dev/null +++ b/src/ComputeSharp.D2D1Interop/Interfaces/__Internals/ID2D1DispatchDataLoader.cs @@ -0,0 +1,18 @@ +using System; +using System.ComponentModel; + +namespace ComputeSharp.__Internals; + +/// +/// A base representing a data loader for a D2D1 shader being dispatched. +/// +[EditorBrowsable(EditorBrowsableState.Never)] +[Obsolete("This interface is not intended to be used directly by user code")] +public interface ID2D1DispatchDataLoader +{ + /// + /// Loads the captured values used by the D2D1 shader to be dispatched. + /// + /// The sequence of serialized captured values. + void LoadConstantBuffer(ReadOnlySpan data); +} diff --git a/src/ComputeSharp.D2D1Interop/Interfaces/__Internals/ID2D1Shader.cs b/src/ComputeSharp.D2D1Interop/Interfaces/__Internals/ID2D1Shader.cs new file mode 100644 index 00000000..13cbc13f --- /dev/null +++ b/src/ComputeSharp.D2D1Interop/Interfaces/__Internals/ID2D1Shader.cs @@ -0,0 +1,49 @@ +using System; +using System.ComponentModel; +using ComputeSharp.__Internals; + +namespace ComputeSharp.D2D1Interop.__Internals; + +/// +/// A base representing a given shader that can be dispatched. +/// +[EditorBrowsable(EditorBrowsableState.Never)] +[Obsolete("This interface is not intended to be used directly by user code")] +public interface ID2D1Shader +{ + /// + /// Gets a unique dispatch identifier for the shader. + /// + /// The unique dispatch identifier for the shader. + [EditorBrowsable(EditorBrowsableState.Never)] + [Obsolete("This method is not intended to be used directly by user code")] + int GetDispatchId(); + + /// + /// Loads the dispatch data for the shader. + /// + /// The type of data loader being used. + /// The instance to use to load the data. + [EditorBrowsable(EditorBrowsableState.Never)] + [Obsolete("This method is not intended to be called directly by user code")] + void LoadDispatchData(ref TLoader loader) + where TLoader : struct, ID2D1DispatchDataLoader; + + /// + /// Builds the HLSL source code for the current shader instance. + /// + /// The resulting instance containing the HLSL source. + [EditorBrowsable(EditorBrowsableState.Never)] + [Obsolete("This method is not intended to be called directly by user code")] + void BuildHlslString(out ArrayPoolStringBuilder builder); + + /// + /// Loads the bytecode for the current shader. + /// + /// The type of bytecode loader being used. + /// The instance to use to load the bytecode. + [EditorBrowsable(EditorBrowsableState.Never)] + [Obsolete("This method is not intended to be used directly by user code")] + void LoadBytecode(ref TLoader loader) + where TLoader : struct, ID2D1BytecodeLoader; +} diff --git a/src/ComputeSharp/Core/Interfaces/__Internals/IShader.cs b/src/ComputeSharp/Core/Interfaces/__Internals/IShader.cs index 262b7d0d..4fa1fb21 100644 --- a/src/ComputeSharp/Core/Interfaces/__Internals/IShader.cs +++ b/src/ComputeSharp/Core/Interfaces/__Internals/IShader.cs @@ -16,14 +16,7 @@ public interface IShader /// The unique dispatch identifier for the shader. [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("This method is not intended to be used directly by user code")] - int GetDispatchId() -#if NET6_0_OR_GREATER - { - throw new NotImplementedException(); - } -#else - ; -#endif + int GetDispatchId(); /// /// Loads the dispatch data for the shader. @@ -37,14 +30,7 @@ public interface IShader [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("This method is not intended to be called directly by user code")] void LoadDispatchData(ref TLoader loader, GraphicsDevice device, int x, int y, int z) - where TLoader : struct, IDispatchDataLoader -#if NET6_0_OR_GREATER - { - throw new NotImplementedException(); - } -#else - ; -#endif + where TLoader : struct, IDispatchDataLoader; /// /// Loads an opaque metadata handle from the metadata of the current shader. @@ -55,14 +41,7 @@ public interface IShader [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("This method is not intended to be called directly by user code")] void LoadDispatchMetadata(ref TLoader loader, out IntPtr result) - where TLoader : struct, IDispatchMetadataLoader -#if NET6_0_OR_GREATER - { - throw new NotImplementedException(); - } -#else - ; -#endif + where TLoader : struct, IDispatchMetadataLoader; /// /// Builds the HLSL source code for the current shader instance. @@ -73,14 +52,7 @@ public interface IShader /// The number of threads in each thread group for the Z axis. [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("This method is not intended to be called directly by user code")] - void BuildHlslString(out ArrayPoolStringBuilder builder, int threadsX, int threadsY, int threadsZ) -#if NET6_0_OR_GREATER - { - throw new NotImplementedException(); - } -#else - ; -#endif + void BuildHlslString(out ArrayPoolStringBuilder builder, int threadsX, int threadsY, int threadsZ); /// /// Loads the bytecode for the current shader. @@ -93,12 +65,5 @@ public interface IShader [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("This method is not intended to be used directly by user code")] void LoadBytecode(ref TLoader loader, int threadsX, int threadsY, int threadsZ) - where TLoader : struct, IBytecodeLoader -#if NET6_0_OR_GREATER - { - throw new NotImplementedException(); - } -#else - ; -#endif + where TLoader : struct, IBytecodeLoader; }