Add double precision support check to DX12 generator

このコミットが含まれているのは:
Sergio Pedri committed 2023-12-17 12:18:41 +01:00
1 親 35bc8ce649
コミット 9bad2e99db
7ファイル変更
+39 -15

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

-1
ファイルの表示
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<DefineConstants>$(DefineConstants);D2D1_GENERATOR</DefineConstants>
</PropertyGroup>
<PropertyGroup>
+1 -1
ファイルの表示
@@ -26,7 +26,7 @@ partial class D3DCompiler
pInterface: &iidOfID3D11ShaderReflection,
ppReflector: (void**)d3D11ShaderReflection.GetAddressOf()).Assert();
ulong doublePrecisionFlags = DirectX.D3D_SHADER_REQUIRES_DOUBLES | DirectX.D3D_SHADER_REQUIRES_11_1_DOUBLE_EXTENSIONS;
const ulong doublePrecisionFlags = DirectX.D3D_SHADER_REQUIRES_DOUBLES | DirectX.D3D_SHADER_REQUIRES_11_1_DOUBLE_EXTENSIONS;
return (d3D11ShaderReflection.Get()->GetRequiresFlags() & doublePrecisionFlags) != 0;
}
+2 -11
ファイルの表示
@@ -11,17 +11,8 @@ internal abstract record HlslBytecodeInfo
/// A successfully compiled HLSL shader.
/// </summary>
/// <param name="Bytecode">The resulting HLSL bytecode.</param>
public sealed record Success(
#if D3D12_GENERATOR
EquatableArray<byte> Bytecode)
#else
#pragma warning disable CS1573
EquatableArray<byte> Bytecode,
bool RequiresDoublePrecisionSupport) // Whether the shader requires support for double precision operations.
#pragma warning restore CS1573
#endif
: HlslBytecodeInfo;
/// <param name="RequiresDoublePrecisionSupport">Whether the shader requires support for double precision operations.</param>
public sealed record Success(EquatableArray<byte> Bytecode, bool RequiresDoublePrecisionSupport) : HlslBytecodeInfo;
/// <summary>
/// An HLSL shader that failed to compile due to a Win32 error.
+6 -1
ファイルの表示
@@ -62,6 +62,11 @@ partial class ComputeShaderDescriptorGenerator
token.ThrowIfCancellationRequested();
// Check whether double precision operations are required
bool requiresDoublePrecisionSupport = DxcShaderCompiler.Instance.IsDoublePrecisionSupportRequired(dxcBlob.Get());
token.ThrowIfCancellationRequested();
byte* buffer = (byte*)dxcBlob.Get()->GetBufferPointer();
int length = checked((int)dxcBlob.Get()->GetBufferSize());
@@ -69,7 +74,7 @@ partial class ComputeShaderDescriptorGenerator
ImmutableArray<byte> bytecode = Unsafe.As<byte[], ImmutableArray<byte>>(ref array);
return new HlslBytecodeInfo.Success(bytecode);
return new HlslBytecodeInfo.Success(bytecode, requiresDoublePrecisionSupport);
}
catch (Win32Exception e)
{
-1
ファイルの表示
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<DefineConstants>$(DefineConstants);D3D12_GENERATOR</DefineConstants>
</PropertyGroup>
<PropertyGroup>
+27
ファイルの表示
@@ -6,6 +6,8 @@ using System.Threading;
using Windows.Win32;
using Windows.Win32.Foundation;
using Windows.Win32.Graphics.Direct3D.Dxc;
using Windows.Win32.Graphics.Direct3D12;
using DirectX = Windows.Win32.PInvoke;
namespace ComputeSharp.SourceGenerators.Dxc;
@@ -247,6 +249,31 @@ internal sealed unsafe class DxcShaderCompiler
return dxcBlobBytecode.Move();
}
/// <summary>
/// Checks whether double precision support is required.
/// </summary>
/// <param name="dxcBlob">The input HLSL bytecode to inspect.</param>
/// <returns>Whether double precision support is required for <paramref name="dxcBlob"/>.</returns>
public bool IsDoublePrecisionSupportRequired(IDxcBlob* dxcBlob)
{
using ComPtr<ID3D12ShaderReflection> d3D12ShaderReflection = default;
Guid iidOfID3D12ShaderReflection = ID3D12ShaderReflection.IID_Guid;
DxcBuffer dxcBuffer = default;
dxcBuffer.Ptr = dxcBlob->GetBufferPointer();
dxcBuffer.Size = dxcBlob->GetBufferSize();
this.dxcUtils.Get()->CreateReflection(
&dxcBuffer,
&iidOfID3D12ShaderReflection,
(void**)d3D12ShaderReflection.GetAddressOf()).Assert();
const ulong doublePrecisionFlags = DirectX.D3D_SHADER_REQUIRES_DOUBLES | DirectX.D3D_SHADER_REQUIRES_11_1_DOUBLE_EXTENSIONS;
return (d3D12ShaderReflection.Get()->GetRequiresFlags() & doublePrecisionFlags) != 0;
}
/// <summary>
/// Throws an exception when a shader compilation fails.
/// </summary>
+3
ファイルの表示
@@ -1,6 +1,9 @@
CLSID_DxcCompiler
CLSID_DxcLibrary
DxcCreateInstance
D3D_SHADER_REQUIRES_DOUBLES
D3D_SHADER_REQUIRES_11_1_DOUBLE_EXTENSIONS
ID3D12ShaderReflection
IDxcCompiler3
IDxcUtils
IDxcResult