From f0fdfa0d61dfa9486914fd278985d2de880be51a Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Tue, 11 May 2021 15:07:01 +0000 Subject: [PATCH] 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 Commit-Queue: Austin Eng Reviewed-by: Austin Eng --- src/dawn_native/ShaderModule.cpp | 12 ++++++------ src/dawn_native/ShaderModule.h | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/dawn_native/ShaderModule.cpp b/src/dawn_native/ShaderModule.cpp index 6903485cc4..a0dc713e78 100644 --- a/src/dawn_native/ShaderModule.cpp +++ b/src/dawn_native/ShaderModule.cpp @@ -1050,7 +1050,7 @@ namespace dawn_native { } // 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 @@ -1070,9 +1070,8 @@ namespace dawn_native { 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 @@ namespace dawn_native { spirv_cfg.emit_vertex_point_size = true; transformInputs.Add(spirv_cfg); - DAWN_TRY_ASSIGN(program, RunTransforms(&transformManager, &program, - transformInputs, nullptr, outMessages)); + DAWN_TRY_ASSIGN(program, RunTransforms(&transformManager, &program, transformInputs, + nullptr, outMessages)); std::vector spirv; DAWN_TRY_ASSIGN(spirv, ModuleToSPIRV(&program)); @@ -1346,6 +1345,7 @@ namespace dawn_native { 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 25347922b6..b5d949f10e 100644 --- a/src/dawn_native/ShaderModule.h +++ b/src/dawn_native/ShaderModule.h @@ -203,6 +203,7 @@ namespace dawn_native { EntryPointMetadataTable mEntryPoints; std::vector mSpirv; std::unique_ptr mTintProgram; + std::unique_ptr mTintSource; // Keep the tint::Source::File alive std::unique_ptr mCompilationMessages; };