diff options
author | zmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-13 20:56:30 +0000 |
---|---|---|
committer | zmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-13 20:56:30 +0000 |
commit | cc6d8c3ef05450fd8139169f0edf14425e635947 (patch) | |
tree | 5eb684aba894765e4603029ffc922d0764109e15 | |
parent | f1e0789a18dcf35b06fe83370596a662297641e3 (diff) | |
download | chromium_src-cc6d8c3ef05450fd8139169f0edf14425e635947.zip chromium_src-cc6d8c3ef05450fd8139169f0edf14425e635947.tar.gz chromium_src-cc6d8c3ef05450fd8139169f0edf14425e635947.tar.bz2 |
Add a flush ID for graphics contexts.
We use a global ID assigning system, and whenever a flush/finish happens, we increase the global ID, and assign it to the related context. This will give a rough indication of the context usage along time line.
BUG=290482
TEST=webgl conformance test: rendering/multisample-corruption.html
R=kbr@chromium.org, piman@chromium.org
Review URL: https://codereview.chromium.org/23995006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223120 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 66 insertions, 9 deletions
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc index 421e57d..74bd71c 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc @@ -13,6 +13,7 @@ #include <algorithm> #include <set> +#include "base/atomicops.h" #include "base/bind.h" #include "base/command_line.h" #include "base/debug/trace_event.h" @@ -73,6 +74,14 @@ size_t ClampUint64ToSizeT(uint64 value) { return static_cast<size_t>(value); } +uint32_t GenFlushID() { + static base::subtle::Atomic32 flush_id = 0; + + base::subtle::Atomic32 my_id = base::subtle::Barrier_AtomicIncrement( + &flush_id, 1); + return static_cast<uint32_t>(my_id); +} + // Singleton used to initialize and terminate the gles2 library. class GLES2Initializer { public: @@ -235,7 +244,8 @@ WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl( start_transfer_buffer_size_(0), min_transfer_buffer_size_(0), max_transfer_buffer_size_(0), - mapped_memory_limit_(gpu::gles2::GLES2Implementation::kNoLimit) { + mapped_memory_limit_(gpu::gles2::GLES2Implementation::kNoLimit), + flush_id_(0) { #if (defined(OS_MACOSX) || defined(OS_WIN)) && !defined(USE_AURA) // Get ViewMsg_SwapBuffers_ACK from browser for single-threaded path. const CommandLine& command_line = *CommandLine::ForCurrentProcess(); @@ -497,6 +507,10 @@ bool WebGraphicsContext3DCommandBufferImpl::makeContextCurrent() { return true; } +uint32_t WebGraphicsContext3DCommandBufferImpl::getLastFlushID() { + return flush_id_; +} + int WebGraphicsContext3DCommandBufferImpl::width() { return cached_width_; } @@ -813,12 +827,14 @@ DELEGATE_TO_GL_1(enableVertexAttribArray, EnableVertexAttribArray, WGC3Duint) void WebGraphicsContext3DCommandBufferImpl::finish() { + flush_id_ = GenFlushID(); gl_->Finish(); if (!visible_ && free_command_buffer_when_invisible_) real_gl_->FreeEverything(); } void WebGraphicsContext3DCommandBufferImpl::flush() { + flush_id_ = GenFlushID(); gl_->Flush(); if (!visible_ && free_command_buffer_when_invisible_) real_gl_->FreeEverything(); @@ -1424,8 +1440,15 @@ DELEGATE_TO_GL_6(copyTextureCHROMIUM, CopyTextureCHROMIUM, WGC3Denum, DELEGATE_TO_GL_3(bindUniformLocationCHROMIUM, BindUniformLocationCHROMIUM, WebGLId, WGC3Dint, const WGC3Dchar*) -DELEGATE_TO_GL(shallowFlushCHROMIUM, ShallowFlushCHROMIUM); -DELEGATE_TO_GL(shallowFinishCHROMIUM, ShallowFinishCHROMIUM); +void WebGraphicsContext3DCommandBufferImpl::shallowFlushCHROMIUM() { + flush_id_ = GenFlushID(); + gl_->ShallowFlushCHROMIUM(); +} + +void WebGraphicsContext3DCommandBufferImpl::shallowFinishCHROMIUM() { + flush_id_ = GenFlushID(); + gl_->ShallowFinishCHROMIUM(); +} DELEGATE_TO_GL_1(waitSyncPoint, WaitSyncPointCHROMIUM, GLuint) diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h index b922eb9..7c6452d 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h @@ -143,6 +143,8 @@ class WebGraphicsContext3DCommandBufferImpl // graphics context fails to create. Do not call from more than one thread. virtual bool makeContextCurrent(); + virtual uint32_t getLastFlushID(); + virtual int width(); virtual int height(); @@ -764,6 +766,8 @@ class WebGraphicsContext3DCommandBufferImpl size_t min_transfer_buffer_size_; size_t max_transfer_buffer_size_; size_t mapped_memory_limit_; + + uint32_t flush_id_; }; } // namespace content diff --git a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc index 6ef1a7f..b86868e 100644 --- a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc +++ b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc @@ -13,6 +13,7 @@ #include <string> +#include "base/atomicops.h" #include "base/bind.h" #include "base/bind_helpers.h" #include "base/callback.h" @@ -45,6 +46,14 @@ void OnSignalSyncPoint( callback->onSyncPointReached(); } +uint32_t GenFlushID() { + static base::subtle::Atomic32 flush_id = 0; + + base::subtle::Atomic32 my_id = base::subtle::Barrier_AtomicIncrement( + &flush_id, 1); + return static_cast<uint32_t>(my_id); +} + // Singleton used to initialize and terminate the gles2 library. class GLES2Initializer { public: @@ -119,7 +128,8 @@ WebGraphicsContext3DInProcessCommandBufferImpl:: context_lost_reason_(GL_NO_ERROR), attributes_(attributes), cached_width_(0), - cached_height_(0) { + cached_height_(0), + flush_id_(0) { } WebGraphicsContext3DInProcessCommandBufferImpl:: @@ -209,6 +219,10 @@ bool WebGraphicsContext3DInProcessCommandBufferImpl::makeContextCurrent() { return context_ && !isContextLost(); } +uint32_t WebGraphicsContext3DInProcessCommandBufferImpl::getLastFlushID() { + return flush_id_; +} + void WebGraphicsContext3DInProcessCommandBufferImpl::ClearContext() { // NOTE: Comment in the line below to check for code that is not calling // eglMakeCurrent where appropriate. The issue is code using @@ -572,9 +586,15 @@ DELEGATE_TO_GL_1(enable, Enable, WGC3Denum) DELEGATE_TO_GL_1(enableVertexAttribArray, EnableVertexAttribArray, WGC3Duint) -DELEGATE_TO_GL(finish, Finish) +void WebGraphicsContext3DInProcessCommandBufferImpl::finish() { + flush_id_ = GenFlushID(); + gl_->Finish(); +} -DELEGATE_TO_GL(flush, Flush) +void WebGraphicsContext3DInProcessCommandBufferImpl::flush() { + flush_id_ = GenFlushID(); + gl_->Flush(); +} DELEGATE_TO_GL_4(framebufferRenderbuffer, FramebufferRenderbuffer, WGC3Denum, WGC3Denum, WGC3Denum, WebGLId) @@ -1160,8 +1180,15 @@ DELEGATE_TO_GL_1(unmapImageCHROMIUM, UnmapImageCHROMIUM, WGC3Duint); DELEGATE_TO_GL_3(bindUniformLocationCHROMIUM, BindUniformLocationCHROMIUM, WebGLId, WGC3Dint, const WGC3Dchar*) -DELEGATE_TO_GL(shallowFlushCHROMIUM, ShallowFlushCHROMIUM) -DELEGATE_TO_GL(shallowFinishCHROMIUM, ShallowFinishCHROMIUM) +void WebGraphicsContext3DInProcessCommandBufferImpl::shallowFlushCHROMIUM() { + flush_id_ = GenFlushID(); + gl_->ShallowFlushCHROMIUM(); +} + +void WebGraphicsContext3DInProcessCommandBufferImpl::shallowFinishCHROMIUM() { + flush_id_ = GenFlushID(); + gl_->ShallowFinishCHROMIUM(); +} DELEGATE_TO_GL_1(genMailboxCHROMIUM, GenMailboxCHROMIUM, WGC3Dbyte*) DELEGATE_TO_GL_2(produceTextureCHROMIUM, ProduceTextureCHROMIUM, diff --git a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h index d763e14..f66e417 100644 --- a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h +++ b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h @@ -74,6 +74,8 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl // WebGraphicsContext3D methods virtual bool makeContextCurrent(); + virtual uint32_t getLastFlushID(); + virtual int width(); virtual int height(); @@ -568,7 +570,6 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl // instead of going through WebGraphicsContext3D. void ClearContext(); - bool is_offscreen_; // Only used when not offscreen. gfx::AcceleratedWidget window_; @@ -589,6 +590,8 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl // Errors raised by synthesizeGLError(). std::vector<WGC3Denum> synthetic_errors_; + + uint32_t flush_id_; }; } // namespace gpu |