X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=effect_chain.cpp;h=c2402daeaef400d9ded80dcbce3378be9f94ac42;hp=af0710e46a2ce6c82cd40cf9eaba7c57ed9d7a9e;hb=825c90789c229f502520bf0b665596d473f2636d;hpb=865a82f44545fa48a67eda605a18315d6ea15cfd diff --git a/effect_chain.cpp b/effect_chain.cpp index af0710e..c2402da 100644 --- a/effect_chain.cpp +++ b/effect_chain.cpp @@ -184,6 +184,13 @@ GLenum EffectChain::get_input_sampler(Node *node, unsigned input_num) const return GL_TEXTURE0 + node->incoming_links[input_num]->bound_sampler_num; } +GLenum EffectChain::has_input_sampler(Node *node, unsigned input_num) const +{ + assert(input_num < node->incoming_links.size()); + return node->incoming_links[input_num]->bound_sampler_num >= 0 && + node->incoming_links[input_num]->bound_sampler_num < 8; +} + void EffectChain::find_all_nonlinear_inputs(Node *node, vector *nonlinear_inputs) { if (node->output_gamma_curve == GAMMA_LINEAR && @@ -369,16 +376,23 @@ void EffectChain::compile_glsl_program(Phase *phase) frag_shader += string("#define INPUT ") + phase->effect_ids[phase->effects.back()] + "\n"; // If we're the last phase, add the right #defines for Y'CbCr multi-output as needed. + vector frag_shader_outputs; // In order. if (phase->output_node->outgoing_links.empty() && output_color_ycbcr) { switch (output_ycbcr_splitting) { case YCBCR_OUTPUT_INTERLEAVED: // No #defines set. + frag_shader_outputs.push_back("FragColor"); break; case YCBCR_OUTPUT_SPLIT_Y_AND_CBCR: frag_shader += "#define YCBCR_OUTPUT_SPLIT_Y_AND_CBCR 1\n"; + frag_shader_outputs.push_back("Y"); + frag_shader_outputs.push_back("Chroma"); break; case YCBCR_OUTPUT_PLANAR: frag_shader += "#define YCBCR_OUTPUT_PLANAR 1\n"; + frag_shader_outputs.push_back("Y"); + frag_shader_outputs.push_back("Cb"); + frag_shader_outputs.push_back("Cr"); break; default: assert(false); @@ -389,6 +403,7 @@ void EffectChain::compile_glsl_program(Phase *phase) // output needs to see it (YCbCrConversionEffect and DitherEffect // do, too). frag_shader_header += "#define YCBCR_ALSO_OUTPUT_RGBA 1\n"; + frag_shader_outputs.push_back("RGBA"); } } frag_shader.append(read_file("footer.frag")); @@ -411,7 +426,9 @@ void EffectChain::compile_glsl_program(Phase *phase) extract_uniform_declarations(effect->uniforms_vec2, "vec2", effect_id, &phase->uniforms_vec2, &frag_shader_uniforms); extract_uniform_declarations(effect->uniforms_vec3, "vec3", effect_id, &phase->uniforms_vec3, &frag_shader_uniforms); extract_uniform_declarations(effect->uniforms_vec4, "vec4", effect_id, &phase->uniforms_vec4, &frag_shader_uniforms); + extract_uniform_array_declarations(effect->uniforms_float_array, "float", effect_id, &phase->uniforms_float, &frag_shader_uniforms); extract_uniform_array_declarations(effect->uniforms_vec2_array, "vec2", effect_id, &phase->uniforms_vec2, &frag_shader_uniforms); + extract_uniform_array_declarations(effect->uniforms_vec3_array, "vec3", effect_id, &phase->uniforms_vec3, &frag_shader_uniforms); extract_uniform_array_declarations(effect->uniforms_vec4_array, "vec4", effect_id, &phase->uniforms_vec4, &frag_shader_uniforms); extract_uniform_declarations(effect->uniforms_mat3, "mat3", effect_id, &phase->uniforms_mat3, &frag_shader_uniforms); } @@ -430,7 +447,7 @@ void EffectChain::compile_glsl_program(Phase *phase) vert_shader[pos + needle.size() - 1] = '1'; } - phase->glsl_program_num = resource_pool->compile_glsl_program(vert_shader, frag_shader); + phase->glsl_program_num = resource_pool->compile_glsl_program(vert_shader, frag_shader, frag_shader_outputs); // Collect the resulting location numbers for each uniform. collect_uniform_locations(phase->glsl_program_num, &phase->uniforms_sampler2d); @@ -500,7 +517,8 @@ Phase *EffectChain::construct_phase(Node *output, map *complete bool start_new_phase = false; if (node->effect->needs_texture_bounce() && - !deps[i]->effect->is_single_texture()) { + !deps[i]->effect->is_single_texture() && + !deps[i]->effect->override_disable_bounce()) { start_new_phase = true; } @@ -1646,6 +1664,12 @@ void EffectChain::render_to_fbo(GLuint dest_fbo, unsigned width, unsigned height { assert(finalized); + // This needs to be set anew, in case we are coming from a different context + // from when we initialized. + check_error(); + glDisable(GL_DITHER); + check_error(); + // Save original viewport. GLuint x = 0, y = 0; @@ -1659,6 +1683,7 @@ void EffectChain::render_to_fbo(GLuint dest_fbo, unsigned width, unsigned height } // Basic state. + check_error(); glDisable(GL_BLEND); check_error(); glDisable(GL_DEPTH_TEST);