Commit 9c0c4b5f authored by Bill Orr's avatar Bill Orr Committed by Commit Bot

Fix black screen when presenting on some WebVR pages on Windows

The issue here was that glBlitFramebufferANGLE fails when the color
formats of the source and destination image aren't compatible.  The
color format for pBufferSurfaces wrapping dxgi textures has changed to
report the underlying dxgi format instead of the egl config used to
create the surface, so we were sometimes failing to copy the WebGL
contents onto our cross-process-sharing texture.

The fix is to use CopySubTextureCHROMIUM instead of blitting
framebuffers. This API won't create new destination textures, and will
convert formats for us.  It also has the benefit of handling flipping
y-direction for us, so we could avoid a copy.

BUG=804628

Change-Id: Ibc55dd092bacbdd1f751adb0b6a854f58e64e22b
Reviewed-on: https://chromium-review.googlesource.com/892091Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Bill Orr <billorr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533224}
parent cd208cb6
...@@ -17,11 +17,9 @@ namespace blink { ...@@ -17,11 +17,9 @@ namespace blink {
GpuMemoryBufferImageCopy::GpuMemoryBufferImageCopy( GpuMemoryBufferImageCopy::GpuMemoryBufferImageCopy(
gpu::gles2::GLES2Interface* gl) gpu::gles2::GLES2Interface* gl)
: gl_(gl) { : gl_(gl) {
gl_->GenFramebuffers(1, &draw_frame_buffer_);
} }
GpuMemoryBufferImageCopy::~GpuMemoryBufferImageCopy() { GpuMemoryBufferImageCopy::~GpuMemoryBufferImageCopy() {
gl_->DeleteFramebuffers(1, &draw_frame_buffer_);
} }
bool GpuMemoryBufferImageCopy::EnsureMemoryBuffer(int width, int height) { bool GpuMemoryBufferImageCopy::EnsureMemoryBuffer(int width, int height) {
...@@ -72,9 +70,6 @@ gfx::GpuMemoryBuffer* GpuMemoryBufferImageCopy::CopyImage(Image* image) { ...@@ -72,9 +70,6 @@ gfx::GpuMemoryBuffer* GpuMemoryBufferImageCopy::CopyImage(Image* image) {
gl_->BindTexImage2DCHROMIUM(target, image_id); gl_->BindTexImage2DCHROMIUM(target, image_id);
} }
gl_->BindTexture(GL_TEXTURE_2D, 0); gl_->BindTexture(GL_TEXTURE_2D, 0);
gl_->BindFramebuffer(GL_DRAW_FRAMEBUFFER, draw_frame_buffer_);
gl_->FramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target,
dest_texture_id, 0);
// Bind the read framebuffer to our image. // Bind the read framebuffer to our image.
StaticBitmapImage* static_image = static_cast<StaticBitmapImage*>(image); StaticBitmapImage* static_image = static_cast<StaticBitmapImage*>(image);
...@@ -86,19 +81,12 @@ gfx::GpuMemoryBuffer* GpuMemoryBufferImageCopy::CopyImage(Image* image) { ...@@ -86,19 +81,12 @@ gfx::GpuMemoryBuffer* GpuMemoryBufferImageCopy::CopyImage(Image* image) {
gl_->WaitSyncTokenCHROMIUM(sync_token.GetData()); gl_->WaitSyncTokenCHROMIUM(sync_token.GetData());
GLuint source_texture_id = gl_->CreateAndConsumeTextureCHROMIUM(mailbox.name); GLuint source_texture_id = gl_->CreateAndConsumeTextureCHROMIUM(mailbox.name);
gl_->BindTexture(GL_TEXTURE_2D, 0); gl_->BindTexture(GL_TEXTURE_2D, 0);
GLuint read_frame_buffer;
gl_->GenFramebuffers(1, &read_frame_buffer);
gl_->BindFramebuffer(GL_READ_FRAMEBUFFER, read_frame_buffer);
gl_->FramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target,
source_texture_id, 0);
// Copy the read framebuffer to the draw framebuffer. gl_->CopySubTextureCHROMIUM(source_texture_id, 0, GL_TEXTURE_2D,
gl_->BlitFramebufferCHROMIUM(0, 0, width, height, 0, 0, width, height, dest_texture_id, 0, 0, 0, 0, 0, width, height,
GL_COLOR_BUFFER_BIT, GL_NEAREST); false, false, false);
// Cleanup the read framebuffer, associated image and texture. // Cleanup the read framebuffer, associated image and texture.
gl_->BindFramebuffer(GL_FRAMEBUFFER, 0);
gl_->DeleteFramebuffers(1, &read_frame_buffer);
gl_->BindTexture(GL_TEXTURE_2D, 0); gl_->BindTexture(GL_TEXTURE_2D, 0);
gl_->DeleteTextures(1, &source_texture_id); gl_->DeleteTextures(1, &source_texture_id);
......
...@@ -26,7 +26,6 @@ class PLATFORM_EXPORT GpuMemoryBufferImageCopy { ...@@ -26,7 +26,6 @@ class PLATFORM_EXPORT GpuMemoryBufferImageCopy {
int last_width_ = 0; int last_width_ = 0;
int last_height_ = 0; int last_height_ = 0;
GLuint draw_frame_buffer_;
gpu::gles2::GLES2Interface* gl_; gpu::gles2::GLES2Interface* gl_;
std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_;
......
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