From 9f6bb77743014e4321e783aae5e84af1c925e572 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 24 Apr 2021 17:57:04 +0300 Subject: [PATCH] Enable creation of SPIR-V modules from GLSL source code --- source/core/module.cpp | 17 ++++++++++++----- source/core/module.h | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) 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; } -- 2.43.0