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

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

Issue 9918027: Make ShareGroup thread safe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add id==0 check Created 8 years, 8 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) 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 "../common/gles2_cmd_utils.h" 16 #include "../common/gles2_cmd_utils.h"
17 #include "../common/scoped_ptr.h" 17 #include "../common/scoped_ptr.h"
18 #include "../client/ref_counted.h" 18 #include "../client/ref_counted.h"
19 #include "../client/gles2_cmd_helper.h" 19 #include "../client/gles2_cmd_helper.h"
20 #include "../client/query_tracker.h" 20 #include "../client/query_tracker.h"
21 #include "../client/ring_buffer.h" 21 #include "../client/ring_buffer.h"
22 #include "../client/share_group.h"
22 #include "gles2_impl_export.h" 23 #include "gles2_impl_export.h"
23 24
24 #if !defined(NDEBUG) && !defined(__native_client__) && !defined(GLES2_CONFORMANC E_TESTS) // NOLINT 25 #if !defined(NDEBUG) && !defined(__native_client__) && !defined(GLES2_CONFORMANC E_TESTS) // NOLINT
25 #if defined(GLES2_INLINE_OPTIMIZATION) 26 #if defined(GLES2_INLINE_OPTIMIZATION)
26 // TODO(gman): Replace with macros that work with inline optmization. 27 // TODO(gman): Replace with macros that work with inline optmization.
27 #define GPU_CLIENT_SINGLE_THREAD_CHECK() 28 #define GPU_CLIENT_SINGLE_THREAD_CHECK()
28 #define GPU_CLIENT_LOG(args) 29 #define GPU_CLIENT_LOG(args)
29 #define GPU_CLIENT_LOG_CODE_BLOCK(code) 30 #define GPU_CLIENT_LOG_CODE_BLOCK(code)
30 #define GPU_CLIENT_DCHECK_CODE_BLOCK(code) 31 #define GPU_CLIENT_DCHECK_CODE_BLOCK(code)
31 #else 32 #else
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 77
77 namespace gpu { 78 namespace gpu {
78 79
79 class MappedMemoryManager; 80 class MappedMemoryManager;
80 class ScopedTransferBufferPtr; 81 class ScopedTransferBufferPtr;
81 class TransferBufferInterface; 82 class TransferBufferInterface;
82 83
83 namespace gles2 { 84 namespace gles2 {
84 85
85 class ClientSideBufferHelper; 86 class ClientSideBufferHelper;
86 class ProgramInfoManager;
87 class ShareGroup;
88
89 // Base class for IdHandlers
90 class IdHandlerInterface {
91 public:
92 IdHandlerInterface() { }
93 virtual ~IdHandlerInterface() { }
94
95 // Makes some ids at or above id_offset.
96 virtual void MakeIds(GLuint id_offset, GLsizei n, GLuint* ids) = 0;
97
98 // Frees some ids.
99 virtual bool FreeIds(GLsizei n, const GLuint* ids) = 0;
100
101 // Marks an id as used for glBind functions. id = 0 does nothing.
102 virtual bool MarkAsUsedForBind(GLuint id) = 0;
103 };
104 87
105 // This class emulates GLES2 over command buffers. It can be used by a client 88 // This class emulates GLES2 over command buffers. It can be used by a client
106 // program so that the program does not need deal with shared memory and command 89 // program so that the program does not need deal with shared memory and command
107 // buffer management. See gl2_lib.h. Note that there is a performance gain to 90 // buffer management. See gl2_lib.h. Note that there is a performance gain to
108 // be had by changing your code to use command buffers directly by using the 91 // be had by changing your code to use command buffers directly by using the
109 // GLES2CmdHelper but that entails changing your code to use and deal with 92 // GLES2CmdHelper but that entails changing your code to use and deal with
110 // shared memory and synchronization issues. 93 // shared memory and synchronization issues.
111 class GLES2_IMPL_EXPORT GLES2Implementation { 94 class GLES2_IMPL_EXPORT GLES2Implementation {
112 public: 95 public:
113 class ErrorMessageCallback { 96 class ErrorMessageCallback {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 void GetProgramInfoCHROMIUMHelper(GLuint program, std::vector<int8>* result); 185 void GetProgramInfoCHROMIUMHelper(GLuint program, std::vector<int8>* result);
203 GLint GetAttribLocationHelper(GLuint program, const char* name); 186 GLint GetAttribLocationHelper(GLuint program, const char* name);
204 GLint GetUniformLocationHelper(GLuint program, const char* name); 187 GLint GetUniformLocationHelper(GLuint program, const char* name);
205 bool GetActiveAttribHelper( 188 bool GetActiveAttribHelper(
206 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, 189 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length,
207 GLint* size, GLenum* type, char* name); 190 GLint* size, GLenum* type, char* name);
208 bool GetActiveUniformHelper( 191 bool GetActiveUniformHelper(
209 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, 192 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length,
210 GLint* size, GLenum* type, char* name); 193 GLint* size, GLenum* type, char* name);
211 194
212 GLuint MakeTextureId() { 195 GLuint MakeTextureId();
213 GLuint id; 196 void FreeTextureId(GLuint id);
214 id_handlers_[id_namespaces::kTextures]->MakeIds(0, 1, &id);
215 return id;
216 }
217
218 void FreeTextureId(GLuint id) {
219 id_handlers_[id_namespaces::kTextures]->FreeIds(1, &id);
220 }
221 197
222 void SetSharedMemoryChunkSizeMultiple(unsigned int multiple); 198 void SetSharedMemoryChunkSizeMultiple(unsigned int multiple);
223 199
224 void FreeUnusedSharedMemory(); 200 void FreeUnusedSharedMemory();
225 void FreeEverything(); 201 void FreeEverything();
226 202
227 void SetErrorMessageCallback(ErrorMessageCallback* callback) { 203 void SetErrorMessageCallback(ErrorMessageCallback* callback) {
228 error_message_callback_ = callback; 204 error_message_callback_ = callback;
229 } 205 }
230 206
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 bool GetProgramivHelper(GLuint program, GLenum pname, GLint* params); 423 bool GetProgramivHelper(GLuint program, GLenum pname, GLint* params);
448 bool GetRenderbufferParameterivHelper( 424 bool GetRenderbufferParameterivHelper(
449 GLenum target, GLenum pname, GLint* params); 425 GLenum target, GLenum pname, GLint* params);
450 bool GetShaderivHelper(GLuint shader, GLenum pname, GLint* params); 426 bool GetShaderivHelper(GLuint shader, GLenum pname, GLint* params);
451 bool GetTexParameterfvHelper(GLenum target, GLenum pname, GLfloat* params); 427 bool GetTexParameterfvHelper(GLenum target, GLenum pname, GLfloat* params);
452 bool GetTexParameterivHelper(GLenum target, GLenum pname, GLint* params); 428 bool GetTexParameterivHelper(GLenum target, GLenum pname, GLint* params);
453 const GLubyte* GetStringHelper(GLenum name); 429 const GLubyte* GetStringHelper(GLenum name);
454 430
455 bool IsExtensionAvailable(const char* ext); 431 bool IsExtensionAvailable(const char* ext);
456 432
433 IdHandlerInterface* GetIdHandler(int id_namespace) const;
434
457 GLES2Util util_; 435 GLES2Util util_;
458 GLES2CmdHelper* helper_; 436 GLES2CmdHelper* helper_;
459 TransferBufferInterface* transfer_buffer_; 437 TransferBufferInterface* transfer_buffer_;
460 scoped_ptr<IdHandlerInterface> id_handlers_[id_namespaces::kNumIdNamespaces];
461 std::string last_error_; 438 std::string last_error_;
462 439
463 std::queue<int32> swap_buffers_tokens_; 440 std::queue<int32> swap_buffers_tokens_;
464 std::queue<int32> rate_limit_tokens_; 441 std::queue<int32> rate_limit_tokens_;
465 442
466 ExtensionStatus angle_pack_reverse_row_order_status; 443 ExtensionStatus angle_pack_reverse_row_order_status;
467 444
468 GLState gl_state_; 445 GLState gl_state_;
469 446
470 // pack alignment as last set by glPixelStorei 447 // pack alignment as last set by glPixelStorei
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 scoped_ptr<ClientSideBufferHelper> client_side_buffer_helper_; 479 scoped_ptr<ClientSideBufferHelper> client_side_buffer_helper_;
503 480
504 GLuint reserved_ids_[2]; 481 GLuint reserved_ids_[2];
505 482
506 // Current GL error bits. 483 // Current GL error bits.
507 uint32 error_bits_; 484 uint32 error_bits_;
508 485
509 // Whether or not to print debugging info. 486 // Whether or not to print debugging info.
510 bool debug_; 487 bool debug_;
511 488
512 // Whether or not this context is sharing resources.
513 bool sharing_resources_;
514
515 bool bind_generates_resource_;
516
517 // Used to check for single threaded access. 489 // Used to check for single threaded access.
518 int use_count_; 490 int use_count_;
519 491
520 // Map of GLenum to Strings for glGetString. We need to cache these because 492 // Map of GLenum to Strings for glGetString. We need to cache these because
521 // the pointer passed back to the client has to remain valid for eternity. 493 // the pointer passed back to the client has to remain valid for eternity.
522 typedef std::map<uint32, std::set<std::string> > GLStringMap; 494 typedef std::map<uint32, std::set<std::string> > GLStringMap;
523 GLStringMap gl_strings_; 495 GLStringMap gl_strings_;
524 496
525 // Similar cache for glGetRequestableExtensionsCHROMIUM. We don't 497 // Similar cache for glGetRequestableExtensionsCHROMIUM. We don't
526 // have an enum for this so handle it separately. 498 // have an enum for this so handle it separately.
527 std::set<std::string> requestable_extensions_set_; 499 std::set<std::string> requestable_extensions_set_;
528 500
529 typedef std::map<const void*, MappedBuffer> MappedBufferMap; 501 typedef std::map<const void*, MappedBuffer> MappedBufferMap;
530 MappedBufferMap mapped_buffers_; 502 MappedBufferMap mapped_buffers_;
531 503
532 typedef std::map<const void*, MappedTexture> MappedTextureMap; 504 typedef std::map<const void*, MappedTexture> MappedTextureMap;
533 MappedTextureMap mapped_textures_; 505 MappedTextureMap mapped_textures_;
534 506
535 scoped_ptr<MappedMemoryManager> mapped_memory_; 507 scoped_ptr<MappedMemoryManager> mapped_memory_;
536 508
537 scoped_ptr<ProgramInfoManager> program_info_manager_;
538
539 scoped_refptr<ShareGroup> share_group_; 509 scoped_refptr<ShareGroup> share_group_;
540 510
541 scoped_ptr<QueryTracker> query_tracker_; 511 scoped_ptr<QueryTracker> query_tracker_;
542 QueryTracker::Query* current_query_; 512 QueryTracker::Query* current_query_;
543 513
544 ErrorMessageCallback* error_message_callback_; 514 ErrorMessageCallback* error_message_callback_;
545 515
546 DISALLOW_COPY_AND_ASSIGN(GLES2Implementation); 516 DISALLOW_COPY_AND_ASSIGN(GLES2Implementation);
547 }; 517 };
548 518
(...skipping 27 matching lines...) Expand all
576 546
577 inline bool GLES2Implementation::GetTexParameterivHelper( 547 inline bool GLES2Implementation::GetTexParameterivHelper(
578 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { 548 GLenum /* target */, GLenum /* pname */, GLint* /* params */) {
579 return false; 549 return false;
580 } 550 }
581 551
582 } // namespace gles2 552 } // namespace gles2
583 } // namespace gpu 553 } // namespace gpu
584 554
585 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ 555 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/atomicops.cc ('k') | gpu/command_buffer/client/gles2_implementation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698