Improve source generator support for dynamic shaders

このコミットが含まれているのは:
Sergio Pedri committed 2021-12-19 16:45:12 +01:00
1 親 80044d69fd
コミット 23b500fe81
5ファイル変更
+27 -32

検索条件に一致するファイルはありません

+1 -2
ファイルの表示
@@ -2,7 +2,6 @@
using System.Runtime.CompilerServices;
using ComputeSharp.__Internals;
using ComputeSharp.Core.Extensions;
using ComputeSharp.Shaders.Translation;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
#if !NET6_0_OR_GREATER
@@ -107,7 +106,7 @@ public static class ReflectionServices
{
Unsafe.AsRef(in shader).BuildHlslString(out ArrayPoolStringBuilder shaderSource, 1, 1, 1);
using ComPtr<IDxcBlob> dxcBlobBytecode = ShaderCompiler.Instance.CompileShader(shaderSource.WrittenSpan);
using ComPtr<IDxcBlob> dxcBlobBytecode = Shaders.Translation.ShaderCompiler.Instance.CompileShader(shaderSource.WrittenSpan);
shaderSource.Dispose();
+8 -3
ファイルの表示
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
@@ -7,16 +8,20 @@ namespace ComputeSharp.__Internals;
/// <summary>
/// A <see langword="class"/> that uses the DXC APIs to compile compute shaders.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This type is not intended to be used directly by user code")]
public static class ShaderCompiler
{
/// <summary>
/// Compiles a new HLSL shader from the input source code.
/// </summary>
/// <param name="source">The HLSL source code to compile.</param>
/// <param name="builder">The <see cref="ArrayPoolStringBuilder"/> instance with the HLSL source code to compile.</param>
/// <returns>The bytecode for the compiled shader.</returns>
public static unsafe IntPtr CompileShader(ReadOnlySpan<char> source)
public static unsafe IntPtr CompileShader(ref ArrayPoolStringBuilder builder)
{
using ComPtr<IDxcBlob> shader = Shaders.Translation.ShaderCompiler.Instance.CompileShader(source);
using ComPtr<IDxcBlob> shader = Shaders.Translation.ShaderCompiler.Instance.CompileShader(builder.WrittenSpan);
builder.Dispose();
_ = shader.Get()->AddRef();