From 13712ba4f358eec2d96cfa00c2bb3e66961a274c Mon Sep 17 00:00:00 2001 From: Antonio Maiorano Date: Wed, 24 Nov 2021 20:05:57 +0000 Subject: [PATCH] Fix dumping of FXC compile flags The logic was incorrect, printing "D3DCOMPILE_OPTIMIZATION_LEVEL2" for levels 0, 2, and 3. Bug: dawn:1162 Change-Id: I6ab7d9d3d22556b6602c778bddd99e5f2274b02b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/70705 Reviewed-by: Corentin Wallez Commit-Queue: Antonio Maiorano --- src/dawn_native/d3d12/ShaderModuleD3D12.cpp | 25 +++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp index fec6e6047d..b70c676613 100644 --- a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp +++ b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp @@ -351,7 +351,8 @@ namespace dawn_native { namespace d3d12 { if (compileFlags & D3DCOMPILE_IEEE_STRICTNESS) { arguments.push_back(L"/Gis"); } - if (compileFlags & D3DCOMPILE_OPTIMIZATION_LEVEL2) { + constexpr uint32_t d3dCompileFlagsBits = D3DCOMPILE_OPTIMIZATION_LEVEL2; + if (compileFlags & d3dCompileFlagsBits) { switch (compileFlags & D3DCOMPILE_OPTIMIZATION_LEVEL2) { case D3DCOMPILE_OPTIMIZATION_LEVEL0: arguments.push_back(L"/O0"); @@ -490,14 +491,20 @@ namespace dawn_native { namespace d3d12 { // Optimization level must be handled separately as two bits are used, and the values // don't map neatly to 0-3. - if ((compileFlags & D3DCOMPILE_OPTIMIZATION_LEVEL2) != 0) { - result += "D3DCOMPILE_OPTIMIZATION_LEVEL2"; - } else if ((compileFlags & D3DCOMPILE_OPTIMIZATION_LEVEL0) != 0) { - result += "D3DCOMPILE_OPTIMIZATION_LEVEL0"; - } else if ((compileFlags & D3DCOMPILE_OPTIMIZATION_LEVEL3) != 0) { - result += "D3DCOMPILE_OPTIMIZATION_LEVEL3"; - } else { - result += "D3DCOMPILE_OPTIMIZATION_LEVEL1"; + constexpr uint32_t d3dCompileFlagsBits = D3DCOMPILE_OPTIMIZATION_LEVEL2; + switch (compileFlags & d3dCompileFlagsBits) { + case D3DCOMPILE_OPTIMIZATION_LEVEL0: + result += "D3DCOMPILE_OPTIMIZATION_LEVEL0"; + break; + case D3DCOMPILE_OPTIMIZATION_LEVEL1: + result += "D3DCOMPILE_OPTIMIZATION_LEVEL1"; + break; + case D3DCOMPILE_OPTIMIZATION_LEVEL2: + result += "D3DCOMPILE_OPTIMIZATION_LEVEL2"; + break; + case D3DCOMPILE_OPTIMIZATION_LEVEL3: + result += "D3DCOMPILE_OPTIMIZATION_LEVEL3"; + break; } result += std::string("\n");