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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.h

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

Powered by Google App Engine
This is Rietveld 408576698