diff options
author | backer@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-10 21:25:55 +0000 |
---|---|---|
committer | backer@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-10 21:25:55 +0000 |
commit | 21700451472d76b2b51fc181d127b95167b73fb3 (patch) | |
tree | 774377a127b79a4b12dbfe253f032850c196897c /gpu | |
parent | 26b6336c8c915c96caacf67e05599a97cf1b0049 (diff) | |
download | chromium_src-21700451472d76b2b51fc181d127b95167b73fb3.zip chromium_src-21700451472d76b2b51fc181d127b95167b73fb3.tar.gz chromium_src-21700451472d76b2b51fc181d127b95167b73fb3.tar.bz2 |
GPU: Prefer to restore from decoder state rather than GL state when possible.
Some drivers are buggy. Wherever possible, use the decoder state restoration
for the Scoped{Texture,Framebuffer}Binders.
BUG=239509
Review URL: https://chromiumcodereview.appspot.com/15021011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@199542 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
11 files changed, 33 insertions, 16 deletions
diff --git a/gpu/command_buffer/service/async_pixel_transfer_delegate_egl.cc b/gpu/command_buffer/service/async_pixel_transfer_delegate_egl.cc index a630881..6aa6f07 100644 --- a/gpu/command_buffer/service/async_pixel_transfer_delegate_egl.cc +++ b/gpu/command_buffer/service/async_pixel_transfer_delegate_egl.cc @@ -177,7 +177,7 @@ class TransferStateInternal DCHECK(texture_id_); DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_); - ui::ScopedTextureBinder texture_binder(GL_TEXTURE_2D, texture_id_); + gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_2D, texture_id_); glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_); bind_callback_.Run(); diff --git a/gpu/command_buffer/service/async_pixel_transfer_delegate_idle.cc b/gpu/command_buffer/service/async_pixel_transfer_delegate_idle.cc index 17b3fd2..dcc3d7b 100644 --- a/gpu/command_buffer/service/async_pixel_transfer_delegate_idle.cc +++ b/gpu/command_buffer/service/async_pixel_transfer_delegate_idle.cc @@ -257,7 +257,7 @@ void AsyncPixelTransferDelegateIdle::PerformAsyncTexImage2D( void* data = GetAddress(safe_shared_memory->shared_memory(), mem_params.shm_data_offset); - ui::ScopedTextureBinder texture_binder(tex_params.target, texture_id); + gfx::ScopedTextureBinder texture_binder(tex_params.target, texture_id); { TRACE_EVENT0("gpu", "glTexImage2D"); @@ -290,7 +290,7 @@ void AsyncPixelTransferDelegateIdle::PerformAsyncTexSubImage2D( mem_params.shm_data_offset); base::TimeTicks begin_time(base::TimeTicks::HighResNow()); - ui::ScopedTextureBinder texture_binder(tex_params.target, texture_id); + gfx::ScopedTextureBinder texture_binder(tex_params.target, texture_id); { TRACE_EVENT0("gpu", "glTexSubImage2D"); diff --git a/gpu/command_buffer/service/context_state.cc b/gpu/command_buffer/service/context_state.cc index a9274b8..069d136 100644 --- a/gpu/command_buffer/service/context_state.cc +++ b/gpu/command_buffer/service/context_state.cc @@ -102,6 +102,14 @@ void ContextState::RestoreActiveTexture() const { glActiveTexture(GL_TEXTURE0 + active_texture_unit); } +void ContextState::RestoreAllTextureUnitBindings() const { + // Restore Texture state. + for (size_t ii = 0; ii < texture_units.size(); ++ii) { + RestoreTextureUnitBindings(ii); + } + RestoreActiveTexture(); +} + void ContextState::RestoreAttribute(GLuint attrib_index) const { const VertexAttrib* attrib = vertex_attrib_manager->GetVertexAttrib(attrib_index); @@ -140,11 +148,7 @@ void ContextState::RestoreGlobalState() const { } void ContextState::RestoreState() const { - // Restore Texture state. - for (size_t ii = 0; ii < texture_units.size(); ++ii) { - RestoreTextureUnitBindings(ii); - } - RestoreActiveTexture(); + RestoreAllTextureUnitBindings(); // Restore Attrib State // TODO: This if should not be needed. RestoreState is getting called diff --git a/gpu/command_buffer/service/context_state.h b/gpu/command_buffer/service/context_state.h index 73e6908..af43eac 100644 --- a/gpu/command_buffer/service/context_state.h +++ b/gpu/command_buffer/service/context_state.h @@ -103,6 +103,7 @@ struct GPU_EXPORT ContextState { void InitState() const; void RestoreActiveTexture() const; + void RestoreAllTextureUnitBindings() const; void RestoreAttribute(GLuint index) const; void RestoreBufferBindings() const; void RestoreGlobalState() const; diff --git a/gpu/command_buffer/service/gl_context_virtual.cc b/gpu/command_buffer/service/gl_context_virtual.cc index d0602b2..d142e01 100644 --- a/gpu/command_buffer/service/gl_context_virtual.cc +++ b/gpu/command_buffer/service/gl_context_virtual.cc @@ -17,7 +17,6 @@ GLContextVirtual::GLContextVirtual( : GLContext(share_group), shared_context_(shared_context), display_(NULL), - state_restorer_(new GLStateRestorerImpl(decoder)), decoder_(decoder) { } @@ -27,6 +26,8 @@ gfx::Display* GLContextVirtual::display() { bool GLContextVirtual::Initialize( gfx::GLSurface* compatible_surface, gfx::GpuPreference gpu_preference) { + SetGLStateRestorer(new GLStateRestorerImpl(decoder_)); + display_ = static_cast<gfx::Display*>(compatible_surface->GetDisplay()); // Virtual contexts obviously can't make a context that is compatible @@ -79,10 +80,6 @@ void* GLContextVirtual::GetHandle() { return shared_context_->GetHandle(); } -gfx::GLStateRestorer* GLContextVirtual::GetGLStateRestorer() { - return state_restorer_.get(); -} - void GLContextVirtual::SetSwapInterval(int interval) { shared_context_->SetSwapInterval(interval); } diff --git a/gpu/command_buffer/service/gl_context_virtual.h b/gpu/command_buffer/service/gl_context_virtual.h index 9957a49..fdecbdd 100644 --- a/gpu/command_buffer/service/gl_context_virtual.h +++ b/gpu/command_buffer/service/gl_context_virtual.h @@ -42,7 +42,6 @@ class GPU_EXPORT GLContextVirtual : public gfx::GLContext { virtual void ReleaseCurrent(gfx::GLSurface* surface) OVERRIDE; virtual bool IsCurrent(gfx::GLSurface* surface) OVERRIDE; virtual void* GetHandle() OVERRIDE; - virtual gfx::GLStateRestorer* GetGLStateRestorer() OVERRIDE; virtual void SetSwapInterval(int interval) OVERRIDE; virtual std::string GetExtensions() OVERRIDE; virtual bool GetTotalGpuMemory(size_t* bytes) OVERRIDE; @@ -56,7 +55,6 @@ class GPU_EXPORT GLContextVirtual : public gfx::GLContext { private: scoped_refptr<gfx::GLContext> shared_context_; gfx::Display* display_; - scoped_ptr<gfx::GLStateRestorer> state_restorer_; base::WeakPtr<gles2::GLES2Decoder> decoder_; DISALLOW_COPY_AND_ASSIGN(GLContextVirtual); diff --git a/gpu/command_buffer/service/gl_state_restorer_impl.cc b/gpu/command_buffer/service/gl_state_restorer_impl.cc index 0290c9a..d39b805 100644 --- a/gpu/command_buffer/service/gl_state_restorer_impl.cc +++ b/gpu/command_buffer/service/gl_state_restorer_impl.cc @@ -21,4 +21,14 @@ void GLStateRestorerImpl::RestoreState() { decoder_->RestoreState(); } +void GLStateRestorerImpl::RestoreAllTextureUnitBindings() { + DCHECK(decoder_.get()); + decoder_->RestoreAllTextureUnitBindings(); +} + +void GLStateRestorerImpl::RestoreFramebufferBindings() { + DCHECK(decoder_.get()); + decoder_->RestoreFramebufferBindings(); +} + } // namespace gpu diff --git a/gpu/command_buffer/service/gl_state_restorer_impl.h b/gpu/command_buffer/service/gl_state_restorer_impl.h index b210ac0..aba3b1d 100644 --- a/gpu/command_buffer/service/gl_state_restorer_impl.h +++ b/gpu/command_buffer/service/gl_state_restorer_impl.h @@ -24,6 +24,8 @@ class GPU_EXPORT GLStateRestorerImpl : public gfx::GLStateRestorer { virtual ~GLStateRestorerImpl(); virtual void RestoreState() OVERRIDE; + virtual void RestoreAllTextureUnitBindings() OVERRIDE; + virtual void RestoreFramebufferBindings() OVERRIDE; private: base::WeakPtr<gles2::GLES2Decoder> decoder_; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index d2d7c11..5425efb 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -604,6 +604,9 @@ class GLES2DecoderImpl : public GLES2Decoder { virtual void RestoreActiveTexture() const OVERRIDE { state_.RestoreActiveTexture(); } + virtual void RestoreAllTextureUnitBindings() const OVERRIDE { + state_.RestoreAllTextureUnitBindings(); + } virtual void RestoreAttribute(unsigned index) const OVERRIDE { state_.RestoreAttribute(index); } diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h index e342da3..14c82f0 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder.h @@ -141,11 +141,12 @@ class GPU_EXPORT GLES2Decoder : public base::SupportsWeakPtr<GLES2Decoder>, // Gets the associated ContextGroup virtual ContextGroup* GetContextGroup() = 0; - // Gets the service id for any simulated backbuffer fbo. + // Restores all of the decoder GL state. virtual void RestoreState() const = 0; // Restore States. virtual void RestoreActiveTexture() const = 0; + virtual void RestoreAllTextureUnitBindings() const = 0; virtual void RestoreAttribute(unsigned index) const = 0; virtual void RestoreBufferBindings() const = 0; virtual void RestoreFramebufferBindings() const = 0; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h index eeecf17..12d1cbd 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h @@ -57,6 +57,7 @@ class MockGLES2Decoder : public GLES2Decoder { MOCK_METHOD0(PerformIdleWork, void()); MOCK_CONST_METHOD0(RestoreState, void()); MOCK_CONST_METHOD0(RestoreActiveTexture, void()); + MOCK_CONST_METHOD0(RestoreAllTextureUnitBindings, void()); MOCK_CONST_METHOD1(RestoreAttribute, void(unsigned index)); MOCK_CONST_METHOD0(RestoreBufferBindings, void()); MOCK_CONST_METHOD0(RestoreFramebufferBindings, void()); |