]> git.tdb.fi Git - libs/gl.git/commitdiff
Enable creation of SPIR-V modules from GLSL source code
authorMikko Rasa <tdb@tdb.fi>
Sat, 24 Apr 2021 14:57:04 +0000 (17:57 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 24 Apr 2021 14:57:04 +0000 (17:57 +0300)
source/core/module.cpp
source/core/module.h

index 6f7fbdb93e9799dc488b7b10646c48cf2bc0c4ac..72a6abca43781a20e84f07abc8dbb1373f2eb295 100644 (file)
@@ -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)
index 4d819dacd5265bd83dc05077d0788698d93e7824..3492a5ded49b795ca37a808a9c8a403fed353d60 100644 (file)
@@ -203,6 +203,7 @@ public:
        void load_code(IO::Base &);
 private:
        virtual void compile(SL::Compiler &);
+       void reflect();
 
 public:
        const std::vector<UInt32> &get_code() const { return code; }