D3D12: Add a toggle to use DXC for HLSL compilation
This patch adds the following: - UseDXC toggle - Loads DXC (and DXIL to sign the DXBC) in d3d12/PlatformFunctions - Adds GetModuleDirectory to SystemUtils GetModuleDirectory was added to prevent loading issues regarding dynamic libraries when the executable is not in the same path as the dawn module. This patch doesn't add DXC to RenderPipelineD3D12 nor ComputePipelineD3D12. Bug: dawn:402 Change-Id: I2b8e4a2b7df31b9c766c748f92e11050c0aec3a0 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/21420 Commit-Queue: Felix Maier <xilefmai@gmail.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
60bb88d23c
commit
20ed6f42b3
|
@ -128,6 +128,9 @@ namespace dawn_native {
|
|||
"Enable use of a small D3D12 shader visible heap, instead of using a large one by "
|
||||
"default. This setting is used to test bindgroup encoding.",
|
||||
"https://crbug.com/dawn/155"}},
|
||||
{Toggle::UseDXC,
|
||||
{"use_dxc", "Use DXC instead of FXC for compiling HLSL",
|
||||
"https://crbug.com/dawn/402"}},
|
||||
}};
|
||||
|
||||
} // anonymous namespace
|
||||
|
|
|
@ -41,6 +41,7 @@ namespace dawn_native {
|
|||
DisableBaseVertex,
|
||||
DisableBaseInstance,
|
||||
UseD3D12SmallShaderVisibleHeapForTesting,
|
||||
UseDXC,
|
||||
|
||||
EnumCount,
|
||||
InvalidEnum = EnumCount,
|
||||
|
|
|
@ -432,6 +432,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
SetToggle(Toggle::UseD3D12ResourceHeapTier2, useResourceHeapTier2);
|
||||
SetToggle(Toggle::UseD3D12RenderPass, GetDeviceInfo().supportsRenderPass);
|
||||
SetToggle(Toggle::UseD3D12ResidencyManagement, true);
|
||||
SetToggle(Toggle::UseDXC, false);
|
||||
|
||||
// By default use the maximum shader-visible heap size allowed.
|
||||
SetToggle(Toggle::UseD3D12SmallShaderVisibleHeapForTesting, false);
|
||||
|
|
|
@ -26,7 +26,9 @@ namespace dawn_native { namespace d3d12 {
|
|||
MaybeError PlatformFunctions::LoadFunctions() {
|
||||
DAWN_TRY(LoadD3D12());
|
||||
DAWN_TRY(LoadDXGI());
|
||||
DAWN_TRY(LoadD3DCompiler());
|
||||
LoadDXIL();
|
||||
LoadDXCompiler();
|
||||
DAWN_TRY(LoadFXCompiler());
|
||||
DAWN_TRY(LoadD3D11());
|
||||
LoadPIXRuntime();
|
||||
return {};
|
||||
|
@ -72,10 +74,24 @@ namespace dawn_native { namespace d3d12 {
|
|||
return {};
|
||||
}
|
||||
|
||||
MaybeError PlatformFunctions::LoadD3DCompiler() {
|
||||
void PlatformFunctions::LoadDXIL() {
|
||||
if (!mDXILLib.Open("dxil.dll", nullptr)) {
|
||||
mDXILLib.Close();
|
||||
}
|
||||
}
|
||||
|
||||
void PlatformFunctions::LoadDXCompiler() {
|
||||
// DXIL must be loaded before DXC, otherwise shader signing is unavailable
|
||||
if (!mDXCompilerLib.Open("dxcompiler.dll", nullptr) ||
|
||||
!mDXCompilerLib.GetProc(&dxcCreateInstance, "DxcCreateInstance", nullptr)) {
|
||||
mDXCompilerLib.Close();
|
||||
}
|
||||
}
|
||||
|
||||
MaybeError PlatformFunctions::LoadFXCompiler() {
|
||||
std::string error;
|
||||
if (!mD3DCompilerLib.Open("d3dcompiler_47.dll", &error) ||
|
||||
!mD3DCompilerLib.GetProc(&d3dCompile, "D3DCompile", &error)) {
|
||||
if (!mFXCompilerLib.Open("d3dcompiler_47.dll", &error) ||
|
||||
!mFXCompilerLib.GetProc(&d3dCompile, "D3DCompile", &error)) {
|
||||
return DAWN_INTERNAL_ERROR(error.c_str());
|
||||
}
|
||||
|
||||
|
@ -86,6 +102,10 @@ namespace dawn_native { namespace d3d12 {
|
|||
return mPIXEventRuntimeLib.Valid();
|
||||
}
|
||||
|
||||
bool PlatformFunctions::IsDXCAvailable() const {
|
||||
return mDXILLib.Valid() && mDXCompilerLib.Valid();
|
||||
}
|
||||
|
||||
void PlatformFunctions::LoadPIXRuntime() {
|
||||
if (!mPIXEventRuntimeLib.Open("WinPixEventRuntime.dll") ||
|
||||
!mPIXEventRuntimeLib.GetProc(&pixBeginEventOnCommandList,
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
MaybeError LoadFunctions();
|
||||
bool IsPIXEventRuntimeLoaded() const;
|
||||
bool IsDXCAvailable() const;
|
||||
|
||||
// Functions from d3d12.dll
|
||||
PFN_D3D12_CREATE_DEVICE d3d12CreateDevice = nullptr;
|
||||
|
@ -58,6 +59,12 @@ namespace dawn_native { namespace d3d12 {
|
|||
_COM_Outptr_ void** ppFactory);
|
||||
PFN_CREATE_DXGI_FACTORY2 createDxgiFactory2 = nullptr;
|
||||
|
||||
// Functions from dxcompiler.dll
|
||||
using PFN_DXC_CREATE_INSTANCE = HRESULT(WINAPI*)(REFCLSID rclsid,
|
||||
REFIID riid,
|
||||
_COM_Outptr_ void** ppCompiler);
|
||||
PFN_DXC_CREATE_INSTANCE dxcCreateInstance = nullptr;
|
||||
|
||||
// Functions from d3d3compiler.dll
|
||||
pD3DCompile d3dCompile = nullptr;
|
||||
|
||||
|
@ -84,13 +91,17 @@ namespace dawn_native { namespace d3d12 {
|
|||
MaybeError LoadD3D12();
|
||||
MaybeError LoadD3D11();
|
||||
MaybeError LoadDXGI();
|
||||
MaybeError LoadD3DCompiler();
|
||||
void LoadDXIL();
|
||||
void LoadDXCompiler();
|
||||
MaybeError LoadFXCompiler();
|
||||
void LoadPIXRuntime();
|
||||
|
||||
DynamicLib mD3D12Lib;
|
||||
DynamicLib mD3D11Lib;
|
||||
DynamicLib mDXGILib;
|
||||
DynamicLib mD3DCompilerLib;
|
||||
DynamicLib mDXILLib;
|
||||
DynamicLib mDXCompilerLib;
|
||||
DynamicLib mFXCompilerLib;
|
||||
DynamicLib mPIXEventRuntimeLib;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue