From: Mikko Rasa Date: Sat, 24 Apr 2021 14:57:04 +0000 (+0300) Subject: Enable creation of SPIR-V modules from GLSL source code X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=9f6bb77743014e4321e783aae5e84af1c925e572;p=libs%2Fgl.git Enable creation of SPIR-V modules from GLSL source code --- diff --git a/source/core/module.cpp b/source/core/module.cpp index 6f7fbdb9..72a6abca 100644 --- a/source/core/module.cpp +++ b/source/core/module.cpp @@ -127,6 +127,18 @@ void SpirVModule::load_code(IO::Base &io) code.insert(code.end(), buffer, buffer+len); } + reflect(); +} + +void SpirVModule::compile(SL::Compiler &compiler) +{ + compiler.compile(SL::Compiler::SPIRV); + code = compiler.get_combined_spirv(); + reflect(); +} + +void SpirVModule::reflect() +{ if(code.empty()) throw invalid_module("Empty SPIR-V code"); @@ -216,11 +228,6 @@ void SpirVModule::load_code(IO::Base &io) spec_constants.push_back(i->second); } -void SpirVModule::compile(SL::Compiler &) -{ - throw logic_error("Not implemented yet"); -} - SpirVModule::EntryPoint::EntryPoint(): stage(VERTEX) diff --git a/source/core/module.h b/source/core/module.h index 4d819dac..3492a5de 100644 --- a/source/core/module.h +++ b/source/core/module.h @@ -203,6 +203,7 @@ public: void load_code(IO::Base &); private: virtual void compile(SL::Compiler &); + void reflect(); public: const std::vector &get_code() const { return code; }