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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 struct GLUniformDefinitionCHROMIUM; | 87 struct GLUniformDefinitionCHROMIUM; |
88 | 88 |
89 namespace gpu { | 89 namespace gpu { |
90 | 90 |
91 class MappedMemoryManager; | 91 class MappedMemoryManager; |
92 class ScopedTransferBufferPtr; | 92 class ScopedTransferBufferPtr; |
93 class TransferBufferInterface; | 93 class TransferBufferInterface; |
94 | 94 |
95 namespace gles2 { | 95 namespace gles2 { |
96 | 96 |
97 class ClientSideBufferHelper; | 97 class VertexArrayObjectManager; |
98 | 98 |
99 // This class emulates GLES2 over command buffers. It can be used by a client | 99 // This class emulates GLES2 over command buffers. It can be used by a client |
100 // program so that the program does not need deal with shared memory and command | 100 // program so that the program does not need deal with shared memory and command |
101 // buffer management. See gl2_lib.h. Note that there is a performance gain to | 101 // buffer management. See gl2_lib.h. Note that there is a performance gain to |
102 // be had by changing your code to use command buffers directly by using the | 102 // be had by changing your code to use command buffers directly by using the |
103 // GLES2CmdHelper but that entails changing your code to use and deal with | 103 // GLES2CmdHelper but that entails changing your code to use and deal with |
104 // shared memory and synchronization issues. | 104 // shared memory and synchronization issues. |
105 class GLES2_IMPL_EXPORT GLES2Implementation : public GLES2Interface { | 105 class GLES2_IMPL_EXPORT GLES2Implementation : public GLES2Interface { |
106 public: | 106 public: |
107 class ErrorMessageCallback { | 107 class ErrorMessageCallback { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 205 |
206 void SetErrorMessageCallback(ErrorMessageCallback* callback) { | 206 void SetErrorMessageCallback(ErrorMessageCallback* callback) { |
207 error_message_callback_ = callback; | 207 error_message_callback_ = callback; |
208 } | 208 } |
209 | 209 |
210 ShareGroup* share_group() const { | 210 ShareGroup* share_group() const { |
211 return share_group_.get(); | 211 return share_group_.get(); |
212 } | 212 } |
213 | 213 |
214 private: | 214 private: |
215 friend class ClientSideBufferHelper; | |
216 friend class GLES2ImplementationTest; | 215 friend class GLES2ImplementationTest; |
| 216 friend class VertexArrayObjectManager; |
217 | 217 |
218 // Used to track whether an extension is available | 218 // Used to track whether an extension is available |
219 enum ExtensionStatus { | 219 enum ExtensionStatus { |
220 kAvailableExtensionStatus, | 220 kAvailableExtensionStatus, |
221 kUnavailableExtensionStatus, | 221 kUnavailableExtensionStatus, |
222 kUnknownExtensionStatus | 222 kUnknownExtensionStatus |
223 }; | 223 }; |
224 | 224 |
225 // Base class for mapped resources. | 225 // Base class for mapped resources. |
226 struct MappedResource { | 226 struct MappedResource { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 bool IsRenderbufferReservedId(GLuint id) { return false; } | 382 bool IsRenderbufferReservedId(GLuint id) { return false; } |
383 bool IsTextureReservedId(GLuint id) { return false; } | 383 bool IsTextureReservedId(GLuint id) { return false; } |
384 bool IsVertexArrayReservedId(GLuint id) { return false; } | 384 bool IsVertexArrayReservedId(GLuint id) { return false; } |
385 | 385 |
386 bool BindBufferHelper(GLenum target, GLuint texture); | 386 bool BindBufferHelper(GLenum target, GLuint texture); |
387 bool BindFramebufferHelper(GLenum target, GLuint texture); | 387 bool BindFramebufferHelper(GLenum target, GLuint texture); |
388 bool BindRenderbufferHelper(GLenum target, GLuint texture); | 388 bool BindRenderbufferHelper(GLenum target, GLuint texture); |
389 bool BindTextureHelper(GLenum target, GLuint texture); | 389 bool BindTextureHelper(GLenum target, GLuint texture); |
390 bool BindVertexArrayHelper(GLuint array); | 390 bool BindVertexArrayHelper(GLuint array); |
391 | 391 |
| 392 void GenBuffersHelper(GLsizei n, const GLuint* buffers); |
| 393 void GenFramebuffersHelper(GLsizei n, const GLuint* framebuffers); |
| 394 void GenRenderbuffersHelper(GLsizei n, const GLuint* renderbuffers); |
| 395 void GenTexturesHelper(GLsizei n, const GLuint* textures); |
| 396 void GenVertexArraysOESHelper(GLsizei n, const GLuint* arrays); |
| 397 void GenQueriesEXTHelper(GLsizei n, const GLuint* queries); |
| 398 |
392 void DeleteBuffersHelper(GLsizei n, const GLuint* buffers); | 399 void DeleteBuffersHelper(GLsizei n, const GLuint* buffers); |
393 void DeleteFramebuffersHelper(GLsizei n, const GLuint* framebuffers); | 400 void DeleteFramebuffersHelper(GLsizei n, const GLuint* framebuffers); |
394 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* renderbuffers); | 401 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* renderbuffers); |
395 void DeleteTexturesHelper(GLsizei n, const GLuint* textures); | 402 void DeleteTexturesHelper(GLsizei n, const GLuint* textures); |
396 bool DeleteProgramHelper(GLuint program); | 403 bool DeleteProgramHelper(GLuint program); |
397 bool DeleteShaderHelper(GLuint shader); | 404 bool DeleteShaderHelper(GLuint shader); |
398 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* textures); | 405 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* queries); |
399 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* arrays); | 406 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* arrays); |
400 | 407 |
401 void DeleteBuffersStub(GLsizei n, const GLuint* buffers); | 408 void DeleteBuffersStub(GLsizei n, const GLuint* buffers); |
402 void DeleteFramebuffersStub(GLsizei n, const GLuint* framebuffers); | 409 void DeleteFramebuffersStub(GLsizei n, const GLuint* framebuffers); |
403 void DeleteRenderbuffersStub(GLsizei n, const GLuint* renderbuffers); | 410 void DeleteRenderbuffersStub(GLsizei n, const GLuint* renderbuffers); |
404 void DeleteTexturesStub(GLsizei n, const GLuint* textures); | 411 void DeleteTexturesStub(GLsizei n, const GLuint* textures); |
405 void DeleteProgramStub(GLsizei n, const GLuint* programs); | 412 void DeleteProgramStub(GLsizei n, const GLuint* programs); |
406 void DeleteShaderStub(GLsizei n, const GLuint* shaders); | 413 void DeleteShaderStub(GLsizei n, const GLuint* shaders); |
407 // TODO(gman): Remove this as queries are not shared. | 414 // TODO(gman): Remove this as queries are not shared. |
408 void DeleteQueriesStub(GLsizei n, const GLuint* queries); | 415 void DeleteQueriesStub(GLsizei n, const GLuint* queries); |
409 void DeleteVertexArraysOESStub(GLsizei n, const GLuint* arrays); | 416 void DeleteVertexArraysOESStub(GLsizei n, const GLuint* arrays); |
410 | 417 |
411 void BufferDataHelper( | 418 void BufferDataHelper( |
412 GLenum target, GLsizeiptr size, const void* data, GLenum usage); | 419 GLenum target, GLsizeiptr size, const void* data, GLenum usage); |
413 void BufferSubDataHelper( | 420 void BufferSubDataHelper( |
414 GLenum target, GLintptr offset, GLsizeiptr size, const void* data); | 421 GLenum target, GLintptr offset, GLsizeiptr size, const void* data); |
415 void BufferSubDataHelperImpl( | 422 void BufferSubDataHelperImpl( |
416 GLenum target, GLintptr offset, GLsizeiptr size, const void* data, | 423 GLenum target, GLintptr offset, GLsizeiptr size, const void* data, |
417 ScopedTransferBufferPtr* buffer); | 424 ScopedTransferBufferPtr* buffer); |
418 | 425 |
419 // Helper for GetVertexAttrib | 426 // Helper for GetVertexAttrib |
420 bool GetVertexAttribHelper(GLuint index, GLenum pname, uint32* param); | 427 bool GetVertexAttribHelper(GLuint index, GLenum pname, uint32* param); |
421 | 428 |
422 GLuint GetMaxValueInBufferCHROMIUMHelper( | 429 GLuint GetMaxValueInBufferCHROMIUMHelper( |
423 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset); | 430 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset); |
424 | 431 |
| 432 void RestoreElementAndArrayBuffers(bool restore); |
| 433 void RestoreArrayBuffer(bool restrore); |
| 434 |
425 // The pixels pointer should already account for unpack skip rows and skip | 435 // The pixels pointer should already account for unpack skip rows and skip |
426 // pixels. | 436 // pixels. |
427 void TexSubImage2DImpl( | 437 void TexSubImage2DImpl( |
428 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, | 438 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, |
429 GLsizei height, GLenum format, GLenum type, uint32 unpadded_row_size, | 439 GLsizei height, GLenum format, GLenum type, uint32 unpadded_row_size, |
430 const void* pixels, uint32 pixels_padded_row_size, GLboolean internal, | 440 const void* pixels, uint32 pixels_padded_row_size, GLboolean internal, |
431 ScopedTransferBufferPtr* buffer, uint32 buffer_padded_row_size); | 441 ScopedTransferBufferPtr* buffer, uint32 buffer_padded_row_size); |
432 | 442 |
433 // Helpers for query functions. | 443 // Helpers for query functions. |
434 bool GetHelper(GLenum pname, GLint* params); | 444 bool GetHelper(GLenum pname, GLint* params); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 | 518 |
509 GLuint bound_framebuffer_; | 519 GLuint bound_framebuffer_; |
510 GLuint bound_renderbuffer_; | 520 GLuint bound_renderbuffer_; |
511 | 521 |
512 // The program in use by glUseProgram | 522 // The program in use by glUseProgram |
513 GLuint current_program_; | 523 GLuint current_program_; |
514 | 524 |
515 // The currently bound array buffer. | 525 // The currently bound array buffer. |
516 GLuint bound_array_buffer_id_; | 526 GLuint bound_array_buffer_id_; |
517 | 527 |
518 // The currently bound element array buffer. | |
519 GLuint bound_element_array_buffer_id_; | |
520 | |
521 // The currently bound pixel transfer buffer. | 528 // The currently bound pixel transfer buffer. |
522 GLuint bound_pixel_unpack_transfer_buffer_id_; | 529 GLuint bound_pixel_unpack_transfer_buffer_id_; |
523 | 530 |
524 // GL names for the buffers used to emulate client side buffers. | 531 // Client side management for vertex array objects. Needed to correctly |
525 GLuint client_side_array_id_; | 532 // track client side arrays. |
526 GLuint client_side_element_array_id_; | 533 scoped_ptr<VertexArrayObjectManager> vertex_array_object_manager_; |
527 | |
528 // Info for each vertex attribute saved so we can simulate client side | |
529 // buffers. | |
530 scoped_ptr<ClientSideBufferHelper> client_side_buffer_helper_; | |
531 | |
532 // The currently bound vertex array object (VAO) | |
533 GLuint bound_vertex_array_id_; | |
534 | 534 |
535 GLuint reserved_ids_[2]; | 535 GLuint reserved_ids_[2]; |
536 | 536 |
537 // Current GL error bits. | 537 // Current GL error bits. |
538 uint32 error_bits_; | 538 uint32 error_bits_; |
539 | 539 |
540 // Whether or not to print debugging info. | 540 // Whether or not to print debugging info. |
541 bool debug_; | 541 bool debug_; |
542 | 542 |
543 // Used to check for single threaded access. | 543 // Used to check for single threaded access. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 | 602 |
603 inline bool GLES2Implementation::GetTexParameterivHelper( | 603 inline bool GLES2Implementation::GetTexParameterivHelper( |
604 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { | 604 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { |
605 return false; | 605 return false; |
606 } | 606 } |
607 | 607 |
608 } // namespace gles2 | 608 } // namespace gles2 |
609 } // namespace gpu | 609 } // namespace gpu |
610 | 610 |
611 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 611 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
OLD | NEW |