Move PixelShaderEffect and interop APIs to ComputeSharp.D2D1Interop
Also added necessary polyfills
このコミットが含まれているのは:
1 親
33c87516f8
コミット
61b51c706b
26ファイル変更
+526
-26
検索条件に一致するファイルはありません
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<DocumentationFile>ComputeSharp.D2D1Interop.xml</DocumentationFile>
|
||||
<Platforms>AnyCPU;x64;ARM64</Platforms>
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using ComputeSharp.D2D1Interop.Extensions;
|
||||
using ComputeSharp.D2D1Interop.Tests.Helpers;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
namespace ComputeSharp.D2D1Interop;
|
||||
|
||||
/// <inheritdoc/>
|
||||
unsafe partial class D2D1InteropServices
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers an effect from an input D2D1 pixel shader, by calling <c>ID2D1Factory1::RegisterEffectFromString</c>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of D2D1 pixel shader to register.</typeparam>
|
||||
/// <param name="d2D1Factory1">A pointer to the <c>ID2D1Factory1</c> instance to use.</param>
|
||||
/// <param name="effectId">The <see cref="Guid"/> of the registered effect, which can be used to call <c>ID2D1DeviceContext::CreateEffect</c>.</param>
|
||||
/// <remarks>For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1_1/nf-d2d1_1-id2d1factory1-registereffectfromstring"/>.</remarks>
|
||||
public static unsafe void RegisterPixelShaderEffectForD2D1Factory1<T>(void* d2D1Factory1, out Guid effectId)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
effectId = default;
|
||||
|
||||
// Setup the input string
|
||||
StringBuilder effectInputsBuilder = new();
|
||||
|
||||
for (int i = 0; i < PixelShaderEffect.For<T>.NumberOfInputs; i++)
|
||||
{
|
||||
effectInputsBuilder.Append($"<Input name='Source");
|
||||
effectInputsBuilder.Append(i);
|
||||
effectInputsBuilder.Append($"'/>");
|
||||
}
|
||||
|
||||
// Prepare the XML with a variable number of inputs
|
||||
string xml = @$"<?xml version='1.0'?>
|
||||
<Effect>
|
||||
<!-- System Properties -->
|
||||
<Property name='DisplayName' type='string' value='{typeof(T).FullName}'/>
|
||||
<Property name='Author' type='string' value='ComputeSharp.D2D1Interop'/>
|
||||
<Property name='Category' type='string' value='Stylize'/>
|
||||
<Property name='Description' type='string' value='A custom D2D1 effect using a pixel shader'/>
|
||||
<Inputs>
|
||||
{effectInputsBuilder}
|
||||
</Inputs>
|
||||
<Property name='Buffer' type='blob'>
|
||||
<Property name='DisplayName' type='string' value='Buffer'/>
|
||||
</Property>
|
||||
</Effect>";
|
||||
|
||||
fixed (char* pXml = xml)
|
||||
fixed (char* pPropertyName = "Buffer")
|
||||
{
|
||||
// Prepare the effect binding functions
|
||||
D2D1_PROPERTY_BINDING d2D1PropertyBinding;
|
||||
d2D1PropertyBinding.propertyName = (ushort*)pPropertyName;
|
||||
d2D1PropertyBinding.getFunction =
|
||||
(delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, uint*, HRESULT>)
|
||||
(delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, uint*, int>)
|
||||
&PixelShaderEffect.GetConstantBuffer;
|
||||
d2D1PropertyBinding.setFunction =
|
||||
(delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, HRESULT>)
|
||||
(delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, int>)
|
||||
&PixelShaderEffect.SetConstantBuffer;
|
||||
|
||||
Guid shaderId = typeof(T).GUID;
|
||||
|
||||
// Register the effect
|
||||
((ID2D1Factory1*)d2D1Factory1)->RegisterEffectFromString(
|
||||
classId: &shaderId,
|
||||
propertyXml: (ushort*)pXml,
|
||||
bindings: &d2D1PropertyBinding,
|
||||
bindingsCount: 1,
|
||||
effectFactory: PixelShaderEffect.For<T>.Factory).Assert();
|
||||
|
||||
effectId = shaderId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an effect wrapping an input D2D1 pixel shader, by calling <c>ID2D1DeviceContext::CreateEffect</c>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of D2D1 pixel shader to create an effect for.</typeparam>
|
||||
/// <param name="d2D1DeviceContext">A pointer to the <c>ID2D1DeviceContext</c> instance to use.</param>
|
||||
/// <param name="d2D1Effect">A pointer to the resulting <c>ID2D1Effect*</c> pointer to produce.</param>
|
||||
/// <remarks>For more info, see <see href="https://docs.microsoft.com/en-us/windows/win32/api/d2d1_1/nf-d2d1_1-id2d1devicecontext-createeffect"/>.</remarks>
|
||||
public static unsafe void CreatePixelShaderEffectFromD2D1DeviceContext<T>(void* d2D1DeviceContext, void** d2D1Effect)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
Guid shaderId = typeof(T).GUID;
|
||||
|
||||
((ID2D1DeviceContext*)d2D1DeviceContext)->CreateEffect(
|
||||
effectId: &shaderId,
|
||||
effect: (ID2D1Effect**)d2D1Effect).Assert();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the constant buffer from an input D2D1 effect, by calling <c>ID2D1Effect::SetValue</c>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of D2D1 pixel shader to set the constant buffer for.</typeparam>
|
||||
/// <param name="shader">The input D2D1 pixel shader to set the contant buffer for.</param>
|
||||
/// <param name="d2D1Effect">A pointer to the <c>ID2D1Effect</c> instance to use.</param>
|
||||
/// <remarks>For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1_1/nf-d2d1_1-id2d1properties-setvalue(uint32_d2d1_property_type_constbyte_uint32)"/>.</remarks>
|
||||
public static unsafe void SetConstantBufferForD2D1Effect<T>(in T shader, void* d2D1Effect)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
// Get the shader state
|
||||
ReadOnlyMemory<byte> buffer = D2D1InteropServices.GetPixelShaderConstantBufferForD2D1DrawInfo(in shader);
|
||||
|
||||
if (buffer.Length > 0)
|
||||
{
|
||||
fixed (byte* p = buffer.Span)
|
||||
{
|
||||
// Load the effect buffer
|
||||
((ID2D1Effect*)d2D1Effect)->SetValue(
|
||||
index: 0,
|
||||
type: D2D1_PROPERTY_TYPE.D2D1_PROPERTY_TYPE_BLOB,
|
||||
data: p,
|
||||
dataSize: (uint)buffer.Length).Assert();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: optimize with a custom dispatch data loader
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace ComputeSharp.D2D1Interop;
|
||||
/// <summary>
|
||||
/// Provides methods to extract reflection info on D2D1 shaders generated using this library.
|
||||
/// </summary>
|
||||
public static unsafe class D2D1InteropServices
|
||||
public static unsafe partial class D2D1InteropServices
|
||||
{
|
||||
/// <summary>
|
||||
/// Loads the bytecode from an input D2D1 pixel shader.
|
||||
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
namespace ComputeSharp.D2D1Interop.Tests.Helpers;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial struct PixelShaderEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// The implementation for <see cref="ID2D1DrawTransform"/>.
|
||||
/// </summary>
|
||||
private unsafe static class ID2D1DrawTransformMethods
|
||||
{
|
||||
/// <inheritdoc cref="ID2D1DrawTransform.QueryInterface"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static int QueryInterface(PixelShaderEffect* @this, Guid* riid, void** ppvObject)
|
||||
{
|
||||
@this = (PixelShaderEffect*)&((void**)@this)[-1];
|
||||
|
||||
return @this->QueryInterface(riid, ppvObject);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1DrawTransform.AddRef"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static uint AddRef(PixelShaderEffect* @this)
|
||||
{
|
||||
@this = (PixelShaderEffect*)&((void**)@this)[-1];
|
||||
|
||||
return @this->AddRef();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1DrawTransform.Release"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static uint Release(PixelShaderEffect* @this)
|
||||
{
|
||||
@this = (PixelShaderEffect*)&((void**)@this)[-1];
|
||||
|
||||
return @this->Release();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1DrawTransform.GetInputCount"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static uint GetInputCount(PixelShaderEffect* @this)
|
||||
{
|
||||
@this = (PixelShaderEffect*)&((void**)@this)[-1];
|
||||
|
||||
return (uint)@this->numberOfInputs;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1DrawTransform.MapOutputRectToInputRects"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static int MapOutputRectToInputRects(PixelShaderEffect* @this, RECT* outputRect, RECT* inputRects, uint inputRectsCount)
|
||||
{
|
||||
@this = (PixelShaderEffect*)&((void**)@this)[-1];
|
||||
|
||||
if (inputRectsCount != 1)
|
||||
{
|
||||
return E.E_INVALIDARG;
|
||||
}
|
||||
|
||||
inputRects[0] = *outputRect;
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1DrawTransform.MapInputRectsToOutputRect"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static int MapInputRectsToOutputRect(PixelShaderEffect* @this, RECT* inputRects, RECT* inputOpaqueSubRects, uint inputRectCount, RECT* outputRect, RECT* outputOpaqueSubRect)
|
||||
{
|
||||
@this = (PixelShaderEffect*)&((void**)@this)[-1];
|
||||
|
||||
if (inputRectCount != 1)
|
||||
{
|
||||
return E.E_INVALIDARG;
|
||||
}
|
||||
|
||||
*outputRect = inputRects[0];
|
||||
|
||||
@this->inputRect = inputRects[0];
|
||||
|
||||
*outputOpaqueSubRect = default;
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1DrawTransform.MapInvalidRect"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static int MapInvalidRect(PixelShaderEffect* @this, uint inputIndex, RECT invalidInputRect, RECT* invalidOutputRect)
|
||||
{
|
||||
@this = (PixelShaderEffect*)&((void**)@this)[-1];
|
||||
|
||||
*invalidOutputRect = @this->inputRect;
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1DrawTransform.SetDrawInfo"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static int SetDrawInfo(PixelShaderEffect* @this, ID2D1DrawInfo* drawInfo)
|
||||
{
|
||||
@this = (PixelShaderEffect*)&((void**)@this)[-1];
|
||||
|
||||
@this->d2D1DrawInfo = drawInfo;
|
||||
|
||||
return drawInfo->SetPixelShader(&@this->shaderId);
|
||||
}
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
namespace ComputeSharp.D2D1Interop.Tests.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// A simple <see cref="ID2D1EffectImpl"/> and <see cref="ID2D1DrawTransform"/> implementation for a given pixel shader.
|
||||
/// </summary>
|
||||
internal unsafe partial struct PixelShaderEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// The implementation for <see cref="ID2D1EffectImpl"/>.
|
||||
/// </summary>
|
||||
private static class ID2D1EffectImplMethods
|
||||
{
|
||||
/// <inheritdoc cref="ID2D1EffectImpl.QueryInterface"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static int QueryInterface(PixelShaderEffect* @this, Guid* riid, void** ppvObject)
|
||||
{
|
||||
return @this->QueryInterface(riid, ppvObject);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1EffectImpl.AddRef"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static uint AddRef(PixelShaderEffect* @this)
|
||||
{
|
||||
return @this->AddRef();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1EffectImpl.Release"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static uint Release(PixelShaderEffect* @this)
|
||||
{
|
||||
return @this->Release();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1EffectImpl.Initialize"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static int Initialize(PixelShaderEffect* @this, ID2D1EffectContext* effectContext, ID2D1TransformGraph* transformGraph)
|
||||
{
|
||||
int hresult = effectContext->LoadPixelShader(
|
||||
shaderId: &@this->shaderId,
|
||||
shaderBuffer: @this->bytecode,
|
||||
shaderBufferCount: (uint)@this->bytecodeSize);
|
||||
|
||||
if (Windows.SUCCEEDED(hresult))
|
||||
{
|
||||
hresult = transformGraph->SetSingleTransformNode((ID2D1TransformNode*)&@this->lpVtblForID2D1DrawTransform);
|
||||
}
|
||||
|
||||
return hresult;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1EffectImpl.PrepareForRender"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static int PrepareForRender(PixelShaderEffect* @this, D2D1_CHANGE_TYPE changeType)
|
||||
{
|
||||
if (@this->constantBuffer is not null)
|
||||
{
|
||||
return @this->d2D1DrawInfo->SetPixelShaderConstantBuffer(
|
||||
buffer: @this->constantBuffer,
|
||||
bufferCount: (uint)@this->constantBufferSize);
|
||||
}
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID2D1EffectImpl.SetGraph"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static int SetGraph(PixelShaderEffect* @this, ID2D1TransformGraph* transformGraph)
|
||||
{
|
||||
return E.E_NOTIMPL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,317 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
namespace ComputeSharp.D2D1Interop.Tests.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// A simple <see cref="ID2D1EffectImpl"/> and <see cref="ID2D1DrawTransform"/> implementation for a given pixel shader.
|
||||
/// </summary>
|
||||
internal unsafe partial struct PixelShaderEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// A wrapper for an effect factory.
|
||||
/// </summary>
|
||||
/// <param name="effectImpl">The resulting effect factory.</param>
|
||||
/// <returns>The <c>HRESULT</c> for the operation.</returns>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
private delegate int FactoryDelegate(IUnknown** effectImpl);
|
||||
|
||||
/// <summary>
|
||||
/// A generic pixel shader implementation.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of shader.</typeparam>
|
||||
public static class For<T>
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="Guid"/> for the shader.
|
||||
/// </summary>
|
||||
private static readonly Guid shaderId;
|
||||
|
||||
/// <summary>
|
||||
/// The shader bytecode.
|
||||
/// </summary>
|
||||
private static readonly byte* bytecode;
|
||||
|
||||
/// <summary>
|
||||
/// The size of <see cref="bytecode"/>.
|
||||
/// </summary>
|
||||
private static readonly int bytecodeSize;
|
||||
|
||||
/// <summary>
|
||||
/// The number of inputs for the shader.
|
||||
/// </summary>
|
||||
private static readonly int numberOfInputs;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="FactoryDelegate"/> wrapper for the shader factory.
|
||||
/// </summary>
|
||||
private static readonly FactoryDelegate EffectFactory = CreateEffect;
|
||||
|
||||
/// <summary>
|
||||
/// The static constructor for <see cref="For{T}"/>.
|
||||
/// </summary>
|
||||
static For()
|
||||
{
|
||||
shaderId = typeof(T).GUID;
|
||||
|
||||
ReadOnlyMemory<byte> buffer = D2D1InteropServices.LoadShaderBytecode<T>();
|
||||
|
||||
bytecode = (byte*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For<T>), buffer.Length);
|
||||
|
||||
buffer.Span.CopyTo(new Span<byte>(bytecode, buffer.Length));
|
||||
|
||||
bytecodeSize = buffer.Length;
|
||||
|
||||
numberOfInputs = ((D2DInputCountAttribute[])typeof(T).GetCustomAttributes(typeof(D2DInputCountAttribute), false))[0].Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the factory for the current effect.
|
||||
/// </summary>
|
||||
public static delegate* unmanaged[Stdcall]<IUnknown**, HRESULT> Factory
|
||||
{
|
||||
get => (delegate* unmanaged[Stdcall]<IUnknown**, HRESULT>)Marshal.GetFunctionPointerForDelegate(EffectFactory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of inputs for the effect.
|
||||
/// </summary>
|
||||
public static int NumberOfInputs => numberOfInputs;
|
||||
|
||||
/// <inheritdoc cref="FactoryDelegate"/>
|
||||
private static int CreateEffect(IUnknown** effectImpl)
|
||||
{
|
||||
return PixelShaderEffect.Factory(shaderId, bytecode, bytecodeSize, numberOfInputs, effectImpl);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The shared vtable pointer for <see cref="PixelShaderEffect"/> instance, for <see cref="ID2D1EffectImplMethods"/>.
|
||||
/// </summary>
|
||||
private static readonly void** VtblForID2D1EffectImpl;
|
||||
|
||||
/// <summary>
|
||||
/// The shared vtable pointer for <see cref="PixelShaderEffect"/> instance, for <see cref="ID2D1DrawTransform"/>.
|
||||
/// </summary>
|
||||
private static readonly void** VtblForID2D1DrawTransform;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the shared state for <see cref="PixelShaderEffect"/>.
|
||||
/// </summary>
|
||||
static PixelShaderEffect()
|
||||
{
|
||||
void** lpVtbl = (void**)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(PixelShaderEffect), sizeof(void*) * 14);
|
||||
|
||||
// ID2D1EffectImpl
|
||||
lpVtbl[0] = (delegate* unmanaged<PixelShaderEffect*, Guid*, void**, int>)&ID2D1EffectImplMethods.QueryInterface;
|
||||
lpVtbl[1] = (delegate* unmanaged<PixelShaderEffect*, uint>)&ID2D1EffectImplMethods.AddRef;
|
||||
lpVtbl[2] = (delegate* unmanaged<PixelShaderEffect*, uint>)&ID2D1EffectImplMethods.Release;
|
||||
lpVtbl[3] = (delegate* unmanaged<PixelShaderEffect*, ID2D1EffectContext*, ID2D1TransformGraph*, int>)&ID2D1EffectImplMethods.Initialize;
|
||||
lpVtbl[4] = (delegate* unmanaged<PixelShaderEffect*, D2D1_CHANGE_TYPE, int>)&ID2D1EffectImplMethods.PrepareForRender;
|
||||
lpVtbl[5] = (delegate* unmanaged<PixelShaderEffect*, ID2D1TransformGraph*, int>)&ID2D1EffectImplMethods.SetGraph;
|
||||
|
||||
// ID2D1DrawTransform
|
||||
lpVtbl[6 + 0] = (delegate* unmanaged<PixelShaderEffect*, Guid*, void**, int>)&ID2D1DrawTransformMethods.QueryInterface;
|
||||
lpVtbl[6 + 1] = (delegate* unmanaged<PixelShaderEffect*, uint>)&ID2D1DrawTransformMethods.AddRef;
|
||||
lpVtbl[6 + 2] = (delegate* unmanaged<PixelShaderEffect*, uint>)&ID2D1DrawTransformMethods.Release;
|
||||
lpVtbl[6 + 3] = (delegate* unmanaged<PixelShaderEffect*, uint>)&ID2D1DrawTransformMethods.GetInputCount;
|
||||
lpVtbl[6 + 4] = (delegate* unmanaged<PixelShaderEffect*, RECT*, RECT*, uint, int>)&ID2D1DrawTransformMethods.MapOutputRectToInputRects;
|
||||
lpVtbl[6 + 5] = (delegate* unmanaged<PixelShaderEffect*, RECT*, RECT*, uint, RECT*, RECT*, int>)&ID2D1DrawTransformMethods.MapInputRectsToOutputRect;
|
||||
lpVtbl[6 + 6] = (delegate* unmanaged<PixelShaderEffect*, uint, RECT, RECT*, int>)&ID2D1DrawTransformMethods.MapInvalidRect;
|
||||
lpVtbl[6 + 7] = (delegate* unmanaged<PixelShaderEffect*, ID2D1DrawInfo*, int>)&ID2D1DrawTransformMethods.SetDrawInfo;
|
||||
|
||||
VtblForID2D1EffectImpl = lpVtbl;
|
||||
VtblForID2D1DrawTransform = &lpVtbl[6];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The vtable pointer for the current instance, for <see cref="ID2D1Effect"/>.
|
||||
/// </summary>
|
||||
private void** lpVtblForID2D1EffectImpl;
|
||||
|
||||
/// <summary>
|
||||
/// The vtable pointer for the current instance, for <see cref="ID2D1DrawTransform"/>.
|
||||
/// </summary>
|
||||
private void** lpVtblForID2D1DrawTransform;
|
||||
|
||||
/// <summary>
|
||||
/// The current reference count for the object (from <c>IUnknown</c>).
|
||||
/// </summary>
|
||||
private volatile int referenceCount;
|
||||
|
||||
/// <summary>
|
||||
/// The constant buffer data, if set.
|
||||
/// </summary>
|
||||
private byte* constantBuffer;
|
||||
|
||||
/// <summary>
|
||||
/// The size of <see cref="constantBuffer"/>, if set.
|
||||
/// </summary>
|
||||
private int constantBufferSize;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Guid"/> for the shader.
|
||||
/// </summary>
|
||||
private Guid shaderId;
|
||||
|
||||
/// <summary>
|
||||
/// The shader bytecode.
|
||||
/// </summary>
|
||||
private byte* bytecode;
|
||||
|
||||
/// <summary>
|
||||
/// The size of <see cref="bytecode"/>.
|
||||
/// </summary>
|
||||
private int bytecodeSize;
|
||||
|
||||
/// <summary>
|
||||
/// The number of inputs for the shader.
|
||||
/// </summary>
|
||||
private int numberOfInputs;
|
||||
|
||||
/// <summary>
|
||||
/// The current input rectangle.
|
||||
/// </summary>
|
||||
private RECT inputRect;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID2D1DrawInfo"/> instance currently in use.
|
||||
/// </summary>
|
||||
private ID2D1DrawInfo* d2D1DrawInfo;
|
||||
|
||||
/// <summary>
|
||||
/// The factory method for <see cref="ID2D1Factory1.RegisterEffectFromString"/>.
|
||||
/// </summary>
|
||||
/// <param name="shaderId">The <see cref="Guid"/> for the shader.</param>
|
||||
/// <param name="bytecode">The shader bytecode.</param>
|
||||
/// <param name="effectImpl">The resulting effect instance.</param>
|
||||
/// <param name="bytecodeSize">The size of <paramref name="bytecode"/>.</param>
|
||||
/// <param name="numberOfInputs">The number of inputs for the shader.</param>
|
||||
/// <returns>This always returns <c>0</c>.</returns>
|
||||
private static int Factory(Guid shaderId, byte* bytecode, int bytecodeSize, int numberOfInputs, IUnknown** effectImpl)
|
||||
{
|
||||
PixelShaderEffect* @this = (PixelShaderEffect*)NativeMemory.Alloc((nuint)sizeof(PixelShaderEffect));
|
||||
|
||||
*@this = default;
|
||||
|
||||
@this->lpVtblForID2D1EffectImpl = VtblForID2D1EffectImpl;
|
||||
@this->lpVtblForID2D1DrawTransform = VtblForID2D1DrawTransform;
|
||||
@this->referenceCount = 1;
|
||||
@this->shaderId = shaderId;
|
||||
@this->bytecode = bytecode;
|
||||
@this->bytecodeSize = bytecodeSize;
|
||||
@this->numberOfInputs = numberOfInputs;
|
||||
|
||||
*effectImpl = (IUnknown*)@this;
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="D2D1_PROPERTY_BINDING.getFunction"/>
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })]
|
||||
public static int GetConstantBuffer(IUnknown* effect, byte* data, uint dataSize, uint* actualSize)
|
||||
{
|
||||
PixelShaderEffect* @this = (PixelShaderEffect*)effect;
|
||||
|
||||
if (@this->constantBufferSize == 0)
|
||||
{
|
||||
*actualSize = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int bytesToCopy = Math.Min((int)dataSize, @this->constantBufferSize);
|
||||
|
||||
Buffer.MemoryCopy(@this->constantBuffer, data, dataSize, bytesToCopy);
|
||||
|
||||
*actualSize = (uint)bytesToCopy;
|
||||
}
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="D2D1_PROPERTY_BINDING.getFunction"/>
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })]
|
||||
public static int SetConstantBuffer(IUnknown* effect, byte* data, uint dataSize)
|
||||
{
|
||||
PixelShaderEffect* @this = (PixelShaderEffect*)effect;
|
||||
|
||||
if (@this->constantBuffer is not null)
|
||||
{
|
||||
NativeMemory.Free(@this->constantBuffer);
|
||||
}
|
||||
|
||||
void* buffer = NativeMemory.Alloc(dataSize);
|
||||
|
||||
Buffer.MemoryCopy(data, buffer, dataSize, dataSize);
|
||||
|
||||
@this->constantBuffer = (byte*)buffer;
|
||||
@this->constantBufferSize = (int)dataSize;
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IUnknown.QueryInterface"/>
|
||||
private int QueryInterface(Guid* riid, void** ppvObject)
|
||||
{
|
||||
if (ppvObject is null)
|
||||
{
|
||||
return E.E_POINTER;
|
||||
}
|
||||
|
||||
// ID2D1EffectImpl
|
||||
if (riid->Equals(Windows.__uuidof<IUnknown>()) ||
|
||||
riid->Equals(Windows.__uuidof<ID2D1EffectImpl>()))
|
||||
{
|
||||
_ = Interlocked.Increment(ref this.referenceCount);
|
||||
|
||||
*ppvObject = Unsafe.AsPointer(ref this);
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
// ID2D1DrawTransform
|
||||
if (riid->Equals(Windows.__uuidof<ID2D1TransformNode>()) ||
|
||||
riid->Equals(Windows.__uuidof<ID2D1Transform>()) ||
|
||||
riid->Equals(Windows.__uuidof<ID2D1DrawTransform>()))
|
||||
{
|
||||
_ = Interlocked.Increment(ref this.referenceCount);
|
||||
|
||||
*ppvObject = (void**)Unsafe.AsPointer(ref this) + 1;
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
*ppvObject = null;
|
||||
|
||||
return E.E_NOINTERFACE;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IUnknown.AddRef"/>
|
||||
private uint AddRef()
|
||||
{
|
||||
return (uint)Interlocked.Increment(ref this.referenceCount);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IUnknown.Release"/>
|
||||
private uint Release()
|
||||
{
|
||||
uint referenceCount = (uint)Interlocked.Decrement(ref this.referenceCount);
|
||||
|
||||
if (referenceCount == 0)
|
||||
{
|
||||
if (this.constantBuffer is not null)
|
||||
{
|
||||
NativeMemory.Free(this.constantBuffer);
|
||||
}
|
||||
|
||||
NativeMemory.Free(Unsafe.AsPointer(ref this));
|
||||
}
|
||||
|
||||
return referenceCount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from um/d2d1_1.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
internal enum D2D1_PROPERTY_TYPE : uint
|
||||
{
|
||||
D2D1_PROPERTY_TYPE_BLOB = 9
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from um/d2d1_1.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
[Guid("E8F7FE7A-191C-466D-AD95-975678BDA998")]
|
||||
[NativeTypeName("struct ID2D1DeviceContext : ID2D1RenderTarget")]
|
||||
[NativeInheritance("ID2D1RenderTarget")]
|
||||
internal unsafe partial struct ID2D1DeviceContext
|
||||
{
|
||||
public void** lpVtbl;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(63)]
|
||||
public HRESULT CreateEffect([NativeTypeName("const IID &")] Guid* effectId, ID2D1Effect** effect)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1DeviceContext*, Guid*, ID2D1Effect**, int>)(lpVtbl[63]))((ID2D1DeviceContext*)Unsafe.AsPointer(ref this), effectId, effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from um/d2d1_1.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
[Guid("28211A43-7D89-476F-8181-2D6159B220AD")]
|
||||
[NativeTypeName("struct ID2D1Effect : ID2D1Properties")]
|
||||
[NativeInheritance("ID2D1Properties")]
|
||||
internal unsafe partial struct ID2D1Effect
|
||||
{
|
||||
public void** lpVtbl;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(9)]
|
||||
public HRESULT SetValue([NativeTypeName("UINT32")] uint index, D2D1_PROPERTY_TYPE type, [NativeTypeName("const BYTE *")] byte* data, [NativeTypeName("UINT32")] uint dataSize)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1Effect*, uint, D2D1_PROPERTY_TYPE, byte*, uint, int>)(lpVtbl[9]))((ID2D1Effect*)Unsafe.AsPointer(ref this), index, type, data, dataSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from um/d2d1_1.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
[Guid("BB12D362-DAEE-4B9A-AA1D-14BA401CFA1F")]
|
||||
[NativeTypeName("struct ID2D1Factory1 : ID2D1Factory")]
|
||||
[NativeInheritance("ID2D1Factory")]
|
||||
internal unsafe partial struct ID2D1Factory1
|
||||
{
|
||||
public void** lpVtbl;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(23)]
|
||||
public HRESULT RegisterEffectFromString([NativeTypeName("const IID &")] Guid* classId, [NativeTypeName("PCWSTR")] ushort* propertyXml, [NativeTypeName("const D2D1_PROPERTY_BINDING *")] D2D1_PROPERTY_BINDING* bindings, [NativeTypeName("UINT32")] uint bindingsCount, [NativeTypeName("const PD2D1_EFFECT_FACTORY")] delegate* unmanaged[Stdcall]<IUnknown**, HRESULT> effectFactory)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1Factory1*, Guid*, ushort*, D2D1_PROPERTY_BINDING*, uint, delegate* unmanaged[Stdcall]<IUnknown**, HRESULT>, int>)(lpVtbl[23]))((ID2D1Factory1*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from um/d2d1effectauthor.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
using System;
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
[Flags]
|
||||
internal enum D2D1_CHANGE_TYPE : uint
|
||||
{
|
||||
D2D1_CHANGE_TYPE_NONE = 0,
|
||||
D2D1_CHANGE_TYPE_PROPERTIES = 1,
|
||||
D2D1_CHANGE_TYPE_CONTEXT = 2,
|
||||
D2D1_CHANGE_TYPE_GRAPH = 3,
|
||||
D2D1_CHANGE_TYPE_FORCE_DWORD = 0xffffffff,
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from um/d2d1effectauthor.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
using System;
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
[Flags]
|
||||
internal enum D2D1_PIXEL_OPTIONS : uint
|
||||
{
|
||||
D2D1_PIXEL_OPTIONS_NONE = 0,
|
||||
D2D1_PIXEL_OPTIONS_TRIVIAL_SAMPLING = 1,
|
||||
D2D1_PIXEL_OPTIONS_FORCE_DWORD = 0xffffffff,
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from um/d2d1effectauthor.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
internal unsafe partial struct D2D1_PROPERTY_BINDING
|
||||
{
|
||||
[NativeTypeName("PCWSTR")]
|
||||
public ushort* propertyName;
|
||||
|
||||
[NativeTypeName("PD2D1_PROPERTY_SET_FUNCTION")]
|
||||
public delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, HRESULT> setFunction;
|
||||
|
||||
[NativeTypeName("PD2D1_PROPERTY_GET_FUNCTION")]
|
||||
public delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, uint*, HRESULT> getFunction;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using TerraFX.Interop.Windows;
|
||||
using static TerraFX.Interop.DirectX.D2D1_PIXEL_OPTIONS;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
@@ -25,5 +26,12 @@ namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1DrawInfo*, byte*, uint, int>)(lpVtbl[7]))((ID2D1DrawInfo*)Unsafe.AsPointer(ref this), buffer, bufferCount);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(10)]
|
||||
public HRESULT SetPixelShader([NativeTypeName("const GUID &")] Guid* shaderId, D2D1_PIXEL_OPTIONS pixelOptions = D2D1_PIXEL_OPTIONS_NONE)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1DrawInfo*, Guid*, D2D1_PIXEL_OPTIONS, int>)(lpVtbl[10]))((ID2D1DrawInfo*)Unsafe.AsPointer(ref this), shaderId, pixelOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from um/d2d1effectauthor.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
[Guid("36BFDCB6-9739-435D-A30D-A653BEFF6A6F")]
|
||||
[NativeTypeName("struct ID2D1DrawTransform : ID2D1Transform")]
|
||||
[NativeInheritance("ID2D1Transform")]
|
||||
internal unsafe partial struct ID2D1DrawTransform
|
||||
{
|
||||
public void** lpVtbl;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(0)]
|
||||
public HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1DrawTransform*, Guid*, void**, int>)(lpVtbl[0]))((ID2D1DrawTransform*)Unsafe.AsPointer(ref this), riid, ppvObject);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(1)]
|
||||
[return: NativeTypeName("ULONG")]
|
||||
public uint AddRef()
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1DrawTransform*, uint>)(lpVtbl[1]))((ID2D1DrawTransform*)Unsafe.AsPointer(ref this));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(2)]
|
||||
[return: NativeTypeName("ULONG")]
|
||||
public uint Release()
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1DrawTransform*, uint>)(lpVtbl[2]))((ID2D1DrawTransform*)Unsafe.AsPointer(ref this));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(3)]
|
||||
[return: NativeTypeName("UINT32")]
|
||||
public uint GetInputCount()
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1DrawTransform*, uint>)(lpVtbl[3]))((ID2D1DrawTransform*)Unsafe.AsPointer(ref this));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(4)]
|
||||
public HRESULT MapOutputRectToInputRects([NativeTypeName("const D2D1_RECT_L *")] RECT* outputRect, [NativeTypeName("D2D1_RECT_L *")] RECT* inputRects, [NativeTypeName("UINT32")] uint inputRectsCount)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1DrawTransform*, RECT*, RECT*, uint, int>)(lpVtbl[4]))((ID2D1DrawTransform*)Unsafe.AsPointer(ref this), outputRect, inputRects, inputRectsCount);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(5)]
|
||||
public HRESULT MapInputRectsToOutputRect([NativeTypeName("const D2D1_RECT_L *")] RECT* inputRects, [NativeTypeName("const D2D1_RECT_L *")] RECT* inputOpaqueSubRects, [NativeTypeName("UINT32")] uint inputRectCount, [NativeTypeName("D2D1_RECT_L *")] RECT* outputRect, [NativeTypeName("D2D1_RECT_L *")] RECT* outputOpaqueSubRect)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1DrawTransform*, RECT*, RECT*, uint, RECT*, RECT*, int>)(lpVtbl[5]))((ID2D1DrawTransform*)Unsafe.AsPointer(ref this), inputRects, inputOpaqueSubRects, inputRectCount, outputRect, outputOpaqueSubRect);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(6)]
|
||||
public HRESULT MapInvalidRect([NativeTypeName("UINT32")] uint inputIndex, [NativeTypeName("D2D1_RECT_L")] RECT invalidInputRect, [NativeTypeName("D2D1_RECT_L *")] RECT* invalidOutputRect)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1DrawTransform*, uint, RECT, RECT*, int>)(lpVtbl[6]))((ID2D1DrawTransform*)Unsafe.AsPointer(ref this), inputIndex, invalidInputRect, invalidOutputRect);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(7)]
|
||||
public HRESULT SetDrawInfo(ID2D1DrawInfo* drawInfo)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1DrawTransform*, ID2D1DrawInfo*, int>)(lpVtbl[7]))((ID2D1DrawTransform*)Unsafe.AsPointer(ref this), drawInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from um/d2d1effectauthor.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
[Guid("3D9F916B-27DC-4AD7-B4F1-64945340F563")]
|
||||
[NativeTypeName("struct ID2D1EffectContext : IUnknown")]
|
||||
[NativeInheritance("IUnknown")]
|
||||
internal unsafe partial struct ID2D1EffectContext
|
||||
{
|
||||
public void** lpVtbl;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(4)]
|
||||
public HRESULT CreateEffect([NativeTypeName("const IID &")] Guid* effectId, void** effect)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1EffectContext*, Guid*, void**, int>)(lpVtbl[4]))((ID2D1EffectContext*)Unsafe.AsPointer(ref this), effectId, effect);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(11)]
|
||||
public HRESULT LoadPixelShader([NativeTypeName("const GUID &")] Guid* shaderId, [NativeTypeName("const BYTE *")] byte* shaderBuffer, [NativeTypeName("UINT32")] uint shaderBufferCount)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1EffectContext*, Guid*, byte*, uint, int>)(lpVtbl[11]))((ID2D1EffectContext*)Unsafe.AsPointer(ref this), shaderId, shaderBuffer, shaderBufferCount);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(14)]
|
||||
public int IsShaderLoaded([NativeTypeName("const GUID &")] Guid* shaderId)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1EffectContext*, Guid*, int>)(lpVtbl[14]))((ID2D1EffectContext*)Unsafe.AsPointer(ref this), shaderId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from um/d2d1effectauthor.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
[Guid("A248FD3F-3E6C-4E63-9F03-7F68ECC91DB9")]
|
||||
[NativeTypeName("struct ID2D1EffectImpl : IUnknown")]
|
||||
[NativeInheritance("IUnknown")]
|
||||
internal unsafe partial struct ID2D1EffectImpl
|
||||
{
|
||||
public void** lpVtbl;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(0)]
|
||||
public HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1EffectImpl*, Guid*, void**, int>)(lpVtbl[0]))((ID2D1EffectImpl*)Unsafe.AsPointer(ref this), riid, ppvObject);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(1)]
|
||||
[return: NativeTypeName("ULONG")]
|
||||
public uint AddRef()
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1EffectImpl*, uint>)(lpVtbl[1]))((ID2D1EffectImpl*)Unsafe.AsPointer(ref this));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(2)]
|
||||
[return: NativeTypeName("ULONG")]
|
||||
public uint Release()
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1EffectImpl*, uint>)(lpVtbl[2]))((ID2D1EffectImpl*)Unsafe.AsPointer(ref this));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(3)]
|
||||
public HRESULT Initialize(ID2D1EffectContext* effectContext, ID2D1TransformGraph* transformGraph)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1EffectImpl*, ID2D1EffectContext*, ID2D1TransformGraph*, int>)(lpVtbl[3]))((ID2D1EffectImpl*)Unsafe.AsPointer(ref this), effectContext, transformGraph);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(4)]
|
||||
public HRESULT PrepareForRender(D2D1_CHANGE_TYPE changeType)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1EffectImpl*, D2D1_CHANGE_TYPE, int>)(lpVtbl[4]))((ID2D1EffectImpl*)Unsafe.AsPointer(ref this), changeType);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(5)]
|
||||
public HRESULT SetGraph(ID2D1TransformGraph* transformGraph)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1EffectImpl*, ID2D1TransformGraph*, int>)(lpVtbl[5]))((ID2D1EffectImpl*)Unsafe.AsPointer(ref this), transformGraph);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from um/d2d1effectauthor.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
[Guid("EF1A287D-342A-4F76-8FDB-DA0D6EA9F92B")]
|
||||
[NativeTypeName("struct ID2D1Transform : ID2D1TransformNode")]
|
||||
[NativeInheritance("ID2D1TransformNode")]
|
||||
internal unsafe partial struct ID2D1Transform
|
||||
{
|
||||
public void** lpVtbl;
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from um/d2d1effectauthor.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
[Guid("13D29038-C3E6-4034-9081-13B53A417992")]
|
||||
[NativeTypeName("struct ID2D1TransformGraph : IUnknown")]
|
||||
[NativeInheritance("IUnknown")]
|
||||
internal unsafe partial struct ID2D1TransformGraph
|
||||
{
|
||||
public void** lpVtbl;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(4)]
|
||||
public HRESULT SetSingleTransformNode(ID2D1TransformNode* node)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1TransformGraph*, ID2D1TransformNode*, int>)(lpVtbl[4]))((ID2D1TransformGraph*)Unsafe.AsPointer(ref this), node);
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from um/d2d1effectauthor.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
[Guid("B2EFE1E7-729F-4102-949F-505FA21BF666")]
|
||||
[NativeTypeName("struct ID2D1TransformNode : IUnknown")]
|
||||
[NativeInheritance("IUnknown")]
|
||||
internal unsafe partial struct ID2D1TransformNode
|
||||
{
|
||||
public void** lpVtbl;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,19 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)..\TerraFX.Interop.Windows\DirectX\um\d3d11shader\D3D.cs" Link="DirectX\um\d3d11shader\D3D.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d2d1effectauthor\D2D1_CHANGE_TYPE.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d2d1effectauthor\D2D1_PIXEL_OPTIONS.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d2d1effectauthor\D2D1_PROPERTY_BINDING.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d2d1effectauthor\ID2D1DrawTransform.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d2d1effectauthor\ID2D1EffectContext.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d2d1effectauthor\ID2D1EffectImpl.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d2d1effectauthor\ID2D1Transform.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d2d1effectauthor\ID2D1TransformGraph.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d2d1effectauthor\ID2D1TransformNode.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d2d1_1\D2D1_PROPERTY_TYPE.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d2d1_1\ID2D1DeviceContext.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d2d1_1\ID2D1Effect.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d2d1_1\ID2D1Factory1.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3dcommon\D3D_INCLUDE_TYPE.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3dcommon\D3D_SHADER_MACRO.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3d11shadeer\D3D11_SHADER_DESC.cs" />
|
||||
@@ -33,5 +46,8 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)..\TerraFX.Interop.Windows\Windows\other\helper-types\NativeTypeNameAttribute.cs" Link="Windows\other\helper-types\NativeTypeNameAttribute.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)..\TerraFX.Interop.Windows\Windows\shared\winerror\S.cs" Link="Windows\shared\winerror\S.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)..\TerraFX.Interop.Windows\Windows\other\helper-types\VtblIndexAttribute.cs" Link="Windows\other\helper-types\VtblIndexAttribute.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Windows\shared\windef\RECT.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Windows\shared\winerror\E.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Windows\shared\winerror\Windows.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from shared/windef.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace TerraFX.Interop.Windows
|
||||
{
|
||||
internal struct RECT
|
||||
{
|
||||
[NativeTypeName("LONG")]
|
||||
public int left;
|
||||
|
||||
[NativeTypeName("LONG")]
|
||||
public int top;
|
||||
|
||||
[NativeTypeName("LONG")]
|
||||
public int right;
|
||||
|
||||
[NativeTypeName("LONG")]
|
||||
public int bottom;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from shared/winerror.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
namespace TerraFX.Interop.Windows
|
||||
{
|
||||
internal static class E
|
||||
{
|
||||
[NativeTypeName("#define E_NOTIMPL _HRESULT_TYPEDEF_(0x80004001L)")]
|
||||
public const int E_NOTIMPL = unchecked((int)(0x80004001));
|
||||
|
||||
[NativeTypeName("#define E_INVALIDARG _HRESULT_TYPEDEF_(0x80070057L)")]
|
||||
public const int E_INVALIDARG = unchecked((int)(0x80070057));
|
||||
|
||||
[NativeTypeName("#define E_NOINTERFACE _HRESULT_TYPEDEF_(0x80004002L)")]
|
||||
public const int E_NOINTERFACE = unchecked((int)(0x80004002));
|
||||
|
||||
[NativeTypeName("#define E_POINTER _HRESULT_TYPEDEF_(0x80004003L)")]
|
||||
public const int E_POINTER = unchecked((int)(0x80004003));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from shared/winerror.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
namespace TerraFX.Interop.Windows
|
||||
{
|
||||
internal static partial class Windows
|
||||
{
|
||||
public static bool SUCCEEDED(HRESULT hr)
|
||||
{
|
||||
return hr >= 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする