Commit 13260155 authored by Brian Salomon's avatar Brian Salomon Committed by Chromium LUCI CQ

YUVToRGBConverter saves/restores sampler objects and uses sampler 0.

Bug: 1152901
Change-Id: I1dc79b0afc83a11d61fcd1ea56a3bbce3fe88f73
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2623187Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Reviewed-by: default avatarccameron <ccameron@chromium.org>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Cr-Commit-Position: refs/heads/master@{#842527}
parent 01ca25e4
......@@ -195,6 +195,10 @@ YUVToRGBConverter::YUVToRGBConverter(const GLVersionInfo& gl_version_info,
g_current_gl_driver->ext.b_GL_ANGLE_get_tex_level_parameter;
has_robust_resource_init_ =
g_current_gl_driver->ext.b_GL_ANGLE_robust_resource_initialization;
has_sampler_objects_ = gl_version_info.IsAtLeastGLES(3, 0) ||
gl_version_info.IsAtLeastGL(3, 3) ||
g_current_gl_driver->ext.b_GL_ARB_sampler_objects;
}
YUVToRGBConverter::~YUVToRGBConverter() {
......@@ -233,9 +237,19 @@ void YUVToRGBConverter::CopyYUV420ToRGB(unsigned target,
GLint old_texture0_binding = -1;
glActiveTexture(GL_TEXTURE0);
glGetIntegerv(source_target_getter, &old_texture0_binding);
GLint old_sampler0_binding = -1;
if (has_sampler_objects_) {
glGetIntegerv(GL_SAMPLER_BINDING, &old_sampler0_binding);
glBindSampler(0, 0);
}
GLint old_texture1_binding = -1;
glActiveTexture(GL_TEXTURE1);
glGetIntegerv(source_target_getter, &old_texture1_binding);
GLint old_sampler1_binding = -1;
if (has_sampler_objects_) {
glGetIntegerv(GL_SAMPLER_BINDING, &old_sampler1_binding);
glBindSampler(1, 0);
}
// Allocate the rgb texture.
glActiveTexture(old_active_texture);
......@@ -312,6 +326,10 @@ void YUVToRGBConverter::CopyYUV420ToRGB(unsigned target,
glActiveTexture(GL_TEXTURE1);
glBindTexture(source_texture_target_, old_texture1_binding);
glActiveTexture(old_active_texture);
if (old_sampler0_binding > 0)
glBindSampler(0, old_sampler0_binding);
if (old_sampler1_binding > 0)
glBindSampler(1, old_sampler1_binding);
}
} // namespace gl
......@@ -44,6 +44,7 @@ class YUVToRGBConverter {
unsigned source_texture_target_ = 0;
bool has_get_tex_level_parameter_ = false;
bool has_robust_resource_init_ = false;
bool has_sampler_objects_ = false;
};
} // namespace gl
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment