[clang-format]
Change-Id: Ie5f2a2499fd8c92e66a88601993e5200754f9b97
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/173020
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/native/ShaderModule.cpp b/src/dawn/native/ShaderModule.cpp
index b55ea40..8629822 100644
--- a/src/dawn/native/ShaderModule.cpp
+++ b/src/dawn/native/ShaderModule.cpp
@@ -1324,48 +1324,47 @@
}
ShaderModuleBase::ScopedUseTintProgram ShaderModuleBase::UseTintProgram() {
- return mTintData.Use(
- [&](auto tintData) {
- if (tintData->tintProgram) {
- return ScopedUseTintProgram(this);
- }
-
- // When the ShaderModuleBase is not referenced externally, and not used for initializing
- // any pipeline, the mTintProgram will be released. However the ShaderModuleBase itself
- // may still alive due to being referenced by some pipelines. In this case, when
- // DeviceBase::APICreateShaderModule() with the same shader source code, Dawn will look
- // up from the cache and return the same ShaderModuleBase. In this case, we have to
- // recreate mTintProgram, when the mTintProgram is required for initializing new
- // pipelines.
- ShaderModuleDescriptor descriptor;
- ShaderModuleWGSLDescriptor wgslDescriptor;
- ShaderModuleSPIRVDescriptor sprivDescriptor;
-
- switch (mType) {
- case Type::Spirv:
- sprivDescriptor.codeSize = mOriginalSpirv.size();
- sprivDescriptor.code = mOriginalSpirv.data();
- descriptor.nextInChain = &sprivDescriptor;
- break;
- case Type::Wgsl:
- wgslDescriptor.code = mWgsl.c_str();
- descriptor.nextInChain = &wgslDescriptor;
- break;
- default:
- DAWN_ASSERT(false);
- }
-
- ShaderModuleParseResult parseResult;
- ValidateAndParseShaderModule(GetDevice(), Unpack(&descriptor), &parseResult,
- /*compilationMessages=*/nullptr)
- .AcquireSuccess();
- DAWN_ASSERT(parseResult.tintProgram != nullptr);
-
- tintData->tintProgram = std::move(parseResult.tintProgram);
- tintData->tintProgramRecreateCount++;
-
+ return mTintData.Use([&](auto tintData) {
+ if (tintData->tintProgram) {
return ScopedUseTintProgram(this);
- });
+ }
+
+ // When the ShaderModuleBase is not referenced externally, and not used for initializing
+ // any pipeline, the mTintProgram will be released. However the ShaderModuleBase itself
+ // may still alive due to being referenced by some pipelines. In this case, when
+ // DeviceBase::APICreateShaderModule() with the same shader source code, Dawn will look
+ // up from the cache and return the same ShaderModuleBase. In this case, we have to
+ // recreate mTintProgram, when the mTintProgram is required for initializing new
+ // pipelines.
+ ShaderModuleDescriptor descriptor;
+ ShaderModuleWGSLDescriptor wgslDescriptor;
+ ShaderModuleSPIRVDescriptor sprivDescriptor;
+
+ switch (mType) {
+ case Type::Spirv:
+ sprivDescriptor.codeSize = mOriginalSpirv.size();
+ sprivDescriptor.code = mOriginalSpirv.data();
+ descriptor.nextInChain = &sprivDescriptor;
+ break;
+ case Type::Wgsl:
+ wgslDescriptor.code = mWgsl.c_str();
+ descriptor.nextInChain = &wgslDescriptor;
+ break;
+ default:
+ DAWN_ASSERT(false);
+ }
+
+ ShaderModuleParseResult parseResult;
+ ValidateAndParseShaderModule(GetDevice(), Unpack(&descriptor), &parseResult,
+ /*compilationMessages=*/nullptr)
+ .AcquireSuccess();
+ DAWN_ASSERT(parseResult.tintProgram != nullptr);
+
+ tintData->tintProgram = std::move(parseResult.tintProgram);
+ tintData->tintProgramRecreateCount++;
+
+ return ScopedUseTintProgram(this);
+ });
}
Ref<TintProgram> ShaderModuleBase::GetTintProgram() const {