diff options
author | Evgeny Zuev <evgeny.zuev@xored.com> | 2017-07-24 18:24:10 +0700 |
---|---|---|
committer | Evgeny Zuev <evgeny.zuev@xored.com> | 2017-07-24 18:25:55 +0700 |
commit | 4ed6e4a70e0396667821d217971b124e0e22c3dc (patch) | |
tree | 482464927527ae106e8db72e5f56d8fb046281c9 /drivers | |
parent | 042bfabd8f11d90daebfe50b615811298701196e (diff) |
Fix switching SRGB extension happen before binding of texture
Previously, texture parameter `_TEXTURE_SRGB_DECODE_EXT` was changed
before the call of `glBindTexture`, which caused modification of previously
bound texture instead of desired one. Now it's changed after `glBindTexture`.
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 56bd3ca2ef..21bdb217fc 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1243,36 +1243,36 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material *p_m if (t->render_target) t->render_target->used_in_frame = true; - if (storage->config.srgb_decode_supported) { - //if SRGB decode extension is present, simply switch the texture to whathever is needed - bool must_srgb = false; + target = t->target; + tex = t->tex_id; + } - if (t->srgb && (texture_hints[i] == ShaderLanguage::ShaderNode::Uniform::HINT_ALBEDO || texture_hints[i] == ShaderLanguage::ShaderNode::Uniform::HINT_BLACK_ALBEDO)) { - must_srgb = true; - } + glBindTexture(target, tex); - if (t->using_srgb != must_srgb) { - if (must_srgb) { - glTexParameteri(t->target, _TEXTURE_SRGB_DECODE_EXT, _DECODE_EXT); + if (t && storage->config.srgb_decode_supported) { + //if SRGB decode extension is present, simply switch the texture to whathever is needed + bool must_srgb = false; + + if (t->srgb && (texture_hints[i] == ShaderLanguage::ShaderNode::Uniform::HINT_ALBEDO || texture_hints[i] == ShaderLanguage::ShaderNode::Uniform::HINT_BLACK_ALBEDO)) { + must_srgb = true; + } + + if (t->using_srgb != must_srgb) { + if (must_srgb) { + glTexParameteri(t->target, _TEXTURE_SRGB_DECODE_EXT, _DECODE_EXT); #ifdef TOOLS_ENABLED - if (t->detect_srgb) { - t->detect_srgb(t->detect_srgb_ud); - } + if (t->detect_srgb) { + t->detect_srgb(t->detect_srgb_ud); + } #endif - } else { - glTexParameteri(t->target, _TEXTURE_SRGB_DECODE_EXT, _SKIP_DECODE_EXT); - } - t->using_srgb = must_srgb; + } else { + glTexParameteri(t->target, _TEXTURE_SRGB_DECODE_EXT, _SKIP_DECODE_EXT); } + t->using_srgb = must_srgb; } - - target = t->target; - tex = t->tex_id; } - glBindTexture(target, tex); - if (i == 0) { state.current_main_tex = tex; } |