Pass resource texture info to built-in ID2D1Effect object
このコミットが含まれているのは:
1 親
b2b445d3a8
コミット
4d0549078b
2ファイル変更
+44
-3
検索条件に一致するファイルはありません
@@ -89,6 +89,16 @@ internal unsafe partial struct PixelShaderEffect
|
||||
/// </summary>
|
||||
private static D2D1ChannelDepth channelDepth;
|
||||
|
||||
/// <summary>
|
||||
/// The number of available resource texture descriptions.
|
||||
/// </summary>
|
||||
private static int resourceTextureDescriptionCount;
|
||||
|
||||
/// <summary>
|
||||
/// The buffer with the available resource texture descriptions for the shader.
|
||||
/// </summary>
|
||||
private static D2D1ResourceTextureDescription* resourceTextureDescriptions;
|
||||
|
||||
/// <summary>
|
||||
/// The factory of <see cref="ID2D1TransformMapper{T}"/> instances to use for each created effect.
|
||||
/// </summary>
|
||||
@@ -119,9 +129,6 @@ internal unsafe partial struct PixelShaderEffect
|
||||
{
|
||||
// Load all shader properties
|
||||
Guid shaderId = typeof(T).GUID;
|
||||
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>();
|
||||
D2D1PixelOptions pixelOptions = D2D1PixelShader.GetPixelOptions<T>();
|
||||
@@ -142,7 +149,18 @@ internal unsafe partial struct PixelShaderEffect
|
||||
|
||||
inputDescriptionsInfo.Span.CopyTo(new Span<D2D1InputDescription>(inputDescriptions, inputDescriptionCount));
|
||||
|
||||
// Prepare the resource texture descriptions
|
||||
ReadOnlyMemory<D2D1ResourceTextureDescription> resourceTextureDescriptionsInfo = D2D1PixelShader.GetResourceTextureDescriptions<T>();
|
||||
int resourceTextureDescriptionCount = resourceTextureDescriptionsInfo.Length;
|
||||
D2D1ResourceTextureDescription* resourceTextureDescriptions = (D2D1ResourceTextureDescription*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For<T>), sizeof(D2D1ResourceTextureDescription) * resourceTextureDescriptionCount);
|
||||
|
||||
resourceTextureDescriptionsInfo.Span.CopyTo(new Span<D2D1ResourceTextureDescription>(resourceTextureDescriptions, resourceTextureDescriptionCount));
|
||||
|
||||
// Copy the bytecode to the target buffer
|
||||
ReadOnlyMemory<byte> bytecodeInfo = D2D1PixelShader.LoadBytecode<T>();
|
||||
int bytecodeSize = bytecodeInfo.Length;
|
||||
byte* bytecode = (byte*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For<T>), bytecodeSize);
|
||||
|
||||
bytecodeInfo.Span.CopyTo(new Span<byte>(bytecode, bytecodeSize));
|
||||
|
||||
// Set the shared state and mark the type as initialized
|
||||
@@ -156,6 +174,8 @@ internal unsafe partial struct PixelShaderEffect
|
||||
For<T>.bytecodeSize = bytecodeSize;
|
||||
For<T>.bufferPrecision = bufferPrecision;
|
||||
For<T>.channelDepth = channelDepth;
|
||||
For<T>.resourceTextureDescriptionCount = resourceTextureDescriptionCount;
|
||||
For<T>.resourceTextureDescriptions = resourceTextureDescriptions;
|
||||
For<T>.d2D1DrawTransformMapperFactory = d2D1DrawTransformMapperFactory;
|
||||
|
||||
isInitialized = true;
|
||||
@@ -240,6 +260,8 @@ internal unsafe partial struct PixelShaderEffect
|
||||
bytecodeSize,
|
||||
bufferPrecision,
|
||||
channelDepth,
|
||||
resourceTextureDescriptionCount,
|
||||
resourceTextureDescriptions,
|
||||
d2D1TransformMapper,
|
||||
effectImpl);
|
||||
}
|
||||
|
||||
@@ -181,6 +181,19 @@ internal unsafe partial struct PixelShaderEffect
|
||||
/// </summary>
|
||||
private D2D1ChannelDepth channelDepth;
|
||||
|
||||
/// <summary>
|
||||
/// The number of available resource texture descriptions.
|
||||
/// </summary>
|
||||
private int resourceTextureDescriptionCount;
|
||||
|
||||
/// <summary>
|
||||
/// The buffer with the available resource texture descriptions for the shader.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This buffer is also shared among effect instances, like <see cref="inputDescriptions"/>.
|
||||
/// </remarks>
|
||||
private D2D1ResourceTextureDescription* resourceTextureDescriptions;
|
||||
|
||||
/// <summary>
|
||||
/// The handle for the <see cref="D2D1TransformMapper"/> instance in use, if any.
|
||||
/// </summary>
|
||||
@@ -209,6 +222,8 @@ internal unsafe partial struct PixelShaderEffect
|
||||
/// <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="resourceTextureDescriptionCount">The number of available resource texture descriptions.</param>
|
||||
/// <param name="resourceTextureDescriptions">The buffer with the available resource texture descriptions for the shader.</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>
|
||||
@@ -223,6 +238,8 @@ internal unsafe partial struct PixelShaderEffect
|
||||
int bytecodeSize,
|
||||
D2D1BufferPrecision bufferPrecision,
|
||||
D2D1ChannelDepth channelDepth,
|
||||
int resourceTextureDescriptionCount,
|
||||
D2D1ResourceTextureDescription* resourceTextureDescriptions,
|
||||
D2D1TransformMapper? d2D1TransformMapper,
|
||||
IUnknown** effectImpl)
|
||||
{
|
||||
@@ -254,6 +271,8 @@ internal unsafe partial struct PixelShaderEffect
|
||||
@this->bytecodeSize = bytecodeSize;
|
||||
@this->bufferPrecision = bufferPrecision;
|
||||
@this->channelDepth = channelDepth;
|
||||
@this->resourceTextureDescriptionCount = resourceTextureDescriptionCount;
|
||||
@this->resourceTextureDescriptions = resourceTextureDescriptions;
|
||||
@this->d2D1TransformMapperHandle = GCHandle.Alloc(d2D1TransformMapper);
|
||||
@this->d2D1DrawInfo = null;
|
||||
@this->d2D1EffectContext = null;
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする