diff --git a/src/dawn_native/ShaderModule.cpp b/src/dawn_native/ShaderModule.cpp index 5db2d22929..262b42a59a 100644 --- a/src/dawn_native/ShaderModule.cpp +++ b/src/dawn_native/ShaderModule.cpp @@ -1126,12 +1126,6 @@ namespace dawn_native { newWgslCode = std::move(result.wgsl); newWgslDesc.source = newWgslCode.c_str(); - if (device->IsToggleEnabled(Toggle::DumpTranslatedShaders)) { - std::ostringstream dumpedMsg; - dumpedMsg << "// Dumped generated WGSL" << std::endl << newWgslCode; - device->EmitLog(WGPULoggingType_Info, dumpedMsg.str().c_str()); - } - spirvDesc = nullptr; wgslDesc = &newWgslDesc; } @@ -1155,6 +1149,12 @@ namespace dawn_native { } else if (wgslDesc) { auto tintSource = std::make_unique("", wgslDesc->source); + if (device->IsToggleEnabled(Toggle::DumpShaders)) { + std::ostringstream dumpedMsg; + dumpedMsg << "// Dumped WGSL:" << std::endl << wgslDesc->source; + device->EmitLog(WGPULoggingType_Info, dumpedMsg.str().c_str()); + } + tint::Program program; DAWN_TRY_ASSIGN(program, ParseWGSL(&tintSource->file, outMessages)); diff --git a/src/dawn_native/Toggles.cpp b/src/dawn_native/Toggles.cpp index 65da56b35c..195aa75e29 100644 --- a/src/dawn_native/Toggles.cpp +++ b/src/dawn_native/Toggles.cpp @@ -189,12 +189,15 @@ namespace dawn_native { "This is useful to prevent a Chromium renderer process from successfully sending" "SPIR-V code to be compiled in the GPU process.", "https://crbug.com/1214923"}}, - {Toggle::DumpTranslatedShaders, - {"dump_translated_shaders", - "Dump generated shaders for debug propose, dumped shaders will be log via " + {Toggle::DumpShaders, + {"dump_shaders", + "Dump shaders for debugging purposes. Dumped shaders will be log via " "EmitLog, thus printed in Chrome console or consumed by user-defined callback " "function.", "https://crbug.com/dawn/792"}}, + {Toggle::DEPRECATED_DumpTranslatedShaders, + {"dump_translated_shaders", "Deprecated. Use dump_shaders", + "https://crbug.com/dawn/792"}}, {Toggle::ForceWGSLStep, {"force_wgsl_step", "When ingesting SPIR-V shaders, force a first conversion to WGSL. This allows " @@ -206,12 +209,19 @@ namespace dawn_native { } // anonymous namespace void TogglesSet::Set(Toggle toggle, bool enabled) { + if (toggle == Toggle::DEPRECATED_DumpTranslatedShaders) { + Set(Toggle::DumpShaders, enabled); + return; + } ASSERT(toggle != Toggle::InvalidEnum); const size_t toggleIndex = static_cast(toggle); toggleBitset.set(toggleIndex, enabled); } bool TogglesSet::Has(Toggle toggle) const { + if (toggle == Toggle::DEPRECATED_DumpTranslatedShaders) { + return Has(Toggle::DumpShaders); + } ASSERT(toggle != Toggle::InvalidEnum); const size_t toggleIndex = static_cast(toggle); return toggleBitset.test(toggleIndex); diff --git a/src/dawn_native/Toggles.h b/src/dawn_native/Toggles.h index 711f8d33c2..ade8e7a635 100644 --- a/src/dawn_native/Toggles.h +++ b/src/dawn_native/Toggles.h @@ -53,7 +53,8 @@ namespace dawn_native { UseTempBufferInSmallFormatTextureToTextureCopyFromGreaterToLessMipLevel, EmitHLSLDebugSymbols, DisallowSpirv, - DumpTranslatedShaders, + DumpShaders, + DEPRECATED_DumpTranslatedShaders, // Use DumpShaders ForceWGSLStep, EnumCount, diff --git a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp index d8b742ac73..614cd7126e 100644 --- a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp +++ b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp @@ -395,7 +395,7 @@ namespace dawn_native { namespace d3d12 { entryPointName = "main"; } - if (device->IsToggleEnabled(Toggle::DumpTranslatedShaders)) { + if (device->IsToggleEnabled(Toggle::DumpShaders)) { std::ostringstream dumpedMsg; dumpedMsg << "/* Dumped generated HLSL */" << std::endl << hlslSource; GetDevice()->EmitLog(WGPULoggingType_Info, dumpedMsg.str().c_str()); diff --git a/src/dawn_native/metal/ShaderModuleMTL.mm b/src/dawn_native/metal/ShaderModuleMTL.mm index d8afff53d2..439e7839da 100644 --- a/src/dawn_native/metal/ShaderModuleMTL.mm +++ b/src/dawn_native/metal/ShaderModuleMTL.mm @@ -310,7 +310,7 @@ namespace dawn_native { namespace metal { #endif )" + msl; - if (GetDevice()->IsToggleEnabled(Toggle::DumpTranslatedShaders)) { + if (GetDevice()->IsToggleEnabled(Toggle::DumpShaders)) { std::ostringstream dumpedMsg; dumpedMsg << "/* Dumped generated MSL */" << std::endl << msl; GetDevice()->EmitLog(WGPULoggingType_Info, dumpedMsg.str().c_str());