Add "fxc_optimizations" toggle set to false by default
FXC sometimes miscompiles code when optimizing (/O2), and there is no discernable workaround. This change sets the optimization level to /O0 when compiling shaders with FXC. Also, no longer default to enabling EmitHLSLDebugSymbols in Debug builds, which disabled optimizations (/Od). This confused me a few times, and is not necessary since we can set this toggle via command line. Bug: dawn:1203 Bug: tint:1175 Bug: tint:1112 Change-Id: Ide9e6ecd45adeca951b8836dee91a8367eca3769 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/70700 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
802292eb52
commit
db6aa8a4ad
|
@ -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
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace dawn_native {
|
|||
UseUserDefinedLabelsInBackend,
|
||||
DisableR8RG8Mipmaps,
|
||||
UseDummyFragmentInVertexOnlyPipeline,
|
||||
FxcOptimizations,
|
||||
|
||||
EnumCount,
|
||||
InvalidEnum = EnumCount,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue