X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=flow.h;h=9536a3808034868810f4ba3143d782b3315b11a4;hb=c015224d38abb896d92c55f1b4517f0600828f68;hp=2e4546861d8c3abbe7157fb9ea6d3537675a6322;hpb=728b20a90b39b96eb5ac5ecd17cd5c3cbaac7009;p=nageru diff --git a/flow.h b/flow.h index 2e45468..9536a38 100644 --- a/flow.h +++ b/flow.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -78,6 +79,8 @@ static constexpr OperatingPoint operating_point4 = { 8.0f // Splat size (pixels). }; +int find_num_levels(int width, int height); + // A class that caches FBOs that render to a given set of textures. // It never frees anything, so it is only suitable for rendering to // the same (small) set of textures over and over again. @@ -381,6 +384,7 @@ private: GLuint uniform_scale_factor; }; +// All operations, except construction and destruction, are thread-safe. class TexturePool { public: GLuint get_texture(GLenum format, GLuint width, GLuint height, GLuint num_layers = 0); @@ -396,7 +400,8 @@ private: bool in_use = false; bool is_renderbuffer = false; }; - std::vector textures; + std::mutex mu; + std::vector textures; // Under mu. }; class DISComputeFlow { @@ -448,7 +453,7 @@ public: Splat(const OperatingPoint &op); // alpha is the time of the interpolated frame (0..1). - void exec(GLuint image_tex, GLuint bidirectional_flow_tex, GLuint flow_tex, GLuint depth_rb, int width, int height, float alpha); + void exec(GLuint gray_tex, GLuint bidirectional_flow_tex, GLuint flow_tex, GLuint depth_rb, int width, int height, float alpha); private: const OperatingPoint op; @@ -459,7 +464,7 @@ private: GLuint splat_program; GLuint uniform_splat_size, uniform_alpha; - GLuint uniform_image_tex, uniform_flow_tex; + GLuint uniform_gray_tex, uniform_flow_tex; GLuint uniform_inv_flow_size; }; @@ -517,11 +522,15 @@ private: class Blend { public: - Blend(); - void exec(GLuint image_tex, GLuint flow_tex, GLuint output_tex, int width, int height, float alpha); + Blend(bool split_ycbcr_output); + + // output2_tex is only used if split_ycbcr_output was true. + void exec(GLuint image_tex, GLuint flow_tex, GLuint output_tex, GLuint output2_tex, int width, int height, float alpha); private: + bool split_ycbcr_output; PersistentFBOSet<1> fbos; + PersistentFBOSet<2> fbos_split; GLuint blend_vs_obj; GLuint blend_fs_obj; GLuint blend_program; @@ -532,12 +541,12 @@ private: class Interpolate { public: - Interpolate(int width, int height, const OperatingPoint &op); + Interpolate(int width, int height, const OperatingPoint &op, bool split_ycbcr_output); - // Returns a texture that must be released with release_texture() - // after use. image_tex must be a two-layer RGBA8 texture with mipmaps - // (unless flow_level == 0). - GLuint exec(GLuint image_tex, GLuint bidirectional_flow_tex, GLuint width, GLuint height, float alpha); + // Returns a texture (or two, if split_ycbcr_output is true) that must + // be released with release_texture() after use. image_tex must be a + // two-layer RGBA8 texture with mipmaps (unless flow_level == 0). + std::pair exec(GLuint image_tex, GLuint gray_tex, GLuint bidirectional_flow_tex, GLuint width, GLuint height, float alpha); void release_texture(GLuint tex) { pool.release_texture(tex); @@ -548,6 +557,7 @@ private: GLuint vertex_vbo, vao; TexturePool pool; const OperatingPoint op; + const bool split_ycbcr_output; Splat splat; HoleFill hole_fill;