Enable input descriptions info in D2D1PixelShaderEffect
このコミットが含まれているのは:
1 親
ecae463892
コミット
69448a8d34
6ファイル変更
+93
-4
検索条件に一致するファイルはありません
@@ -54,6 +54,16 @@ internal unsafe partial struct PixelShaderEffect
|
||||
/// </summary>
|
||||
private static D2D1PixelShaderInputType* inputTypes;
|
||||
|
||||
/// <summary>
|
||||
/// The number of available input descriptions.
|
||||
/// </summary>
|
||||
private static int inputDescriptionCount;
|
||||
|
||||
/// <summary>
|
||||
/// The buffer with the available input descriptions for the shader.
|
||||
/// </summary>
|
||||
private static D2D1InputDescription* inputDescriptions;
|
||||
|
||||
/// <summary>
|
||||
/// The shader bytecode.
|
||||
/// </summary>
|
||||
@@ -104,8 +114,8 @@ internal unsafe partial struct PixelShaderEffect
|
||||
{
|
||||
// Load all shader properties
|
||||
Guid shaderId = typeof(T).GUID;
|
||||
ReadOnlyMemory<byte> buffer = D2D1PixelShader.LoadBytecode<T>();
|
||||
int bytecodeSize = buffer.Length;
|
||||
ReadOnlyMemory<byte> bytecodeInfo = D2D1PixelShader.LoadBytecode<T>();
|
||||
int bytecodeSize = bytecodeInfo.Length;
|
||||
byte* bytecode = (byte*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For<T>), bytecodeSize);
|
||||
D2D1BufferPrecision bufferPrecision = D2D1PixelShader.GetOutputBufferPrecision<T>();
|
||||
D2D1ChannelDepth channelDepth = D2D1PixelShader.GetOutputBufferChannelDepth<T>();
|
||||
@@ -119,13 +129,22 @@ internal unsafe partial struct PixelShaderEffect
|
||||
inputTypes[i] = D2D1PixelShader.GetInputType<T>(i);
|
||||
}
|
||||
|
||||
// Prepare the input descriptions
|
||||
ReadOnlyMemory<D2D1InputDescription> inputDescriptionsInfo = D2D1PixelShader.GetInputDescriptions<T>();
|
||||
int inputDescriptionCount = inputDescriptionsInfo.Length;
|
||||
D2D1InputDescription* inputDescriptions = (D2D1InputDescription*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For<T>), inputDescriptionCount);
|
||||
|
||||
inputDescriptionsInfo.Span.CopyTo(new Span<D2D1InputDescription>(inputDescriptions, inputDescriptionCount));
|
||||
|
||||
// Copy the bytecode to the target buffer
|
||||
buffer.Span.CopyTo(new Span<byte>(bytecode, bytecodeSize));
|
||||
bytecodeInfo.Span.CopyTo(new Span<byte>(bytecode, bytecodeSize));
|
||||
|
||||
// Set the shared state and mark the type as initialized
|
||||
For<T>.shaderId = shaderId;
|
||||
For<T>.inputCount = inputCount;
|
||||
For<T>.inputTypes = inputTypes;
|
||||
For<T>.inputDescriptionCount = inputDescriptionCount;
|
||||
For<T>.inputDescriptions = inputDescriptions;
|
||||
For<T>.bytecode = bytecode;
|
||||
For<T>.bytecodeSize = bytecodeSize;
|
||||
For<T>.bufferPrecision = bufferPrecision;
|
||||
@@ -207,6 +226,8 @@ internal unsafe partial struct PixelShaderEffect
|
||||
shaderId,
|
||||
inputCount,
|
||||
inputTypes,
|
||||
inputDescriptionCount,
|
||||
inputDescriptions,
|
||||
bytecode,
|
||||
bytecodeSize,
|
||||
bufferPrecision,
|
||||
|
||||
+26
-1
@@ -331,13 +331,38 @@ partial struct PixelShaderEffect
|
||||
return hresult;
|
||||
}
|
||||
|
||||
// If any input descriptions are present, set them
|
||||
if (@this->inputDescriptionCount > 0)
|
||||
{
|
||||
for (int i = 0; i < @this->inputDescriptionCount; i++)
|
||||
{
|
||||
ref D2D1InputDescription inputDescription = ref @this->inputDescriptions[i];
|
||||
|
||||
D2D1_INPUT_DESCRIPTION d2D1InputDescription;
|
||||
d2D1InputDescription.filter = (D2D1_FILTER)inputDescription.Filter;
|
||||
d2D1InputDescription.levelOfDetailCount = (uint)inputDescription.LevelOfDetail;
|
||||
|
||||
hresult = drawInfo->SetInputDescription((uint)inputDescription.Index, d2D1InputDescription);
|
||||
|
||||
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(
|
||||
hresult = drawInfo->SetOutputBuffer(
|
||||
(D2D1_BUFFER_PRECISION)@this->bufferPrecision,
|
||||
(D2D1_CHANNEL_DEPTH)@this->channelDepth);
|
||||
|
||||
if (hresult != S.S_OK)
|
||||
{
|
||||
return hresult;
|
||||
}
|
||||
}
|
||||
|
||||
return S.S_OK;
|
||||
|
||||
@@ -161,6 +161,20 @@ internal unsafe partial struct PixelShaderEffect
|
||||
/// </remarks>
|
||||
private D2D1PixelShaderInputType* inputTypes;
|
||||
|
||||
/// <summary>
|
||||
/// The number of available input descriptions.
|
||||
/// </summary>
|
||||
private int inputDescriptionCount;
|
||||
|
||||
/// <summary>
|
||||
/// The buffer with the available input descriptions for the shader.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This buffer is also shared among effect instances, so it should not be released. It is
|
||||
/// owned by <see cref="For{T}"/>, which will release it when the target type is unloaded.
|
||||
/// </remarks>
|
||||
private D2D1InputDescription* inputDescriptions;
|
||||
|
||||
/// <summary>
|
||||
/// The shader bytecode.
|
||||
/// </summary>
|
||||
@@ -197,6 +211,8 @@ internal unsafe partial struct PixelShaderEffect
|
||||
/// <param name="shaderId">The <see cref="Guid"/> for the shader.</param>
|
||||
/// <param name="inputCount">The number of inputs for the shader.</param>
|
||||
/// <param name="inputTypes">The buffer with the types of inputs for the shader.</param>
|
||||
/// <param name="inputDescriptionCount">The number of available input descriptions.</param>
|
||||
/// <param name="inputDescriptions">The buffer with the available input descriptions 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>
|
||||
@@ -208,6 +224,8 @@ internal unsafe partial struct PixelShaderEffect
|
||||
Guid shaderId,
|
||||
int inputCount,
|
||||
D2D1PixelShaderInputType* inputTypes,
|
||||
int inputDescriptionCount,
|
||||
D2D1InputDescription* inputDescriptions,
|
||||
byte* bytecode,
|
||||
int bytecodeSize,
|
||||
D2D1BufferPrecision bufferPrecision,
|
||||
@@ -225,6 +243,8 @@ internal unsafe partial struct PixelShaderEffect
|
||||
@this->shaderId = shaderId;
|
||||
@this->inputCount = inputCount;
|
||||
@this->inputTypes = inputTypes;
|
||||
@this->inputDescriptionCount = inputDescriptionCount;
|
||||
@this->inputDescriptions = inputDescriptions;
|
||||
@this->bytecode = bytecode;
|
||||
@this->bytecodeSize = bytecodeSize;
|
||||
@this->bufferPrecision = bufferPrecision;
|
||||
|
||||
@@ -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/d2d1effectauthor.h in the Windows SDK for Windows 10.0.22000.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
internal partial struct D2D1_INPUT_DESCRIPTION
|
||||
{
|
||||
public D2D1_FILTER filter;
|
||||
|
||||
[NativeTypeName("UINT32")]
|
||||
public uint levelOfDetailCount;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,13 @@ namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
public void** lpVtbl;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(3)]
|
||||
public HRESULT SetInputDescription([NativeTypeName("UINT32")] uint inputIndex, D2D1_INPUT_DESCRIPTION inputDescription)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID2D1DrawInfo*, uint, D2D1_INPUT_DESCRIPTION, int>)(lpVtbl[3]))((ID2D1DrawInfo*)Unsafe.AsPointer(ref this), inputIndex, inputDescription);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(4)]
|
||||
public HRESULT SetOutputBuffer(D2D1_BUFFER_PRECISION bufferPrecision, D2D1_CHANNEL_DEPTH channelDepth)
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d2d1effectauthor\D2D1_FILTER.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\D2D1_INPUT_DESCRIPTION.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" />
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする