]> git.sesse.net Git - movit/blobdiff - effect.h
Use UBOs instead of glUniform. Work in progress; no clear wins seen yet.
[movit] / effect.h
index ebbb6726104051caaba9b4e58df21279682dc1f3..d812db0ad2f900be6a9c7289fc5466d507758f48 100644 (file)
--- a/effect.h
+++ b/effect.h
@@ -59,7 +59,9 @@ struct Uniform {
        const T *value;  // Owner by the effect.
        size_t num_values;  // Number of elements; for arrays only. _Not_ the vector length.
        std::string prefix;  // Filled in only after phases have been constructed.
-       GLint location;  // Filled in only after phases have been constructed. -1 if no location.
+       GLuint location;  // Filled in only after phases have been constructed. GL_INVALID_INDEX if no location, or if using UBOs.
+       GLint ubo_offset;  // Same. -1 if no location or if not using UBOs.
+       GLint ubo_num_elem; // Same. 0 if no location or if not using UBOs.
 };
 
 class Effect {
@@ -316,11 +318,8 @@ protected:
        //
        // Neither of these take ownership of the pointer.
 
-       // int is special since GLSL pre-1.30 doesn't have integer uniforms.
-       // Thus, ints that you register will _not_ be converted to GLSL uniforms.
+       // These correspond directly to int/float/vec2/vec3/vec4 in GLSL.
        void register_int(const std::string &key, int *value);
-
-       // These correspond directly to float/vec2/vec3/vec4 in GLSL.
        void register_float(const std::string &key, float *value);
        void register_vec2(const std::string &key, float *values);
        void register_vec3(const std::string &key, float *values);
@@ -353,7 +352,9 @@ protected:
        void register_uniform_vec2(const std::string &key, const float *values);
        void register_uniform_vec3(const std::string &key, const float *values);
        void register_uniform_vec4(const std::string &key, const float *values);
+       void register_uniform_float_array(const std::string &key, const float *values, size_t num_values);
        void register_uniform_vec2_array(const std::string &key, const float *values, size_t num_values);
+       void register_uniform_vec3_array(const std::string &key, const float *values, size_t num_values);
        void register_uniform_vec4_array(const std::string &key, const float *values, size_t num_values);
        void register_uniform_mat3(const std::string &key, const Eigen::Matrix3d *matrix);
 
@@ -372,7 +373,9 @@ private:
        std::vector<Uniform<float> > uniforms_vec2;
        std::vector<Uniform<float> > uniforms_vec3;
        std::vector<Uniform<float> > uniforms_vec4;
+       std::vector<Uniform<float> > uniforms_float_array;
        std::vector<Uniform<float> > uniforms_vec2_array;
+       std::vector<Uniform<float> > uniforms_vec3_array;
        std::vector<Uniform<float> > uniforms_vec4_array;
        std::vector<Uniform<Eigen::Matrix3d> > uniforms_mat3;
        friend class EffectChain;