]> git.sesse.net Git - movit/blobdiff - effect_chain.cpp
Reduce the amount of duplication between overloads in test_util.h, by using a few...
[movit] / effect_chain.cpp
index c6bac8078e13b10ed9af621e9b00e80f9cfa8361..aefae8f0c908a105457d0e2416481eda6c0a4297 100644 (file)
@@ -555,20 +555,31 @@ void EffectChain::compile_glsl_program(Phase *phase)
                extract_uniform_declarations(effect->uniforms_mat3, "mat3", effect_id, &phase->uniforms_mat3, &frag_shader_uniforms);
        }
 
-       frag_shader = frag_shader_header + frag_shader_uniforms + frag_shader;
-
        string vert_shader = read_version_dependent_file("vs", "vert");
 
        // If we're the last phase and need to flip the picture to compensate for
-       // the origin, tell the vertex shader so.
-       if (phase->output_node->outgoing_links.empty() && output_origin == OUTPUT_ORIGIN_TOP_LEFT) {
-               const string needle = "#define FLIP_ORIGIN 0";
-               size_t pos = vert_shader.find(needle);
-               assert(pos != string::npos);
+       // the origin, tell the vertex or compute shader so.
+       bool is_last_phase;
+       if (has_dummy_effect) {
+               is_last_phase = (phase->output_node->outgoing_links.size() == 1 &&
+                       phase->output_node->outgoing_links[0]->effect->effect_type_id() == "ComputeShaderOutputDisplayEffect");
+       } else {
+               is_last_phase = phase->output_node->outgoing_links.empty();
+       }
+       if (is_last_phase && output_origin == OUTPUT_ORIGIN_TOP_LEFT) {
+               if (phase->is_compute_shader) {
+                       frag_shader_header += "#define FLIP_ORIGIN 1\n";
+               } else {
+                       const string needle = "#define FLIP_ORIGIN 0";
+                       size_t pos = vert_shader.find(needle);
+                       assert(pos != string::npos);
 
-               vert_shader[pos + needle.size() - 1] = '1';
+                       vert_shader[pos + needle.size() - 1] = '1';
+               }
        }
 
+       frag_shader = frag_shader_header + frag_shader_uniforms + frag_shader;
+
        if (phase->is_compute_shader) {
                phase->glsl_program_num = resource_pool->compile_glsl_compute_program(frag_shader);
 
@@ -1039,7 +1050,7 @@ void EffectChain::inform_input_sizes(Phase *phase)
 // desired output size might change based on the inputs.
 void EffectChain::find_output_size(Phase *phase)
 {
-       Node *output_node = phase->effects.back();
+       Node *output_node = phase->is_compute_shader ? phase->compute_shader_node : phase->effects.back();
 
        // If the last effect explicitly sets an output size, use that.
        if (output_node->effect->changes_output_size()) {
@@ -2172,7 +2183,7 @@ void EffectChain::execute_phase(Phase *phase,
 
        if (phase->is_compute_shader) {
                unsigned x, y, z;
-               phase->output_node->effect->get_compute_dimensions(phase->output_width, phase->output_height, &x, &y, &z);
+               phase->compute_shader_node->effect->get_compute_dimensions(phase->output_width, phase->output_height, &x, &y, &z);
 
                // Uniforms need to come after set_gl_state() _and_ get_compute_dimensions(),
                // since they can be updated from there.