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> |
11 #include <queue> | 11 #include <queue> |
12 #include <set> | 12 #include <set> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "../client/buffer_tracker.h" | 17 #include "../client/buffer_tracker.h" |
18 #include "../client/client_context_state.h" | 18 #include "../client/client_context_state.h" |
| 19 #include "../client/gpu_memory_buffer_factory.h" |
19 #include "../client/gles2_cmd_helper.h" | 20 #include "../client/gles2_cmd_helper.h" |
20 #include "../client/gles2_interface.h" | 21 #include "../client/gles2_interface.h" |
21 #include "../client/query_tracker.h" | 22 #include "../client/query_tracker.h" |
22 #include "../client/ref_counted.h" | 23 #include "../client/ref_counted.h" |
23 #include "../client/ring_buffer.h" | 24 #include "../client/ring_buffer.h" |
24 #include "../client/share_group.h" | 25 #include "../client/share_group.h" |
25 #include "../common/compiler_specific.h" | 26 #include "../common/compiler_specific.h" |
26 #include "../common/debug_marker_manager.h" | 27 #include "../common/debug_marker_manager.h" |
27 #include "../common/gles2_cmd_utils.h" | 28 #include "../common/gles2_cmd_utils.h" |
28 #include "gles2_impl_export.h" | 29 #include "gles2_impl_export.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 struct GLUniformDefinitionCHROMIUM; | 96 struct GLUniformDefinitionCHROMIUM; |
96 | 97 |
97 namespace gpu { | 98 namespace gpu { |
98 | 99 |
99 class MappedMemoryManager; | 100 class MappedMemoryManager; |
100 class ScopedTransferBufferPtr; | 101 class ScopedTransferBufferPtr; |
101 class TransferBufferInterface; | 102 class TransferBufferInterface; |
102 | 103 |
103 namespace gles2 { | 104 namespace gles2 { |
104 | 105 |
| 106 class GpuMemoryBufferFactory; |
| 107 class GpuMemoryBufferTracker; |
105 class VertexArrayObjectManager; | 108 class VertexArrayObjectManager; |
106 | 109 |
107 // This class emulates GLES2 over command buffers. It can be used by a client | 110 // This class emulates GLES2 over command buffers. It can be used by a client |
108 // program so that the program does not need deal with shared memory and command | 111 // program so that the program does not need deal with shared memory and command |
109 // buffer management. See gl2_lib.h. Note that there is a performance gain to | 112 // buffer management. See gl2_lib.h. Note that there is a performance gain to |
110 // be had by changing your code to use command buffers directly by using the | 113 // be had by changing your code to use command buffers directly by using the |
111 // GLES2CmdHelper but that entails changing your code to use and deal with | 114 // GLES2CmdHelper but that entails changing your code to use and deal with |
112 // shared memory and synchronization issues. | 115 // shared memory and synchronization issues. |
113 class GLES2_IMPL_EXPORT GLES2Implementation : public GLES2Interface { | 116 class GLES2_IMPL_EXPORT GLES2Implementation : public GLES2Interface { |
114 public: | 117 public: |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 void FreeEverything(); | 215 void FreeEverything(); |
213 | 216 |
214 void SetErrorMessageCallback(ErrorMessageCallback* callback) { | 217 void SetErrorMessageCallback(ErrorMessageCallback* callback) { |
215 error_message_callback_ = callback; | 218 error_message_callback_ = callback; |
216 } | 219 } |
217 | 220 |
218 ShareGroup* share_group() const { | 221 ShareGroup* share_group() const { |
219 return share_group_.get(); | 222 return share_group_.get(); |
220 } | 223 } |
221 | 224 |
| 225 // GLES2Implementation owns the |factory|. |
| 226 void SetGpuMemoryBufferFactory(scoped_ptr<GpuMemoryBufferFactory> factory) { |
| 227 gpu_memory_buffer_factory_ = factory.Pass(); |
| 228 } |
| 229 |
222 private: | 230 private: |
223 friend class GLES2ImplementationTest; | 231 friend class GLES2ImplementationTest; |
224 friend class VertexArrayObjectManager; | 232 friend class VertexArrayObjectManager; |
225 | 233 |
226 // Used to track whether an extension is available | 234 // Used to track whether an extension is available |
227 enum ExtensionStatus { | 235 enum ExtensionStatus { |
228 kAvailableExtensionStatus, | 236 kAvailableExtensionStatus, |
229 kUnavailableExtensionStatus, | 237 kUnavailableExtensionStatus, |
230 kUnknownExtensionStatus | 238 kUnknownExtensionStatus |
231 }; | 239 }; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 bool BindRenderbufferHelper(GLenum target, GLuint texture); | 408 bool BindRenderbufferHelper(GLenum target, GLuint texture); |
401 bool BindTextureHelper(GLenum target, GLuint texture); | 409 bool BindTextureHelper(GLenum target, GLuint texture); |
402 bool BindVertexArrayHelper(GLuint array); | 410 bool BindVertexArrayHelper(GLuint array); |
403 | 411 |
404 void GenBuffersHelper(GLsizei n, const GLuint* buffers); | 412 void GenBuffersHelper(GLsizei n, const GLuint* buffers); |
405 void GenFramebuffersHelper(GLsizei n, const GLuint* framebuffers); | 413 void GenFramebuffersHelper(GLsizei n, const GLuint* framebuffers); |
406 void GenRenderbuffersHelper(GLsizei n, const GLuint* renderbuffers); | 414 void GenRenderbuffersHelper(GLsizei n, const GLuint* renderbuffers); |
407 void GenTexturesHelper(GLsizei n, const GLuint* textures); | 415 void GenTexturesHelper(GLsizei n, const GLuint* textures); |
408 void GenVertexArraysOESHelper(GLsizei n, const GLuint* arrays); | 416 void GenVertexArraysOESHelper(GLsizei n, const GLuint* arrays); |
409 void GenQueriesEXTHelper(GLsizei n, const GLuint* queries); | 417 void GenQueriesEXTHelper(GLsizei n, const GLuint* queries); |
| 418 void GenImageBuffersHelper(GLsizei n, const GLuint* imagebuffers); |
410 | 419 |
411 void DeleteBuffersHelper(GLsizei n, const GLuint* buffers); | 420 void DeleteBuffersHelper(GLsizei n, const GLuint* buffers); |
412 void DeleteFramebuffersHelper(GLsizei n, const GLuint* framebuffers); | 421 void DeleteFramebuffersHelper(GLsizei n, const GLuint* framebuffers); |
413 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* renderbuffers); | 422 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* renderbuffers); |
414 void DeleteTexturesHelper(GLsizei n, const GLuint* textures); | 423 void DeleteTexturesHelper(GLsizei n, const GLuint* textures); |
415 bool DeleteProgramHelper(GLuint program); | 424 bool DeleteProgramHelper(GLuint program); |
416 bool DeleteShaderHelper(GLuint shader); | 425 bool DeleteShaderHelper(GLuint shader); |
417 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* queries); | 426 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* queries); |
418 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* arrays); | 427 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* arrays); |
| 428 void DeleteImageBuffersHelper(GLsizei n, const GLuint* imagebuffers); |
419 | 429 |
420 void DeleteBuffersStub(GLsizei n, const GLuint* buffers); | 430 void DeleteBuffersStub(GLsizei n, const GLuint* buffers); |
421 void DeleteFramebuffersStub(GLsizei n, const GLuint* framebuffers); | 431 void DeleteFramebuffersStub(GLsizei n, const GLuint* framebuffers); |
| 432 void DeleteImageBuffersStub(GLsizei n, const GLuint* imagebuffers); |
422 void DeleteRenderbuffersStub(GLsizei n, const GLuint* renderbuffers); | 433 void DeleteRenderbuffersStub(GLsizei n, const GLuint* renderbuffers); |
423 void DeleteTexturesStub(GLsizei n, const GLuint* textures); | 434 void DeleteTexturesStub(GLsizei n, const GLuint* textures); |
424 void DeleteProgramStub(GLsizei n, const GLuint* programs); | 435 void DeleteProgramStub(GLsizei n, const GLuint* programs); |
425 void DeleteShaderStub(GLsizei n, const GLuint* shaders); | 436 void DeleteShaderStub(GLsizei n, const GLuint* shaders); |
426 // TODO(gman): Remove this as queries are not shared. | 437 // TODO(gman): Remove this as queries are not shared. |
427 void DeleteQueriesStub(GLsizei n, const GLuint* queries); | 438 void DeleteQueriesStub(GLsizei n, const GLuint* queries); |
428 void DeleteVertexArraysOESStub(GLsizei n, const GLuint* arrays); | 439 void DeleteVertexArraysOESStub(GLsizei n, const GLuint* arrays); |
429 | 440 |
430 void BufferDataHelper( | 441 void BufferDataHelper( |
431 GLenum target, GLsizeiptr size, const void* data, GLenum usage); | 442 GLenum target, GLsizeiptr size, const void* data, GLenum usage); |
432 void BufferSubDataHelper( | 443 void BufferSubDataHelper( |
433 GLenum target, GLintptr offset, GLsizeiptr size, const void* data); | 444 GLenum target, GLintptr offset, GLsizeiptr size, const void* data); |
434 void BufferSubDataHelperImpl( | 445 void BufferSubDataHelperImpl( |
435 GLenum target, GLintptr offset, GLsizeiptr size, const void* data, | 446 GLenum target, GLintptr offset, GLsizeiptr size, const void* data, |
436 ScopedTransferBufferPtr* buffer); | 447 ScopedTransferBufferPtr* buffer); |
437 | 448 |
| 449 // Helper for ImageBufferData |
| 450 void CreateGpuMemoryBuffer2DCHROMIUMHelper( |
| 451 GLuint image_id, GLint width, GLint height); |
| 452 |
438 // Helper for GetVertexAttrib | 453 // Helper for GetVertexAttrib |
439 bool GetVertexAttribHelper(GLuint index, GLenum pname, uint32* param); | 454 bool GetVertexAttribHelper(GLuint index, GLenum pname, uint32* param); |
440 | 455 |
441 GLuint GetMaxValueInBufferCHROMIUMHelper( | 456 GLuint GetMaxValueInBufferCHROMIUMHelper( |
442 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset); | 457 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset); |
443 | 458 |
444 void RestoreElementAndArrayBuffers(bool restore); | 459 void RestoreElementAndArrayBuffers(bool restore); |
445 void RestoreArrayBuffer(bool restrore); | 460 void RestoreArrayBuffer(bool restrore); |
446 | 461 |
447 // The pixels pointer should already account for unpack skip rows and skip | 462 // The pixels pointer should already account for unpack skip rows and skip |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 const std::string& GetLogPrefix() const; | 506 const std::string& GetLogPrefix() const; |
492 | 507 |
493 #if defined(GL_CLIENT_FAIL_GL_ERRORS) | 508 #if defined(GL_CLIENT_FAIL_GL_ERRORS) |
494 void CheckGLError(); | 509 void CheckGLError(); |
495 void FailGLError(GLenum error); | 510 void FailGLError(GLenum error); |
496 #else | 511 #else |
497 void CheckGLError() { } | 512 void CheckGLError() { } |
498 void FailGLError(GLenum /* error */) { } | 513 void FailGLError(GLenum /* error */) { } |
499 #endif | 514 #endif |
500 | 515 |
| 516 void GetBoundGpuMemoryBuffer(const char* function_name, GLuint* buffer_id); |
| 517 |
501 GLES2Util util_; | 518 GLES2Util util_; |
502 GLES2CmdHelper* helper_; | 519 GLES2CmdHelper* helper_; |
503 TransferBufferInterface* transfer_buffer_; | 520 TransferBufferInterface* transfer_buffer_; |
504 std::string last_error_; | 521 std::string last_error_; |
505 DebugMarkerManager debug_marker_manager_; | 522 DebugMarkerManager debug_marker_manager_; |
506 std::string this_in_hex_; | 523 std::string this_in_hex_; |
507 | 524 |
508 std::queue<int32> swap_buffers_tokens_; | 525 std::queue<int32> swap_buffers_tokens_; |
509 std::queue<int32> rate_limit_tokens_; | 526 std::queue<int32> rate_limit_tokens_; |
510 | 527 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 // The program in use by glUseProgram | 564 // The program in use by glUseProgram |
548 GLuint current_program_; | 565 GLuint current_program_; |
549 | 566 |
550 // The currently bound array buffer. | 567 // The currently bound array buffer. |
551 GLuint bound_array_buffer_id_; | 568 GLuint bound_array_buffer_id_; |
552 | 569 |
553 // The currently bound pixel transfer buffers. | 570 // The currently bound pixel transfer buffers. |
554 GLuint bound_pixel_pack_transfer_buffer_id_; | 571 GLuint bound_pixel_pack_transfer_buffer_id_; |
555 GLuint bound_pixel_unpack_transfer_buffer_id_; | 572 GLuint bound_pixel_unpack_transfer_buffer_id_; |
556 | 573 |
| 574 // The currently bound GPU memory buffer |
| 575 GLuint bound_gpu_memory_buffer_id_; |
| 576 |
557 // Client side management for vertex array objects. Needed to correctly | 577 // Client side management for vertex array objects. Needed to correctly |
558 // track client side arrays. | 578 // track client side arrays. |
559 scoped_ptr<VertexArrayObjectManager> vertex_array_object_manager_; | 579 scoped_ptr<VertexArrayObjectManager> vertex_array_object_manager_; |
560 | 580 |
561 GLuint reserved_ids_[2]; | 581 GLuint reserved_ids_[2]; |
562 | 582 |
563 // Current GL error bits. | 583 // Current GL error bits. |
564 uint32 error_bits_; | 584 uint32 error_bits_; |
565 | 585 |
566 // Whether or not to print debugging info. | 586 // Whether or not to print debugging info. |
(...skipping 26 matching lines...) Expand all Loading... |
593 ShaderPrecisionCacheMap; | 613 ShaderPrecisionCacheMap; |
594 ShaderPrecisionCacheMap shader_precision_cache_; | 614 ShaderPrecisionCacheMap shader_precision_cache_; |
595 | 615 |
596 scoped_refptr<ShareGroup> share_group_; | 616 scoped_refptr<ShareGroup> share_group_; |
597 | 617 |
598 scoped_ptr<QueryTracker> query_tracker_; | 618 scoped_ptr<QueryTracker> query_tracker_; |
599 QueryTracker::Query* current_query_; | 619 QueryTracker::Query* current_query_; |
600 | 620 |
601 scoped_ptr<BufferTracker> buffer_tracker_; | 621 scoped_ptr<BufferTracker> buffer_tracker_; |
602 | 622 |
| 623 scoped_ptr<GpuMemoryBufferTracker> gpu_memory_buffer_tracker_; |
| 624 |
603 ErrorMessageCallback* error_message_callback_; | 625 ErrorMessageCallback* error_message_callback_; |
604 | 626 |
605 scoped_ptr<std::string> current_trace_name_; | 627 scoped_ptr<std::string> current_trace_name_; |
606 | 628 |
| 629 scoped_ptr<GpuMemoryBufferFactory> gpu_memory_buffer_factory_; |
| 630 |
607 DISALLOW_COPY_AND_ASSIGN(GLES2Implementation); | 631 DISALLOW_COPY_AND_ASSIGN(GLES2Implementation); |
608 }; | 632 }; |
609 | 633 |
610 inline bool GLES2Implementation::GetBufferParameterivHelper( | 634 inline bool GLES2Implementation::GetBufferParameterivHelper( |
611 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { | 635 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { |
612 return false; | 636 return false; |
613 } | 637 } |
614 | 638 |
615 inline bool GLES2Implementation::GetFramebufferAttachmentParameterivHelper( | 639 inline bool GLES2Implementation::GetFramebufferAttachmentParameterivHelper( |
616 GLenum /* target */, | 640 GLenum /* target */, |
(...skipping 20 matching lines...) Expand all Loading... |
637 | 661 |
638 inline bool GLES2Implementation::GetTexParameterivHelper( | 662 inline bool GLES2Implementation::GetTexParameterivHelper( |
639 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { | 663 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { |
640 return false; | 664 return false; |
641 } | 665 } |
642 | 666 |
643 } // namespace gles2 | 667 } // namespace gles2 |
644 } // namespace gpu | 668 } // namespace gpu |
645 | 669 |
646 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 670 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
OLD | NEW |