+ // And an output flow texture. (Well, we could have used texture barriers,
+ // but I don't feel lucky today.)
+ GLuint flow_out_tex;
+ glCreateTextures(GL_TEXTURE_2D, 1, &flow_out_tex);
+ glTextureStorage2D(flow_out_tex, 1, GL_RG16F, width_patches, height_patches);
+
+ GLuint flow_fbo;
+ glCreateFramebuffers(1, &flow_fbo);
+ glNamedFramebufferTexture(flow_fbo, GL_COLOR_ATTACHMENT0, flow_out_tex, 0);
+
+ glUseProgram(motion_search_program);
+
+ bind_sampler(motion_search_program, "image0_tex", 0, tex0_view, nearest_sampler);
+ bind_sampler(motion_search_program, "image1_tex", 1, tex1_view, linear_sampler);
+ bind_sampler(motion_search_program, "grad0_tex", 2, grad0_tex, nearest_sampler);
+ bind_sampler(motion_search_program, "flow_tex", 3, flow_tex, nearest_sampler);
+
+ glProgramUniform1f(motion_search_program, glGetUniformLocation(motion_search_program, "image_width"), level_width);
+ glProgramUniform1f(motion_search_program, glGetUniformLocation(motion_search_program, "image_height"), level_height);
+ glProgramUniform1f(motion_search_program, glGetUniformLocation(motion_search_program, "inv_image_width"), 1.0f / level_width);
+ glProgramUniform1f(motion_search_program, glGetUniformLocation(motion_search_program, "inv_image_height"), 1.0f / level_height);
+