1 #ifndef MSP_GL_PROGRAM_BACKEND_H_
2 #define MSP_GL_PROGRAM_BACKEND_H_
7 #include <msp/core/noncopyable.h>
8 #include "reflectdata.h"
13 class OpenGLProgram: public NonCopyable
15 friend class OpenGLPipelineState;
31 using FuncPtr = void (*)(unsigned, unsigned, const void *);
37 UniformCall(unsigned l, unsigned s, FuncPtr f): location(l), size(s), func(f) { }
41 unsigned stage_ids[MAX_STAGES] = { };
43 std::vector<UniformCall> uniform_calls;
44 std::string debug_name;
47 OpenGLProgram(OpenGLProgram &&);
50 bool has_stages() const;
51 unsigned add_stage(Stage);
52 void add_glsl_stages(const GlslModule &, const std::map<std::string, int> &);
53 void compile_glsl_stage(const GlslModule &, unsigned);
54 void add_spirv_stages(const SpirVModule &, const std::map<std::string, int> &);
56 void link(const Module &);
57 void query_uniforms();
58 void query_uniform_blocks(const std::vector<ReflectData::UniformInfo *> &);
59 void query_attributes();
60 void finalize_uniforms();
62 bool is_compute() const { return stage_ids[COMPUTE]; }
63 bool has_tessellation() const { return stage_ids[TESS_CONTROL] && stage_ids[TESS_EVAL]; }
65 void set_debug_name(const std::string &);
66 void set_stage_debug_name(unsigned, Stage);
69 using ProgramBackend = OpenGLProgram;