From b91e8a9fbefe87049602009704d61188d67a6a70 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 12 Jan 2021 02:59:12 +0000 Subject: [PATCH] Add a Unsafe SPIR-V generate call. Currently Dawn may use the tint generator or the SPIRV-Cross generator. In the case of SPIRV-Cross, we need to generate the SPIR-V with the original names otherwise SPIRV-Cross won't be able to match up the entry point name with the names in the shader. Change-Id: Ica473030009b282fee352f2d1c1acc93f1db592c Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37222 Reviewed-by: dan sinclair Commit-Queue: dan sinclair --- src/writer/spirv/generator.cc | 16 ++++++++++++++++ src/writer/spirv/generator.h | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/src/writer/spirv/generator.cc b/src/writer/spirv/generator.cc index 41dfb07065..190af5f4c1 100644 --- a/src/writer/spirv/generator.cc +++ b/src/writer/spirv/generator.cc @@ -51,6 +51,22 @@ bool Generator::Generate() { return true; } +bool Generator::GenerateUnsafe() { + auto unsafe_namer = std::make_unique(module_); + builder_ = std::make_unique(module_, unsafe_namer.get()); + + if (!builder_->Build()) { + set_error(builder_->error()); + return false; + } + + writer_->WriteHeader(builder_->id_bound()); + writer_->WriteBuilder(builder_.get()); + + builder_ = std::make_unique(module_, namer_.get()); + return true; +} + bool Generator::GenerateEntryPoint(ast::PipelineStage, const std::string&) { return false; } diff --git a/src/writer/spirv/generator.h b/src/writer/spirv/generator.h index d84d753afc..7f73d490d8 100644 --- a/src/writer/spirv/generator.h +++ b/src/writer/spirv/generator.h @@ -48,6 +48,11 @@ class Generator : public writer::Writer { /// @returns true on successful generation; false otherwise bool Generate() override; + /// Generates the result data + /// DO NOT USE. Temporary fix for Dawn usage of SPRIV-Cross + /// @returns true on successful generation; false otherwise + bool GenerateUnsafe(); + /// Converts a single entry point /// @param stage the pipeline stage /// @param name the entry point name