diff --git a/src/dawn_native/Toggles.cpp b/src/dawn_native/Toggles.cpp index 8c7f33f6b4..b0e2dea250 100644 --- a/src/dawn_native/Toggles.cpp +++ b/src/dawn_native/Toggles.cpp @@ -225,6 +225,12 @@ namespace dawn_native { "be enabled for OpenGL ES backend, and serves as a workaround by default enabled on " "some Metal devices with Intel GPU to ensure the depth result is correct.", "https://crbug.com/dawn/136"}}, + {Toggle::FxcOptimizations, + {"fxc_optimizations", + "Enable optimizations when compiling with FXC. Disabled by default because FXC " + "miscompiles in many cases when optimizations are enabled.", + "https://crbug.com/dawn/1203"}}, + // Dummy comment to separate the }} so it is clearer what to copy-paste to add a toggle. }}; } // anonymous namespace diff --git a/src/dawn_native/Toggles.h b/src/dawn_native/Toggles.h index 88a9d6d378..4682cbd57b 100644 --- a/src/dawn_native/Toggles.h +++ b/src/dawn_native/Toggles.h @@ -60,6 +60,7 @@ namespace dawn_native { UseUserDefinedLabelsInBackend, DisableR8RG8Mipmaps, UseDummyFragmentInVertexOnlyPipeline, + FxcOptimizations, EnumCount, InvalidEnum = EnumCount, diff --git a/src/dawn_native/d3d12/ComputePipelineD3D12.cpp b/src/dawn_native/d3d12/ComputePipelineD3D12.cpp index dd8d225400..b6037ddd7b 100644 --- a/src/dawn_native/d3d12/ComputePipelineD3D12.cpp +++ b/src/dawn_native/d3d12/ComputePipelineD3D12.cpp @@ -34,6 +34,11 @@ namespace dawn_native { namespace d3d12 { Device* device = ToBackend(GetDevice()); uint32_t compileFlags = 0; + if (!device->IsToggleEnabled(Toggle::UseDXC) && + !device->IsToggleEnabled(Toggle::FxcOptimizations)) { + compileFlags |= D3DCOMPILE_OPTIMIZATION_LEVEL0; + } + if (device->IsToggleEnabled(Toggle::EmitHLSLDebugSymbols)) { compileFlags |= D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION; } diff --git a/src/dawn_native/d3d12/DeviceD3D12.cpp b/src/dawn_native/d3d12/DeviceD3D12.cpp index 8eb4a8780d..a9bf0331ff 100644 --- a/src/dawn_native/d3d12/DeviceD3D12.cpp +++ b/src/dawn_native/d3d12/DeviceD3D12.cpp @@ -518,10 +518,9 @@ namespace dawn_native { namespace d3d12 { SetToggle(Toggle::UseD3D12ResidencyManagement, true); SetToggle(Toggle::UseDXC, false); -#if defined(_DEBUG) - // Enable better shader debugging with the graphics debugging tools. - SetToggle(Toggle::EmitHLSLDebugSymbols, true); -#endif + // Disable optimizations when using FXC + // See https://crbug.com/dawn/1203 + SetToggle(Toggle::FxcOptimizations, false); // By default use the maximum shader-visible heap size allowed. SetToggle(Toggle::UseD3D12SmallShaderVisibleHeapForTesting, false); diff --git a/src/dawn_native/d3d12/RenderPipelineD3D12.cpp b/src/dawn_native/d3d12/RenderPipelineD3D12.cpp index dbe62522d4..de90d1d55c 100644 --- a/src/dawn_native/d3d12/RenderPipelineD3D12.cpp +++ b/src/dawn_native/d3d12/RenderPipelineD3D12.cpp @@ -326,6 +326,11 @@ namespace dawn_native { namespace d3d12 { Device* device = ToBackend(GetDevice()); uint32_t compileFlags = 0; + if (!device->IsToggleEnabled(Toggle::UseDXC) && + !device->IsToggleEnabled(Toggle::FxcOptimizations)) { + compileFlags |= D3DCOMPILE_OPTIMIZATION_LEVEL0; + } + if (device->IsToggleEnabled(Toggle::EmitHLSLDebugSymbols)) { compileFlags |= D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION; }