Adopt static abstracts in ComputeSharp.D2D1 (and WinUI)
このコミットが含まれているのは:
1 親
167041bee0
コミット
786efaf38f
24ファイル変更
+100
-151
検索条件に一致するファイルはありません
@@ -25,7 +25,7 @@ internal static unsafe class ID2D1EffectExtensions
|
||||
public static T GetConstantBuffer<T>(this ref ID2D1Effect d2D1Effect)
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
int constantBufferSize = D2D1PixelShader.GetConstantBufferSize<T>();
|
||||
int constantBufferSize = T.ConstantBufferSize;
|
||||
|
||||
// Special cases the constant buffer type being empty. If that's the case, there is no
|
||||
// need to try to retrieve the constant buffer from the underlying effect anyway, and
|
||||
@@ -67,7 +67,7 @@ internal static unsafe class ID2D1EffectExtensions
|
||||
// avoid crashing when someone's just setting an empty constant buffer, which is
|
||||
// unnecessary but still valid (eg. a stateless shader). This could be the case if
|
||||
// someone was eg. binding or using some other automated system to set constant buffer.
|
||||
if (D2D1PixelShader.GetConstantBufferSize<T>() == 0)
|
||||
if (T.ConstantBufferSize == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ABI.Microsoft.Graphics.Canvas;
|
||||
using ComputeSharp.D2D1.Extensions;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
using ComputeSharp.D2D1.WinUI.Extensions;
|
||||
using ComputeSharp.D2D1.WinUI.Helpers;
|
||||
using ComputeSharp.Win32;
|
||||
@@ -63,7 +62,7 @@ unsafe partial class PixelShaderEffect<T>
|
||||
if (!this.isEffectFactoryRegistered)
|
||||
{
|
||||
ResourceManager.RegisterEffectFactory(
|
||||
effectId: D2D1PixelShaderEffect.GetEffectId<T>(),
|
||||
effectId: T.EffectId,
|
||||
factory: new EffectFactory());
|
||||
|
||||
this.isEffectFactoryRegistered = true;
|
||||
|
||||
@@ -250,7 +250,7 @@ unsafe partial class PixelShaderEffect<T>
|
||||
{
|
||||
fixed (ID2D1Effect** d2D1Effect = this.d2D1Effect)
|
||||
{
|
||||
Guid effectId = D2D1PixelShaderEffect.GetEffectId<T>();
|
||||
Guid effectId = T.EffectId;
|
||||
|
||||
using ComPtr<ID2D1DeviceContext> d2D1DeviceContextEffective = default;
|
||||
using ComPtr<ID2D1DeviceContextLease> d2D1DeviceContextLease = default;
|
||||
|
||||
+2
-6
@@ -223,11 +223,9 @@ partial class PixelShaderEffect<T>
|
||||
/// <returns>The bitmask of indices for resource textures in the target shader.</returns>
|
||||
private static int GetIndexBitmask()
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
int indexBitmask = 0;
|
||||
|
||||
foreach (ref readonly D2D1ResourceTextureDescription description in shader.ResourceTextureDescriptions.Span)
|
||||
foreach (ref readonly D2D1ResourceTextureDescription description in T.ResourceTextureDescriptions.Span)
|
||||
{
|
||||
indexBitmask |= 1 << description.Index;
|
||||
}
|
||||
@@ -241,9 +239,7 @@ partial class PixelShaderEffect<T>
|
||||
/// <returns>The collection of valid indices for the current effect.</returns>
|
||||
private static ImmutableArray<int> GetIndices()
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
ReadOnlySpan<D2D1ResourceTextureDescription> descriptions = shader.ResourceTextureDescriptions.Span;
|
||||
ReadOnlySpan<D2D1ResourceTextureDescription> descriptions = T.ResourceTextureDescriptions.Span;
|
||||
|
||||
// Skip the array allocation if there are no resource texture descriptions
|
||||
if (descriptions.IsEmpty)
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
using ComputeSharp.D2D1.WinUI.Buffers;
|
||||
using ComputeSharp.D2D1.WinUI.Collections;
|
||||
using Windows.Graphics.Effects;
|
||||
@@ -41,7 +40,7 @@ partial class PixelShaderEffect<T>
|
||||
public int Count
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => D2D1PixelShader.GetInputCount<T>();
|
||||
get => T.InputCount;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -49,13 +48,13 @@ partial class PixelShaderEffect<T>
|
||||
{
|
||||
get
|
||||
{
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, D2D1PixelShader.GetInputCount<T>(), nameof(index));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, T.InputCount, nameof(index));
|
||||
|
||||
return Owner.GetSource(index);
|
||||
}
|
||||
set
|
||||
{
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, D2D1PixelShader.GetInputCount<T>(), nameof(index));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, T.InputCount, nameof(index));
|
||||
|
||||
Owner.SetSource(value, index);
|
||||
}
|
||||
@@ -210,7 +209,7 @@ partial class PixelShaderEffect<T>
|
||||
/// <returns>The collection of valid indices for the current effect.</returns>
|
||||
private static ImmutableArray<int> GetIndices()
|
||||
{
|
||||
int inputCount = D2D1PixelShader.GetInputCount<T>();
|
||||
int inputCount = T.InputCount;
|
||||
|
||||
if (inputCount == 0)
|
||||
{
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする