Commit a758ce4a authored by Kenneth Russell's avatar Kenneth Russell

Fix BlitFramebuffer RGB emulation on macOS.

The fix for Issue 699566 regressed blits between user framebuffers on
macOS when alpha:false and antialias:false. Only apply the workaround
when blitting to the default WebGL back buffer.

Tested by new conformance test
conformance2/rendering/blitframebuffer-r11f-g11f-b10f.html from
https://github.com/KhronosGroup/WebGL/pull/2469 .

BUG=751206
TBR=zmo@chromium.org
NOTRY=true

Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I6025bcd562675318d6cd9d3fcc50aa90fa83642b
Reviewed-on: https://chromium-review.googlesource.com/596679Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491300}
parent 31c2a76a
...@@ -404,7 +404,7 @@ void WebGL2RenderingContextBase::blitFramebuffer(GLint src_x0, ...@@ -404,7 +404,7 @@ void WebGL2RenderingContextBase::blitFramebuffer(GLint src_x0,
return; return;
DrawingBuffer::ScopedRGBEmulationForBlitFramebuffer emulation( DrawingBuffer::ScopedRGBEmulationForBlitFramebuffer emulation(
GetDrawingBuffer()); GetDrawingBuffer(), !!GetFramebufferBinding(GL_DRAW_FRAMEBUFFER));
ContextGL()->BlitFramebufferCHROMIUM(src_x0, src_y0, src_x1, src_y1, dst_x0, ContextGL()->BlitFramebufferCHROMIUM(src_x0, src_y0, src_x1, src_y1, dst_x0,
dst_y0, dst_x1, dst_y1, mask, filter); dst_y0, dst_x1, dst_y1, mask, filter);
} }
......
...@@ -580,9 +580,11 @@ DrawingBuffer::CreateOrRecycleColorBuffer() { ...@@ -580,9 +580,11 @@ DrawingBuffer::CreateOrRecycleColorBuffer() {
} }
DrawingBuffer::ScopedRGBEmulationForBlitFramebuffer:: DrawingBuffer::ScopedRGBEmulationForBlitFramebuffer::
ScopedRGBEmulationForBlitFramebuffer(DrawingBuffer* drawing_buffer) ScopedRGBEmulationForBlitFramebuffer(DrawingBuffer* drawing_buffer,
bool is_user_draw_framebuffer_bound)
: drawing_buffer_(drawing_buffer) { : drawing_buffer_(drawing_buffer) {
doing_work_ = drawing_buffer->SetupRGBEmulationForBlitFramebuffer(); doing_work_ = drawing_buffer->SetupRGBEmulationForBlitFramebuffer(
is_user_draw_framebuffer_bound);
} }
DrawingBuffer::ScopedRGBEmulationForBlitFramebuffer:: DrawingBuffer::ScopedRGBEmulationForBlitFramebuffer::
...@@ -1295,14 +1297,21 @@ GLenum DrawingBuffer::GetMultisampledRenderbufferFormat() { ...@@ -1295,14 +1297,21 @@ GLenum DrawingBuffer::GetMultisampledRenderbufferFormat() {
return GL_RGB8_OES; return GL_RGB8_OES;
} }
bool DrawingBuffer::SetupRGBEmulationForBlitFramebuffer() { bool DrawingBuffer::SetupRGBEmulationForBlitFramebuffer(
bool is_user_draw_framebuffer_bound) {
// We only need to do this work if: // We only need to do this work if:
// - We are blitting to the default framebuffer
// - The user has selected alpha:false and antialias:false // - The user has selected alpha:false and antialias:false
// - We are using CHROMIUM_image with RGB emulation // - We are using CHROMIUM_image with RGB emulation
// macOS is the only platform on which this is necessary. // macOS is the only platform on which this is necessary.
if (want_alpha_channel_ || anti_aliasing_mode_ != kNone) if (is_user_draw_framebuffer_bound) {
return false; return false;
}
if (want_alpha_channel_ || anti_aliasing_mode_ != kNone) {
return false;
}
if (!(ShouldUseChromiumImage() && if (!(ShouldUseChromiumImage() &&
ContextProvider()->GetCapabilities().chromium_image_rgb_emulation)) ContextProvider()->GetCapabilities().chromium_image_rgb_emulation))
......
...@@ -236,7 +236,8 @@ class PLATFORM_EXPORT DrawingBuffer ...@@ -236,7 +236,8 @@ class PLATFORM_EXPORT DrawingBuffer
// store and RGB emulation is in use (basically, macOS only). // store and RGB emulation is in use (basically, macOS only).
class PLATFORM_EXPORT ScopedRGBEmulationForBlitFramebuffer { class PLATFORM_EXPORT ScopedRGBEmulationForBlitFramebuffer {
public: public:
ScopedRGBEmulationForBlitFramebuffer(DrawingBuffer*); ScopedRGBEmulationForBlitFramebuffer(DrawingBuffer*,
bool is_user_draw_framebuffer_bound);
~ScopedRGBEmulationForBlitFramebuffer(); ~ScopedRGBEmulationForBlitFramebuffer();
private: private:
...@@ -457,7 +458,7 @@ class PLATFORM_EXPORT DrawingBuffer ...@@ -457,7 +458,7 @@ class PLATFORM_EXPORT DrawingBuffer
// Helpers to ensure correct behavior of BlitFramebuffer when using // Helpers to ensure correct behavior of BlitFramebuffer when using
// an emulated RGB CHROMIUM_image back buffer. // an emulated RGB CHROMIUM_image back buffer.
bool SetupRGBEmulationForBlitFramebuffer(); bool SetupRGBEmulationForBlitFramebuffer(bool is_user_draw_framebuffer_bound);
void CleanupRGBEmulationForBlitFramebuffer(); void CleanupRGBEmulationForBlitFramebuffer();
// Weak, reset by beginDestruction. // Weak, reset by beginDestruction.
......
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