Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 7253052: Execute all GL commands up to the put offset reported by a flush. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 virtual void ResizeOffscreenFrameBuffer(const gfx::Size& size); 728 virtual void ResizeOffscreenFrameBuffer(const gfx::Size& size);
729 virtual bool UpdateOffscreenFrameBufferSize(); 729 virtual bool UpdateOffscreenFrameBufferSize();
730 virtual bool MakeCurrent(); 730 virtual bool MakeCurrent();
731 virtual GLES2Util* GetGLES2Util() { return &util_; } 731 virtual GLES2Util* GetGLES2Util() { return &util_; }
732 virtual gfx::GLContext* GetGLContext() { return context_.get(); } 732 virtual gfx::GLContext* GetGLContext() { return context_.get(); }
733 virtual gfx::GLSurface* GetGLSurface() { return surface_.get(); } 733 virtual gfx::GLSurface* GetGLSurface() { return surface_.get(); }
734 virtual ContextGroup* GetContextGroup() { return group_.get(); } 734 virtual ContextGroup* GetContextGroup() { return group_.get(); }
735 735
736 virtual void SetResizeCallback(Callback1<gfx::Size>::Type* callback); 736 virtual void SetResizeCallback(Callback1<gfx::Size>::Type* callback);
737 virtual void SetSwapBuffersCallback(Callback0::Type* callback); 737 virtual void SetSwapBuffersCallback(Callback0::Type* callback);
738 virtual void SetLatchCallback(const base::Callback<void(bool)>& callback);;
739 virtual bool GetServiceTextureId(uint32 client_texture_id, 738 virtual bool GetServiceTextureId(uint32 client_texture_id,
740 uint32* service_texture_id); 739 uint32* service_texture_id);
741 740
742 // Restores the current state to the user's settings. 741 // Restores the current state to the user's settings.
743 void RestoreCurrentFramebufferBindings(); 742 void RestoreCurrentFramebufferBindings();
744 void RestoreCurrentRenderbufferBindings(); 743 void RestoreCurrentRenderbufferBindings();
745 void RestoreCurrentTexture2DBindings(); 744 void RestoreCurrentTexture2DBindings();
746 745
747 // Sets DEPTH_TEST, STENCIL_TEST and color mask for the current framebuffer. 746 // Sets DEPTH_TEST, STENCIL_TEST and color mask for the current framebuffer.
748 void ApplyDirtyState(); 747 void ApplyDirtyState();
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 GLuint copy_texture_to_parent_texture_fb_; 1516 GLuint copy_texture_to_parent_texture_fb_;
1518 1517
1519 // The copy that is saved when SwapBuffers is called. It is also 1518 // The copy that is saved when SwapBuffers is called. It is also
1520 // used as the destination for multi-sample resolves. 1519 // used as the destination for multi-sample resolves.
1521 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_; 1520 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_;
1522 scoped_ptr<Texture> offscreen_saved_color_texture_; 1521 scoped_ptr<Texture> offscreen_saved_color_texture_;
1523 GLenum offscreen_saved_color_format_; 1522 GLenum offscreen_saved_color_format_;
1524 1523
1525 scoped_ptr<Callback1<gfx::Size>::Type> resize_callback_; 1524 scoped_ptr<Callback1<gfx::Size>::Type> resize_callback_;
1526 scoped_ptr<Callback0::Type> swap_buffers_callback_; 1525 scoped_ptr<Callback0::Type> swap_buffers_callback_;
1527 base::Callback<void(bool)> latch_callback_;
1528 1526
1529 // The format of the back buffer_ 1527 // The format of the back buffer_
1530 GLenum back_buffer_color_format_; 1528 GLenum back_buffer_color_format_;
1531 bool back_buffer_has_depth_; 1529 bool back_buffer_has_depth_;
1532 bool back_buffer_has_stencil_; 1530 bool back_buffer_has_stencil_;
1533 1531
1534 bool teximage2d_faster_than_texsubimage2d_; 1532 bool teximage2d_faster_than_texsubimage2d_;
1535 bool bufferdata_faster_than_buffersubdata_; 1533 bool bufferdata_faster_than_buffersubdata_;
1536 1534
1537 // The last error message set. 1535 // The last error message set.
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
2580 } 2578 }
2581 2579
2582 void GLES2DecoderImpl::SetResizeCallback(Callback1<gfx::Size>::Type* callback) { 2580 void GLES2DecoderImpl::SetResizeCallback(Callback1<gfx::Size>::Type* callback) {
2583 resize_callback_.reset(callback); 2581 resize_callback_.reset(callback);
2584 } 2582 }
2585 2583
2586 void GLES2DecoderImpl::SetSwapBuffersCallback(Callback0::Type* callback) { 2584 void GLES2DecoderImpl::SetSwapBuffersCallback(Callback0::Type* callback) {
2587 swap_buffers_callback_.reset(callback); 2585 swap_buffers_callback_.reset(callback);
2588 } 2586 }
2589 2587
2590 void GLES2DecoderImpl::SetLatchCallback(
2591 const base::Callback<void(bool)>& callback) {
2592 latch_callback_ = callback;
2593 }
2594
2595 bool GLES2DecoderImpl::GetServiceTextureId(uint32 client_texture_id, 2588 bool GLES2DecoderImpl::GetServiceTextureId(uint32 client_texture_id,
2596 uint32* service_texture_id) { 2589 uint32* service_texture_id) {
2597 TextureManager::TextureInfo* texture = 2590 TextureManager::TextureInfo* texture =
2598 texture_manager()->GetTextureInfo(client_texture_id); 2591 texture_manager()->GetTextureInfo(client_texture_id);
2599 if (texture) { 2592 if (texture) {
2600 *service_texture_id = texture->service_id(); 2593 *service_texture_id = texture->service_id();
2601 return true; 2594 return true;
2602 } 2595 }
2603 return false; 2596 return false;
2604 } 2597 }
(...skipping 4110 matching lines...) Expand 10 before | Expand all | Expand 10 after
6715 } 6708 }
6716 } 6709 }
6717 6710
6718 if (swap_buffers_callback_.get()) { 6711 if (swap_buffers_callback_.get()) {
6719 swap_buffers_callback_->Run(); 6712 swap_buffers_callback_->Run();
6720 } 6713 }
6721 6714
6722 return error::kNoError; 6715 return error::kNoError;
6723 } 6716 }
6724 6717
6725 error::Error GLES2DecoderImpl::HandleSetLatchCHROMIUM(
6726 uint32 immediate_data_size, const gles2::SetLatchCHROMIUM& c) {
6727 TRACE_EVENT1("gpu", "SetLatch", "latch_id", c.latch_id);
6728 // Ensure the side effects of previous commands are visible to other contexts.
6729 // There is no need to do this for ANGLE because it uses a
6730 // single D3D device for all contexts.
6731 if (!IsAngle())
6732 glFlush();
6733
6734 int32 shm_id = gpu::kLatchSharedMemoryId;
6735 uint32 latch_id = c.latch_id;
6736 uint32 shm_offset = 0;
6737 base::subtle::Atomic32* latch;
6738 if (!SafeMultiplyUint32(latch_id, sizeof(*latch), &shm_offset)) {
6739 return error::kOutOfBounds;
6740 }
6741 latch = GetSharedMemoryAs<base::subtle::Atomic32*>(
6742 shm_id, shm_offset, sizeof(*latch));
6743 if (!latch) {
6744 return error::kOutOfBounds;
6745 }
6746 base::subtle::Atomic32 old =
6747 base::subtle::NoBarrier_CompareAndSwap(latch, 0, 1);
6748 DCHECK(old == 0);
6749 if (!latch_callback_.is_null())
6750 latch_callback_.Run(true);
6751 return error::kNoError;
6752 }
6753
6754 error::Error GLES2DecoderImpl::HandleWaitLatchCHROMIUM(
6755 uint32 immediate_data_size, const gles2::WaitLatchCHROMIUM& c) {
6756 TRACE_EVENT1("gpu", "WaitLatch", "latch_id", c.latch_id);
6757 int32 shm_id = gpu::kLatchSharedMemoryId;
6758 uint32 latch_id = c.latch_id;
6759 uint32 shm_offset = 0;
6760 base::subtle::Atomic32* latch;
6761 if (!SafeMultiplyUint32(latch_id, sizeof(*latch), &shm_offset)) {
6762 return error::kOutOfBounds;
6763 }
6764 latch = GetSharedMemoryAs<base::subtle::Atomic32*>(
6765 shm_id, shm_offset, sizeof(*latch));
6766 if (!latch) {
6767 return error::kOutOfBounds;
6768 }
6769
6770 base::subtle::Atomic32 old =
6771 base::subtle::NoBarrier_CompareAndSwap(latch, 1, 0);
6772 if (old == 0) {
6773 if (!latch_callback_.is_null())
6774 latch_callback_.Run(false);
6775 return error::kWaiting;
6776 } else {
6777 return error::kNoError;
6778 }
6779 }
6780
6781 error::Error GLES2DecoderImpl::HandleCommandBufferEnableCHROMIUM( 6718 error::Error GLES2DecoderImpl::HandleCommandBufferEnableCHROMIUM(
6782 uint32 immediate_data_size, const gles2::CommandBufferEnableCHROMIUM& c) { 6719 uint32 immediate_data_size, const gles2::CommandBufferEnableCHROMIUM& c) {
6783 Bucket* bucket = GetBucket(c.bucket_id); 6720 Bucket* bucket = GetBucket(c.bucket_id);
6784 typedef gles2::CommandBufferEnableCHROMIUM::Result Result; 6721 typedef gles2::CommandBufferEnableCHROMIUM::Result Result;
6785 Result* result = GetSharedMemoryAs<Result*>( 6722 Result* result = GetSharedMemoryAs<Result*>(
6786 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 6723 c.result_shm_id, c.result_shm_offset, sizeof(*result));
6787 if (!result) { 6724 if (!result) {
6788 return error::kOutOfBounds; 6725 return error::kOutOfBounds;
6789 } 6726 }
6790 // Check that the client initialized the result. 6727 // Check that the client initialized the result.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
6935 return error::kNoError; 6872 return error::kNoError;
6936 } 6873 }
6937 6874
6938 // Include the auto-generated part of this file. We split this because it means 6875 // Include the auto-generated part of this file. We split this because it means
6939 // we can easily edit the non-auto generated parts right here in this file 6876 // we can easily edit the non-auto generated parts right here in this file
6940 // instead of having to edit some template or the code generator. 6877 // instead of having to edit some template or the code generator.
6941 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 6878 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
6942 6879
6943 } // namespace gles2 6880 } // namespace gles2
6944 } // namespace gpu 6881 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698