X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fprogram.h;h=dd7d4b5f029789a074815ff94d9112e27c6818a6;hp=b7f46ee4082a74a17ff68aa24328b6c5c01cf9f5;hb=959efbf61663efd7879070ce0447e02c8a447ce0;hpb=1b23728908f5ec9beb08b2b70737c3903745fddc diff --git a/source/core/program.h b/source/core/program.h index b7f46ee4..dd7d4b5f 100644 --- a/source/core/program.h +++ b/source/core/program.h @@ -1,24 +1,26 @@ #ifndef MSP_GL_PROGRAM_H_ #define MSP_GL_PROGRAM_H_ +#include #include #include #include -#include "gl.h" #include "module.h" +#include "program_backend.h" #include "reflectdata.h" -#include "vertexformat.h" namespace Msp { namespace GL { /** -A complete shader program. Programs can be assembled of individual Shaders or -generated with a set of standard features. +A shader program consisting of one or more stages. + +Programs are created from Modules. Specialization values can be applied to +customize behaviour of the module. */ -class Program +class Program: public ProgramBackend { - friend class PipelineState; + friend ProgramBackend; public: class Loader: public DataFile::CollectionObjectLoader @@ -27,8 +29,6 @@ public: Loader(Program &, Collection &); private: - virtual void finish(); - void module(const std::string &); }; @@ -50,62 +50,24 @@ private: void specialize_int(const std::string &, int); }; - enum Stage - { - VERTEX, - GEOMETRY, - FRAGMENT, - MAX_STAGES - }; - - struct TransientData - { - std::map textures; - std::map blocks; - std::map spec_values; - }; - - unsigned id; - unsigned stage_ids[MAX_STAGES]; - const Module *module; - TransientData *transient; - bool linked; ReflectData reflect_data; - 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::map()); -private: - void init(); -public: - virtual ~Program(); - void add_stages(const Module &, const std::map & = std::map()); private: - bool has_stages() const; - unsigned add_stage(Stage); - void add_glsl_stages(const GlslModule &, const std::map &); - void compile_glsl_stage(unsigned); - void add_spirv_stages(const SpirVModule &, const std::map &); - -public: - void link(); -private: - void query_uniforms(); - void query_uniform_blocks(const std::vector &); - void query_attributes(); - void collect_uniforms(); + void collect_uniforms(const SpirVModule &); void collect_block_uniforms(const SpirVModule::Structure &, const std::string &, unsigned, std::vector &); - void collect_attributes(); + void collect_attributes(const SpirVModule &); + void collect_builtins(const SpirVModule &); + void collect_builtins(const SpirVModule::Structure &); public: - bool is_linked() const { return linked; } - ReflectData::LayoutHash get_uniform_layout_hash() const { return reflect_data.layout_hash; } const std::vector &get_uniform_blocks() const { return reflect_data.uniform_blocks; } const ReflectData::UniformBlockInfo &get_uniform_block_info(const std::string &) const; @@ -118,10 +80,9 @@ public: const std::vector &get_attributes() const { return reflect_data.attributes; } const ReflectData::AttributeInfo &get_attribute_info(const std::string &) const; int get_attribute_location(const std::string &) const; + unsigned get_n_clip_distances() const { return reflect_data.n_clip_distances; } - void set_debug_name(const std::string &); -private: - void set_stage_debug_name(unsigned, Stage); + using ProgramBackend::set_debug_name; }; } // namespace GL