Merge pull request #655 from Sergio0694/dev/inline-arrays
Use [InlineArray] where applicable
このコミットが含まれているのは:
6ファイル変更
+21
-306
検索条件に一致するファイルはありません
@@ -1,113 +1,18 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Windows.Graphics.Effects;
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
|
||||
namespace ComputeSharp.D2D1.WinUI.Buffers;
|
||||
|
||||
/// <summary>
|
||||
/// A fixed buffer type containing 16 <see cref="IGraphicsEffectSource"/> fields.
|
||||
/// </summary>
|
||||
[InlineArray(16)]
|
||||
internal struct GraphicsEffectSourceBuffer
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="SourceReference"/> instance at index 0.
|
||||
/// </summary>
|
||||
public SourceReference Source0;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SourceReference"/> instance at index 1.
|
||||
/// </summary>
|
||||
public SourceReference Source1;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SourceReference"/> instance at index 2.
|
||||
/// </summary>
|
||||
public SourceReference Source2;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SourceReference"/> instance at index 3.
|
||||
/// </summary>
|
||||
public SourceReference Source3;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SourceReference"/> instance at index 4.
|
||||
/// </summary>
|
||||
public SourceReference Source4;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SourceReference"/> instance at index 5.
|
||||
/// </summary>
|
||||
public SourceReference Source5;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SourceReference"/> instance at index 6.
|
||||
/// </summary>
|
||||
public SourceReference Source6;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SourceReference"/> instance at index 7.
|
||||
/// </summary>
|
||||
public SourceReference Source7;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SourceReference"/> instance at index 8.
|
||||
/// </summary>
|
||||
public SourceReference Source8;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SourceReference"/> instance at index 9.
|
||||
/// </summary>
|
||||
public SourceReference Source9;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SourceReference"/> instance at index 10.
|
||||
/// </summary>
|
||||
public SourceReference Source10;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SourceReference"/> instance at index 11.
|
||||
/// </summary>
|
||||
public SourceReference Source11;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SourceReference"/> instance at index 12.
|
||||
/// </summary>
|
||||
public SourceReference Source12;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SourceReference"/> instance at index 13.
|
||||
/// </summary>
|
||||
public SourceReference Source13;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SourceReference"/> instance at index 14.
|
||||
/// </summary>
|
||||
public SourceReference Source14;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SourceReference"/> instance at index 15.
|
||||
/// </summary>
|
||||
public SourceReference Source15;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="SourceReference"/> value at a given index.
|
||||
/// </summary>
|
||||
/// <param name="index">The index of the <see cref="SourceReference"/> value to get a reference to.</param>
|
||||
/// <returns>A reference to the <see cref="SourceReference"/> value at a given index.</returns>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="index"/> is not a valid index for the current effect.</exception>
|
||||
[UnscopedRef]
|
||||
public ref SourceReference this[int index]
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, 16);
|
||||
|
||||
ref SourceReference r0 = ref Unsafe.As<GraphicsEffectSourceBuffer, SourceReference>(ref this);
|
||||
ref SourceReference r1 = ref Unsafe.Add(ref r0, index);
|
||||
|
||||
return ref r1;
|
||||
}
|
||||
}
|
||||
private SourceReference source0;
|
||||
}
|
||||
@@ -1,113 +1,18 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
|
||||
#pragma warning disable IDE0044, IDE0051
|
||||
|
||||
namespace ComputeSharp.D2D1.WinUI.Buffers;
|
||||
|
||||
/// <summary>
|
||||
/// A fixed buffer type containing 16 <see cref="D2D1ResourceTextureManager"/> fields.
|
||||
/// </summary>
|
||||
[InlineArray(16)]
|
||||
internal struct ResourceTextureManagerBuffer
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1ResourceTextureManager"/> instance at index 0.
|
||||
/// </summary>
|
||||
public D2D1ResourceTextureManager? ResourceTextureManager0;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1ResourceTextureManager"/> instance at index 1.
|
||||
/// </summary>
|
||||
public D2D1ResourceTextureManager? ResourceTextureManager1;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1ResourceTextureManager"/> instance at index 2.
|
||||
/// </summary>
|
||||
public D2D1ResourceTextureManager? ResourceTextureManager2;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1ResourceTextureManager"/> instance at index 3.
|
||||
/// </summary>
|
||||
public D2D1ResourceTextureManager? ResourceTextureManager3;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1ResourceTextureManager"/> instance at index 4.
|
||||
/// </summary>
|
||||
public D2D1ResourceTextureManager? ResourceTextureManager4;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1ResourceTextureManager"/> instance at index 5.
|
||||
/// </summary>
|
||||
public D2D1ResourceTextureManager? ResourceTextureManager5;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1ResourceTextureManager"/> instance at index 6.
|
||||
/// </summary>
|
||||
public D2D1ResourceTextureManager? ResourceTextureManager6;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1ResourceTextureManager"/> instance at index 7.
|
||||
/// </summary>
|
||||
public D2D1ResourceTextureManager? ResourceTextureManager7;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1ResourceTextureManager"/> instance at index 8.
|
||||
/// </summary>
|
||||
public D2D1ResourceTextureManager? ResourceTextureManager8;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1ResourceTextureManager"/> instance at index 9.
|
||||
/// </summary>
|
||||
public D2D1ResourceTextureManager? ResourceTextureManager9;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1ResourceTextureManager"/> instance at index 10.
|
||||
/// </summary>
|
||||
public D2D1ResourceTextureManager? ResourceTextureManager10;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1ResourceTextureManager"/> instance at index 11.
|
||||
/// </summary>
|
||||
public D2D1ResourceTextureManager? ResourceTextureManager11;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1ResourceTextureManager"/> instance at index 12.
|
||||
/// </summary>
|
||||
public D2D1ResourceTextureManager? ResourceTextureManager12;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1ResourceTextureManager"/> instance at index 13.
|
||||
/// </summary>
|
||||
public D2D1ResourceTextureManager? ResourceTextureManager13;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1ResourceTextureManager"/> instance at index 14.
|
||||
/// </summary>
|
||||
public D2D1ResourceTextureManager? ResourceTextureManager14;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D2D1ResourceTextureManager"/> instance at index 15.
|
||||
/// </summary>
|
||||
public D2D1ResourceTextureManager? ResourceTextureManager15;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="D2D1ResourceTextureManager"/> value at a given index.
|
||||
/// </summary>
|
||||
/// <param name="index">The index of the <see cref="D2D1ResourceTextureManager"/> value to get a reference to.</param>
|
||||
/// <returns>A reference to the <see cref="D2D1ResourceTextureManager"/> value at a given index.</returns>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="index"/> is not a valid index for the current effect.</exception>
|
||||
[UnscopedRef]
|
||||
public ref D2D1ResourceTextureManager? this[int index]
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, 16);
|
||||
|
||||
ref D2D1ResourceTextureManager? r0 = ref Unsafe.As<ResourceTextureManagerBuffer, D2D1ResourceTextureManager?>(ref this);
|
||||
ref D2D1ResourceTextureManager? r1 = ref Unsafe.Add(ref r0, index);
|
||||
|
||||
return ref r1;
|
||||
}
|
||||
}
|
||||
private D2D1ResourceTextureManager? resourceTextureManager0;
|
||||
}
|
||||
+1
-1
@@ -108,7 +108,7 @@ internal unsafe partial struct PixelShaderEffect
|
||||
|
||||
for (int i = 0; i < resourceTextureDescriptions.Length; i++)
|
||||
{
|
||||
using ComPtr<ID2D1ResourceTextureManager> resourceTextureManager = new(@this->resourceTextureManagerBuffer[i]);
|
||||
ref readonly ComPtr<ID2D1ResourceTextureManager> resourceTextureManager = ref @this->resourceTextureManagerBuffer[i];
|
||||
|
||||
// If the current resource texture manager is not set, we cannot render, as there's an unbound resource texture
|
||||
if (resourceTextureManager.Get() is null)
|
||||
|
||||
@@ -180,9 +180,7 @@ unsafe partial struct PixelShaderEffect
|
||||
default(ArgumentOutOfRangeException).ThrowIfLessThan((int)dataSize, sizeof(void*), nameof(dataSize));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThanOrEqual(index, GetGlobals().ResourceTextureCount);
|
||||
|
||||
using ComPtr<ID2D1ResourceTextureManager> resourceTextureManager = new(this.resourceTextureManagerBuffer[index]);
|
||||
|
||||
resourceTextureManager.CopyTo((ID2D1ResourceTextureManager**)data).Assert();
|
||||
this.resourceTextureManagerBuffer[index].CopyTo((ID2D1ResourceTextureManager**)data).Assert();
|
||||
|
||||
if (actualSize is not null)
|
||||
{
|
||||
@@ -240,13 +238,8 @@ unsafe partial struct PixelShaderEffect
|
||||
resourceTextureManagerInternal.Get()->Initialize(this.d2D1EffectContext, &dimensions).Assert();
|
||||
}
|
||||
|
||||
ref ID2D1ResourceTextureManager* currentResourceTextureManager = ref this.resourceTextureManagerBuffer[index];
|
||||
|
||||
// If there's already an existing manager at this index, release it
|
||||
ComPtr.Dispose(currentResourceTextureManager);
|
||||
|
||||
// Store the resource texture manager into the buffer
|
||||
currentResourceTextureManager = resourceTextureManager.Detach();
|
||||
this.resourceTextureManagerBuffer[index].Attach(resourceTextureManager.Detach());
|
||||
|
||||
return S.S_OK;
|
||||
}
|
||||
|
||||
+5
-94
@@ -1,7 +1,8 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Effects.ResourceManagers;
|
||||
using ComputeSharp.Win32;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable IDE0051
|
||||
|
||||
namespace ComputeSharp.D2D1.Interop.Effects;
|
||||
|
||||
@@ -11,102 +12,12 @@ partial struct PixelShaderEffect
|
||||
/// <summary>
|
||||
/// A buffer of 16 <see cref="ID2D1ResourceTextureManager"/> objects.
|
||||
/// </summary>
|
||||
[InlineArray(16)]
|
||||
private unsafe struct ResourceTextureManagerBuffer
|
||||
{
|
||||
/// <summary>
|
||||
/// The pointer to the <see cref="ID2D1ResourceTextureManager"/> instance at index 0.
|
||||
/// The <see cref="ID2D1ResourceTextureManager"/> instance at index 0.
|
||||
/// </summary>
|
||||
public ID2D1ResourceTextureManager* ResourceTextureManager0;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the <see cref="ID2D1ResourceTextureManager"/> instance at index 1.
|
||||
/// </summary>
|
||||
public ID2D1ResourceTextureManager* ResourceTextureManager1;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the <see cref="ID2D1ResourceTextureManager"/> instance at index 2.
|
||||
/// </summary>
|
||||
public ID2D1ResourceTextureManager* ResourceTextureManager2;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the <see cref="ID2D1ResourceTextureManager"/> instance at index 3.
|
||||
/// </summary>
|
||||
public ID2D1ResourceTextureManager* ResourceTextureManager3;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the <see cref="ID2D1ResourceTextureManager"/> instance at index 4.
|
||||
/// </summary>
|
||||
public ID2D1ResourceTextureManager* ResourceTextureManager4;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the <see cref="ID2D1ResourceTextureManager"/> instance at index 5.
|
||||
/// </summary>
|
||||
public ID2D1ResourceTextureManager* ResourceTextureManager5;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the <see cref="ID2D1ResourceTextureManager"/> instance at index 6.
|
||||
/// </summary>
|
||||
public ID2D1ResourceTextureManager* ResourceTextureManager6;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the <see cref="ID2D1ResourceTextureManager"/> instance at index 7.
|
||||
/// </summary>
|
||||
public ID2D1ResourceTextureManager* ResourceTextureManager7;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the <see cref="ID2D1ResourceTextureManager"/> instance at index 8.
|
||||
/// </summary>
|
||||
public ID2D1ResourceTextureManager* ResourceTextureManager8;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the <see cref="ID2D1ResourceTextureManager"/> instance at index 9.
|
||||
/// </summary>
|
||||
public ID2D1ResourceTextureManager* ResourceTextureManager9;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the <see cref="ID2D1ResourceTextureManager"/> instance at index 10.
|
||||
/// </summary>
|
||||
public ID2D1ResourceTextureManager* ResourceTextureManager10;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the <see cref="ID2D1ResourceTextureManager"/> instance at index 11.
|
||||
/// </summary>
|
||||
public ID2D1ResourceTextureManager* ResourceTextureManager11;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the <see cref="ID2D1ResourceTextureManager"/> instance at index 12.
|
||||
/// </summary>
|
||||
public ID2D1ResourceTextureManager* ResourceTextureManager12;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the <see cref="ID2D1ResourceTextureManager"/> instance at index 13.
|
||||
/// </summary>
|
||||
public ID2D1ResourceTextureManager* ResourceTextureManager13;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the <see cref="ID2D1ResourceTextureManager"/> instance at index 14.
|
||||
/// </summary>
|
||||
public ID2D1ResourceTextureManager* ResourceTextureManager14;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the <see cref="ID2D1ResourceTextureManager"/> instance at index 15.
|
||||
/// </summary>
|
||||
public ID2D1ResourceTextureManager* ResourceTextureManager15;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see langword="ref"/> to the <see cref="ID2D1ResourceTextureManager"/> pointer at a given index.
|
||||
/// </summary>
|
||||
/// <param name="index">The index of the instance to retrieve.</param>
|
||||
/// <returns>A <see langword="ref"/> to the <see cref="ID2D1ResourceTextureManager"/> pointer at a given index.</returns>
|
||||
public ref ID2D1ResourceTextureManager* this[int index]
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
ID2D1ResourceTextureManager** @this = (ID2D1ResourceTextureManager**)Unsafe.AsPointer(ref this);
|
||||
|
||||
return ref @this[index];
|
||||
}
|
||||
}
|
||||
private ComPtr<ID2D1ResourceTextureManager> resourceTextureManager0;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Effects.ResourceManagers;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers;
|
||||
using ComputeSharp.Win32;
|
||||
|
||||
@@ -201,11 +202,11 @@ internal unsafe partial struct PixelShaderEffect
|
||||
ComPtr.Dispose(this.d2D1EffectContext);
|
||||
|
||||
// Retrieve all possible resource texture managers in use and release the ones that had been
|
||||
// assigned (from one of the property bindings). We just hardcode 16 here and dont access
|
||||
// the globals, as technically invoking APIs on it might throw an exception.
|
||||
for (int i = 0; i < 16; i++)
|
||||
// assigned (from one of the property bindings). We just try to dispose all of them here and
|
||||
// don't access the globals, as technically invoking APIs on it might throw an exception.
|
||||
foreach (ref ComPtr<ID2D1ResourceTextureManager> resourceTextureManager in (Span<ComPtr<ID2D1ResourceTextureManager>>)this.resourceTextureManagerBuffer)
|
||||
{
|
||||
ComPtr.Dispose(this.resourceTextureManagerBuffer[i]);
|
||||
resourceTextureManager.Dispose();
|
||||
}
|
||||
|
||||
NativeMemory.Free(Unsafe.AsPointer(ref this));
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする