Skip to content

Commit

Permalink
Workaround for Intel 6xxx clear to 0/1 bug
Browse files Browse the repository at this point in the history
This is ported form skia fixing https://skia-review.googlesource.com/c/17327/
and https://skia-review.googlesource.com/c/16427/

BUG=710443
TEST=WebGL conformance test:framebuffer-texture-clear.html
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

Review-Url: https://codereview.chromium.org/2934733002
Cr-Commit-Position: refs/heads/master@{#486150}
  • Loading branch information
qjia7 authored and Commit Bot committed Jul 12, 2017
1 parent c5f3486 commit 01aa041
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 1 deletion.
8 changes: 8 additions & 0 deletions gpu/command_buffer/service/gles2_cmd_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/gl_version_info.h"
#include "ui/gl/gl_workarounds.h"
#include "ui/gl/gpu_timing.h"

#if defined(OS_MACOSX)
Expand Down Expand Up @@ -3186,6 +3187,13 @@ bool GLES2DecoderImpl::Initialize(
// Create GPU Tracer for timing values.
gpu_tracer_.reset(new GPUTracer(this));

// Pass some workarounds to GLContext so that we can apply them in RealGLApi.
gl::GLWorkarounds gl_workarounds;
if (workarounds().clear_to_zero_or_one_broken) {
gl_workarounds.clear_to_zero_or_one_broken = true;
}
GetGLContext()->SetGLWorkarounds(gl_workarounds);

if (workarounds().disable_timestamp_queries) {
// Forcing time elapsed query for any GPU Timing Client forces it for all
// clients in the context.
Expand Down
19 changes: 18 additions & 1 deletion gpu/config/gpu_driver_bug_list.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gpu driver bug list",
"version": "10.17",
"version": "10.18",
"entries": [
{
"id": 1,
Expand Down Expand Up @@ -2564,6 +2564,23 @@
"features": [
"rely_on_implicit_sync_for_swap_buffers"
]
},
{
"id": 236,
"description": "glClearColor does not always work on Intel 6xxx Mac drivers",
"cr_bugs": [710443],
"os": {
"type": "macosx",
"version": {
"op": "<",
"value": "10.12.6"
}
},
"vendor_id": "0x8086",
"device_id": ["0x1626", "0x162B", "0x1622"],
"features": [
"clear_to_zero_or_one_broken"
]
}
],
"comment": [
Expand Down
2 changes: 2 additions & 0 deletions gpu/config/gpu_driver_bug_workaround_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
broken_egl_image_ref_counting) \
GPU_OP(CLEAR_ALPHA_IN_READPIXELS, \
clear_alpha_in_readpixels) \
GPU_OP(CLEAR_TO_ZERO_OR_ONE_BROKEN, \
clear_to_zero_or_one_broken) \
GPU_OP(CLEAR_UNIFORMS_BEFORE_FIRST_PROGRAM_USE, \
clear_uniforms_before_first_program_use) \
GPU_OP(COUNT_ALL_IN_VARYINGS_PACKING, \
Expand Down
1 change: 1 addition & 0 deletions ui/gl/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ component("gl") {
"gl_utils.h",
"gl_version_info.cc",
"gl_version_info.h",
"gl_workarounds.h",
"gpu_switching_manager.cc",
"gpu_switching_manager.h",
"gpu_timing.cc",
Expand Down
9 changes: 9 additions & 0 deletions ui/gl/gl_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ GLContext::~GLContext() {
GLApi* GLContext::CreateGLApi(DriverGL* driver) {
real_gl_api_ = new RealGLApi;
real_gl_api_->Initialize(driver);
real_gl_api_->set_gl_workarounds(gl_workarounds_);
return real_gl_api_;
}

Expand Down Expand Up @@ -210,6 +211,14 @@ void GLContext::SetCurrent(GLSurface* surface) {
}
}

void GLContext::SetGLWorkarounds(const GLWorkarounds& workarounds) {
DCHECK(IsCurrent(nullptr));
gl_workarounds_ = workarounds;
if (real_gl_api_) {
real_gl_api_->set_gl_workarounds(gl_workarounds_);
}
}

GLStateRestorer* GLContext::GetGLStateRestorer() {
return state_restorer_.get();
}
Expand Down
6 changes: 6 additions & 0 deletions ui/gl/gl_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "ui/gl/gl_export.h"
#include "ui/gl/gl_share_group.h"
#include "ui/gl/gl_state_restorer.h"
#include "ui/gl/gl_workarounds.h"
#include "ui/gl/gpu_preference.h"

namespace gl {
Expand Down Expand Up @@ -96,6 +97,9 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> {
// Creates a GPUTimingClient class which abstracts various GPU Timing exts.
virtual scoped_refptr<GPUTimingClient> CreateGPUTimingClient() = 0;

// Set the GL workarounds.
void SetGLWorkarounds(const GLWorkarounds& workarounds);

// Gets the GLStateRestorer for the context.
GLStateRestorer* GetGLStateRestorer();

Expand Down Expand Up @@ -222,6 +226,8 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> {

std::unique_ptr<GLVersionInfo> GenerateGLVersionInfo();

GLWorkarounds gl_workarounds_;

bool static_bindings_initialized_ = false;
bool dynamic_bindings_initialized_ = false;
std::unique_ptr<DriverGL> driver_gl_;
Expand Down
19 changes: 19 additions & 0 deletions ui/gl/gl_gl_api_implementation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,21 @@ void RealGLApi::glClearFn(GLbitfield mask) {
GLApiBase::glClearFn(mask);
}

void RealGLApi::glClearColorFn(GLclampf red,
GLclampf green,
GLclampf blue,
GLclampf alpha) {
if (gl_workarounds_.clear_to_zero_or_one_broken && (1 == red || 0 == red) &&
(1 == green || 0 == green) && (1 == blue || 0 == blue) &&
(1 == alpha || 0 == alpha)) {
if (1 == alpha)
alpha = 2;
else
alpha = -1;
}
GLApiBase::glClearColorFn(red, green, blue, alpha);
}

void RealGLApi::glDrawArraysFn(GLenum mode, GLint first, GLsizei count) {
if (!g_null_draw_bindings_enabled)
GLApiBase::glDrawArraysFn(mode, first, count);
Expand Down Expand Up @@ -491,6 +506,10 @@ void RealGLApi::InitializeFilteredExtensions() {
}
}

void RealGLApi::set_gl_workarounds(const GLWorkarounds& workarounds) {
gl_workarounds_ = workarounds;
}

void RealGLApi::set_version(std::unique_ptr<GLVersionInfo> version) {
version_ = std::move(version);
}
Expand Down
7 changes: 7 additions & 0 deletions ui/gl/gl_gl_api_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/compiler_specific.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_export.h"
#include "ui/gl/gl_workarounds.h"

namespace base {
class CommandLine;
Expand Down Expand Up @@ -103,6 +104,10 @@ class GL_EXPORT RealGLApi : public GLApiBase {
GLsizei height) override;

void glClearFn(GLbitfield mask) override;
void glClearColorFn(GLclampf red,
GLclampf green,
GLclampf blue,
GLclampf alpha) override;
void glDrawArraysFn(GLenum mode, GLint first, GLsizei count) override;
void glDrawElementsFn(GLenum mode,
GLsizei count,
Expand All @@ -113,6 +118,7 @@ class GL_EXPORT RealGLApi : public GLApiBase {
void glDepthRangeFn(GLclampd z_near, GLclampd z_far) override;

void InitializeFilteredExtensions();
void set_gl_workarounds(const GLWorkarounds& workarounds);
void set_version(std::unique_ptr<GLVersionInfo> version);

private:
Expand All @@ -121,6 +127,7 @@ class GL_EXPORT RealGLApi : public GLApiBase {
std::vector<std::string> filtered_exts_;
std::string filtered_exts_str_;

GLWorkarounds gl_workarounds_;
std::unique_ptr<GLVersionInfo> version_;

#if DCHECK_IS_ON()
Expand Down
18 changes: 18 additions & 0 deletions ui/gl/gl_workarounds.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_GL_GL_WORKAROUNDS_H_
#define UI_GL_GL_WORKAROUNDS_H_

namespace gl {

struct GLWorkarounds {
// glClearColor does not always work on Intel 6xxx Mac drivers. See
// crbug.com/710443.
bool clear_to_zero_or_one_broken = false;
};

} // namespace gl

#endif // UI_GL_GL_WORKAROUNDS_H_

0 comments on commit 01aa041

Please sign in to comment.