float vr_alpha = 1.0f, vr_delta = 0.25f, vr_gamma = 0.25f;
bool enable_timing = true;
+bool detailed_timing = false;
bool enable_variational_refinement = true; // Just for debugging.
bool enable_interpolation = false;
void render_to(const array<GLuint, num_elements> &textures);
// Convenience wrappers.
- void render_to(GLuint texture0, enable_if<num_elements == 1> * = nullptr) {
+ void render_to(GLuint texture0) {
render_to({{texture0}});
}
- void render_to(GLuint texture0, GLuint texture1, enable_if<num_elements == 2> * = nullptr) {
+ void render_to(GLuint texture0, GLuint texture1) {
render_to({{texture0, texture1}});
}
- void render_to(GLuint texture0, GLuint texture1, GLuint texture2, enable_if<num_elements == 3> * = nullptr) {
+ void render_to(GLuint texture0, GLuint texture1, GLuint texture2) {
render_to({{texture0, texture1, texture2}});
}
- void render_to(GLuint texture0, GLuint texture1, GLuint texture2, GLuint texture3, enable_if<num_elements == 4> * = nullptr) {
+ void render_to(GLuint texture0, GLuint texture1, GLuint texture2, GLuint texture3) {
render_to({{texture0, texture1, texture2, texture3}});
}
class SOR {
public:
SOR();
- void exec(GLuint diff_flow_tex, GLuint equation_tex, GLuint smoothness_x_tex, GLuint smoothness_y_tex, int level_width, int level_height, int num_iterations);
+ void exec(GLuint diff_flow_tex, GLuint equation_tex, GLuint smoothness_x_tex, GLuint smoothness_y_tex, int level_width, int level_height, int num_iterations, ScopedTimer *sor_timer);
private:
PersistentFBOSet<1> fbos;
uniform_phase = glGetUniformLocation(sor_program, "phase");
}
-void SOR::exec(GLuint diff_flow_tex, GLuint equation_tex, GLuint smoothness_x_tex, GLuint smoothness_y_tex, int level_width, int level_height, int num_iterations)
+void SOR::exec(GLuint diff_flow_tex, GLuint equation_tex, GLuint smoothness_x_tex, GLuint smoothness_y_tex, int level_width, int level_height, int num_iterations, ScopedTimer *sor_timer)
{
glUseProgram(sor_program);
fbos.render_to(diff_flow_tex);
for (int i = 0; i < num_iterations; ++i) {
- glProgramUniform1i(sor_program, uniform_phase, 0);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- glTextureBarrier();
- glProgramUniform1i(sor_program, uniform_phase, 1);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- if (i != num_iterations - 1) {
+ {
+ ScopedTimer timer("Red pass", sor_timer);
+ glProgramUniform1i(sor_program, uniform_phase, 0);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glTextureBarrier();
}
+ {
+ ScopedTimer timer("Black pass", sor_timer);
+ glProgramUniform1i(sor_program, uniform_phase, 1);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ if (i != num_iterations - 1) {
+ glTextureBarrier();
+ }
+ }
}
}
ScopedTimer total_timer("Total", &timers);
for (int level = coarsest_level; level >= int(finest_level); --level) {
char timer_name[256];
- snprintf(timer_name, sizeof(timer_name), "Level %d", level);
+ snprintf(timer_name, sizeof(timer_name), "Level %d (%d x %d)", level, width >> level, height >> level);
ScopedTimer level_timer(timer_name, &total_timer);
int level_width = width >> level;
// Note that these are to/from the same texture.
{
ScopedTimer timer("SOR", &varref_timer);
- sor.exec(du_dv_tex, equation_tex, smoothness_x_tex, smoothness_y_tex, level_width, level_height, 5);
+ sor.exec(du_dv_tex, equation_tex, smoothness_x_tex, smoothness_y_tex, level_width, level_height, 5, &timer);
}
}
{ "intensity-relative-weight", required_argument, 0, 'i' }, // delta.
{ "gradient-relative-weight", required_argument, 0, 'g' }, // gamma.
{ "disable-timing", no_argument, 0, 1000 },
+ { "detailed-timing", no_argument, 0, 1003 },
{ "ignore-variational-refinement", no_argument, 0, 1001 }, // Still calculates it, just doesn't apply it.
{ "interpolate", no_argument, 0, 1002 }
};
case 1002:
enable_interpolation = true;
break;
+ case 1003:
+ detailed_timing = true;
+ break;
default:
fprintf(stderr, "Unknown option '%s'\n", argv[option_index]);
exit(1);
SDL_GLContext context = SDL_GL_CreateContext(window);
assert(context != nullptr);
+ glDisable(GL_DITHER);
+
// FIXME: Should be part of DISComputeFlow (but needs to be initialized
// before all the render passes).
float vertices[] = {