ShaderModule: Deprecate dump_translated_shaders for dump_shaders

And print the WGSL program even when !force_wgsl_step
Shaders are often built through string concatenation.
Being able to always dump this is useful.

Change-Id: I5da3866b333e8a80931c7c2837f0247e8f38213d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57380
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2021-07-14 20:59:54 +00:00 committed by Dawn LUCI CQ
parent b81021dc82
commit d9d6e7fc40
5 changed files with 23 additions and 12 deletions

View File

@ -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<TintSource>("", 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));

View File

@ -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<size_t>(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<size_t>(toggle);
return toggleBitset.test(toggleIndex);

View File

@ -53,7 +53,8 @@ namespace dawn_native {
UseTempBufferInSmallFormatTextureToTextureCopyFromGreaterToLessMipLevel,
EmitHLSLDebugSymbols,
DisallowSpirv,
DumpTranslatedShaders,
DumpShaders,
DEPRECATED_DumpTranslatedShaders, // Use DumpShaders
ForceWGSLStep,
EnumCount,

View File

@ -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());

View File

@ -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());