| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(ptr && \ | 68 GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(ptr && \ |
| 69 (ptr[0] == static_cast<type>(0) || ptr[0] == static_cast<type>(-1))); | 69 (ptr[0] == static_cast<type>(0) || ptr[0] == static_cast<type>(-1))); |
| 70 | 70 |
| 71 namespace gpu { | 71 namespace gpu { |
| 72 | 72 |
| 73 class MappedMemoryManager; | 73 class MappedMemoryManager; |
| 74 | 74 |
| 75 namespace gles2 { | 75 namespace gles2 { |
| 76 | 76 |
| 77 class ClientSideBufferHelper; | 77 class ClientSideBufferHelper; |
| 78 class ProgramInfoManager; | |
| 79 | 78 |
| 80 // Base class for IdHandlers | 79 // Base class for IdHandlers |
| 81 class IdHandlerInterface { | 80 class IdHandlerInterface { |
| 82 public: | 81 public: |
| 83 IdHandlerInterface() { } | 82 IdHandlerInterface() { } |
| 84 virtual ~IdHandlerInterface() { } | 83 virtual ~IdHandlerInterface() { } |
| 85 | 84 |
| 86 // Makes some ids at or above id_offset. | 85 // Makes some ids at or above id_offset. |
| 87 virtual void MakeIds(GLuint id_offset, GLsizei n, GLuint* ids) = 0; | 86 virtual void MakeIds(GLuint id_offset, GLsizei n, GLuint* ids) = 0; |
| 88 | 87 |
| 89 // Frees some ids. | 88 // Frees some ids. |
| 90 virtual bool FreeIds(GLsizei n, const GLuint* ids) = 0; | 89 virtual void FreeIds(GLsizei n, const GLuint* ids) = 0; |
| 91 | 90 |
| 92 // Marks an id as used for glBind functions. id = 0 does nothing. | 91 // Marks an id as used for glBind functions. id = 0 does nothing. |
| 93 virtual bool MarkAsUsedForBind(GLuint id) = 0; | 92 virtual bool MarkAsUsedForBind(GLuint id) = 0; |
| 94 }; | 93 }; |
| 95 | 94 |
| 96 // This class emulates GLES2 over command buffers. It can be used by a client | 95 // This class emulates GLES2 over command buffers. It can be used by a client |
| 97 // program so that the program does not need deal with shared memory and command | 96 // program so that the program does not need deal with shared memory and command |
| 98 // buffer management. See gl2_lib.h. Note that there is a performance gain to | 97 // buffer management. See gl2_lib.h. Note that there is a performance gain to |
| 99 // be had by changing your code to use command buffers directly by using the | 98 // be had by changing your code to use command buffers directly by using the |
| 100 // GLES2CmdHelper but that entails changing your code to use and deal with | 99 // GLES2CmdHelper but that entails changing your code to use and deal with |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 static const GLuint kClientSideElementArrayId = 0xFEDCBA99u; | 148 static const GLuint kClientSideElementArrayId = 0xFEDCBA99u; |
| 150 | 149 |
| 151 // Number of swap buffers allowed before waiting. | 150 // Number of swap buffers allowed before waiting. |
| 152 static const size_t kMaxSwapBuffers = 2; | 151 static const size_t kMaxSwapBuffers = 2; |
| 153 | 152 |
| 154 GLES2Implementation( | 153 GLES2Implementation( |
| 155 GLES2CmdHelper* helper, | 154 GLES2CmdHelper* helper, |
| 156 size_t transfer_buffer_size, | 155 size_t transfer_buffer_size, |
| 157 void* transfer_buffer, | 156 void* transfer_buffer, |
| 158 int32 transfer_buffer_id, | 157 int32 transfer_buffer_id, |
| 159 bool share_resources, | 158 bool share_resources); |
| 160 bool bind_generates_resource = true); // Will remove in 2 CLs! | |
| 161 | 159 |
| 162 ~GLES2Implementation(); | 160 ~GLES2Implementation(); |
| 163 | 161 |
| 164 // The GLES2CmdHelper being used by this GLES2Implementation. You can use | 162 // The GLES2CmdHelper being used by this GLES2Implementation. You can use |
| 165 // this to issue cmds at a lower level for certain kinds of optimization. | 163 // this to issue cmds at a lower level for certain kinds of optimization. |
| 166 GLES2CmdHelper* helper() const { | 164 GLES2CmdHelper* helper() const { |
| 167 return helper_; | 165 return helper_; |
| 168 } | 166 } |
| 169 | 167 |
| 170 // Include the auto-generated part of this class. We split this because | 168 // Include the auto-generated part of this class. We split this because |
| 171 // it means we can easily edit the non-auto generated parts right here in | 169 // it means we can easily edit the non-auto generated parts right here in |
| 172 // this file instead of having to edit some template or the code generator. | 170 // this file instead of having to edit some template or the code generator. |
| 173 #include "../client/gles2_implementation_autogen.h" | 171 #include "../client/gles2_implementation_autogen.h" |
| 174 | 172 |
| 175 void DisableVertexAttribArray(GLuint index); | 173 void DisableVertexAttribArray(GLuint index); |
| 176 void EnableVertexAttribArray(GLuint index); | 174 void EnableVertexAttribArray(GLuint index); |
| 177 void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params); | 175 void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params); |
| 178 void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params); | 176 void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params); |
| 179 | 177 |
| 180 void GetProgramInfoCHROMIUMHelper(GLuint program, std::vector<int8>* result); | |
| 181 GLint GetAttribLocationHelper(GLuint program, const char* name); | |
| 182 GLint GetUniformLocationHelper(GLuint program, const char* name); | |
| 183 bool GetActiveAttribHelper( | |
| 184 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, | |
| 185 GLint* size, GLenum* type, char* name); | |
| 186 bool GetActiveUniformHelper( | |
| 187 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, | |
| 188 GLint* size, GLenum* type, char* name); | |
| 189 | |
| 190 GLuint MakeTextureId() { | 178 GLuint MakeTextureId() { |
| 191 GLuint id; | 179 GLuint id; |
| 192 texture_id_handler_->MakeIds(0, 1, &id); | 180 texture_id_handler_->MakeIds(0, 1, &id); |
| 193 return id; | 181 return id; |
| 194 } | 182 } |
| 195 | 183 |
| 196 void FreeTextureId(GLuint id) { | 184 void FreeTextureId(GLuint id) { |
| 197 texture_id_handler_->FreeIds(1, &id); | 185 texture_id_handler_->FreeIds(1, &id); |
| 198 } | 186 } |
| 199 | 187 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 | 364 |
| 377 void BindBufferHelper(GLenum target, GLuint texture); | 365 void BindBufferHelper(GLenum target, GLuint texture); |
| 378 void BindFramebufferHelper(GLenum target, GLuint texture); | 366 void BindFramebufferHelper(GLenum target, GLuint texture); |
| 379 void BindRenderbufferHelper(GLenum target, GLuint texture); | 367 void BindRenderbufferHelper(GLenum target, GLuint texture); |
| 380 void BindTextureHelper(GLenum target, GLuint texture); | 368 void BindTextureHelper(GLenum target, GLuint texture); |
| 381 | 369 |
| 382 void DeleteBuffersHelper(GLsizei n, const GLuint* buffers); | 370 void DeleteBuffersHelper(GLsizei n, const GLuint* buffers); |
| 383 void DeleteFramebuffersHelper(GLsizei n, const GLuint* framebuffers); | 371 void DeleteFramebuffersHelper(GLsizei n, const GLuint* framebuffers); |
| 384 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* renderbuffers); | 372 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* renderbuffers); |
| 385 void DeleteTexturesHelper(GLsizei n, const GLuint* textures); | 373 void DeleteTexturesHelper(GLsizei n, const GLuint* textures); |
| 386 bool DeleteProgramHelper(GLuint program); | |
| 387 bool DeleteShaderHelper(GLuint shader); | |
| 388 | 374 |
| 389 // Helper for GetVertexAttrib | 375 // Helper for GetVertexAttrib |
| 390 bool GetVertexAttribHelper(GLuint index, GLenum pname, uint32* param); | 376 bool GetVertexAttribHelper(GLuint index, GLenum pname, uint32* param); |
| 391 | 377 |
| 392 // Asks the service for the max index in an element array buffer. | 378 // Asks the service for the max index in an element array buffer. |
| 393 GLsizei GetMaxIndexInElementArrayBuffer( | 379 GLsizei GetMaxIndexInElementArrayBuffer( |
| 394 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset); | 380 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset); |
| 395 | 381 |
| 396 bool CopyRectToBufferFlipped( | 382 bool CopyRectToBufferFlipped( |
| 397 const void* pixels, GLsizei width, GLsizei height, GLenum format, | 383 const void* pixels, GLsizei width, GLsizei height, GLenum format, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 | 455 |
| 470 // Current GL error bits. | 456 // Current GL error bits. |
| 471 uint32 error_bits_; | 457 uint32 error_bits_; |
| 472 | 458 |
| 473 // Whether or not to print debugging info. | 459 // Whether or not to print debugging info. |
| 474 bool debug_; | 460 bool debug_; |
| 475 | 461 |
| 476 // Whether or not this context is sharing resources. | 462 // Whether or not this context is sharing resources. |
| 477 bool sharing_resources_; | 463 bool sharing_resources_; |
| 478 | 464 |
| 479 bool bind_generates_resource_; | |
| 480 | |
| 481 // Map of GLenum to Strings for glGetString. We need to cache these because | 465 // Map of GLenum to Strings for glGetString. We need to cache these because |
| 482 // the pointer passed back to the client has to remain valid for eternity. | 466 // the pointer passed back to the client has to remain valid for eternity. |
| 483 typedef std::map<uint32, std::set<std::string> > GLStringMap; | 467 typedef std::map<uint32, std::set<std::string> > GLStringMap; |
| 484 GLStringMap gl_strings_; | 468 GLStringMap gl_strings_; |
| 485 | 469 |
| 486 // Similar cache for glGetRequestableExtensionsCHROMIUM. We don't | 470 // Similar cache for glGetRequestableExtensionsCHROMIUM. We don't |
| 487 // have an enum for this so handle it separately. | 471 // have an enum for this so handle it separately. |
| 488 std::set<std::string> requestable_extensions_set_; | 472 std::set<std::string> requestable_extensions_set_; |
| 489 | 473 |
| 490 typedef std::map<const void*, MappedBuffer> MappedBufferMap; | 474 typedef std::map<const void*, MappedBuffer> MappedBufferMap; |
| 491 MappedBufferMap mapped_buffers_; | 475 MappedBufferMap mapped_buffers_; |
| 492 | 476 |
| 493 typedef std::map<const void*, MappedTexture> MappedTextureMap; | 477 typedef std::map<const void*, MappedTexture> MappedTextureMap; |
| 494 MappedTextureMap mapped_textures_; | 478 MappedTextureMap mapped_textures_; |
| 495 | 479 |
| 496 scoped_ptr<MappedMemoryManager> mapped_memory_; | 480 scoped_ptr<MappedMemoryManager> mapped_memory_; |
| 497 | 481 |
| 498 scoped_ptr<ProgramInfoManager> program_info_manager_; | |
| 499 | |
| 500 DISALLOW_COPY_AND_ASSIGN(GLES2Implementation); | 482 DISALLOW_COPY_AND_ASSIGN(GLES2Implementation); |
| 501 }; | 483 }; |
| 502 | 484 |
| 503 inline bool GLES2Implementation::GetBufferParameterivHelper( | 485 inline bool GLES2Implementation::GetBufferParameterivHelper( |
| 504 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { | 486 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { |
| 505 return false; | 487 return false; |
| 506 } | 488 } |
| 507 | 489 |
| 508 inline bool GLES2Implementation::GetFramebufferAttachmentParameterivHelper( | 490 inline bool GLES2Implementation::GetFramebufferAttachmentParameterivHelper( |
| 509 GLenum /* target */, | 491 GLenum /* target */, |
| 510 GLenum /* attachment */, | 492 GLenum /* attachment */, |
| 511 GLenum /* pname */, | 493 GLenum /* pname */, |
| 512 GLint* /* params */) { | 494 GLint* /* params */) { |
| 513 return false; | 495 return false; |
| 514 } | 496 } |
| 515 | 497 |
| 498 inline bool GLES2Implementation::GetProgramivHelper( |
| 499 GLuint /* program */, GLenum /* pname */, GLint* /* params */) { |
| 500 return false; |
| 501 } |
| 502 |
| 516 inline bool GLES2Implementation::GetRenderbufferParameterivHelper( | 503 inline bool GLES2Implementation::GetRenderbufferParameterivHelper( |
| 517 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { | 504 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { |
| 518 return false; | 505 return false; |
| 519 } | 506 } |
| 520 | 507 |
| 521 inline bool GLES2Implementation::GetShaderivHelper( | 508 inline bool GLES2Implementation::GetShaderivHelper( |
| 522 GLuint /* shader */, GLenum /* pname */, GLint* /* params */) { | 509 GLuint /* shader */, GLenum /* pname */, GLint* /* params */) { |
| 523 return false; | 510 return false; |
| 524 } | 511 } |
| 525 | 512 |
| 526 inline bool GLES2Implementation::GetTexParameterfvHelper( | 513 inline bool GLES2Implementation::GetTexParameterfvHelper( |
| 527 GLenum /* target */, GLenum /* pname */, GLfloat* /* params */) { | 514 GLenum /* target */, GLenum /* pname */, GLfloat* /* params */) { |
| 528 return false; | 515 return false; |
| 529 } | 516 } |
| 530 | 517 |
| 531 inline bool GLES2Implementation::GetTexParameterivHelper( | 518 inline bool GLES2Implementation::GetTexParameterivHelper( |
| 532 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { | 519 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { |
| 533 return false; | 520 return false; |
| 534 } | 521 } |
| 535 | 522 |
| 536 } // namespace gles2 | 523 } // namespace gles2 |
| 537 } // namespace gpu | 524 } // namespace gpu |
| 538 | 525 |
| 539 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 526 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
| OLD | NEW |