D3D12: Only enable toggle 'use_dxc' when Dawn can load DXC DLLs

This patch adds an additional check in the initialization of device
on D3D12 backend to ensure that 'use_dxc' is enabled only when Dawn
can load DXC DLLs (dxil.dll and dxcompiler.dll).

BUG=dawn:402

Change-Id: I85bc8698cf54b612244efc3673241f60a9cee209
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33060
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao 2020-11-18 00:14:31 +00:00 committed by Commit Bot service account
parent d4e7f08e0b
commit a0758a1aef
4 changed files with 16 additions and 2 deletions

View File

@ -126,7 +126,9 @@ namespace dawn_native {
"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",
{"use_dxc",
"Use DXC instead of FXC for compiling HLSL when both dxcompiler.dll and dxil.dll "
"is available.",
"https://crbug.com/dawn/402"}},
{Toggle::DisableRobustness,
{"disable_robustness", "Disable robust buffer access", "https://crbug.com/dawn/480"}},

View File

@ -153,6 +153,10 @@ namespace dawn_native { namespace d3d12 {
// Device shouldn't be used until after DeviceBase::Initialize so we must wait until after
// device initialization to call NextSerial
DAWN_TRY(NextSerial());
// The environment can only use DXC when it's available. Override the decision if it is not
// applicable.
ApplyUseDxcToggle();
return {};
}
@ -188,6 +192,12 @@ namespace dawn_native { namespace d3d12 {
return ToBackend(GetAdapter())->GetBackend()->GetFactory();
}
void Device::ApplyUseDxcToggle() {
if (!ToBackend(GetAdapter())->GetBackend()->GetFunctions()->IsDXCAvailable()) {
ForceSetToggle(Toggle::UseDXC, false);
}
}
ResultOrError<IDxcLibrary*> Device::GetOrCreateDxcLibrary() const {
return ToBackend(GetAdapter())->GetBackend()->GetOrCreateDxcLibrary();
}

View File

@ -178,6 +178,8 @@ namespace dawn_native { namespace d3d12 {
MaybeError CheckDebugLayerAndGenerateErrors();
void ApplyUseDxcToggle();
ComPtr<ID3D12Fence> mFence;
HANDLE mFenceEvent = nullptr;
ExecutionSerial CheckAndUpdateCompletedSerials() override;

View File

@ -108,4 +108,4 @@ TEST_P(ShaderFloat16Tests, Basic16BitFloatFeaturesTest) {
EXPECT_BUFFER_U16_RANGE_EQ(expected, bufferOut, 0, 2);
}
DAWN_INSTANTIATE_TEST(ShaderFloat16Tests, MetalBackend(), VulkanBackend());
DAWN_INSTANTIATE_TEST(ShaderFloat16Tests, D3D12Backend(), MetalBackend(), VulkanBackend());