From 677744faccc5d3ac14fd468267f622ba6187dc74 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 14 Apr 2021 19:12:31 +0300 Subject: [PATCH] Add generator ID for the SPIR-V compiler --- source/glsl/spirv.cpp | 2 +- source/glsl/spirvconstants.h | 3 ++- source/glsl/spirvwriter.cpp | 4 ++-- source/glsl/spirvwriter.h | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/source/glsl/spirv.cpp b/source/glsl/spirv.cpp index 799e31d6..be226b3c 100644 --- a/source/glsl/spirv.cpp +++ b/source/glsl/spirv.cpp @@ -141,7 +141,7 @@ void SpirVGenerator::apply(Module &module) i->content.visit(*this); } - writer.finalize(next_id); + writer.finalize(SPIRV_GENERATOR_MSP, next_id); } SpirVGenerator::StorageClass SpirVGenerator::get_interface_storage(const string &iface, bool block) diff --git a/source/glsl/spirvconstants.h b/source/glsl/spirvconstants.h index b981d191..9e21b269 100644 --- a/source/glsl/spirvconstants.h +++ b/source/glsl/spirvconstants.h @@ -8,7 +8,8 @@ namespace SL { enum SpirVConstants { SPIRV_MAGIC = 0x07230203, - SPIRV_MAGIC_REVERSED = 0x03022307 + SPIRV_MAGIC_REVERSED = 0x03022307, + SPIRV_GENERATOR_MSP = 29 }; enum SpirVOpcode diff --git a/source/glsl/spirvwriter.cpp b/source/glsl/spirvwriter.cpp index 77ddbdb9..30369f2c 100644 --- a/source/glsl/spirvwriter.cpp +++ b/source/glsl/spirvwriter.cpp @@ -190,11 +190,11 @@ void SpirVWriter::end_function_body() content.function_body.clear(); } -void SpirVWriter::finalize(Id id_bound) +void SpirVWriter::finalize(unsigned generator, Id id_bound) { content.code.push_back(SPIRV_MAGIC); content.code.push_back(0x00010500); - content.code.push_back(0); // Generator + content.code.push_back(generator<<16); content.code.push_back(id_bound); content.code.push_back(0); // Reserved append(content.code, content.capabilities); diff --git a/source/glsl/spirvwriter.h b/source/glsl/spirvwriter.h index 94f44e88..fb5ec644 100644 --- a/source/glsl/spirvwriter.h +++ b/source/glsl/spirvwriter.h @@ -64,7 +64,7 @@ public: bool has_current_block() const { return current_block_id; } void begin_function_body(Id); void end_function_body(); - void finalize(Id); + void finalize(unsigned, Id); }; } // namespace SL -- 2.45.2