summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorsievers@google.com <sievers@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-24 18:02:02 +0000
committersievers@google.com <sievers@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-24 18:02:02 +0000
commit6dafc99a98eeabe8ffea451aa7eb4b3668c703c3 (patch)
tree0a6845769fb8da7eb5b6aac0058f3e28a9de099b /ui
parent8b494dad6d8e92f188fb60af2db7f8277dd3974a (diff)
downloadchromium_src-6dafc99a98eeabe8ffea451aa7eb4b3668c703c3.zip
chromium_src-6dafc99a98eeabe8ffea451aa7eb4b3668c703c3.tar.gz
chromium_src-6dafc99a98eeabe8ffea451aa7eb4b3668c703c3.tar.bz2
Revert 258122 "gpu: Allow fences to check whether a flush has oc..."
Seems to expose some GL call sites without current context. Reverting for the time being... BUG=355275 > gpu: Allow fences to check whether a flush has occurred > > This skips waiting on a fence that was created but never committed. > > BUG=352419 > > Review URL: https://codereview.chromium.org/197563003 TBR=sievers@chromium.org Review URL: https://codereview.chromium.org/209853004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258965 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/gl/gl_context.cc27
-rw-r--r--ui/gl/gl_context.h26
-rw-r--r--ui/gl/gl_fence.cc59
-rw-r--r--ui/gl/gl_fence.h7
-rw-r--r--ui/gl/gl_gl_api_implementation.cc25
-rw-r--r--ui/gl/gl_gl_api_implementation.h9
6 files changed, 14 insertions, 139 deletions
diff --git a/ui/gl/gl_context.cc b/ui/gl/gl_context.cc
index d2deb61..cd9a28c 100644
--- a/ui/gl/gl_context.cc
+++ b/ui/gl/gl_context.cc
@@ -26,20 +26,6 @@ base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky
current_real_context_ = LAZY_INSTANCE_INITIALIZER;
} // namespace
-GLContext::FlushEvent::FlushEvent() {
-}
-
-GLContext::FlushEvent::~FlushEvent() {
-}
-
-void GLContext::FlushEvent::Signal() {
- flag_.Set();
-}
-
-bool GLContext::FlushEvent::IsSignaled() {
- return flag_.IsSet();
-}
-
GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) {
if (!share_group_.get())
share_group_ = new GLShareGroup;
@@ -54,13 +40,6 @@ GLContext::~GLContext() {
}
}
-scoped_refptr<GLContext::FlushEvent> GLContext::SignalFlush() {
- DCHECK(IsCurrent(NULL));
- scoped_refptr<FlushEvent> flush_event = new FlushEvent();
- flush_events_.push_back(flush_event);
- return flush_event;
-}
-
bool GLContext::GetTotalGpuMemory(size_t* bytes) {
DCHECK(bytes);
*bytes = 0;
@@ -193,12 +172,6 @@ void GLContext::SetRealGLApi() {
SetGLToRealGLApi();
}
-void GLContext::OnFlush() {
- for (size_t n = 0; n < flush_events_.size(); n++)
- flush_events_[n]->Signal();
- flush_events_.clear();
-}
-
GLContextReal::GLContextReal(GLShareGroup* share_group)
: GLContext(share_group) {}
diff --git a/ui/gl/gl_context.h b/ui/gl/gl_context.h
index b4a7a16..f40b1bb 100644
--- a/ui/gl/gl_context.h
+++ b/ui/gl/gl_context.h
@@ -6,12 +6,10 @@
#define UI_GL_GL_CONTEXT_H_
#include <string>
-#include <vector>
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "base/synchronization/cancellation_flag.h"
#include "ui/gl/gl_share_group.h"
#include "ui/gl/gl_state_restorer.h"
#include "ui/gl/gpu_preference.h"
@@ -34,25 +32,6 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> {
virtual bool Initialize(
GLSurface* compatible_surface, GpuPreference gpu_preference) = 0;
- class FlushEvent : public base::RefCountedThreadSafe<FlushEvent> {
- public:
- bool IsSignaled();
-
- private:
- friend class base::RefCountedThreadSafe<FlushEvent>;
- friend class GLContext;
- FlushEvent();
- virtual ~FlushEvent();
- void Signal();
-
- base::CancellationFlag flag_;
- };
-
- // Needs to be called with this context current. It will return a FlushEvent
- // that is initially unsignaled, but will transition to signaled after the
- // next glFlush() or glFinish() occurs in this context.
- scoped_refptr<FlushEvent> SignalFlush();
-
// Destroys the GL context.
virtual void Destroy() = 0;
@@ -135,9 +114,6 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> {
// Returns the GL renderer string. The context must be current.
virtual std::string GetGLRenderer();
- // Called when glFlush()/glFinish() is called with this context current.
- void OnFlush();
-
protected:
virtual ~GLContext();
@@ -164,8 +140,6 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> {
scoped_ptr<GLStateRestorer> state_restorer_;
scoped_ptr<GLVersionInfo> version_info_;
- std::vector<scoped_refptr<FlushEvent> > flush_events_;
-
DISALLOW_COPY_AND_ASSIGN(GLContext);
};
diff --git a/ui/gl/gl_fence.cc b/ui/gl/gl_fence.cc
index 262de48..f44570e 100644
--- a/ui/gl/gl_fence.cc
+++ b/ui/gl/gl_fence.cc
@@ -25,11 +25,8 @@ class GLFenceNVFence: public gfx::GLFence {
// We will arbitrarily return TRUE for consistency.
glGenFencesNV(1, &fence_);
glSetFenceNV(fence_, GL_ALL_COMPLETED_NV);
- if (flush) {
+ if (flush)
glFlush();
- } else {
- flush_event_ = gfx::GLContext::GetCurrent()->SignalFlush();
- }
}
virtual bool HasCompleted() OVERRIDE {
@@ -37,15 +34,11 @@ class GLFenceNVFence: public gfx::GLFence {
}
virtual void ClientWait() OVERRIDE {
- if (!flush_event_ || flush_event_->IsSignaled()) {
- glFinishFenceNV(fence_);
- } else {
- LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping...";
- }
+ glFinishFenceNV(fence_);
}
virtual void ServerWait() OVERRIDE {
- ClientWait();
+ glFinishFenceNV(fence_);
}
private:
@@ -54,18 +47,14 @@ class GLFenceNVFence: public gfx::GLFence {
}
GLuint fence_;
- scoped_refptr<gfx::GLContext::FlushEvent> flush_event_;
};
class GLFenceARBSync: public gfx::GLFence {
public:
GLFenceARBSync(bool flush) {
sync_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
- if (flush) {
+ if (flush)
glFlush();
- } else {
- flush_event_ = gfx::GLContext::GetCurrent()->SignalFlush();
- }
}
virtual bool HasCompleted() OVERRIDE {
@@ -80,19 +69,11 @@ class GLFenceARBSync: public gfx::GLFence {
}
virtual void ClientWait() OVERRIDE {
- if (!flush_event_ || flush_event_->IsSignaled()) {
- glClientWaitSync(sync_, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);
- } else {
- LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping...";
- }
+ glClientWaitSync(sync_, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);
}
virtual void ServerWait() OVERRIDE {
- if (!flush_event_ || flush_event_->IsSignaled()) {
- glWaitSync(sync_, 0, GL_TIMEOUT_IGNORED);
- } else {
- LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping...";
- }
+ glWaitSync(sync_, 0, GL_TIMEOUT_IGNORED);
}
private:
@@ -101,7 +82,6 @@ class GLFenceARBSync: public gfx::GLFence {
}
GLsync sync_;
- scoped_refptr<gfx::GLContext::FlushEvent> flush_event_;
};
#if !defined(OS_MACOSX)
@@ -110,11 +90,8 @@ class EGLFenceSync : public gfx::GLFence {
EGLFenceSync(bool flush) {
display_ = eglGetCurrentDisplay();
sync_ = eglCreateSyncKHR(display_, EGL_SYNC_FENCE_KHR, NULL);
- if (flush) {
+ if (flush)
glFlush();
- } else {
- flush_event_ = gfx::GLContext::GetCurrent()->SignalFlush();
- }
}
virtual bool HasCompleted() OVERRIDE {
@@ -125,22 +102,14 @@ class EGLFenceSync : public gfx::GLFence {
}
virtual void ClientWait() OVERRIDE {
- if (!flush_event_ || flush_event_->IsSignaled()) {
- EGLint flags = 0;
- EGLTimeKHR time = EGL_FOREVER_KHR;
- eglClientWaitSyncKHR(display_, sync_, flags, time);
- } else {
- LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping...";
- }
+ EGLint flags = 0;
+ EGLTimeKHR time = EGL_FOREVER_KHR;
+ eglClientWaitSyncKHR(display_, sync_, flags, time);
}
virtual void ServerWait() OVERRIDE {
- if (!flush_event_ || flush_event_->IsSignaled()) {
- EGLint flags = 0;
- eglWaitSyncKHR(display_, sync_, flags);
- } else {
- LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping...";
- }
+ EGLint flags = 0;
+ eglWaitSyncKHR(display_, sync_, flags);
}
@@ -151,15 +120,11 @@ class EGLFenceSync : public gfx::GLFence {
EGLSyncKHR sync_;
EGLDisplay display_;
- scoped_refptr<gfx::GLContext::FlushEvent> flush_event_;
};
#endif // !OS_MACOSX
// static
gfx::GLFence* CreateFence(bool flush) {
- DCHECK(gfx::GLContext::GetCurrent())
- << "Trying to create fence with no context";
-
#if !defined(OS_MACOSX)
if (gfx::g_driver_egl.ext.b_EGL_KHR_fence_sync)
return new EGLFenceSync(flush);
diff --git a/ui/gl/gl_fence.h b/ui/gl/gl_fence.h
index 021f345..c1967ec 100644
--- a/ui/gl/gl_fence.h
+++ b/ui/gl/gl_fence.h
@@ -16,16 +16,11 @@ class GL_EXPORT GLFence {
virtual ~GLFence();
static GLFence* Create();
-
// Creates a fence that is not guaranteed to signal until the current context
- // is flushed. It is illegal to call Client/ServerWait() on a fence without
- // having explicitly called glFlush() or glFinish() in the originating
- // context.
+ // is flushed. Use with caution.
static GLFence* CreateWithoutFlush();
-
virtual bool HasCompleted() = 0;
virtual void ClientWait() = 0;
-
// Will block the server if supported, but might fall back to blocking the
// client.
virtual void ServerWait() = 0;
diff --git a/ui/gl/gl_gl_api_implementation.cc b/ui/gl/gl_gl_api_implementation.cc
index 0965d91..f925f64 100644
--- a/ui/gl/gl_gl_api_implementation.cc
+++ b/ui/gl/gl_gl_api_implementation.cc
@@ -343,11 +343,6 @@ void GLApiBase::InitializeBase(DriverGL* driver) {
driver_ = driver;
}
-void GLApiBase::SignalFlush() {
- DCHECK(GLContext::GetCurrent());
- GLContext::GetCurrent()->OnFlush();
-}
-
RealGLApi::RealGLApi() {
}
@@ -358,16 +353,6 @@ void RealGLApi::Initialize(DriverGL* driver) {
InitializeBase(driver);
}
-void RealGLApi::glFlushFn() {
- GLApiBase::glFlushFn();
- GLApiBase::SignalFlush();
-}
-
-void RealGLApi::glFinishFn() {
- GLApiBase::glFinishFn();
- GLApiBase::SignalFlush();
-}
-
TraceGLApi::~TraceGLApi() {
}
@@ -460,14 +445,4 @@ const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) {
}
}
-void VirtualGLApi::glFlushFn() {
- GLApiBase::glFlushFn();
- GLApiBase::SignalFlush();
-}
-
-void VirtualGLApi::glFinishFn() {
- GLApiBase::glFinishFn();
- GLApiBase::SignalFlush();
-}
-
} // namespace gfx
diff --git a/ui/gl/gl_gl_api_implementation.h b/ui/gl/gl_gl_api_implementation.h
index e764ec3..c87dbd1 100644
--- a/ui/gl/gl_gl_api_implementation.h
+++ b/ui/gl/gl_gl_api_implementation.h
@@ -41,7 +41,6 @@ class GL_EXPORT GLApiBase : public GLApi {
GLApiBase();
virtual ~GLApiBase();
void InitializeBase(DriverGL* driver);
- void SignalFlush();
DriverGL* driver_;
};
@@ -52,10 +51,6 @@ class GL_EXPORT RealGLApi : public GLApiBase {
RealGLApi();
virtual ~RealGLApi();
void Initialize(DriverGL* driver);
-
- private:
- virtual void glFinishFn() OVERRIDE;
- virtual void glFlushFn() OVERRIDE;
};
// Inserts a TRACE for every GL call.
@@ -87,12 +82,10 @@ class GL_EXPORT VirtualGLApi : public GLApiBase {
void OnReleaseVirtuallyCurrent(GLContext* virtual_context);
-private:
// Overridden functions from GLApiBase
virtual const GLubyte* glGetStringFn(GLenum name) OVERRIDE;
- virtual void glFinishFn() OVERRIDE;
- virtual void glFlushFn() OVERRIDE;
+ private:
// The real context we're running on.
GLContext* real_context_;