Adopt static abstracts in ComputeSharp.D2D1 (and WinUI)
このコミットが含まれているのは:
1 親
167041bee0
コミット
786efaf38f
24ファイル変更
+100
-151
検索条件に一致するファイルはありません
@@ -18,7 +18,7 @@ public interface ID2D1PixelShaderDescriptor<T>
|
||||
/// <remarks>
|
||||
/// This only applies to effects created from <see cref="D2D1PixelShaderEffect"/>.
|
||||
/// </remarks>
|
||||
ref readonly Guid EffectId { get; }
|
||||
static abstract ref readonly Guid EffectId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the display name of the D2D effect using this shader, if specified.
|
||||
@@ -26,7 +26,7 @@ public interface ID2D1PixelShaderDescriptor<T>
|
||||
/// <remarks>
|
||||
/// This only applies to effects created from <see cref="D2D1PixelShaderEffect"/>.
|
||||
/// </remarks>
|
||||
string? EffectDisplayName { get; }
|
||||
static abstract string? EffectDisplayName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description of the D2D effect using this shader, if specified.
|
||||
@@ -34,7 +34,7 @@ public interface ID2D1PixelShaderDescriptor<T>
|
||||
/// <remarks>
|
||||
/// This only applies to effects created from <see cref="D2D1PixelShaderEffect"/>.
|
||||
/// </remarks>
|
||||
string? EffectDescription { get; }
|
||||
static abstract string? EffectDescription { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the category of the D2D effect using this shader, if specified.
|
||||
@@ -42,7 +42,7 @@ public interface ID2D1PixelShaderDescriptor<T>
|
||||
/// <remarks>
|
||||
/// This only applies to effects created from <see cref="D2D1PixelShaderEffect"/>.
|
||||
/// </remarks>
|
||||
string? EffectCategory { get; }
|
||||
static abstract string? EffectCategory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the author of the D2D effect using this shader, if specified.
|
||||
@@ -50,52 +50,52 @@ public interface ID2D1PixelShaderDescriptor<T>
|
||||
/// <remarks>
|
||||
/// This only applies to effects created from <see cref="D2D1PixelShaderEffect"/>.
|
||||
/// </remarks>
|
||||
string? EffectAuthor { get; }
|
||||
static abstract string? EffectAuthor { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size in bytes of the constant buffer for the current shader.
|
||||
/// </summary>
|
||||
int ConstantBufferSize { get; }
|
||||
static abstract int ConstantBufferSize { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of inputs for the current shader.
|
||||
/// </summary>
|
||||
int InputCount { get; }
|
||||
static abstract int InputCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of resource textures for the current shader.
|
||||
/// </summary>
|
||||
int ResourceTextureCount { get; }
|
||||
static abstract int ResourceTextureCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the input types for the current shader.
|
||||
/// </summary>
|
||||
ReadOnlyMemory<D2D1PixelShaderInputType> InputTypes { get; }
|
||||
static abstract ReadOnlyMemory<D2D1PixelShaderInputType> InputTypes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the input descriptions for the current shader.
|
||||
/// </summary>
|
||||
ReadOnlyMemory<D2D1InputDescription> InputDescriptions { get; }
|
||||
static abstract ReadOnlyMemory<D2D1InputDescription> InputDescriptions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the resource texture descriptions for the shader.
|
||||
/// </summary>
|
||||
ReadOnlyMemory<D2D1ResourceTextureDescription> ResourceTextureDescriptions { get; }
|
||||
static abstract ReadOnlyMemory<D2D1ResourceTextureDescription> ResourceTextureDescriptions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the pixel options for the current shader.
|
||||
/// </summary>
|
||||
D2D1PixelOptions PixelOptions { get; }
|
||||
static abstract D2D1PixelOptions PixelOptions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the buffer precision for the shader.
|
||||
/// </summary>
|
||||
D2D1BufferPrecision BufferPrecision { get; }
|
||||
static abstract D2D1BufferPrecision BufferPrecision { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the channel depth for the shader.
|
||||
/// </summary>
|
||||
D2D1ChannelDepth ChannelDepth { get; }
|
||||
static abstract D2D1ChannelDepth ChannelDepth { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the shader profile for the current shader.
|
||||
@@ -103,7 +103,7 @@ public interface ID2D1PixelShaderDescriptor<T>
|
||||
/// <remarks>
|
||||
/// This shader profile is either explicitly set by users, or the default one for D2D1 shaders.
|
||||
/// </remarks>
|
||||
D2D1ShaderProfile ShaderProfile { get; }
|
||||
static abstract D2D1ShaderProfile ShaderProfile { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the compile options for the current shader.
|
||||
@@ -111,12 +111,12 @@ public interface ID2D1PixelShaderDescriptor<T>
|
||||
/// <remarks>
|
||||
/// This compile options are either explicitly set by users, or the default one for D2D1 shaders.
|
||||
/// </remarks>
|
||||
D2D1CompileOptions CompileOptions { get; }
|
||||
static abstract D2D1CompileOptions CompileOptions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HLSL source code for the current shader instance.
|
||||
/// </summary>
|
||||
string HlslSource { get; }
|
||||
static abstract string HlslSource { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HLSL bytecode for the current shader, if available.
|
||||
@@ -124,14 +124,14 @@ public interface ID2D1PixelShaderDescriptor<T>
|
||||
/// <remarks>
|
||||
/// If no precompiled HLSL bytecode is available, the returned <see cref="ReadOnlyMemory{T}"/> instance will be empty.
|
||||
/// </remarks>
|
||||
ReadOnlyMemory<byte> HlslBytecode { get; }
|
||||
static abstract ReadOnlyMemory<byte> HlslBytecode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <typeparamref name="T"/> shader instance from a constant buffer.
|
||||
/// </summary>
|
||||
/// <param name="buffer">The input constant buffer to read.</param>
|
||||
/// <remarks>The input buffer must be retrieved from <see cref="LoadConstantBuffer"/>.</remarks>
|
||||
T CreateFromConstantBuffer(ReadOnlySpan<byte> buffer);
|
||||
static abstract T CreateFromConstantBuffer(ReadOnlySpan<byte> buffer);
|
||||
|
||||
/// <summary>
|
||||
/// Loads the constant buffer of a given input shader.
|
||||
@@ -139,6 +139,6 @@ public interface ID2D1PixelShaderDescriptor<T>
|
||||
/// <typeparam name="TLoader">The type of data loader being used.</typeparam>
|
||||
/// <param name="shader">The input shader to load the constant buffer for.</param>
|
||||
/// <param name="loader">The <typeparamref name="TLoader"/> instance to use to load the constant buffer.</param>
|
||||
void LoadConstantBuffer<TLoader>(in T shader, ref TLoader loader)
|
||||
static abstract void LoadConstantBuffer<TLoader>(in T shader, ref TLoader loader)
|
||||
where TLoader : struct, ID2D1ConstantBufferLoader;
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.D2D1.Descriptors;
|
||||
using ComputeSharp.D2D1.Extensions;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers;
|
||||
@@ -45,9 +44,7 @@ public readonly unsafe ref struct D2D1DrawInfoUpdateContext<T>
|
||||
this.d2D1DrawInfoUpdateContext->GetConstantBuffer(pBuffer, constantBufferSize).Assert();
|
||||
}
|
||||
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
shader = shader.CreateFromConstantBuffer(buffer);
|
||||
T shader = T.CreateFromConstantBuffer(buffer);
|
||||
|
||||
ArrayPool<byte>.Shared.Return(buffer);
|
||||
|
||||
@@ -62,6 +59,6 @@ public readonly unsafe ref struct D2D1DrawInfoUpdateContext<T>
|
||||
{
|
||||
D2D1DrawInfoUpdateContextConstantBufferLoader dataLoader = new(this.d2D1DrawInfoUpdateContext);
|
||||
|
||||
Unsafe.AsRef(in shader).LoadConstantBuffer(in shader, ref dataLoader);
|
||||
T.LoadConstantBuffer(in shader, ref dataLoader);
|
||||
}
|
||||
}
|
||||
@@ -20,9 +20,7 @@ public static class D2D1PixelShader
|
||||
public static int GetConstantBufferSize<T>()
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
return shader.ConstantBufferSize;
|
||||
return T.ConstantBufferSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -33,9 +31,7 @@ public static class D2D1PixelShader
|
||||
public static int GetInputCount<T>()
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
return shader.InputCount;
|
||||
return T.InputCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -46,9 +42,7 @@ public static class D2D1PixelShader
|
||||
public static int GetResourceTextureCount<T>()
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
return shader.ResourceTextureCount;
|
||||
return T.ResourceTextureCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -59,9 +53,7 @@ public static class D2D1PixelShader
|
||||
public static ReadOnlyMemory<D2D1PixelShaderInputType> GetInputTypes<T>()
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
return shader.InputTypes;
|
||||
return T.InputTypes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -72,9 +64,7 @@ public static class D2D1PixelShader
|
||||
public static ReadOnlyMemory<D2D1InputDescription> GetInputDescriptions<T>()
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
return shader.InputDescriptions;
|
||||
return T.InputDescriptions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -85,9 +75,7 @@ public static class D2D1PixelShader
|
||||
public static ReadOnlyMemory<D2D1ResourceTextureDescription> GetResourceTextureDescriptions<T>()
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
return shader.ResourceTextureDescriptions;
|
||||
return T.ResourceTextureDescriptions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -98,9 +86,7 @@ public static class D2D1PixelShader
|
||||
public static D2D1PixelOptions GetPixelOptions<T>()
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
return shader.PixelOptions;
|
||||
return T.PixelOptions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -111,9 +97,7 @@ public static class D2D1PixelShader
|
||||
public static D2D1BufferPrecision GetOutputBufferPrecision<T>()
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
return shader.BufferPrecision;
|
||||
return T.BufferPrecision;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -124,9 +108,7 @@ public static class D2D1PixelShader
|
||||
public static D2D1ChannelDepth GetOutputBufferChannelDepth<T>()
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
return shader.ChannelDepth;
|
||||
return T.ChannelDepth;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -144,13 +126,11 @@ public static class D2D1PixelShader
|
||||
public static ReadOnlyMemory<byte> LoadBytecode<T>()
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
// This method is the one used by the built-in ID2D1Effect, so it has special optimization
|
||||
// to help both performance and especially trimming. That is, we first check whether the
|
||||
// HLSL code is already available, which should get completely inlined when using the
|
||||
// generated code. This allows the entire fallback path below to be trimmed out.
|
||||
if (shader.HlslBytecode is ReadOnlyMemory<byte> { Length: > 0 } hlslBytecode)
|
||||
if (T.HlslBytecode is ReadOnlyMemory<byte> { Length: > 0 } hlslBytecode)
|
||||
{
|
||||
return hlslBytecode;
|
||||
}
|
||||
@@ -334,16 +314,12 @@ public static class D2D1PixelShader
|
||||
out D2D1CompileOptions effectiveCompileOptions)
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
string hlslSource = shader.HlslSource;
|
||||
|
||||
// Set the effective profile and option to the requested ones or the default values
|
||||
effectiveShaderProfile = requestedShaderProfile ?? shader.ShaderProfile;
|
||||
effectiveCompileOptions = requestedCompileOptions ?? shader.CompileOptions;
|
||||
effectiveShaderProfile = requestedShaderProfile ?? T.ShaderProfile;
|
||||
effectiveCompileOptions = requestedCompileOptions ?? T.CompileOptions;
|
||||
|
||||
// Compile the shader with the current settings
|
||||
using ComPtr<ID3DBlob> dynamicBytecode = D3DCompiler.Compile(hlslSource.AsSpan(), effectiveShaderProfile, effectiveCompileOptions);
|
||||
using ComPtr<ID3DBlob> dynamicBytecode = D3DCompiler.Compile(T.HlslSource, effectiveShaderProfile, effectiveCompileOptions);
|
||||
|
||||
byte* bytecodePtr = (byte*)dynamicBytecode.Get()->GetBufferPointer();
|
||||
int bytecodeSize = (int)dynamicBytecode.Get()->GetBufferSize();
|
||||
@@ -367,15 +343,13 @@ public static class D2D1PixelShader
|
||||
out D2D1CompileOptions effectiveCompileOptions)
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
// Check whether there is precompiled bytecode we can use
|
||||
if (shader.HlslBytecode is ReadOnlyMemory<byte> { Length: > 0 } hlslBytecode &&
|
||||
(requestedShaderProfile is null || shader.ShaderProfile == requestedShaderProfile.GetValueOrDefault()) &&
|
||||
(requestedCompileOptions is null || shader.CompileOptions == requestedCompileOptions.GetValueOrDefault()))
|
||||
if (T.HlslBytecode is ReadOnlyMemory<byte> { Length: > 0 } hlslBytecode &&
|
||||
(requestedShaderProfile is null || T.ShaderProfile == requestedShaderProfile.GetValueOrDefault()) &&
|
||||
(requestedCompileOptions is null || T.CompileOptions == requestedCompileOptions.GetValueOrDefault()))
|
||||
{
|
||||
effectiveShaderProfile = shader.ShaderProfile;
|
||||
effectiveCompileOptions = shader.CompileOptions;
|
||||
effectiveShaderProfile = T.ShaderProfile;
|
||||
effectiveCompileOptions = T.CompileOptions;
|
||||
|
||||
return hlslBytecode;
|
||||
}
|
||||
@@ -398,7 +372,7 @@ public static class D2D1PixelShader
|
||||
{
|
||||
D2D1ByteArrayConstantBufferLoader dataLoader = default;
|
||||
|
||||
Unsafe.AsRef(in shader).LoadConstantBuffer(in shader, ref dataLoader);
|
||||
T.LoadConstantBuffer(in shader, ref dataLoader);
|
||||
|
||||
return dataLoader.GetResultingDispatchData();
|
||||
}
|
||||
@@ -437,7 +411,7 @@ public static class D2D1PixelShader
|
||||
{
|
||||
D2D1ByteBufferConstantBufferLoader dataLoader = new(buffer, span.Length);
|
||||
|
||||
Unsafe.AsRef(in shader).LoadConstantBuffer(in shader, ref dataLoader);
|
||||
T.LoadConstantBuffer(in shader, ref dataLoader);
|
||||
|
||||
return dataLoader.TryGetWrittenBytes(out bytesWritten);
|
||||
}
|
||||
@@ -458,7 +432,7 @@ public static class D2D1PixelShader
|
||||
|
||||
D2D1DrawInfoConstantBufferLoader dataLoader = new((ID2D1DrawInfo*)d2D1DrawInfo);
|
||||
|
||||
Unsafe.AsRef(in shader).LoadConstantBuffer(in shader, ref dataLoader);
|
||||
T.LoadConstantBuffer(in shader, ref dataLoader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -490,11 +464,9 @@ public static class D2D1PixelShader
|
||||
public static bool TryCreateFromConstantBuffer<T>(ReadOnlySpan<byte> span, out T shader)
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out shader);
|
||||
|
||||
if (span.Length >= shader.ConstantBufferSize)
|
||||
if (span.Length >= T.ConstantBufferSize)
|
||||
{
|
||||
shader = shader.CreateFromConstantBuffer(span);
|
||||
shader = T.CreateFromConstantBuffer(span);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using ComputeSharp.D2D1.Descriptors;
|
||||
using ComputeSharp.D2D1.Extensions;
|
||||
@@ -26,9 +25,7 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
public static ref readonly Guid GetEffectId<T>()
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
return ref shader.EffectId;
|
||||
return ref T.EffectId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -39,9 +36,7 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
public static string? GetEffectDisplayName<T>()
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
return shader.EffectDisplayName;
|
||||
return T.EffectDisplayName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -52,9 +47,7 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
public static string? GetEffectDescription<T>()
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
return shader.EffectDescription;
|
||||
return T.EffectDescription;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -65,9 +58,7 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
public static string? GetEffectCategory<T>()
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
return shader.EffectCategory;
|
||||
return T.EffectCategory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -78,9 +69,7 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
public static string? GetEffectAuthor<T>()
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
return shader.EffectAuthor;
|
||||
return T.EffectAuthor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -194,7 +183,7 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
classId: pGuid,
|
||||
propertyXml: (ushort*)pXml,
|
||||
bindings: d2D1PropertyBinding,
|
||||
bindingsCount: (uint)(D2D1PixelShaderEffectProperty.NumberOfAlwaysAvailableProperties + D2D1PixelShader.GetResourceTextureCount<T>()),
|
||||
bindingsCount: (uint)(D2D1PixelShaderEffectProperty.NumberOfAlwaysAvailableProperties + T.ResourceTextureCount),
|
||||
effectFactory: PixelShaderEffect.Globals<T>.Instance.Factory).Assert();
|
||||
}
|
||||
|
||||
@@ -249,8 +238,8 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
writer.Write(D2D1EffectRegistrationData.V1.BlobId);
|
||||
|
||||
// Effect id and number of inputs
|
||||
writer.Write(GetEffectId<T>());
|
||||
writer.Write(D2D1PixelShader.GetInputCount<T>());
|
||||
writer.Write(T.EffectId);
|
||||
writer.Write(T.InputCount);
|
||||
|
||||
// Retrieve the effect XML and include it into the registration blob
|
||||
using (D2D1EffectXmlFactory.EffectXml effectXml = D2D1EffectXmlFactory.GetXmlBuffer<T>())
|
||||
@@ -272,7 +261,7 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
}
|
||||
|
||||
// Bindings
|
||||
writer.Write(D2D1PixelShaderEffectProperty.NumberOfAlwaysAvailableProperties + D2D1PixelShader.GetResourceTextureCount<T>());
|
||||
writer.Write(D2D1PixelShaderEffectProperty.NumberOfAlwaysAvailableProperties + T.ResourceTextureCount);
|
||||
writer.Write("ConstantBuffer"u8);
|
||||
writer.Write((byte)'\0');
|
||||
writer.Write((nint)(delegate* unmanaged<IUnknown*, byte*, uint, uint*, HRESULT>)&PixelShaderEffect.GetConstantBufferImpl);
|
||||
@@ -283,7 +272,7 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
writer.Write((nint)(delegate* unmanaged<IUnknown*, byte*, uint, HRESULT>)&PixelShaderEffect.SetTransformMapperImpl);
|
||||
|
||||
// Add all resource texture manager property bindings
|
||||
for (int i = 0; i < D2D1PixelShader.GetResourceTextureCount<T>(); i++)
|
||||
for (int i = 0; i < T.ResourceTextureCount; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
@@ -441,7 +430,7 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
|
||||
D2D1EffectConstantBufferLoader dataLoader = new((ID2D1Effect*)d2D1Effect);
|
||||
|
||||
Unsafe.AsRef(in shader).LoadConstantBuffer(in shader, ref dataLoader);
|
||||
T.LoadConstantBuffer(in shader, ref dataLoader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.D2D1.Descriptors;
|
||||
using ComputeSharp.D2D1.Extensions;
|
||||
using ComputeSharp.Win32;
|
||||
@@ -27,8 +26,6 @@ public static class D2D1ReflectionServices
|
||||
public static unsafe D2D1ShaderInfo GetShaderInfo<T>()
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
ReadOnlyMemory<byte> hlslBytecode = D2D1PixelShader.LoadBytecode<T>();
|
||||
|
||||
using ComPtr<ID3D11ShaderReflection> d3D11ShaderReflection = default;
|
||||
@@ -52,7 +49,7 @@ public static class D2D1ReflectionServices
|
||||
|
||||
return new(
|
||||
CompilerVersion: new string(d3D11ShaderDescription.Creator),
|
||||
HlslSource: shader.HlslSource,
|
||||
HlslSource: T.HlslSource,
|
||||
HlslBytecode: hlslBytecode,
|
||||
ConstantBufferCount: d3D11ShaderDescription.ConstantBuffers,
|
||||
BoundResourceCount: d3D11ShaderDescription.BoundResources,
|
||||
|
||||
@@ -107,34 +107,34 @@ internal unsafe partial struct PixelShaderEffect
|
||||
public static Globals<T> Instance { get; } = new();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override ref readonly Guid EffectId => ref D2D1PixelShaderEffect.GetEffectId<T>();
|
||||
public override ref readonly Guid EffectId => ref T.EffectId;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int ConstantBufferSize => D2D1PixelShader.GetConstantBufferSize<T>();
|
||||
public override int ConstantBufferSize => T.ConstantBufferSize;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int InputCount => D2D1PixelShader.GetInputCount<T>();
|
||||
public override int InputCount => T.InputCount;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int ResourceTextureCount => D2D1PixelShader.GetResourceTextureCount<T>();
|
||||
public override int ResourceTextureCount => T.ResourceTextureCount;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override ReadOnlyMemory<D2D1PixelShaderInputType> InputTypes => D2D1PixelShader.GetInputTypes<T>();
|
||||
public override ReadOnlyMemory<D2D1PixelShaderInputType> InputTypes => T.InputTypes;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override ReadOnlyMemory<D2D1InputDescription> InputDescriptions => D2D1PixelShader.GetInputDescriptions<T>();
|
||||
public override ReadOnlyMemory<D2D1InputDescription> InputDescriptions => T.InputDescriptions;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override ReadOnlyMemory<D2D1ResourceTextureDescription> ResourceTextureDescriptions => D2D1PixelShader.GetResourceTextureDescriptions<T>();
|
||||
public override ReadOnlyMemory<D2D1ResourceTextureDescription> ResourceTextureDescriptions => T.ResourceTextureDescriptions;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override D2D1PixelOptions PixelOptions => D2D1PixelShader.GetPixelOptions<T>();
|
||||
public override D2D1PixelOptions PixelOptions => T.PixelOptions;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override D2D1BufferPrecision BufferPrecision => D2D1PixelShader.GetOutputBufferPrecision<T>();
|
||||
public override D2D1BufferPrecision BufferPrecision => T.BufferPrecision;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override D2D1ChannelDepth ChannelDepth => D2D1PixelShader.GetOutputBufferChannelDepth<T>();
|
||||
public override D2D1ChannelDepth ChannelDepth => T.ChannelDepth;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override ReadOnlyMemory<byte> HlslBytecode
|
||||
|
||||
@@ -26,12 +26,12 @@ internal static unsafe class D2D1EffectXmlFactory
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
// Compute all necessary values first, outside of the lock
|
||||
string? displayName = D2D1PixelShaderEffect.GetEffectDisplayName<T>();
|
||||
string? description = D2D1PixelShaderEffect.GetEffectDescription<T>();
|
||||
string? category = D2D1PixelShaderEffect.GetEffectCategory<T>();
|
||||
string? author = D2D1PixelShaderEffect.GetEffectAuthor<T>();
|
||||
int inputCount = D2D1PixelShader.GetInputCount<T>();
|
||||
int resourceTextureCount = D2D1PixelShader.GetResourceTextureCount<T>();
|
||||
string? displayName = T.EffectDisplayName;
|
||||
string? description = T.EffectDescription;
|
||||
string? category = T.EffectCategory;
|
||||
string? author = T.EffectAuthor;
|
||||
int inputCount = T.InputCount;
|
||||
int resourceTextureCount = T.ResourceTextureCount;
|
||||
|
||||
StringBuilder builder = XmlBuilder;
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする