ShaderModule: Keep the tint::Source::File alive
Certain backends performs transformations on the tint::Program in the ShaderModule.
These transformations may raise diagnostics.
Tint diagnostics generated from an underlying tint::Source::File need that File kept alive.
Change-Id: I32deceb4cedb419e914631d342884fc27972b5cb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/50581
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/dawn_native/ShaderModule.cpp b/src/dawn_native/ShaderModule.cpp
index 6903485..a0dc713 100644
--- a/src/dawn_native/ShaderModule.cpp
+++ b/src/dawn_native/ShaderModule.cpp
@@ -1050,7 +1050,7 @@
}
// TintSource is a PIMPL container for a tint::Source::File, which needs to be kept alive for as
- // long as tint diagnostics are inspected.
+ // long as tint diagnostics are inspected / printed.
class TintSource {
public:
template <typename... ARGS>
@@ -1070,9 +1070,8 @@
return DAWN_VALIDATION_ERROR("Shader module descriptor missing chained descriptor");
}
// For now only a single SPIRV or WGSL subdescriptor is allowed.
- DAWN_TRY(ValidateSingleSType(chainedDescriptor,
- wgpu::SType::ShaderModuleSPIRVDescriptor,
- wgpu::SType::ShaderModuleWGSLDescriptor));
+ DAWN_TRY(ValidateSingleSType(chainedDescriptor, wgpu::SType::ShaderModuleSPIRVDescriptor,
+ wgpu::SType::ShaderModuleWGSLDescriptor));
OwnedCompilationMessages* outMessages = parseResult->compilationMessages.get();
@@ -1114,8 +1113,8 @@
spirv_cfg.emit_vertex_point_size = true;
transformInputs.Add<tint::transform::Spirv::Config>(spirv_cfg);
- DAWN_TRY_ASSIGN(program, RunTransforms(&transformManager, &program,
- transformInputs, nullptr, outMessages));
+ DAWN_TRY_ASSIGN(program, RunTransforms(&transformManager, &program, transformInputs,
+ nullptr, outMessages));
std::vector<uint32_t> spirv;
DAWN_TRY_ASSIGN(spirv, ModuleToSPIRV(&program));
@@ -1346,6 +1345,7 @@
MaybeError ShaderModuleBase::InitializeBase(ShaderModuleParseResult* parseResult) {
mTintProgram = std::move(parseResult->tintProgram);
+ mTintSource = std::move(parseResult->tintSource);
mSpirv = std::move(parseResult->spirv);
mCompilationMessages = std::move(parseResult->compilationMessages);
diff --git a/src/dawn_native/ShaderModule.h b/src/dawn_native/ShaderModule.h
index 2534792..b5d949f 100644
--- a/src/dawn_native/ShaderModule.h
+++ b/src/dawn_native/ShaderModule.h
@@ -203,6 +203,7 @@
EntryPointMetadataTable mEntryPoints;
std::vector<uint32_t> mSpirv;
std::unique_ptr<tint::Program> mTintProgram;
+ std::unique_ptr<TintSource> mTintSource; // Keep the tint::Source::File alive
std::unique_ptr<OwnedCompilationMessages> mCompilationMessages;
};