From f78c28dcb7cec54df40e352e6413a5dcf1709bb8 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Tue, 6 Jul 2021 14:14:00 +0000 Subject: [PATCH] Add support for dump_translated_shaders to the Metal backend Bug: None Change-Id: Icecbe221970ec10e6497309108dec5ccefc0a944 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57060 Commit-Queue: Corentin Wallez Commit-Queue: Ben Clayton Auto-Submit: Corentin Wallez Reviewed-by: Ben Clayton --- src/dawn_native/metal/ShaderModuleMTL.mm | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/dawn_native/metal/ShaderModuleMTL.mm b/src/dawn_native/metal/ShaderModuleMTL.mm index 382ee86277..eddc904bc8 100644 --- a/src/dawn_native/metal/ShaderModuleMTL.mm +++ b/src/dawn_native/metal/ShaderModuleMTL.mm @@ -122,9 +122,12 @@ namespace dawn_native { namespace metal { transformManager.Add(); } transformManager.Add(); - transformManager.Add(); transformManager.Add(); + if (!GetDevice()->IsToggleEnabled(Toggle::DumpTranslatedShaders)) { + transformManager.Add(); + } + transformInputs.Add(std::move(bindingPoints), std::move(accessControls), /* mayCollide */ true); @@ -143,7 +146,11 @@ namespace dawn_native { namespace metal { } *remappedEntryPointName = it->second; } else { - return DAWN_VALIDATION_ERROR("Transform output missing renamer data."); + if (GetDevice()->IsToggleEnabled(Toggle::DumpTranslatedShaders)) { + *remappedEntryPointName = entryPointName; + } else { + return DAWN_VALIDATION_ERROR("Transform output missing renamer data."); + } } if (auto* data = transformOutputs.Get()) { @@ -312,6 +319,12 @@ namespace dawn_native { namespace metal { #endif )" + msl; + if (GetDevice()->IsToggleEnabled(Toggle::DumpTranslatedShaders)) { + std::ostringstream dumpedMsg; + dumpedMsg << "/* Dumped generated MSL */" << std::endl << msl; + GetDevice()->EmitLog(WGPULoggingType_Info, dumpedMsg.str().c_str()); + } + NSRef mslSource = AcquireNSRef([[NSString alloc] initWithUTF8String:msl.c_str()]); auto mtlDevice = ToBackend(GetDevice())->GetMTLDevice();