using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
namespace ComputeSharp.D2D1.__Internals;
///
/// A that uses the DXC APIs to compile compute shaders.
///
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This type is not intended to be used directly by user code")]
public static class D2D1ShaderCompiler
{
///
/// Compiles a new HLSL shader from the input source code.
///
/// The type of bytecode loader being used.
/// The type of D2D1 shader being dispatched.
/// The instance to use to load the bytecode.
/// The input instance representing the D2D1 shader to run.
/// The shader profile to use to compile the shader.
/// The compiler options to use to compile the shader.
public static unsafe void LoadDynamicBytecode(ref TLoader loader, in T shader, D2D1ShaderProfile shaderProfile, D2D1CompileOptions options)
where TLoader : struct, ID2D1BytecodeLoader
where T : struct, ID2D1Shader
{
Unsafe.AsRef(in shader).BuildHlslSource(out string hlslSource);
using ComPtr d3DBlobBytecode = Shaders.Translation.D3DCompiler.Compile(
hlslSource.AsSpan(),
shaderProfile,
options);
loader.LoadDynamicBytecode((IntPtr)d3DBlobBytecode.Get());
}
}