Add ID2D1Shader.InitializeFromDispatchData API to support transforms

このコミットが含まれているのは:
Sergio Pedri committed 2022-04-24 21:04:31 +02:00
1 親 a36bae8e5a
コミット d0dfd82f06
10ファイル変更
+339 -55

検索条件に一致するファイルはありません

@@ -6,11 +6,44 @@ namespace ComputeSharp.D2D1;
/// <summary>
/// An <see langword="interface"/> providing support for custom, stateful draw transform mappings for shaders.
/// </summary>
public interface ID2D1DrawTransformMapper
public interface ID2D1TransformMapper<T>
where T : unmanaged, ID2D1PixelShader
{
/// <summary>
/// <para>
/// Allows a transform to state how it would map a a set of sample rectangles on its input to an output rectangle.
/// </para>
/// <para>
/// This is effectively the inverse mapping of <see cref="MapOutputToInputs"/>.
/// </para>
/// </summary>
/// <param name="shader">The input D2D1 pixel shader being executed on the current effect (this can be used to retrieve shader properties).</param>
/// <param name="inputs">The input rectangles to be mapped to the output rectangle. This parameter is always equal to the input bounds.</param>
/// <param name="opaqueInputs">The input rectangles to be mapped to the opaque output rectangle.</param>
/// <param name="output">The output rectangle that maps to the corresponding input rectangle.</param>
/// <param name="opaqueOutput">The output rectangle that maps to the corresponding opaque input rectangle.</param>
/// <remarks>
/// <para>
/// Unlike <see cref="MapOutputToInputs"/> and <see cref="MapInvalidOutput"/>, this method is explicitly called by the renderer at
/// a determined place in its rendering algorithm. The transform implementation may change its state based on the input rectangles
/// and use this information to control its rendering information. This method is always called before the
/// <see cref="MapInvalidOutput"/> and <see cref="MapOutputToInputs"/> methods.
/// </para>
/// <para>
/// For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1effectauthor/nf-d2d1effectauthor-id2d1transform-mapinputrectstooutputrect"/>.
/// </para>
/// </remarks>
void MapInputsToOutput(
in T shader,
ReadOnlySpan<Rectangle> inputs,
ReadOnlySpan<Rectangle> opaqueInputs,
out Rectangle output,
out Rectangle opaqueOutput);
/// <summary>
/// Allows a transform to state how it would map a rectangle requested on its output to a set of sample rectangles on its input.
/// </summary>
/// <param name="shader">The input D2D1 pixel shader being executed on the current effect (this can be used to retrieve shader properties).</param>
/// <param name="output">The output rectangle from which the inputs must be mapped.</param>
/// <param name="inputs">The corresponding set of inputs. The inputs will directly correspond to the transform inputs.</param>
/// <remarks>
@@ -23,31 +56,12 @@ public interface ID2D1DrawTransformMapper
/// For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1effectauthor/nf-d2d1effectauthor-id2d1transform-mapoutputrecttoinputrects"/>.
/// </para>
/// </remarks>
void MapOutputToInputs(in Rectangle output, Span<Rectangle> inputs);
/// <summary>
/// Performs the inverse mapping of <see cref="MapOutputToInputs(in Rectangle, Span{Rectangle})"/>.
/// </summary>
/// <param name="inputs">The input rectangles to be mapped to the output rectangle. This parameter is always equal to the input bounds.</param>
/// <param name="opaqueInputs">The input rectangles to be mapped to the opaque output rectangle.</param>
/// <param name="output">The output rectangle that maps to the corresponding input rectangle.</param>
/// <param name="opaqueOutput">The output rectangle that maps to the corresponding opaque input rectangle.</param>
/// <remarks>
/// <para>
/// Unlike <see cref="MapOutputToInputs(in Rectangle, Span{Rectangle})"/> and <see cref="MapInvalidOutput(int, Rectangle, out Rectangle)"/>, this
/// method is explicitly called by the renderer at a determined place in its rendering algorithm. The transform implementation may change its state
/// based on the input rectangles and use this information to control its rendering information. This method is always called before the
/// <see cref="MapInvalidOutput(int, Rectangle, out Rectangle)"/> and <see cref="MapOutputToInputs(in Rectangle, Span{Rectangle})"/> methods.
/// </para>
/// <para>
/// For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1effectauthor/nf-d2d1effectauthor-id2d1transform-mapinputrectstooutputrect"/>.
/// </para>
/// </remarks>
void MapInputsToOutput(ReadOnlySpan<Rectangle> inputs, ReadOnlySpan<Rectangle> opaqueInputs, out Rectangle output, out Rectangle opaqueOutput);
void MapOutputToInputs(in T shader, in Rectangle output, Span<Rectangle> inputs);
/// <summary>
/// Sets the input rectangles for this rendering pass into the transform.
/// </summary>
/// <param name="shader">The input D2D1 pixel shader being executed on the current effect (this can be used to retrieve shader properties).</param>
/// <param name="inputIndex">The index of the input rectangle.</param>
/// <param name="invalidInput">The invalid input rectangle.</param>
/// <param name="invalidOutput">The output rectangle to which the input rectangle must be mapped.</param>
@@ -55,12 +69,12 @@ public interface ID2D1DrawTransformMapper
/// <para>
/// The transform implementation must regard this method as purely functional. The transform implementation can base the mapped input rectangle on
/// the transform implementation's current state as specified by the encapsulating effect properties. But the transform implementation can't change
/// its own state in response to a call to <see cref="MapInvalidOutput(int, Rectangle, out Rectangle)"/>. Direct2D can call this method at any time
/// and in any sequence following a call to <see cref="MapInputsToOutput(ReadOnlySpan{Rectangle}, ReadOnlySpan{Rectangle}, out Rectangle, out Rectangle)"/>.
/// its own state in response to a call to <see cref="MapInvalidOutput"/>. Direct2D can call this method at any time
/// and in any sequence following a call to <see cref="MapInputsToOutput"/>.
/// </para>
/// <para>
/// For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1effectauthor/nf-d2d1effectauthor-id2d1transform-mapinvalidrect"/>.
/// </para>
/// </remarks>
void MapInvalidOutput(int inputIndex, Rectangle invalidInput, out Rectangle invalidOutput);
void MapInvalidOutput(in T shader, int inputIndex, Rectangle invalidInput, out Rectangle invalidOutput);
}
+16
ファイルの表示
@@ -10,6 +10,22 @@ namespace ComputeSharp.D2D1.__Internals;
[Obsolete("This interface is not intended to be used directly by user code")]
public interface ID2D1Shader
{
/// <summary>
/// Initializes the current shader from a buffer with the serialized dispatch data.
/// </summary>
/// <param name="data">The input buffer with the serialized dispatch data.</param>
/// <remarks>The input buffer must be retrieved from <see cref="LoadDispatchData"/>.</remarks>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This method is not intended to be called directly by user code")]
void InitializeFromDispatchData(ReadOnlySpan<byte> data)
#if NET6_0_OR_GREATER
{
throw new NotImplementedException();
}
#else
;
#endif
/// <summary>
/// Loads the dispatch data for the shader.
/// </summary>