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

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

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

Powered by Google App Engine
This is Rietveld 408576698