From d80f4139bc4baa119a5dfcf74cdcf3a75b977efc Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Mon, 2 Jun 2025 16:47:16 -0700 Subject: Add a new slang-test option `-enable-debug-layers` (#7300) * Add a new slang-test option `-enable-debug-layers` A variable `disableDebugLayer` is renamed to `enableDebugLayers`, and a corresponding command-line argument is added, `-enable-debug-layers`. The previous option `-disable-debug-layer` is still available, but it prints a deprecation warning message. The reason why it is added is to make the option available to both Debug and Release. On Debug build, it will be enabled by default, and it will be disabled on Release build. We should be able to not only disable it, but also enable it on Release build. Ideally this option should be enabled all the time, but currently there are too many VUID error messages printed and we are enabling only for Debug build for now. Note that the CI/CD will run with the option disabled until we resolve all of VUID errors. --- tools/slang-test/options.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'tools/slang-test/options.cpp') diff --git a/tools/slang-test/options.cpp b/tools/slang-test/options.cpp index da4f9cffe..aa538e75e 100644 --- a/tools/slang-test/options.cpp +++ b/tools/slang-test/options.cpp @@ -88,6 +88,8 @@ static bool _isSubCommand(const char* arg) " -use-test-server Run tests using test server\n" " -use-fully-isolated-test-server Run each test in isolated server\n" " -capability Compile with the given capability\n" + " -enable-debug-layers [true|false] Enable or disable Validation Layer for Vulkan\n" + " and Debug Device for DX\n" #if _DEBUG " -disable-debug-layers Disable the debug layers (default enabled in debug " "build)\n" @@ -120,6 +122,19 @@ static bool _isSubCommand(const char* arg) char const* const* argCursor = argv; char const* const* argEnd = argCursor + argCount; +#if _DEBUG + // Enabling debug layers by default in debug builds. + // For DX12 it will use the debug layer, for Vulkan it will enable validation layers. + // + // CI/CD will explicitly disable this until we address all of VUID errors. + // https://github.com/shader-slang/slang/issues/4798 + // + // When you run the Debug build locally, you may see more errors if not disabled with + // '-enable-debug-layers false'. + // + optionsOut->enableDebugLayers = true; +#endif + // first argument is the application name if (argCursor != argEnd) { @@ -410,10 +425,32 @@ static bool _isSubCommand(const char* arg) { optionsOut->skipReferenceImageGeneration = true; } + else if (strcmp(arg, "-enable-debug-layers") == 0) + { + optionsOut->enableDebugLayers = true; + + if (argCursor == argEnd) + { + stdError.print("error: expected operand for '%s'\n", arg); + showHelp(stdError); + return SLANG_FAIL; + } + + // Check for false variants + const char* value = *argCursor++; + if (value[0] == 'f' || value[0] == 'F' || value[0] == 'n' || value[0] == 'N' || + value[0] == '0' || + ((value[0] == 'o' || value[0] == 'O') && (value[1] == 'f' || value[1] == 'F'))) + { + optionsOut->enableDebugLayers = false; + } + } #if _DEBUG else if (strcmp(arg, "-disable-debug-layers") == 0) { - optionsOut->debugLayerEnabled = false; + stdError.print("warning: '-disable-debug-layers' is deprecated, use " + "'-enable-debug-layers false'\n"); + optionsOut->enableDebugLayers = false; } #endif else -- cgit v1.2.3