Fix DXC shader source not showing up in PIX
Unlike FXC, DXC does not embed debug ingo in the shader object by
default. We must enable this via "/Qembed_debug".
Although not required, we also make sure to handle
D3DCOMPILE_SKIP_OPTIMIZATION by passing in "/Od", as this flag is also
enabled along with D3DCOMPILE_DEBUG when "emit_hlsl_debug_symbols"
is enabled.
Note when DXC parses optimization flags, /O[0-3[ and /Od, it will pick
the very last one that's passed in, so we make sure to pass in /Od last.
We should probably ensure that we only ever set one of these in Dawn to
avoid confusion.
Bug: dawn:2339
Change-Id: Icdfcd46a4360ac5ffa4ad31f36698897fbbba854
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/169761
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/dawn/native/d3d/ShaderUtils.cpp b/src/dawn/native/d3d/ShaderUtils.cpp
index 7938e6b..e9aad66 100644
--- a/src/dawn/native/d3d/ShaderUtils.cpp
+++ b/src/dawn/native/d3d/ShaderUtils.cpp
@@ -79,8 +79,15 @@
break;
}
}
+ if (compileFlags & D3DCOMPILE_SKIP_OPTIMIZATION) {
+ arguments.push_back(L"/Od");
+ }
if (compileFlags & D3DCOMPILE_DEBUG) {
arguments.push_back(L"/Zi");
+ // Unlike FXC, DXC does not embed debug info into the shader object by default, as it's
+ // preferable to save it to pdb files to keep shader objects small. Embed it for now, and we
+ // can consider exposing an option for users to supply a path to dump pdbs to in the future.
+ arguments.push_back(L"/Qembed_debug");
}
if (compileFlags & D3DCOMPILE_PACK_MATRIX_ROW_MAJOR) {
arguments.push_back(L"/Zpr");