Wire up [D2D1CompileOptions] to all generated code and public APIs
Also removes the diagnostics for invalid linking setup
このコミットが含まれているのは:
1 親
b4b8b76d2f
コミット
d75993107a
10ファイル変更
+133
-68
検索条件に一致するファイルはありません
@@ -88,9 +88,10 @@ public interface ID2D1Shader
|
||||
/// <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="options">The compile options to use to get the shader bytecode (if <see langword="null"/>, the precompiled shader will be used).</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, D2D1ShaderProfile? shaderProfile)
|
||||
void LoadBytecode<TLoader>(ref TLoader loader, D2D1ShaderProfile? shaderProfile, D2D1CompileOptions? options)
|
||||
where TLoader : struct, ID2D1BytecodeLoader;
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public static class D2D1PixelShader
|
||||
public static ReadOnlyMemory<byte> LoadBytecode<T>()
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
return LoadOrCompileBytecode<T>(null);
|
||||
return LoadOrCompileBytecode<T>(null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -40,13 +40,40 @@ public static class D2D1PixelShader
|
||||
/// <param name="shaderProfile">The shader profile to use to get the shader bytecode.</param>
|
||||
/// <returns>A <see cref="ReadOnlyMemory{T}"/> instance with the resulting shader bytecode.</returns>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// If precompiled shader for the profile does not exist, the shader will be compiled with either the custom compile options specified on the shader
|
||||
/// type <typeparamref name="T"/> (through <see cref="D2DCompileOptionsAttribute"/>), or using <see cref="D2D1CompileOptions.Default"/> otherwise.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Additionally, in case no custom compile options are specified and the the shader type <typeparamref name="T"/>
|
||||
/// supports linking, <see cref="D2D1CompileOptions.EnableLinking"/> will also be automatically added.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// If the input shader was precompiled, the returned <see cref="ReadOnlyMemory{T}"/> instance will wrap a pinned memory buffer (from the PE section).
|
||||
/// If the shader was compiled at runtime, the returned <see cref="ReadOnlyMemory{T}"/> instance will wrap a <see cref="byte"/> array with the bytecode.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public static ReadOnlyMemory<byte> LoadBytecode<T>(D2D1ShaderProfile shaderProfile)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
return LoadOrCompileBytecode<T>(shaderProfile);
|
||||
return LoadOrCompileBytecode<T>(shaderProfile, null);
|
||||
}
|
||||
|
||||
/// <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="shaderProfile">The shader profile to use to get the shader bytecode.</param>
|
||||
/// <param name="options">The compile options to use to get the shader bytecode.</param>
|
||||
/// <returns>A <see cref="ReadOnlyMemory{T}"/> instance with the resulting shader bytecode.</returns>
|
||||
/// <remarks>
|
||||
/// If the input shader was precompiled, the returned <see cref="ReadOnlyMemory{T}"/> instance will wrap a pinned memory buffer (from the PE section).
|
||||
/// If the shader was compiled at runtime, the returned <see cref="ReadOnlyMemory{T}"/> instance will wrap a <see cref="byte"/> array with the bytecode.
|
||||
/// </remarks>
|
||||
public static ReadOnlyMemory<byte> LoadBytecode<T>(D2D1ShaderProfile shaderProfile, D2D1CompileOptions options)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
return LoadOrCompileBytecode<T>(shaderProfile, options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -54,16 +81,17 @@ public static class D2D1PixelShader
|
||||
/// </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="options">The compile options to use to get the shader bytecode.</param>
|
||||
/// <returns>A <see cref="ReadOnlyMemory{T}"/> instance with the resulting shader bytecode.</returns>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the input shader has not been precompiled.</exception>
|
||||
private static unsafe ReadOnlyMemory<byte> LoadOrCompileBytecode<T>(D2D1ShaderProfile? shaderProfile)
|
||||
private static unsafe ReadOnlyMemory<byte> LoadOrCompileBytecode<T>(D2D1ShaderProfile? shaderProfile, D2D1CompileOptions? options)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
D2D1ShaderBytecodeLoader bytecodeLoader = default;
|
||||
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
shader.LoadBytecode(ref bytecodeLoader, shaderProfile);
|
||||
shader.LoadBytecode(ref bytecodeLoader, shaderProfile, options);
|
||||
|
||||
using ComPtr<ID3DBlob> dynamicBytecode = bytecodeLoader.GetResultingShaderBytecode(out ReadOnlySpan<byte> precompiledBytecode);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public static class D2D1ReflectionServices
|
||||
|
||||
D2D1ShaderBytecodeLoader bytecodeLoader = default;
|
||||
|
||||
shader.LoadBytecode(ref bytecodeLoader, D2D1ShaderProfile.PixelShader50);
|
||||
shader.LoadBytecode(ref bytecodeLoader, D2D1ShaderProfile.PixelShader50, D2D1CompileOptions.Default);
|
||||
|
||||
using ComPtr<ID3DBlob> dynamicBytecode = bytecodeLoader.GetResultingShaderBytecode(out ReadOnlySpan<byte> precompiledBytecode);
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ public static class D2D1ShaderCompiler
|
||||
/// <param name="loader">The <typeparamref name="TLoader"/> instance to use to load the bytecode.</param>
|
||||
/// <param name="shader">The input <typeparamref name="T"/> instance representing the D2D1 shader to run.</param>
|
||||
/// <param name="shaderProfile">The shader profile to use to compile the shader.</param>
|
||||
/// <param name="enableLinkingSupport">Whether to enable linking support for the shader.</param>
|
||||
public static unsafe void LoadDynamicBytecode<TLoader, T>(ref TLoader loader, in T shader, D2D1ShaderProfile? shaderProfile, bool enableLinkingSupport)
|
||||
/// <param name="options">The compiler options to use to compile the shader.</param>
|
||||
public static unsafe void LoadDynamicBytecode<TLoader, T>(ref TLoader loader, in T shader, D2D1ShaderProfile shaderProfile, D2D1CompileOptions options)
|
||||
where TLoader : struct, ID2D1BytecodeLoader
|
||||
where T : struct, ID2D1Shader
|
||||
{
|
||||
@@ -30,8 +30,8 @@ public static class D2D1ShaderCompiler
|
||||
|
||||
using ComPtr<ID3DBlob> d3DBlobBytecode = Shaders.Translation.D3DCompiler.Compile(
|
||||
hlslSource.AsSpan(),
|
||||
shaderProfile ?? D2D1ShaderProfile.PixelShader50,
|
||||
D2D1CompileOptions.Default | (enableLinkingSupport ? D2D1CompileOptions.EnableLinking : 0));
|
||||
shaderProfile,
|
||||
options);
|
||||
|
||||
loader.LoadDynamicBytecode((IntPtr)d3DBlobBytecode.Get());
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする