Enable output buffer configuration in D2D1PixelShaderEffect
このコミットが含まれているのは:
1 親
e292eb6d9d
コミット
966f5ee06d
8ファイル変更
+95
-4
検索条件に一致するファイルはありません
@@ -12,15 +12,15 @@ public enum D2D1ChannelDepth
|
||||
/// <summary>
|
||||
/// The channel depth is the default, and it will be inherited by the inputs.
|
||||
/// </summary>
|
||||
Default,
|
||||
Default = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The channel depth is 1.
|
||||
/// </summary>
|
||||
One,
|
||||
One = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The channel depth is 4.
|
||||
/// </summary>
|
||||
Four
|
||||
Four = 4
|
||||
}
|
||||
@@ -64,6 +64,16 @@ internal unsafe partial struct PixelShaderEffect
|
||||
/// </summary>
|
||||
private static int bytecodeSize;
|
||||
|
||||
/// <summary>
|
||||
/// The buffer precision for the resulting output buffer.
|
||||
/// </summary>
|
||||
private static D2D1BufferPrecision bufferPrecision;
|
||||
|
||||
/// <summary>
|
||||
/// The channel depth for the resulting output buffer.
|
||||
/// </summary>
|
||||
private static D2D1ChannelDepth channelDepth;
|
||||
|
||||
/// <summary>
|
||||
/// The factory of <see cref="ID2D1TransformMapper{T}"/> instances to use for each created effect.
|
||||
/// </summary>
|
||||
@@ -97,6 +107,8 @@ internal unsafe partial struct PixelShaderEffect
|
||||
ReadOnlyMemory<byte> buffer = D2D1PixelShader.LoadBytecode<T>();
|
||||
int bytecodeSize = buffer.Length;
|
||||
byte* bytecode = (byte*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For<T>), bytecodeSize);
|
||||
D2D1BufferPrecision bufferPrecision = D2D1PixelShader.GetOutputBufferPrecision<T>();
|
||||
D2D1ChannelDepth channelDepth = D2D1PixelShader.GetOutputBufferChannelDepth<T>();
|
||||
|
||||
// Prepare the inputs info
|
||||
int inputCount = D2D1PixelShader.GetInputCount<T>();
|
||||
@@ -116,6 +128,8 @@ internal unsafe partial struct PixelShaderEffect
|
||||
For<T>.inputTypes = inputTypes;
|
||||
For<T>.bytecode = bytecode;
|
||||
For<T>.bytecodeSize = bytecodeSize;
|
||||
For<T>.bufferPrecision = bufferPrecision;
|
||||
For<T>.channelDepth = channelDepth;
|
||||
For<T>.d2D1DrawTransformMapperFactory = d2D1DrawTransformMapperFactory;
|
||||
|
||||
isInitialized = true;
|
||||
@@ -195,6 +209,8 @@ internal unsafe partial struct PixelShaderEffect
|
||||
inputTypes,
|
||||
bytecode,
|
||||
bytecodeSize,
|
||||
bufferPrecision,
|
||||
channelDepth,
|
||||
d2D1TransformMapper,
|
||||
effectImpl);
|
||||
}
|
||||
|
||||
+18
-1
@@ -323,7 +323,24 @@ partial struct PixelShaderEffect
|
||||
|
||||
@this->d2D1DrawInfo = drawInfo;
|
||||
|
||||
return drawInfo->SetPixelShader(&@this->shaderId);
|
||||
// Set the pixel shader for the effect
|
||||
HRESULT hresult = drawInfo->SetPixelShader(&@this->shaderId);
|
||||
|
||||
if (hresult != S.S_OK)
|
||||
{
|
||||
return hresult;
|
||||
}
|
||||
|
||||
// If a custom buffer precision or channel depth is requested, set it
|
||||
if (@this->bufferPrecision != D2D1BufferPrecision.Unknown ||
|
||||
@this->channelDepth != D2D1ChannelDepth.Default)
|
||||
{
|
||||
return drawInfo->SetOutputBuffer(
|
||||
(D2D1_BUFFER_PRECISION)@this->bufferPrecision,
|
||||
(D2D1_CHANNEL_DEPTH)@this->channelDepth);
|
||||
}
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,6 +171,16 @@ internal unsafe partial struct PixelShaderEffect
|
||||
/// </summary>
|
||||
private int bytecodeSize;
|
||||
|
||||
/// <summary>
|
||||
/// The buffer precision for the resulting output buffer.
|
||||
/// </summary>
|
||||
private D2D1BufferPrecision bufferPrecision;
|
||||
|
||||
/// <summary>
|
||||
/// The channel depth for the resulting output buffer.
|
||||
/// </summary>
|
||||
private D2D1ChannelDepth channelDepth;
|
||||
|
||||
/// <summary>
|
||||
/// The handle for the <see cref="D2D1TransformMapper"/> instance in use, if any.
|
||||
/// </summary>
|
||||
@@ -189,6 +199,8 @@ internal unsafe partial struct PixelShaderEffect
|
||||
/// <param name="inputTypes">The buffer with the types of inputs for the shader.</param>
|
||||
/// <param name="bytecode">The shader bytecode.</param>
|
||||
/// <param name="bytecodeSize">The size of <paramref name="bytecode"/>.</param>
|
||||
/// <param name="bufferPrecision">The buffer precision for the resulting output buffer.</param>
|
||||
/// <param name="channelDepth">The channel depth for the resulting output buffer.</param>
|
||||
/// <param name="d2D1TransformMapper">The <see cref="D2D1TransformMapper"/> instance to use for the effect.</param>
|
||||
/// <param name="effectImpl">The resulting effect instance.</param>
|
||||
/// <returns>This always returns <c>0</c>.</returns>
|
||||
@@ -198,6 +210,8 @@ internal unsafe partial struct PixelShaderEffect
|
||||
D2D1PixelShaderInputType* inputTypes,
|
||||
byte* bytecode,
|
||||
int bytecodeSize,
|
||||
D2D1BufferPrecision bufferPrecision,
|
||||
D2D1ChannelDepth channelDepth,
|
||||
D2D1TransformMapper? d2D1TransformMapper,
|
||||
IUnknown** effectImpl)
|
||||
{
|
||||
@@ -213,6 +227,8 @@ internal unsafe partial struct PixelShaderEffect
|
||||
@this->inputTypes = inputTypes;
|
||||
@this->bytecode = bytecode;
|
||||
@this->bytecodeSize = bytecodeSize;
|
||||
@this->bufferPrecision = bufferPrecision;
|
||||
@this->channelDepth = channelDepth;
|
||||
@this->d2D1TransformMapperHandle = GCHandle.Alloc(d2D1TransformMapper);
|
||||
|
||||
*effectImpl = (IUnknown*)@this;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// 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_BUFFER_PRECISION : uint
|
||||
{
|
||||
D2D1_BUFFER_PRECISION_UNKNOWN = 0,
|
||||
D2D1_BUFFER_PRECISION_8BPC_UNORM = 1,
|
||||
D2D1_BUFFER_PRECISION_8BPC_UNORM_SRGB = 2,
|
||||
D2D1_BUFFER_PRECISION_16BPC_UNORM = 3,
|
||||
D2D1_BUFFER_PRECISION_16BPC_FLOAT = 4,
|
||||
D2D1_BUFFER_PRECISION_32BPC_FLOAT = 5,
|
||||
D2D1_BUFFER_PRECISION_FORCE_DWORD = 0xffffffff
|
||||
}
|
||||
}
|
||||
@@ -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 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_CHANNEL_DEPTH : uint
|
||||
{
|
||||
D2D1_CHANNEL_DEPTH_DEFAULT = 0,
|
||||
D2D1_CHANNEL_DEPTH_1 = 1,
|
||||
D2D1_CHANNEL_DEPTH_4 = 4,
|
||||
D2D1_CHANNEL_DEPTH_FORCE_DWORD = 0xffffffff
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,13 @@ namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
public void** lpVtbl;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(4)]
|
||||
public HRESULT SetOutputBuffer(D2D1_BUFFER_PRECISION bufferPrecision, D2D1_CHANNEL_DEPTH channelDepth)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1DrawInfo*, D2D1_BUFFER_PRECISION, D2D1_CHANNEL_DEPTH, int>)(lpVtbl[4]))((ID2D1DrawInfo*)Unsafe.AsPointer(ref this), bufferPrecision, channelDepth);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(7)]
|
||||
public HRESULT SetPixelShaderConstantBuffer([NativeTypeName("const BYTE *")] byte* buffer, [NativeTypeName("UINT32")] uint bufferCount)
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
<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_CHANNEL_DEPTH.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d2d1_1\D2D1_BUFFER_PRECISION.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" />
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする