Commit ef2f5c55 authored by Jonathan Backer's avatar Jonathan Backer Committed by Commit Bot

Read texture binding from GLES2Impl

One of the hazards of using the ContextGL and RasterInterface from
RasterContextProvider is that the texture bindings could become
inconsistent between the 2. This CL makes RasterImplementationGLES2
check the bindings in GLES2Implementation, which should help reduce
inconsistencies.

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I84394fe279cca0f02c6d41c9f5b5a3319772f33b
Bug: 897724
Reviewed-on: https://chromium-review.googlesource.com/c/1289513Reviewed-by: default avatarVictor Miura <vmiura@chromium.org>
Commit-Queue: Jonathan Backer <backer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602326}
parent 480ee2d1
...@@ -724,6 +724,10 @@ bool GLES2Implementation::GetHelper(GLenum pname, GLint* params) { ...@@ -724,6 +724,10 @@ bool GLES2Implementation::GetHelper(GLenum pname, GLint* params) {
case GL_TEXTURE_BINDING_EXTERNAL_OES: case GL_TEXTURE_BINDING_EXTERNAL_OES:
*params = texture_units_[active_texture_unit_].bound_texture_external_oes; *params = texture_units_[active_texture_unit_].bound_texture_external_oes;
return true; return true;
case GL_TEXTURE_BINDING_RECTANGLE_ARB:
*params =
texture_units_[active_texture_unit_].bound_texture_rectangle_arb;
return true;
case GL_PIXEL_PACK_TRANSFER_BUFFER_BINDING_CHROMIUM: case GL_PIXEL_PACK_TRANSFER_BUFFER_BINDING_CHROMIUM:
*params = bound_pixel_pack_transfer_buffer_id_; *params = bound_pixel_pack_transfer_buffer_id_;
return true; return true;
...@@ -4440,6 +4444,12 @@ void GLES2Implementation::BindTextureHelper(GLenum target, GLuint texture) { ...@@ -4440,6 +4444,12 @@ void GLES2Implementation::BindTextureHelper(GLenum target, GLuint texture) {
changed = true; changed = true;
} }
break; break;
case GL_TEXTURE_RECTANGLE_ARB:
if (unit.bound_texture_rectangle_arb != texture) {
unit.bound_texture_rectangle_arb = texture;
changed = true;
}
break;
default: default:
changed = true; changed = true;
break; break;
...@@ -4615,6 +4625,9 @@ void GLES2Implementation::UnbindTexturesHelper(GLsizei n, ...@@ -4615,6 +4625,9 @@ void GLES2Implementation::UnbindTexturesHelper(GLsizei n,
if (textures[ii] == unit.bound_texture_external_oes) { if (textures[ii] == unit.bound_texture_external_oes) {
unit.bound_texture_external_oes = 0; unit.bound_texture_external_oes = 0;
} }
if (textures[ii] == unit.bound_texture_rectangle_arb) {
unit.bound_texture_rectangle_arb = 0;
}
} }
} }
} }
......
...@@ -311,21 +311,22 @@ class GLES2_IMPL_EXPORT GLES2Implementation : public GLES2Interface, ...@@ -311,21 +311,22 @@ class GLES2_IMPL_EXPORT GLES2Implementation : public GLES2Interface,
}; };
struct TextureUnit { struct TextureUnit {
TextureUnit() TextureUnit() {}
: bound_texture_2d(0),
bound_texture_cube_map(0),
bound_texture_external_oes(0) {}
// texture currently bound to this unit's GL_TEXTURE_2D with glBindTexture // texture currently bound to this unit's GL_TEXTURE_2D with glBindTexture
GLuint bound_texture_2d; GLuint bound_texture_2d = 0;
// texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with // texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with
// glBindTexture // glBindTexture
GLuint bound_texture_cube_map; GLuint bound_texture_cube_map = 0;
// texture currently bound to this unit's GL_TEXTURE_EXTERNAL_OES with // texture currently bound to this unit's GL_TEXTURE_EXTERNAL_OES with
// glBindTexture // glBindTexture
GLuint bound_texture_external_oes; GLuint bound_texture_external_oes = 0;
// texture currently bound to this unit's GL_TEXTURE_RECTANGLE_ARB with
// glBindTexture
GLuint bound_texture_rectangle_arb = 0;
}; };
// Prevents problematic reentrancy during error callbacks. // Prevents problematic reentrancy during error callbacks.
......
...@@ -57,10 +57,27 @@ RasterImplementationGLES::Texture* RasterImplementationGLES::GetTexture( ...@@ -57,10 +57,27 @@ RasterImplementationGLES::Texture* RasterImplementationGLES::GetTexture(
RasterImplementationGLES::Texture* RasterImplementationGLES::EnsureTextureBound( RasterImplementationGLES::Texture* RasterImplementationGLES::EnsureTextureBound(
RasterImplementationGLES::Texture* texture) { RasterImplementationGLES::Texture* texture) {
DCHECK(texture); DCHECK(texture);
if (bound_texture_ != texture) { // Reads client side cache of bindings in GLES2Implementation.
bound_texture_ = texture; GLint bound_texture = 0;
gl_->BindTexture(texture->target, texture->id); GLenum pname = 0;
switch (texture->target) {
case GL_TEXTURE_2D:
pname = GL_TEXTURE_BINDING_2D;
break;
case GL_TEXTURE_RECTANGLE_ARB:
pname = GL_TEXTURE_BINDING_RECTANGLE_ARB;
break;
case GL_TEXTURE_EXTERNAL_OES:
pname = GL_TEXTURE_BINDING_EXTERNAL_OES;
break;
default:
NOTREACHED();
} }
if (pname != 0)
gl_->GetIntegerv(pname, &bound_texture);
if (bound_texture != static_cast<GLint>(texture->id))
gl_->BindTexture(texture->target, texture->id);
return texture; return texture;
} }
...@@ -171,9 +188,6 @@ void RasterImplementationGLES::DeleteTextures(GLsizei n, ...@@ -171,9 +188,6 @@ void RasterImplementationGLES::DeleteTextures(GLsizei n,
auto texture_iter = texture_info_.find(textures[i]); auto texture_iter = texture_info_.find(textures[i]);
DCHECK(texture_iter != texture_info_.end()); DCHECK(texture_iter != texture_info_.end());
if (bound_texture_ == &texture_iter->second)
bound_texture_ = nullptr;
texture_info_.erase(texture_iter); texture_info_.erase(texture_iter);
} }
...@@ -334,7 +348,6 @@ void RasterImplementationGLES::EndGpuRaster() { ...@@ -334,7 +348,6 @@ void RasterImplementationGLES::EndGpuRaster() {
gl_->TraceEndCHROMIUM(); gl_->TraceEndCHROMIUM();
// Reset cached raster state. // Reset cached raster state.
bound_texture_ = nullptr;
gl_->ActiveTexture(GL_TEXTURE0); gl_->ActiveTexture(GL_TEXTURE0);
} }
......
...@@ -151,7 +151,6 @@ class RASTER_EXPORT RasterImplementationGLES : public RasterInterface { ...@@ -151,7 +151,6 @@ class RASTER_EXPORT RasterImplementationGLES : public RasterInterface {
bool use_texture_storage_image_; bool use_texture_storage_image_;
std::unordered_map<GLuint, Texture> texture_info_; std::unordered_map<GLuint, Texture> texture_info_;
Texture* bound_texture_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(RasterImplementationGLES); DISALLOW_COPY_AND_ASSIGN(RasterImplementationGLES);
}; };
......
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