| 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 <list> |
| 10 #include <map> | 11 #include <map> |
| 11 #include <queue> | 12 #include <queue> |
| 12 #include <set> | 13 #include <set> |
| 13 #include <string> | 14 #include <string> |
| 15 #include <utility> |
| 14 #include <vector> | 16 #include <vector> |
| 15 | 17 |
| 16 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 17 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 19 #include "gles2_impl_export.h" | |
| 20 #include "gpu/command_buffer/client/buffer_tracker.h" | 21 #include "gpu/command_buffer/client/buffer_tracker.h" |
| 21 #include "gpu/command_buffer/client/client_context_state.h" | 22 #include "gpu/command_buffer/client/client_context_state.h" |
| 22 #include "gpu/command_buffer/client/context_support.h" | 23 #include "gpu/command_buffer/client/context_support.h" |
| 23 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 24 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
| 25 #include "gpu/command_buffer/client/gles2_impl_export.h" |
| 24 #include "gpu/command_buffer/client/gles2_interface.h" | 26 #include "gpu/command_buffer/client/gles2_interface.h" |
| 25 #include "gpu/command_buffer/client/gpu_memory_buffer_tracker.h" | 27 #include "gpu/command_buffer/client/gpu_memory_buffer_tracker.h" |
| 26 #include "gpu/command_buffer/client/mapped_memory.h" | 28 #include "gpu/command_buffer/client/mapped_memory.h" |
| 27 #include "gpu/command_buffer/client/query_tracker.h" | 29 #include "gpu/command_buffer/client/query_tracker.h" |
| 28 #include "gpu/command_buffer/client/ref_counted.h" | 30 #include "gpu/command_buffer/client/ref_counted.h" |
| 29 #include "gpu/command_buffer/client/ring_buffer.h" | 31 #include "gpu/command_buffer/client/ring_buffer.h" |
| 30 #include "gpu/command_buffer/client/share_group.h" | 32 #include "gpu/command_buffer/client/share_group.h" |
| 31 #include "gpu/command_buffer/common/capabilities.h" | 33 #include "gpu/command_buffer/common/capabilities.h" |
| 32 #include "gpu/command_buffer/common/debug_marker_manager.h" | 34 #include "gpu/command_buffer/common/debug_marker_manager.h" |
| 33 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 35 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 36 #include "gpu/command_buffer/common/id_allocator.h" |
| 34 | 37 |
| 35 #if !defined(NDEBUG) && !defined(__native_client__) && !defined(GLES2_CONFORMANC
E_TESTS) // NOLINT | 38 #if !defined(NDEBUG) && !defined(__native_client__) && !defined(GLES2_CONFORMANC
E_TESTS) // NOLINT |
| 36 #if defined(GLES2_INLINE_OPTIMIZATION) | 39 #if defined(GLES2_INLINE_OPTIMIZATION) |
| 37 // TODO(gman): Replace with macros that work with inline optmization. | 40 // TODO(gman): Replace with macros that work with inline optmization. |
| 38 #define GPU_CLIENT_SINGLE_THREAD_CHECK() | 41 #define GPU_CLIENT_SINGLE_THREAD_CHECK() |
| 39 #define GPU_CLIENT_LOG(args) | 42 #define GPU_CLIENT_LOG(args) |
| 40 #define GPU_CLIENT_LOG_CODE_BLOCK(code) | 43 #define GPU_CLIENT_LOG_CODE_BLOCK(code) |
| 41 #define GPU_CLIENT_DCHECK_CODE_BLOCK(code) | 44 #define GPU_CLIENT_DCHECK_CODE_BLOCK(code) |
| 42 #else | 45 #else |
| 43 #include "base/logging.h" | 46 #include "base/logging.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 GLint max_varying_vectors; | 149 GLint max_varying_vectors; |
| 147 GLint max_vertex_attribs; | 150 GLint max_vertex_attribs; |
| 148 GLint max_vertex_texture_image_units; | 151 GLint max_vertex_texture_image_units; |
| 149 GLint max_vertex_uniform_vectors; | 152 GLint max_vertex_uniform_vectors; |
| 150 GLint num_compressed_texture_formats; | 153 GLint num_compressed_texture_formats; |
| 151 GLint num_shader_binary_formats; | 154 GLint num_shader_binary_formats; |
| 152 GLint bind_generates_resource_chromium; | 155 GLint bind_generates_resource_chromium; |
| 153 }; | 156 }; |
| 154 IntState int_state; | 157 IntState int_state; |
| 155 | 158 |
| 156 typedef std::pair<GLenum,GLenum> ShaderPrecisionKey; | 159 typedef std::pair<GLenum, GLenum> ShaderPrecisionKey; |
| 157 typedef std::map<ShaderPrecisionKey, | 160 typedef std::map<ShaderPrecisionKey, |
| 158 cmds::GetShaderPrecisionFormat::Result> | 161 cmds::GetShaderPrecisionFormat::Result> |
| 159 ShaderPrecisionMap; | 162 ShaderPrecisionMap; |
| 160 ShaderPrecisionMap shader_precisions; | 163 ShaderPrecisionMap shader_precisions; |
| 161 }; | 164 }; |
| 162 | 165 |
| 163 // The maxiumum result size from simple GL get commands. | 166 // The maxiumum result size from simple GL get commands. |
| 164 static const size_t kMaxSizeOfSimpleResult = 16 * sizeof(uint32); // NOLINT. | 167 static const size_t kMaxSizeOfSimpleResult = 16 * sizeof(uint32); // NOLINT. |
| 165 | 168 |
| 166 // used for testing only. If more things are reseved add them here. | 169 // used for testing only. If more things are reseved add them here. |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 GLuint bound_texture_cube_map; | 378 GLuint bound_texture_cube_map; |
| 376 | 379 |
| 377 // texture currently bound to this unit's GL_TEXTURE_EXTERNAL_OES with | 380 // texture currently bound to this unit's GL_TEXTURE_EXTERNAL_OES with |
| 378 // glBindTexture | 381 // glBindTexture |
| 379 GLuint bound_texture_external_oes; | 382 GLuint bound_texture_external_oes; |
| 380 }; | 383 }; |
| 381 | 384 |
| 382 // Checks for single threaded access. | 385 // Checks for single threaded access. |
| 383 class SingleThreadChecker { | 386 class SingleThreadChecker { |
| 384 public: | 387 public: |
| 385 SingleThreadChecker(GLES2Implementation* gles2_implementation); | 388 explicit SingleThreadChecker(GLES2Implementation* gles2_implementation); |
| 386 ~SingleThreadChecker(); | 389 ~SingleThreadChecker(); |
| 387 | 390 |
| 388 private: | 391 private: |
| 389 GLES2Implementation* gles2_implementation_; | 392 GLES2Implementation* gles2_implementation_; |
| 390 }; | 393 }; |
| 391 | 394 |
| 392 // Gets the value of the result. | 395 // Gets the value of the result. |
| 393 template <typename T> | 396 template <typename T> |
| 394 T GetResultAs() { | 397 T GetResultAs() { |
| 395 return static_cast<T>(GetResultBuffer()); | 398 return static_cast<T>(GetResultBuffer()); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 bool DeleteShaderHelper(GLuint shader); | 527 bool DeleteShaderHelper(GLuint shader); |
| 525 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* queries); | 528 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* queries); |
| 526 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* arrays); | 529 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* arrays); |
| 527 | 530 |
| 528 void DeleteBuffersStub(GLsizei n, const GLuint* buffers); | 531 void DeleteBuffersStub(GLsizei n, const GLuint* buffers); |
| 529 void DeleteFramebuffersStub(GLsizei n, const GLuint* framebuffers); | 532 void DeleteFramebuffersStub(GLsizei n, const GLuint* framebuffers); |
| 530 void DeleteRenderbuffersStub(GLsizei n, const GLuint* renderbuffers); | 533 void DeleteRenderbuffersStub(GLsizei n, const GLuint* renderbuffers); |
| 531 void DeleteTexturesStub(GLsizei n, const GLuint* textures); | 534 void DeleteTexturesStub(GLsizei n, const GLuint* textures); |
| 532 void DeleteProgramStub(GLsizei n, const GLuint* programs); | 535 void DeleteProgramStub(GLsizei n, const GLuint* programs); |
| 533 void DeleteShaderStub(GLsizei n, const GLuint* shaders); | 536 void DeleteShaderStub(GLsizei n, const GLuint* shaders); |
| 534 // TODO(gman): Remove this as queries are not shared. | |
| 535 void DeleteQueriesStub(GLsizei n, const GLuint* queries); | |
| 536 void DeleteVertexArraysOESStub(GLsizei n, const GLuint* arrays); | 537 void DeleteVertexArraysOESStub(GLsizei n, const GLuint* arrays); |
| 537 | 538 |
| 538 void BufferDataHelper( | 539 void BufferDataHelper( |
| 539 GLenum target, GLsizeiptr size, const void* data, GLenum usage); | 540 GLenum target, GLsizeiptr size, const void* data, GLenum usage); |
| 540 void BufferSubDataHelper( | 541 void BufferSubDataHelper( |
| 541 GLenum target, GLintptr offset, GLsizeiptr size, const void* data); | 542 GLenum target, GLintptr offset, GLsizeiptr size, const void* data); |
| 542 void BufferSubDataHelperImpl( | 543 void BufferSubDataHelperImpl( |
| 543 GLenum target, GLintptr offset, GLsizeiptr size, const void* data, | 544 GLenum target, GLintptr offset, GLsizeiptr size, const void* data, |
| 544 ScopedTransferBufferPtr* buffer); | 545 ScopedTransferBufferPtr* buffer); |
| 545 | 546 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 bool GetTexParameterfvHelper(GLenum target, GLenum pname, GLfloat* params); | 586 bool GetTexParameterfvHelper(GLenum target, GLenum pname, GLfloat* params); |
| 586 bool GetTexParameterivHelper(GLenum target, GLenum pname, GLint* params); | 587 bool GetTexParameterivHelper(GLenum target, GLenum pname, GLint* params); |
| 587 const GLubyte* GetStringHelper(GLenum name); | 588 const GLubyte* GetStringHelper(GLenum name); |
| 588 | 589 |
| 589 bool IsExtensionAvailable(const char* ext); | 590 bool IsExtensionAvailable(const char* ext); |
| 590 | 591 |
| 591 // Caches certain capabilties state. Return true if cached. | 592 // Caches certain capabilties state. Return true if cached. |
| 592 bool SetCapabilityState(GLenum cap, bool enabled); | 593 bool SetCapabilityState(GLenum cap, bool enabled); |
| 593 | 594 |
| 594 IdHandlerInterface* GetIdHandler(int id_namespace) const; | 595 IdHandlerInterface* GetIdHandler(int id_namespace) const; |
| 596 // IdAllocators for objects that can't be shared among contexts. |
| 597 // For now, used only for Queries. TODO(hj.r.chung) Should be added for |
| 598 // Framebuffer and Vertex array objects. |
| 599 IdAllocatorInterface* GetIdAllocator(int id_namespace) const; |
| 595 | 600 |
| 596 void FinishHelper(); | 601 void FinishHelper(); |
| 597 | 602 |
| 598 void RunIfContextNotLost(const base::Closure& callback); | 603 void RunIfContextNotLost(const base::Closure& callback); |
| 599 | 604 |
| 600 void OnSwapBuffersComplete(); | 605 void OnSwapBuffersComplete(); |
| 601 | 606 |
| 602 // Validate if an offset is valid, i.e., non-negative and fit into 32-bit. | 607 // Validate if an offset is valid, i.e., non-negative and fit into 32-bit. |
| 603 // If not, generate an approriate error, and return false. | 608 // If not, generate an approriate error, and return false. |
| 604 bool ValidateOffset(const char* func, GLintptr offset); | 609 bool ValidateOffset(const char* func, GLintptr offset); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 MappedTextureMap mapped_textures_; | 762 MappedTextureMap mapped_textures_; |
| 758 | 763 |
| 759 scoped_ptr<MappedMemoryManager> mapped_memory_; | 764 scoped_ptr<MappedMemoryManager> mapped_memory_; |
| 760 | 765 |
| 761 scoped_refptr<ShareGroup> share_group_; | 766 scoped_refptr<ShareGroup> share_group_; |
| 762 ShareGroupContextData share_group_context_data_; | 767 ShareGroupContextData share_group_context_data_; |
| 763 | 768 |
| 764 scoped_ptr<QueryTracker> query_tracker_; | 769 scoped_ptr<QueryTracker> query_tracker_; |
| 765 typedef std::map<GLuint, QueryTracker::Query*> QueryMap; | 770 typedef std::map<GLuint, QueryTracker::Query*> QueryMap; |
| 766 QueryMap current_queries_; | 771 QueryMap current_queries_; |
| 772 scoped_ptr<IdAllocatorInterface> query_id_allocator_; |
| 767 | 773 |
| 768 scoped_ptr<BufferTracker> buffer_tracker_; | 774 scoped_ptr<BufferTracker> buffer_tracker_; |
| 769 | 775 |
| 770 scoped_ptr<GpuMemoryBufferTracker> gpu_memory_buffer_tracker_; | 776 scoped_ptr<GpuMemoryBufferTracker> gpu_memory_buffer_tracker_; |
| 771 | 777 |
| 772 GLES2ImplementationErrorMessageCallback* error_message_callback_; | 778 GLES2ImplementationErrorMessageCallback* error_message_callback_; |
| 773 | 779 |
| 774 scoped_ptr<std::string> current_trace_name_; | 780 scoped_ptr<std::string> current_trace_name_; |
| 775 | 781 |
| 776 GpuControl* gpu_control_; | 782 GpuControl* gpu_control_; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 | 820 |
| 815 inline bool GLES2Implementation::GetTexParameterivHelper( | 821 inline bool GLES2Implementation::GetTexParameterivHelper( |
| 816 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { | 822 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { |
| 817 return false; | 823 return false; |
| 818 } | 824 } |
| 819 | 825 |
| 820 } // namespace gles2 | 826 } // namespace gles2 |
| 821 } // namespace gpu | 827 } // namespace gpu |
| 822 | 828 |
| 823 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 829 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
| OLD | NEW |