Add D2D1ShaderProfile parameter to ID2D1Shader.LoadBytecode
このコミットが含まれているのは:
1 親
5cca651dd5
コミット
3da3500a5d
6ファイル変更
+40
-6
検索条件に一致するファイルはありません
@@ -14,7 +14,7 @@ public interface ID2D1BytecodeLoader
|
||||
/// Loads a dynamic shader bytecode.
|
||||
/// </summary>
|
||||
/// <param name="handle">An opaque handle to the shader bytecode.</param>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the shader has already been initialized.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the shader has already been initialized or a precompiled bytecode was requested when not available..</exception>
|
||||
void LoadDynamicBytecode(IntPtr handle);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -33,10 +33,12 @@ public interface ID2D1Shader
|
||||
/// </summary>
|
||||
/// <typeparam name="TLoader">The type of bytecode loader being used.</typeparam>
|
||||
/// <param name="loader">The <typeparamref name="TLoader"/> instance to use to load the bytecode.</param>
|
||||
/// <param name="shaderProfile">The shader profile to use to get the shader bytecode (if <see langword="null"/>, the precompiled shader will be used).</param>
|
||||
/// <param name="hlslSource">The HLSL source that was compiled.</param>
|
||||
/// <exception cref="InvalidOperationException">Thrown if a precompiled bytecode was requested (<paramref name="shaderProfile"/> is <see langword="null"/>), but it wasn't availablle.</exception>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This method is not intended to be used directly by user code")]
|
||||
void LoadBytecode<TLoader>(ref TLoader loader, out string hlslSource)
|
||||
void LoadBytecode<TLoader>(ref TLoader loader, D2D1ShaderProfile? shaderProfile, out string hlslSource)
|
||||
where TLoader : struct, ID2D1BytecodeLoader
|
||||
#if NET6_0_OR_GREATER
|
||||
{
|
||||
|
||||
@@ -20,16 +20,46 @@ public static unsafe class D2D1InteropServices
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of D2D1 pixel shader to load the bytecode for.</typeparam>
|
||||
/// <param name="bytecode">A <see cref="ReadOnlyMemory{T}"/> instance with the resulting shader bytecode.</param>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the input shader has not been precompiled.</exception>
|
||||
/// <remarks>
|
||||
/// If the input shader was precompiled, <paramref name="bytecode"/> will wrap a pinned memory buffer (from the PE section).
|
||||
/// If the shader was compiled at runtime, <paramref name="bytecode"/> will wrap a <see cref="byte"/> array with the bytecode.
|
||||
/// This method will only run correctly if the input shader has been precompiled, or it will throw an exception.
|
||||
/// The returned <paramref name="bytecode"/> will wrap a pinned memory buffer (from the PE section).
|
||||
/// </remarks>
|
||||
public static void LoadShaderBytecode<T>(out ReadOnlyMemory<byte> bytecode)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
LoadOrCompileShaderBytecode<T>(null, out bytecode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads the bytecode from an input D2D1 pixel shader.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of D2D1 pixel shader to load the bytecode for.</typeparam>
|
||||
/// <param name="bytecode">A <see cref="ReadOnlyMemory{T}"/> instance with the resulting shader bytecode.</param>
|
||||
/// <param name="shaderProfile">The shader profile to use to get the shader bytecode.</param>
|
||||
/// <remarks>
|
||||
/// If the input shader was precompiled, <paramref name="bytecode"/> will wrap a pinned memory buffer (from the PE section).
|
||||
/// If the shader was compiled at runtime, <paramref name="bytecode"/> will wrap a <see cref="byte"/> array with the bytecode.
|
||||
/// </remarks>
|
||||
public static void LoadShaderBytecode<T>(D2D1ShaderProfile shaderProfile, out ReadOnlyMemory<byte> bytecode)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
LoadOrCompileShaderBytecode<T>(shaderProfile, out bytecode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads or compiles the bytecode from an input D2D1 pixel shader.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of D2D1 pixel shader to load the bytecode for.</typeparam>
|
||||
/// <param name="shaderProfile">The shader profile to use to get the shader bytecode.</param>
|
||||
/// <param name="bytecode">A <see cref="ReadOnlyMemory{T}"/> instance with the resulting shader bytecode.</param>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the input shader has not been precompiled.</exception>
|
||||
private static void LoadOrCompileShaderBytecode<T>(D2D1ShaderProfile? shaderProfile, out ReadOnlyMemory<byte> bytecode)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
D2D1ShaderBytecodeLoader bytecodeLoader = default;
|
||||
|
||||
Unsafe.NullRef<T>().LoadBytecode(ref bytecodeLoader, out _);
|
||||
Unsafe.NullRef<T>().LoadBytecode(ref bytecodeLoader, shaderProfile, out _);
|
||||
|
||||
using ComPtr<ID3DBlob> dynamicBytecode = bytecodeLoader.GetResultingShaderBytecode(out ReadOnlySpan<byte> precompiledBytecode);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public static class D2D1ReflectionServices
|
||||
{
|
||||
D2D1ShaderBytecodeLoader bytecodeLoader = default;
|
||||
|
||||
Unsafe.NullRef<T>().LoadBytecode(ref bytecodeLoader, out string hlslSource);
|
||||
Unsafe.NullRef<T>().LoadBytecode(ref bytecodeLoader, D2D1ShaderProfile.PixelShader50, out string hlslSource);
|
||||
|
||||
using ComPtr<ID3DBlob> dynamicBytecode = bytecodeLoader.GetResultingShaderBytecode(out ReadOnlySpan<byte> precompiledBytecode);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ public interface IBytecodeLoader
|
||||
/// </summary>
|
||||
/// <param name="handle">An opaque handle to the shader bytecode.</param>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the shader has already been initialized.</exception>
|
||||
/// <exception cref="NotSupportedException">Thrown if <paramref name="handle"/> is <see langword="null"/> (indicating an unsupported configuration).</exception>
|
||||
void LoadDynamicBytecode(IntPtr handle);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -90,6 +90,7 @@ public interface IShader
|
||||
/// <param name="threadsX">The number of threads in each thread group for the X axis.</param>
|
||||
/// <param name="threadsY">The number of threads in each thread group for the Y axis.</param>
|
||||
/// <param name="threadsZ">The number of threads in each thread group for the Z axis.</param>
|
||||
/// <exception cref="NotSupportedException">Thrown if the bytecode required runtime compilation and it wasn't supported on the current configuration.</exception>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This method is not intended to be used directly by user code")]
|
||||
void LoadBytecode<TLoader>(ref TLoader loader, int threadsX, int threadsY, int threadsZ)
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする