]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/program.h
Use default member initializers for simple types
[libs/gl.git] / source / core / program.h
index 41c5897dc08ccb54a5461a798c78b425b5315bf9..fd1c1ae09d10e12943ca13140339b96d59cd5ecf 100644 (file)
@@ -6,6 +6,7 @@
 #include <vector>
 #include <msp/datafile/objectloader.h>
 #include "module.h"
+#include "program_backend.h"
 #include "reflectdata.h"
 
 namespace Msp {
@@ -15,9 +16,9 @@ namespace GL {
 A complete shader program.  Programs can be assembled of individual Shaders or
 generated with a set of standard features.
 */
-class Program
+class Program: public ProgramBackend
 {
-       friend class PipelineState;
+       friend ProgramBackend;
 
 public:
        class Loader: public DataFile::CollectionObjectLoader<Program>
@@ -47,63 +48,17 @@ private:
                void specialize_int(const std::string &, int);
        };
 
-       enum Stage
-       {
-               VERTEX,
-               GEOMETRY,
-               FRAGMENT,
-               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 *);
-
-               unsigned location;
-               unsigned size;
-               FuncPtr func;
-
-               UniformCall(unsigned l, unsigned s, FuncPtr f): location(l), size(s), func(f) { }
-       };
-
-       unsigned id;
-       unsigned stage_ids[MAX_STAGES];
-       bool linked;
        ReflectData reflect_data;
-       std::vector<UniformCall> uniform_calls;
-       std::string debug_name;
 
 public:
        /// Constructs an empty Program with no shader stages attached.
-       Program();
+       Program() = default;
 
        /// Constructs a Program from a Module, with specialization constants.
        Program(const Module &, const std::map<std::string, int> & = std::map<std::string, int>());
 
-private:
-       void init();
-public:
-       virtual ~Program();
-
        void add_stages(const Module &, const std::map<std::string, int> & = std::map<std::string, int>());
 private:
-       bool has_stages() const;
-       unsigned add_stage(Stage);
-       void add_glsl_stages(const GlslModule &, const std::map<std::string, int> &, TransientData &);
-       void compile_glsl_stage(const GlslModule &, unsigned);
-       void add_spirv_stages(const SpirVModule &, const std::map<std::string, int> &, TransientData &);
-
-       void finalize(const Module &, const TransientData &);
-       void query_uniforms();
-       void query_uniform_blocks(const std::vector<ReflectData::UniformInfo *> &);
-       void query_attributes();
        void collect_uniforms(const SpirVModule &, const std::map<unsigned, int> &);
        void collect_block_uniforms(const SpirVModule::Structure &, const std::string &, unsigned, const std::map<unsigned, int> &, std::vector<std::string> &);
        void collect_attributes(const SpirVModule &);
@@ -122,9 +77,7 @@ public:
        const ReflectData::AttributeInfo &get_attribute_info(const std::string &) const;
        int get_attribute_location(const std::string &) const;
 
-       void set_debug_name(const std::string &);
-private:
-       void set_stage_debug_name(unsigned, Stage);
+       using ProgramBackend::set_debug_name;
 };
 
 } // namespace GL