Update ComputeSharp.D2D1.UI code for new APIs
このコミットが含まれているのは:
1 親
76ae699797
コミット
070990d4d4
4ファイル変更
+22
-107
検索条件に一致するファイルはありません
@@ -37,8 +37,6 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\IUnknownExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\RcwMarshaller.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\ResourceManager.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Loaders\D2D1ImmutableArrayResourceTextureDescriptionsLoader.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Loaders\D2D1IndexBitmaskResourceTextureDescriptionsLoader.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)PixelShaderEffect{T}.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)PixelShaderEffect{T}.ICanvasEffect.cs" />
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.D2D1.__Internals;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp.D2D1.Shaders.Loaders;
|
||||
|
||||
/// <summary>
|
||||
/// A resource texture index array loader for D2D1 pixel shaders.
|
||||
/// </summary>
|
||||
internal struct D2D1ImmutableArrayResourceTextureDescriptionsLoader : ID2D1ResourceTextureDescriptionsLoader
|
||||
{
|
||||
/// <summary>
|
||||
/// The array of indices for resource textures for the current effect.
|
||||
/// </summary>
|
||||
private ImmutableArray<int> indices;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the resulting array of indices for resource textures for the current effect.
|
||||
/// </summary>
|
||||
/// <returns>An array of indices for resource textures for the current effect.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly ImmutableArray<int> GetResultingIndices()
|
||||
{
|
||||
return this.indices;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void ID2D1ResourceTextureDescriptionsLoader.LoadResourceTextureDescriptions(ReadOnlySpan<byte> data)
|
||||
{
|
||||
if (data.IsEmpty)
|
||||
{
|
||||
this.indices = ImmutableArray<int>.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadOnlySpan<D2D1ResourceTextureDescription> descriptions = MemoryMarshal.Cast<byte, D2D1ResourceTextureDescription>(data);
|
||||
|
||||
int[] indices = new int[descriptions.Length];
|
||||
|
||||
for (int i = 0; i < descriptions.Length; i++)
|
||||
{
|
||||
indices[i] = descriptions[i].Index;
|
||||
}
|
||||
|
||||
this.indices = Unsafe.As<int[], ImmutableArray<int>>(ref indices);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.D2D1.__Internals;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp.D2D1.Shaders.Loaders;
|
||||
|
||||
/// <summary>
|
||||
/// A resource texture index bitmask loader for D2D1 pixel shaders.
|
||||
/// </summary>
|
||||
internal struct D2D1IndexBitmaskResourceTextureDescriptionsLoader : ID2D1ResourceTextureDescriptionsLoader
|
||||
{
|
||||
/// <summary>
|
||||
/// The bitmask of indices for resource textures in the target shader.
|
||||
/// </summary>
|
||||
private int indexBitmask;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the resulting bitmask of indices for resource textures in the target shader.
|
||||
/// </summary>
|
||||
/// <returns>A bitmask of indices for resource textures in the target shader.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly int GetResultingIndexBitmask()
|
||||
{
|
||||
return this.indexBitmask;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void ID2D1ResourceTextureDescriptionsLoader.LoadResourceTextureDescriptions(ReadOnlySpan<byte> data)
|
||||
{
|
||||
int indexBitmask = 0;
|
||||
|
||||
foreach (ref readonly D2D1ResourceTextureDescription description in MemoryMarshal.Cast<byte, D2D1ResourceTextureDescription>(data))
|
||||
{
|
||||
indexBitmask |= 1 << description.Index;
|
||||
}
|
||||
|
||||
this.indexBitmask = indexBitmask;
|
||||
}
|
||||
}
|
||||
+22
-9
@@ -5,7 +5,6 @@ using System.Collections.Immutable;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
using ComputeSharp.D2D1.Shaders.Loaders;
|
||||
#if WINDOWS_UWP
|
||||
using ComputeSharp.D2D1.Uwp.Buffers;
|
||||
using ComputeSharp.D2D1.Uwp.Collections;
|
||||
@@ -233,13 +232,16 @@ partial class PixelShaderEffect<T>
|
||||
/// <returns>The bitmask of indices for resource textures in the target shader.</returns>
|
||||
private static int GetIndexBitmask()
|
||||
{
|
||||
D2D1IndexBitmaskResourceTextureDescriptionsLoader bitmaskLoader = default;
|
||||
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
shader.LoadResourceTextureDescriptions(ref bitmaskLoader);
|
||||
int indexBitmask = 0;
|
||||
|
||||
return bitmaskLoader.GetResultingIndexBitmask();
|
||||
foreach (ref readonly D2D1ResourceTextureDescription description in shader.ResourceTextureDescriptions.Span)
|
||||
{
|
||||
indexBitmask |= 1 << description.Index;
|
||||
}
|
||||
|
||||
return indexBitmask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -248,13 +250,24 @@ partial class PixelShaderEffect<T>
|
||||
/// <returns>The collection of valid indices for the current effect.</returns>
|
||||
private static ImmutableArray<int> GetIndices()
|
||||
{
|
||||
D2D1ImmutableArrayResourceTextureDescriptionsLoader indicesLoader = default;
|
||||
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
shader.LoadResourceTextureDescriptions(ref indicesLoader);
|
||||
ReadOnlySpan<D2D1ResourceTextureDescription> descriptions = shader.ResourceTextureDescriptions.Span;
|
||||
|
||||
return indicesLoader.GetResultingIndices();
|
||||
// Skip the array allocation if there are no resource texture descriptions
|
||||
if (descriptions.IsEmpty)
|
||||
{
|
||||
return ImmutableArray<int>.Empty;
|
||||
}
|
||||
|
||||
int[] indices = new int[descriptions.Length];
|
||||
|
||||
for (int i = 0; i < descriptions.Length; i++)
|
||||
{
|
||||
indices[i] = descriptions[i].Index;
|
||||
}
|
||||
|
||||
return Unsafe.As<int[], ImmutableArray<int>>(ref indices);
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする