Commit 2f3cd109 authored by Rafael Cintron's avatar Rafael Cintron Committed by Commit Bot

Improve robustness of SwapChainFactoryDXGI::MakeBacking

SwapChainFactoryDXGI::MakeBacking calls BindTexImage on the
GLImageDXGISwapChain before binding the GL texture as GL_TEXTURE_2D.

This causes eglBindTexImage validation to run on whatever texture
happens to be bound as GL_TEXTURE_2D, causing random failures.

To fix this problem, MakeTextureAndSetParameters was moved before
the call to BindTexImage. Now eglBindTexImage validation runs on the
correct texture.

Change-Id: I3ad60c45c4acfb1b2a2fc8e5d15964accbdf8027
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1636612Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#664614}
parent 85607561
...@@ -308,7 +308,10 @@ std::unique_ptr<SharedImageBacking> SwapChainFactoryDXGI::MakeBacking( ...@@ -308,7 +308,10 @@ std::unique_ptr<SharedImageBacking> SwapChainFactoryDXGI::MakeBacking(
} }
DCHECK(d3d11_texture); DCHECK(d3d11_texture);
unsigned target = GL_TEXTURE_2D; const unsigned target = GL_TEXTURE_2D;
gl::GLApi* api = gl::g_current_gl_context;
const GLuint service_id = MakeTextureAndSetParameters(api, target);
auto image = base::MakeRefCounted<gl::GLImageDXGISwapChain>( auto image = base::MakeRefCounted<gl::GLImageDXGISwapChain>(
size, viz::BufferFormat(format), d3d11_texture, swap_chain); size, viz::BufferFormat(format), d3d11_texture, swap_chain);
if (!image->BindTexImage(target)) { if (!image->BindTexImage(target)) {
...@@ -316,9 +319,6 @@ std::unique_ptr<SharedImageBacking> SwapChainFactoryDXGI::MakeBacking( ...@@ -316,9 +319,6 @@ std::unique_ptr<SharedImageBacking> SwapChainFactoryDXGI::MakeBacking(
return nullptr; return nullptr;
} }
gl::GLApi* api = gl::g_current_gl_context;
GLuint service_id = MakeTextureAndSetParameters(api, target);
gles2::Texture* texture = nullptr; gles2::Texture* texture = nullptr;
scoped_refptr<gles2::TexturePassthrough> passthrough_texture; scoped_refptr<gles2::TexturePassthrough> passthrough_texture;
......
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