output_color_rgba(false),
output_color_ycbcr(false),
dither_effect(NULL),
+ ycbcr_conversion_effect_node(NULL),
intermediate_format(GL_RGBA16F),
intermediate_transformation(NO_FRAMEBUFFER_TRANSFORMATION),
num_dither_bits(0),
output_ycbcr_format = ycbcr_format;
if (finalized) {
- // Find the YCbCrConversionEffect node. We don't store it to avoid
- // an unneeded ABI break (this can be fixed on next break).
- for (Node *node : nodes) {
- if (node->effect->effect_type_id() == "YCbCrConversionEffect") {
- YCbCrConversionEffect *effect = (YCbCrConversionEffect *)(node->effect);
- effect->change_output_format(ycbcr_format);
- }
- }
+ YCbCrConversionEffect *effect = (YCbCrConversionEffect *)(ycbcr_conversion_effect_node->effect);
+ effect->change_output_format(ycbcr_format);
}
}
return;
}
Node *output = find_output_node();
- Node *ycbcr = add_node(new YCbCrConversionEffect(output_ycbcr_format));
- connect_nodes(output, ycbcr);
+ ycbcr_conversion_effect_node = add_node(new YCbCrConversionEffect(output_ycbcr_format));
+ connect_nodes(output, ycbcr_conversion_effect_node);
}
// If the user has requested dither, add a DitherEffect right at the end
check_error();
glDisable(GL_DITHER);
check_error();
- glEnable(GL_FRAMEBUFFER_SRGB);
+
+ const bool final_srgb = glIsEnabled(GL_FRAMEBUFFER_SRGB);
check_error();
+ bool current_srgb = final_srgb;
// Save original viewport.
GLuint x = 0, y = 0;
CHECK(dither_effect->set_int("output_height", height));
}
}
- execute_phase(phase, phase_num == phases.size() - 1, &bound_attribute_indices, &output_textures, &generated_mipmaps);
+ bool last_phase = (phase_num == phases.size() - 1);
+
+ // Enable sRGB rendering for intermediates in case we are
+ // rendering to an sRGB format.
+ bool needs_srgb = last_phase ? final_srgb : true;
+ if (needs_srgb && !current_srgb) {
+ glEnable(GL_FRAMEBUFFER_SRGB);
+ check_error();
+ current_srgb = true;
+ } else if (!needs_srgb && current_srgb) {
+ glDisable(GL_FRAMEBUFFER_SRGB);
+ check_error();
+ current_srgb = true;
+ }
+
+ execute_phase(phase, last_phase, &bound_attribute_indices, &output_textures, &generated_mipmaps);
if (do_phase_timing) {
glEndQuery(GL_TIME_ELAPSED);
}