+// A rendering phase; a single GLSL program rendering a single quad.
+struct Phase {
+ Node *output_node;
+
+ GLuint glsl_program_num; // Owned by the resource_pool.
+
+ // Position and texcoord attribute indexes, although it doesn't matter
+ // which is which, because they contain the same data.
+ std::set<GLint> attribute_indexes;
+
+ bool input_needs_mipmaps;
+
+ // Inputs are only inputs from other phases (ie., those that come from RTT);
+ // input textures are counted as part of <effects>.
+ std::vector<Phase *> inputs;
+ // Bound sampler numbers for each input. Redundant in a sense
+ // (it always corresponds to the index), but we need somewhere
+ // to hold the value for the uniform.
+ std::vector<int> input_samplers;
+ std::vector<Node *> effects; // In order.
+ unsigned output_width, output_height, virtual_output_width, virtual_output_height;
+
+ // Identifier used to create unique variables in GLSL.
+ // Unique per-phase to increase cacheability of compiled shaders.
+ std::map<Node *, std::string> effect_ids;
+
+ // Uniforms for this phase; combined from all the effects.
+ std::vector<Uniform<int> > uniforms_sampler2d;
+ std::vector<Uniform<bool> > uniforms_bool;
+ std::vector<Uniform<int> > uniforms_int;
+ std::vector<Uniform<float> > uniforms_float;
+ std::vector<Uniform<float> > uniforms_vec2;
+ std::vector<Uniform<float> > uniforms_vec3;
+ std::vector<Uniform<float> > uniforms_vec4;
+ std::vector<Uniform<Eigen::Matrix3d> > uniforms_mat3;
+
+ GLuint ubo; // GL_INVALID_INDEX if not using UBOs.
+ GLuint uniform_block_index;
+ std::vector<char> ubo_data;
+
+ // For measurement of GPU time used.
+ std::list<GLuint> timer_query_objects_running;
+ std::list<GLuint> timer_query_objects_free;
+ uint64_t time_elapsed_ns;
+ uint64_t num_measured_iterations;