]> git.sesse.net Git - nageru/blobdiff - flow.cpp
Fix some uniforms not getting through to the motion search vertex shader.
[nageru] / flow.cpp
index 93ac447f0021f7dacec0bbd2c9265ee0e6a2c561..df6ac6df625d96586049234fc9c0e9094eca9017 100644 (file)
--- a/flow.cpp
+++ b/flow.cpp
@@ -38,6 +38,7 @@ constexpr unsigned patch_size_pixels = 12;
 float vr_gamma = 10.0f, vr_delta = 5.0f, vr_alpha = 10.0f;
 
 bool enable_timing = true;
+bool enable_variational_refinement = true;  // Just for debugging.
 
 // Some global OpenGL objects.
 // TODO: These should really be part of DISComputeFlow.
@@ -352,7 +353,7 @@ private:
        GLuint motion_search_program;
        GLuint motion_search_vao;
 
-       GLuint uniform_image_size, uniform_inv_image_size, uniform_inv_prev_level_size;
+       GLuint uniform_image_size, uniform_inv_image_size, uniform_inv_flow_size, uniform_inv_prev_level_size;
        GLuint uniform_image0_tex, uniform_image1_tex, uniform_grad0_tex, uniform_flow_tex;
 };
 
@@ -373,6 +374,7 @@ MotionSearch::MotionSearch()
 
        uniform_image_size = glGetUniformLocation(motion_search_program, "image_size");
        uniform_inv_image_size = glGetUniformLocation(motion_search_program, "inv_image_size");
+       uniform_inv_flow_size = glGetUniformLocation(motion_search_program, "inv_flow_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");
@@ -391,6 +393,7 @@ void MotionSearch::exec(GLuint tex0_view, GLuint tex1_view, GLuint grad0_tex, GL
 
        glProgramUniform2f(motion_search_program, uniform_image_size, level_width, level_height);
        glProgramUniform2f(motion_search_program, uniform_inv_image_size, 1.0f / level_width, 1.0f / level_height);
+       glProgramUniform2f(motion_search_program, uniform_inv_flow_size, 1.0f / width_patches, 1.0f / height_patches);
        glProgramUniform2f(motion_search_program, uniform_inv_prev_level_size, 1.0f / prev_level_width, 1.0f / prev_level_height);
 
        glViewport(0, 0, width_patches, height_patches);
@@ -1207,8 +1210,10 @@ GLuint DISComputeFlow::exec(GLuint tex0, GLuint tex1)
                // Add the differential flow found by the variational refinement to the base flow,
                // giving the final flow estimate for this level.
                // The output is in diff_flow_tex; we don't need to make a new texture.
-               // You can comment out this part if you wish to test disabling of the variational refinement.
-               {
+               //
+               // Disabling this doesn't save any time (although we could easily make it so that
+               // it is more efficient), but it helps debug the motion search.
+               if (enable_variational_refinement) {
                        ScopedTimer timer("Add differential flow", &varref_timer);
                        add_base_flow.exec(base_flow_tex, du_dv_tex, level_width, level_height);
                }
@@ -1316,7 +1321,8 @@ int main(int argc, char **argv)
                 { "alpha", required_argument, 0, 'a' },
                 { "delta", required_argument, 0, 'd' },
                 { "gamma", required_argument, 0, 'g' },
-               { "disable-timing", no_argument, 0, 1000 }
+               { "disable-timing", no_argument, 0, 1000 },
+               { "ignore-variational-refinement", no_argument, 0, 1001 }  // Still calculates it, just doesn't apply it.
        };
 
        for ( ;; ) {
@@ -1339,6 +1345,9 @@ int main(int argc, char **argv)
                case 1000:
                        enable_timing = false;
                        break;
+               case 1001:
+                       enable_variational_refinement = false;
+                       break;
                default:
                        fprintf(stderr, "Unknown option '%s'\n", argv[option_index]);
                        exit(1);