Add double precision support check to DX12 generator
このコミットが含まれているのは:
1 親
35bc8ce649
コミット
9bad2e99db
7ファイル変更
+39
-15
検索条件に一致するファイルはありません
@@ -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,7 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<DefineConstants>$(DefineConstants);D3D12_GENERATOR</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
CLSID_DxcCompiler
|
||||
CLSID_DxcLibrary
|
||||
DxcCreateInstance
|
||||
D3D_SHADER_REQUIRES_DOUBLES
|
||||
D3D_SHADER_REQUIRES_11_1_DOUBLE_EXTENSIONS
|
||||
ID3D12ShaderReflection
|
||||
IDxcCompiler3
|
||||
IDxcUtils
|
||||
IDxcResult
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする