X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fprogram.h;h=33413eb01da23eb035fa0fc04e1fc5c488d7c323;hb=7c069241318b7133ac2df65ee13cb1d2968c5974;hp=fc60db46fcc2265af0b1ad9282eec1b5b19f6dcb;hpb=7aaec9a70b8d7733429bec043f8e33e02956f266;p=libs%2Fgl.git diff --git a/source/core/program.h b/source/core/program.h index fc60db46..33413eb0 100644 --- a/source/core/program.h +++ b/source/core/program.h @@ -5,12 +5,15 @@ #include #include #include "bindable.h" +#include "datatype.h" #include "gl.h" #include "vertexformat.h" namespace Msp { namespace GL { +class GlslModule; +class Module; class Shader; /** @@ -20,10 +23,10 @@ generated with a set of standard features. class Program: public Bindable { public: - class Loader: public DataFile::ObjectLoader + class Loader: public DataFile::CollectionObjectLoader { public: - Loader(Program &); + Loader(Program &, Collection &); private: virtual void finish(); @@ -31,9 +34,29 @@ public: void attribute(unsigned, const std::string &); void fragment_shader(const std::string &); void geometry_shader(const std::string &); + void module(const std::string &); void vertex_shader(const std::string &); }; +private: + class SpecializationLoader: public DataFile::Loader + { + private: + std::map &spec_values; + + static ActionMap shared_actions; + + public: + SpecializationLoader(std::map &); + + private: + virtual void init_actions(); + + void specialize_bool(const std::string &, bool); + void specialize_int(const std::string &, int); + }; + +public: typedef unsigned LayoutHash; struct UniformBlockInfo; @@ -42,10 +65,10 @@ public: std::string name; const UniformBlockInfo *block; unsigned location; - unsigned size; + unsigned array_size; unsigned array_stride; unsigned matrix_stride; - GLenum type; + DataType type; }; struct UniformBlockInfo @@ -61,19 +84,18 @@ public: { std::string name; unsigned location; - unsigned size; - GLenum type; + unsigned array_size; + DataType type; }; - typedef std::vector ShaderList; typedef std::map UniformMap; typedef std::map UniformBlockMap; typedef std::map AttributeMap; private: unsigned id; - ShaderList shaders; - ShaderList owned_data; + std::vector stage_ids; + const Module *module; bool linked; UniformBlockMap uniform_blocks; UniformMap uniforms; @@ -81,32 +103,41 @@ private: AttributeMap attributes; public: - /// Constructs an empty Program with no Shaders attached. + /// Constructs an empty Program with no shader stages attached. Program(); /// Constructs a Program from unified source code using ProgramCompiler. - Program(const std::string &); + DEPRECATED Program(const std::string &); /// Constructs a Program from vertex and fragment shader source code. - Program(const std::string &, const std::string &); + DEPRECATED Program(const std::string &, const std::string &); + + /// Constructs a Program from a Module, with specialization constants. + Program(const Module &, const std::map & = std::map()); private: void init(); public: virtual ~Program(); - void attach_shader(Shader &shader); - void attach_shader_owned(Shader *shader); - void detach_shader(Shader &shader); - const ShaderList &get_attached_shaders() const { return shaders; } + void add_stages(const Module &, const std::map & = std::map()); +private: + unsigned add_stage(GLenum); + void add_glsl_stages(const GlslModule &, const std::map &); + void compile_glsl_stage(unsigned); + +public: + DEPRECATED void attach_shader(Shader &shader); + DEPRECATED void attach_shader_owned(Shader *shader); + DEPRECATED void detach_shader(Shader &shader); + DEPRECATED const std::vector &get_attached_shaders() const; - void bind_attribute(unsigned, const std::string &); - void bind_attribute(VertexComponent, const std::string &); - void bind_fragment_data(unsigned, const std::string &); + DEPRECATED void bind_attribute(unsigned, const std::string &); + DEPRECATED void bind_attribute(VertexAttribute, const std::string &); + DEPRECATED void bind_fragment_data(unsigned, const std::string &); void link(); private: - static void require_type(GLenum); void query_uniforms(); void query_uniform_blocks(const std::vector &); void query_attributes(); @@ -114,7 +145,7 @@ private: static bool uniform_location_compare(const UniformInfo *, const UniformInfo *); public: bool is_linked() const { return linked; } - std::string get_info_log() const; + DEPRECATED std::string get_info_log() const; LayoutHash get_uniform_layout_hash() const { return uniform_layout_hash; } const UniformBlockMap &get_uniform_blocks() const { return uniform_blocks; }