Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 5 #ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
| 6 #define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 6 #define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
| 7 | 7 |
| 8 #include <GLES2/gl2.h> | 8 #include <GLES2/gl2.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 584 | 584 |
| 585 // Asserts that the context is lost. | 585 // Asserts that the context is lost. |
| 586 // NOTE: This is an expensive call and should only be called | 586 // NOTE: This is an expensive call and should only be called |
| 587 // for error checking. | 587 // for error checking. |
| 588 bool MustBeContextLost(); | 588 bool MustBeContextLost(); |
| 589 | 589 |
| 590 void RunIfContextNotLost(const base::Closure& callback); | 590 void RunIfContextNotLost(const base::Closure& callback); |
| 591 | 591 |
| 592 void OnSwapBuffersComplete(); | 592 void OnSwapBuffersComplete(); |
| 593 | 593 |
| 594 // Remove the transfer buffer from the buffer tracker. For buffers used | |
| 595 // asynchronously the memory is free:ed if the upload has completed. For | |
| 596 // other buffers, the memory is either free:ed immediately or free:ed pending | |
| 597 // a token. | |
| 598 void RemoveTransferBuffer(BufferTracker::Buffer* buffer); | |
| 599 | |
| 600 // Returns true if the async upload token has passed. | |
| 601 // | |
| 602 // NOTE: This will detect wrapped async tokens by checking if the most | |
| 603 // significant bit of async token to check is 1 but the last read is 0, i.e. | |
| 604 // the uint32 wrapped. | |
| 605 bool HasAsyncUploadTokenPassed(uint32 token) const { | |
| 606 if (token <= async_upload_sync_->async_token) | |
| 607 return true; | |
| 608 if (token & 0x80000000 && | |
| 609 !(async_upload_sync_->async_token & 0x80000000)) { | |
|
piman
2014/02/07 22:58:20
Reading async_token twice seems race-prone, it cou
jadahl
2014/02/08 09:18:25
True. Good catch.
| |
| 610 return true; // we wrapped | |
| 611 } | |
| 612 return false; | |
| 613 } | |
| 614 | |
| 615 // Get the next async upload token. | |
| 616 uint32 NextAsyncUploadToken(); | |
| 617 | |
| 618 // Ensure that the shared memory used for synchronizing async upload tokens | |
| 619 // has been mapped. | |
| 620 // | |
| 621 // Returns false on error, true on success. | |
| 622 bool EnsureAsyncUploadSync(); | |
| 623 | |
| 624 // Checks the last read asynchronously upload token and frees any unmanaged | |
| 625 // transfer buffer that has its async token passed. | |
| 626 // | |
| 627 // If |wait| is true, poll until all unmanaged transfer buffers has been | |
| 628 // free:ed. | |
| 629 void PollAsyncUploads(bool wait); | |
| 630 | |
| 594 bool GetBoundPixelTransferBuffer( | 631 bool GetBoundPixelTransferBuffer( |
| 595 GLenum target, const char* function_name, GLuint* buffer_id); | 632 GLenum target, const char* function_name, GLuint* buffer_id); |
| 596 BufferTracker::Buffer* GetBoundPixelUnpackTransferBufferIfValid( | 633 BufferTracker::Buffer* GetBoundPixelUnpackTransferBufferIfValid( |
| 597 GLuint buffer_id, | 634 GLuint buffer_id, |
| 598 const char* function_name, GLuint offset, GLsizei size); | 635 const char* function_name, GLuint offset, GLsizei size); |
| 599 | 636 |
| 600 const std::string& GetLogPrefix() const; | 637 const std::string& GetLogPrefix() const; |
| 601 | 638 |
| 602 #if defined(GL_CLIENT_FAIL_GL_ERRORS) | 639 #if defined(GL_CLIENT_FAIL_GL_ERRORS) |
| 603 void CheckGLError(); | 640 void CheckGLError(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 656 // The program in use by glUseProgram | 693 // The program in use by glUseProgram |
| 657 GLuint current_program_; | 694 GLuint current_program_; |
| 658 | 695 |
| 659 // The currently bound array buffer. | 696 // The currently bound array buffer. |
| 660 GLuint bound_array_buffer_id_; | 697 GLuint bound_array_buffer_id_; |
| 661 | 698 |
| 662 // The currently bound pixel transfer buffers. | 699 // The currently bound pixel transfer buffers. |
| 663 GLuint bound_pixel_pack_transfer_buffer_id_; | 700 GLuint bound_pixel_pack_transfer_buffer_id_; |
| 664 GLuint bound_pixel_unpack_transfer_buffer_id_; | 701 GLuint bound_pixel_unpack_transfer_buffer_id_; |
| 665 | 702 |
| 703 // The current asynchronous pixel buffer upload token. | |
| 704 uint32 async_upload_token_; | |
| 705 | |
| 706 // The shared memory used for synchronizing asynchronous upload tokens. | |
| 707 AsyncUploadSync* async_upload_sync_; | |
| 708 int32 async_upload_sync_shm_id_; | |
| 709 unsigned int async_upload_sync_shm_offset_; | |
| 710 | |
| 711 // Unmanaged pixel transfer buffer memory pending asynchronous upload token. | |
| 712 typedef std::list<std::pair<void*, uint32> > DetachedAsyncUploadMemoryList; | |
| 713 DetachedAsyncUploadMemoryList detached_async_upload_memory_; | |
| 714 | |
| 666 // Client side management for vertex array objects. Needed to correctly | 715 // Client side management for vertex array objects. Needed to correctly |
| 667 // track client side arrays. | 716 // track client side arrays. |
| 668 scoped_ptr<VertexArrayObjectManager> vertex_array_object_manager_; | 717 scoped_ptr<VertexArrayObjectManager> vertex_array_object_manager_; |
| 669 | 718 |
| 670 GLuint reserved_ids_[2]; | 719 GLuint reserved_ids_[2]; |
| 671 | 720 |
| 672 // Current GL error bits. | 721 // Current GL error bits. |
| 673 uint32 error_bits_; | 722 uint32 error_bits_; |
| 674 | 723 |
| 675 // Whether or not to print debugging info. | 724 // Whether or not to print debugging info. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 754 | 803 |
| 755 inline bool GLES2Implementation::GetTexParameterivHelper( | 804 inline bool GLES2Implementation::GetTexParameterivHelper( |
| 756 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { | 805 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { |
| 757 return false; | 806 return false; |
| 758 } | 807 } |
| 759 | 808 |
| 760 } // namespace gles2 | 809 } // namespace gles2 |
| 761 } // namespace gpu | 810 } // namespace gpu |
| 762 | 811 |
| 763 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 812 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
| OLD | NEW |