Skip to content

Commit

Permalink
Merge pull request #91322 from clayjohn/GLES3-bcs-error
Browse files Browse the repository at this point in the history
Ensure that environment is available before checking for BCS
  • Loading branch information
akien-mga committed May 2, 2024
2 parents 25fe3d4 + 8eae822 commit d798094
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions drivers/gles3/rasterizer_scene_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2706,27 +2706,32 @@ void RasterizerSceneGLES3::_render_post_processing(const RenderDataGLES3 *p_rend
rb->check_glow_buffers();
}

bool use_bcs = environment_get_adjustments_enabled(p_render_data->environment);
uint64_t bcs_spec_constants = 0;
RID color_correction_texture = environment_get_color_correction(p_render_data->environment);
if (use_bcs && color_correction_texture.is_valid()) {
bcs_spec_constants |= PostShaderGLES3::USE_BCS;
bcs_spec_constants |= PostShaderGLES3::USE_COLOR_CORRECTION;

bool use_1d_lut = environment_get_use_1d_color_correction(p_render_data->environment);
GLenum texture_target = GL_TEXTURE_3D;
if (use_1d_lut) {
bcs_spec_constants |= PostShaderGLES3::USE_1D_LUT;
texture_target = GL_TEXTURE_2D;
}
if (p_render_data->environment.is_valid()) {
bool use_bcs = environment_get_adjustments_enabled(p_render_data->environment);
RID color_correction_texture = environment_get_color_correction(p_render_data->environment);
if (use_bcs) {
bcs_spec_constants |= PostShaderGLES3::USE_BCS;

if (color_correction_texture.is_valid()) {
bcs_spec_constants |= PostShaderGLES3::USE_COLOR_CORRECTION;

glActiveTexture(GL_TEXTURE2);
glBindTexture(texture_target, texture_storage->texture_get_texid(color_correction_texture));
glTexParameteri(texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(texture_target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
bool use_1d_lut = environment_get_use_1d_color_correction(p_render_data->environment);
GLenum texture_target = GL_TEXTURE_3D;
if (use_1d_lut) {
bcs_spec_constants |= PostShaderGLES3::USE_1D_LUT;
texture_target = GL_TEXTURE_2D;
}

glActiveTexture(GL_TEXTURE2);
glBindTexture(texture_target, texture_storage->texture_get_texid(color_correction_texture));
glTexParameteri(texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(texture_target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
}
}
}

if (view_count == 1) {
Expand Down

0 comments on commit d798094

Please sign in to comment.