]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/opengl/program_backend.h
Simplify Program by removing transient data
[libs/gl.git] / source / backends / opengl / program_backend.h
index 4ae729e2c95525cc2ef8e102991d0bc25e464632..14650708e32abe77ee8f3ac3e851212e4b2ce895 100644 (file)
@@ -4,12 +4,13 @@
 #include <map>
 #include <string>
 #include <vector>
+#include <msp/core/noncopyable.h>
 #include "reflectdata.h"
 
 namespace Msp {
 namespace GL {
 
-class OpenGLProgram
+class OpenGLProgram: public NonCopyable
 {
        friend class OpenGLPipelineState;
 
@@ -22,13 +23,6 @@ protected:
                MAX_STAGES
        };
 
-       struct TransientData
-       {
-               std::map<std::string, unsigned> textures;
-               std::map<std::string, unsigned> blocks;
-               std::map<unsigned, int> spec_values;
-       };
-
        struct UniformCall
        {
                using FuncPtr = void (*)(unsigned, unsigned, const void *);
@@ -40,26 +34,27 @@ protected:
                UniformCall(unsigned l, unsigned s, FuncPtr f): location(l), size(s), func(f) { }
        };
 
-       unsigned id;
-       unsigned stage_ids[MAX_STAGES];
-       bool linked;
+       unsigned id = 0;
+       unsigned stage_ids[MAX_STAGES] = { };
+       bool linked = false;
        std::vector<UniformCall> uniform_calls;
        std::string debug_name;
 
        OpenGLProgram();
+       OpenGLProgram(OpenGLProgram &&);
        ~OpenGLProgram();
 
        bool has_stages() const;
        unsigned add_stage(Stage);
-       void add_glsl_stages(const GlslModule &, const std::map<std::string, int> &, TransientData &);
+       void add_glsl_stages(const GlslModule &, const std::map<std::string, int> &);
        void compile_glsl_stage(const GlslModule &, unsigned);
-       void add_spirv_stages(const SpirVModule &, const std::map<std::string, int> &, TransientData &);
+       void add_spirv_stages(const SpirVModule &, const std::map<std::string, int> &);
 
-       void finalize(const Module &);
+       void link(const Module &);
        void query_uniforms();
        void query_uniform_blocks(const std::vector<ReflectData::UniformInfo *> &);
        void query_attributes();
-       void apply_bindings(const TransientData &);
+       void finalize_uniforms();
 
        void set_debug_name(const std::string &);
        void set_stage_debug_name(unsigned, Stage);