]> git.sesse.net Git - nageru/blobdiff - flow.cpp
Pack the gradients and image together into a single 32-bit texture; seems to help...
[nageru] / flow.cpp
index 512bdaf12e3ff283b07af22ffd40645ae0cebd5b..3f3ff90ee6da46af401cf4ec636fc1581fd021bd 100644 (file)
--- a/flow.cpp
+++ b/flow.cpp
@@ -379,7 +379,6 @@ void GrayscaleConversion::exec(GLint tex, GLint gray_tex, int width, int height)
        glViewport(0, 0, width, height);
        fbos.render_to(gray_tex);
        glBindVertexArray(gray_vao);
-       glUseProgram(gray_program);
        glDisable(GL_BLEND);
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 }
@@ -422,7 +421,6 @@ void Sobel::exec(GLint tex0_view, GLint grad0_tex, int level_width, int level_he
 
        glViewport(0, 0, level_width, level_height);
        fbos.render_to(grad0_tex);
-       glUseProgram(sobel_program);
        glDisable(GL_BLEND);
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 }
@@ -441,7 +439,7 @@ private:
        GLuint motion_search_program;
 
        GLuint uniform_inv_image_size, uniform_inv_prev_level_size;
-       GLuint uniform_image0_tex, uniform_image1_tex, uniform_grad0_tex, uniform_flow_tex;
+       GLuint uniform_image1_tex, uniform_grad0_tex, uniform_flow_tex;
 };
 
 MotionSearch::MotionSearch()
@@ -452,7 +450,6 @@ MotionSearch::MotionSearch()
 
        uniform_inv_image_size = glGetUniformLocation(motion_search_program, "inv_image_size");
        uniform_inv_prev_level_size = glGetUniformLocation(motion_search_program, "inv_prev_level_size");
-       uniform_image0_tex = glGetUniformLocation(motion_search_program, "image0_tex");
        uniform_image1_tex = glGetUniformLocation(motion_search_program, "image1_tex");
        uniform_grad0_tex = glGetUniformLocation(motion_search_program, "grad0_tex");
        uniform_flow_tex = glGetUniformLocation(motion_search_program, "flow_tex");
@@ -462,9 +459,8 @@ void MotionSearch::exec(GLuint tex0_view, GLuint tex1_view, GLuint grad0_tex, GL
 {
        glUseProgram(motion_search_program);
 
-       bind_sampler(motion_search_program, uniform_image0_tex, 0, tex0_view, nearest_sampler);
        bind_sampler(motion_search_program, uniform_image1_tex, 1, tex1_view, linear_sampler);
-       bind_sampler(motion_search_program, uniform_grad0_tex, 2, grad0_tex, zero_border_sampler);
+       bind_sampler(motion_search_program, uniform_grad0_tex, 2, grad0_tex, linear_sampler);
        bind_sampler(motion_search_program, uniform_flow_tex, 3, flow_tex, linear_sampler);
 
        glProgramUniform2f(motion_search_program, uniform_inv_image_size, 1.0f / level_width, 1.0f / level_height);
@@ -472,7 +468,6 @@ void MotionSearch::exec(GLuint tex0_view, GLuint tex1_view, GLuint grad0_tex, GL
 
        glViewport(0, 0, width_patches, height_patches);
        fbos.render_to(flow_out_tex);
-       glUseProgram(motion_search_program);
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 }
 
@@ -1038,7 +1033,7 @@ GLuint DISComputeFlow::exec(GLuint tex0, GLuint tex1, ResizeStrategy resize_stra
 
                // Create a new texture; we could be fancy and render use a multi-level
                // texture, but meh.
-               GLuint grad0_tex = pool.get_texture(GL_RG16F, level_width, level_height);
+               GLuint grad0_tex = pool.get_texture(GL_R32UI, level_width, level_height);
 
                // Find the derivative.
                {
@@ -1448,7 +1443,6 @@ void Blend::exec(GLuint tex0, GLuint tex1, GLuint flow_tex, GLuint output_tex, i
 
        glViewport(0, 0, level_width, level_height);
        fbos.render_to(output_tex);
-       glUseProgram(blend_program);
        glDisable(GL_BLEND);  // A bit ironic, perhaps.
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 }