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

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

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 // A class to emulate GLES2 over command buffers. 5 // A class to emulate GLES2 over command buffers.
6 6
7 #include "../client/gles2_implementation.h" 7 #include "../client/gles2_implementation.h"
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <queue> 11 #include <queue>
12 #include <GLES2/gl2ext.h> 12 #include <GLES2/gl2ext.h>
13 #include "../client/mapped_memory.h" 13 #include "../client/mapped_memory.h"
14 #include "../client/program_info_manager.h" 14 #include "../client/program_info_manager.h"
15 #include "../client/query_tracker.h" 15 #include "../client/query_tracker.h"
16 #include "../client/share_group.h"
17 #include "../client/transfer_buffer.h" 16 #include "../client/transfer_buffer.h"
18 #include "../common/gles2_cmd_utils.h" 17 #include "../common/gles2_cmd_utils.h"
19 #include "../common/id_allocator.h"
20 #include "../common/trace_event.h" 18 #include "../common/trace_event.h"
21 19
22 #if defined(__native_client__) && !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 20 #if defined(__native_client__) && !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
23 #define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS 21 #define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS
24 #endif 22 #endif
25 23
26 #if defined(GPU_CLIENT_DEBUG) 24 #if defined(GPU_CLIENT_DEBUG)
27 #include "ui/gfx/gl/gl_switches.h" 25 #include "ui/gfx/gl/gl_switches.h"
28 #include "base/command_line.h" 26 #include "base/command_line.h"
29 #endif 27 #endif
30 28
31 namespace gpu { 29 namespace gpu {
32 namespace gles2 { 30 namespace gles2 {
33 31
34 // A 32-bit and 64-bit compatible way of converting a pointer to a GLuint. 32 // A 32-bit and 64-bit compatible way of converting a pointer to a GLuint.
35 static GLuint ToGLuint(const void* ptr) { 33 static GLuint ToGLuint(const void* ptr) {
36 return static_cast<GLuint>(reinterpret_cast<size_t>(ptr)); 34 return static_cast<GLuint>(reinterpret_cast<size_t>(ptr));
37 } 35 }
38 36
39 // An id handler for non-shared ids.
40 class NonSharedIdHandler : public IdHandlerInterface {
41 public:
42 NonSharedIdHandler() { }
43 virtual ~NonSharedIdHandler() { }
44
45 // Overridden from IdHandlerInterface.
46 virtual void MakeIds(GLuint id_offset, GLsizei n, GLuint* ids) {
47 if (id_offset == 0) {
48 for (GLsizei ii = 0; ii < n; ++ii) {
49 ids[ii] = id_allocator_.AllocateID();
50 }
51 } else {
52 for (GLsizei ii = 0; ii < n; ++ii) {
53 ids[ii] = id_allocator_.AllocateIDAtOrAbove(id_offset);
54 id_offset = ids[ii] + 1;
55 }
56 }
57 }
58
59 // Overridden from IdHandlerInterface.
60 virtual bool FreeIds(GLsizei n, const GLuint* ids) {
61 for (GLsizei ii = 0; ii < n; ++ii) {
62 id_allocator_.FreeID(ids[ii]);
63 }
64 return true;
65 }
66
67 // Overridden from IdHandlerInterface.
68 virtual bool MarkAsUsedForBind(GLuint id) {
69 return id == 0 ? true : id_allocator_.MarkAsUsed(id);
70 }
71 private:
72 IdAllocator id_allocator_;
73 };
74
75 // An id handler for non-shared ids that are never reused.
76 class NonSharedNonReusedIdHandler : public IdHandlerInterface {
77 public:
78 NonSharedNonReusedIdHandler() : last_id_(0) { }
79 virtual ~NonSharedNonReusedIdHandler() { }
80
81 // Overridden from IdHandlerInterface.
82 virtual void MakeIds(GLuint id_offset, GLsizei n, GLuint* ids) {
83 for (GLsizei ii = 0; ii < n; ++ii) {
84 ids[ii] = ++last_id_ + id_offset;
85 }
86 }
87
88 // Overridden from IdHandlerInterface.
89 virtual bool FreeIds(GLsizei /* n */, const GLuint* /* ids */) {
90 // Ids are never freed.
91 return true;
92 }
93
94 // Overridden from IdHandlerInterface.
95 virtual bool MarkAsUsedForBind(GLuint /* id */) {
96 // This is only used for Shaders and Programs which have no bind.
97 return false;
98 }
99
100 private:
101 GLuint last_id_;
102 };
103
104 // An id handler for shared ids.
105 class SharedIdHandler : public IdHandlerInterface {
106 public:
107 SharedIdHandler(
108 GLES2Implementation* gles2,
109 id_namespaces::IdNamespaces id_namespace)
110 : gles2_(gles2),
111 id_namespace_(id_namespace) {
112 }
113
114 virtual ~SharedIdHandler() { }
115
116 virtual void MakeIds(GLuint id_offset, GLsizei n, GLuint* ids) {
117 gles2_->GenSharedIdsCHROMIUM(id_namespace_, id_offset, n, ids);
118 }
119
120 virtual bool FreeIds(GLsizei n, const GLuint* ids) {
121 gles2_->DeleteSharedIdsCHROMIUM(id_namespace_, n, ids);
122 // We need to ensure that the delete call is evaluated on the service side
123 // before any other contexts issue commands using these client ids.
124 gles2_->helper()->CommandBufferHelper::Flush();
125 return true;
126 }
127
128 virtual bool MarkAsUsedForBind(GLuint /* id */) {
129 // This has no meaning for shared resources.
130 return true;
131 }
132
133 private:
134 GLES2Implementation* gles2_;
135 id_namespaces::IdNamespaces id_namespace_;
136 };
137
138 // An id handler for shared ids that requires ids are made before using and
139 // that only the context that created the id can delete it.
140 // Assumes the service will enforce that non made ids generate an error.
141 class StrictSharedIdHandler : public IdHandlerInterface {
142 public:
143 StrictSharedIdHandler(
144 GLES2Implementation* gles2,
145 id_namespaces::IdNamespaces id_namespace)
146 : gles2_(gles2),
147 id_namespace_(id_namespace) {
148 }
149
150 virtual ~StrictSharedIdHandler() {
151 Destroy();
152 }
153
154 virtual void MakeIds(GLuint id_offset, GLsizei n, GLuint* ids) {
155 for (GLsizei ii = 0; ii < n; ++ii) {
156 ids[ii] = GetId(id_offset);
157 }
158 }
159
160 virtual bool FreeIds(GLsizei n, const GLuint* ids) {
161 // OpenGL sematics. If any id is bad none of them get freed.
162 for (GLsizei ii = 0; ii < n; ++ii) {
163 GLuint id = ids[ii];
164 if (id != 0) {
165 ResourceIdSet::iterator it = used_ids_.find(id);
166 if (it == used_ids_.end()) {
167 return false;
168 }
169 }
170 }
171 for (GLsizei ii = 0; ii < n; ++ii) {
172 GLuint id = ids[ii];
173 if (id != 0) {
174 ResourceIdSet::iterator it = used_ids_.find(id);
175 if (it != used_ids_.end()) {
176 used_ids_.erase(it);
177 free_ids_.push(id);
178 }
179 }
180 }
181 return true;
182 }
183
184 virtual bool MarkAsUsedForBind(GLuint /* id */) {
185 // This has no meaning for shared resources.
186 return true;
187 }
188
189 private:
190 static const GLsizei kNumIdsToGet = 2048;
191 typedef std::queue<GLuint> ResourceIdQueue;
192 typedef std::set<GLuint> ResourceIdSet;
193
194 void Destroy() {
195 // Free all the ids not being used.
196 while (!free_ids_.empty()) {
197 GLuint ids[kNumIdsToGet];
198 int count = 0;
199 while (count < kNumIdsToGet && !free_ids_.empty()) {
200 ids[count++] = free_ids_.front();
201 free_ids_.pop();
202 }
203 gles2_->DeleteSharedIdsCHROMIUM(id_namespace_, count, ids);
204 }
205 }
206
207 GLuint GetId(GLuint id_offset) {
208 if (free_ids_.empty()) {
209 GLuint ids[kNumIdsToGet];
210 gles2_->GenSharedIdsCHROMIUM(id_namespace_, id_offset, kNumIdsToGet, ids);
211 for (GLsizei ii = 0; ii < kNumIdsToGet; ++ii) {
212 free_ids_.push(ids[ii]);
213 }
214 }
215 GLuint id = free_ids_.front();
216 free_ids_.pop();
217 used_ids_.insert(id);
218 return id;
219 }
220
221 GLES2Implementation* gles2_;
222 id_namespaces::IdNamespaces id_namespace_;
223 ResourceIdSet used_ids_;
224 ResourceIdQueue free_ids_;
225 };
226
227 #ifndef _MSC_VER
228 const GLsizei StrictSharedIdHandler::kNumIdsToGet;
229 #endif
230
231 static GLsizei RoundUpToMultipleOf4(GLsizei size) { 37 static GLsizei RoundUpToMultipleOf4(GLsizei size) {
232 return (size + 3) & ~3; 38 return (size + 3) & ~3;
233 } 39 }
234 40
235 // This class tracks VertexAttribPointers and helps emulate client side buffers. 41 // This class tracks VertexAttribPointers and helps emulate client side buffers.
236 // 42 //
237 // The way client side buffers work is we shadow all the Vertex Attribs so we 43 // The way client side buffers work is we shadow all the Vertex Attribs so we
238 // know which ones are pointing to client side buffers. 44 // know which ones are pointing to client side buffers.
239 // 45 //
240 // At Draw time, for any attribs pointing to client side buffers we copy them 46 // At Draw time, for any attribs pointing to client side buffers we copy them
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 scoped_array<int8> collection_buffer_; 358 scoped_array<int8> collection_buffer_;
553 359
554 DISALLOW_COPY_AND_ASSIGN(ClientSideBufferHelper); 360 DISALLOW_COPY_AND_ASSIGN(ClientSideBufferHelper);
555 }; 361 };
556 362
557 #if !defined(_MSC_VER) 363 #if !defined(_MSC_VER)
558 const size_t GLES2Implementation::kMaxSizeOfSimpleResult; 364 const size_t GLES2Implementation::kMaxSizeOfSimpleResult;
559 const unsigned int GLES2Implementation::kStartingOffset; 365 const unsigned int GLES2Implementation::kStartingOffset;
560 #endif 366 #endif
561 367
562 COMPILE_ASSERT(gpu::kInvalidResource == 0,
563 INVALID_RESOURCE_NOT_0_AS_GL_EXPECTS);
564
565 GLES2Implementation::SingleThreadChecker::SingleThreadChecker( 368 GLES2Implementation::SingleThreadChecker::SingleThreadChecker(
566 GLES2Implementation* gles2_implementation) 369 GLES2Implementation* gles2_implementation)
567 : gles2_implementation_(gles2_implementation) { 370 : gles2_implementation_(gles2_implementation) {
568 GPU_CHECK_EQ(0, gles2_implementation_->use_count_); 371 GPU_CHECK_EQ(0, gles2_implementation_->use_count_);
569 ++gles2_implementation_->use_count_; 372 ++gles2_implementation_->use_count_;
570 } 373 }
571 374
572 GLES2Implementation::SingleThreadChecker::~SingleThreadChecker() { 375 GLES2Implementation::SingleThreadChecker::~SingleThreadChecker() {
573 --gles2_implementation_->use_count_; 376 --gles2_implementation_->use_count_;
574 GPU_CHECK_EQ(0, gles2_implementation_->use_count_); 377 GPU_CHECK_EQ(0, gles2_implementation_->use_count_);
(...skipping 14 matching lines...) Expand all
589 pack_reverse_row_order_(false), 392 pack_reverse_row_order_(false),
590 active_texture_unit_(0), 393 active_texture_unit_(0),
591 bound_framebuffer_(0), 394 bound_framebuffer_(0),
592 bound_renderbuffer_(0), 395 bound_renderbuffer_(0),
593 bound_array_buffer_id_(0), 396 bound_array_buffer_id_(0),
594 bound_element_array_buffer_id_(0), 397 bound_element_array_buffer_id_(0),
595 client_side_array_id_(0), 398 client_side_array_id_(0),
596 client_side_element_array_id_(0), 399 client_side_element_array_id_(0),
597 error_bits_(0), 400 error_bits_(0),
598 debug_(false), 401 debug_(false),
599 sharing_resources_(share_resources),
600 bind_generates_resource_(bind_generates_resource),
601 use_count_(0), 402 use_count_(0),
602 current_query_(NULL), 403 current_query_(NULL),
603 error_message_callback_(NULL) { 404 error_message_callback_(NULL) {
604 GPU_DCHECK(helper); 405 GPU_DCHECK(helper);
605 GPU_DCHECK(transfer_buffer); 406 GPU_DCHECK(transfer_buffer);
606 GPU_CLIENT_LOG_CODE_BLOCK({ 407 GPU_CLIENT_LOG_CODE_BLOCK({
607 debug_ = CommandLine::ForCurrentProcess()->HasSwitch( 408 debug_ = CommandLine::ForCurrentProcess()->HasSwitch(
608 switches::kEnableGPUClientLogging); 409 switches::kEnableGPUClientLogging);
609 }); 410 });
610 411
611 share_group_ = (share_group ? share_group : new ShareGroup()); 412 share_group_ = (share_group ? share_group : new ShareGroup(
413 share_resources, bind_generates_resource));
612 414
613 memset(&reserved_ids_, 0, sizeof(reserved_ids_)); 415 memset(&reserved_ids_, 0, sizeof(reserved_ids_));
614 } 416 }
615 417
616 bool GLES2Implementation::Initialize( 418 bool GLES2Implementation::Initialize(
617 unsigned int starting_transfer_buffer_size, 419 unsigned int starting_transfer_buffer_size,
618 unsigned int min_transfer_buffer_size, 420 unsigned int min_transfer_buffer_size,
619 unsigned int max_transfer_buffer_size) { 421 unsigned int max_transfer_buffer_size) {
620 GPU_DCHECK_GE(starting_transfer_buffer_size, min_transfer_buffer_size); 422 GPU_DCHECK_GE(starting_transfer_buffer_size, min_transfer_buffer_size);
621 GPU_DCHECK_LE(starting_transfer_buffer_size, max_transfer_buffer_size); 423 GPU_DCHECK_LE(starting_transfer_buffer_size, max_transfer_buffer_size);
622 GPU_DCHECK_GE(min_transfer_buffer_size, kStartingOffset); 424 GPU_DCHECK_GE(min_transfer_buffer_size, kStartingOffset);
623 425
624 if (!transfer_buffer_->Initialize( 426 if (!transfer_buffer_->Initialize(
625 starting_transfer_buffer_size, 427 starting_transfer_buffer_size,
626 kStartingOffset, 428 kStartingOffset,
627 min_transfer_buffer_size, 429 min_transfer_buffer_size,
628 max_transfer_buffer_size, 430 max_transfer_buffer_size,
629 kAlignment, 431 kAlignment,
630 kSizeToFlush)) { 432 kSizeToFlush)) {
631 return false; 433 return false;
632 } 434 }
633 435
634 mapped_memory_.reset(new MappedMemoryManager(helper_)); 436 mapped_memory_.reset(new MappedMemoryManager(helper_));
635 SetSharedMemoryChunkSizeMultiple(1024 * 1024 * 2); 437 SetSharedMemoryChunkSizeMultiple(1024 * 1024 * 2);
636 438
637 if (sharing_resources_) {
638 if (!bind_generates_resource_) {
639 for (int i = 0; i < id_namespaces::kNumIdNamespaces; ++i) {
640 id_handlers_[i].reset(new StrictSharedIdHandler(
641 this, static_cast<id_namespaces::IdNamespaces>(i)));
642 }
643 } else {
644 for (int i = 0; i < id_namespaces::kNumIdNamespaces; ++i) {
645 id_handlers_[i].reset(new SharedIdHandler(
646 this, static_cast<id_namespaces::IdNamespaces>(i)));
647 }
648 }
649 } else {
650 for (int i = 0; i < id_namespaces::kNumIdNamespaces; ++i) {
651 if (i == id_namespaces::kProgramsAndShaders)
652 id_handlers_[i].reset(new NonSharedNonReusedIdHandler);
653 else
654 id_handlers_[i].reset(new NonSharedIdHandler);
655 }
656 }
657
658 static const GLenum pnames[] = { 439 static const GLenum pnames[] = {
659 GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, 440 GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
660 GL_MAX_CUBE_MAP_TEXTURE_SIZE, 441 GL_MAX_CUBE_MAP_TEXTURE_SIZE,
661 GL_MAX_FRAGMENT_UNIFORM_VECTORS, 442 GL_MAX_FRAGMENT_UNIFORM_VECTORS,
662 GL_MAX_RENDERBUFFER_SIZE, 443 GL_MAX_RENDERBUFFER_SIZE,
663 GL_MAX_TEXTURE_IMAGE_UNITS, 444 GL_MAX_TEXTURE_IMAGE_UNITS,
664 GL_MAX_TEXTURE_SIZE, 445 GL_MAX_TEXTURE_SIZE,
665 GL_MAX_VARYING_VECTORS, 446 GL_MAX_VARYING_VECTORS,
666 GL_MAX_VERTEX_ATTRIBS, 447 GL_MAX_VERTEX_ATTRIBS,
667 GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, 448 GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS,
668 GL_MAX_VERTEX_UNIFORM_VECTORS, 449 GL_MAX_VERTEX_UNIFORM_VECTORS,
669 GL_NUM_COMPRESSED_TEXTURE_FORMATS, 450 GL_NUM_COMPRESSED_TEXTURE_FORMATS,
670 GL_NUM_SHADER_BINARY_FORMATS, 451 GL_NUM_SHADER_BINARY_FORMATS,
671 }; 452 };
672 453
673 util_.set_num_compressed_texture_formats( 454 util_.set_num_compressed_texture_formats(
674 gl_state_.num_compressed_texture_formats); 455 gl_state_.num_compressed_texture_formats);
675 util_.set_num_shader_binary_formats( 456 util_.set_num_shader_binary_formats(
676 gl_state_.num_shader_binary_formats); 457 gl_state_.num_shader_binary_formats);
677 458
678 GetMultipleIntegervCHROMIUM( 459 GetMultipleIntegervCHROMIUM(
679 pnames, arraysize(pnames), &gl_state_.max_combined_texture_image_units, 460 pnames, arraysize(pnames), &gl_state_.max_combined_texture_image_units,
680 sizeof(gl_state_)); 461 sizeof(gl_state_));
681 462
682 texture_units_.reset( 463 texture_units_.reset(
683 new TextureUnit[gl_state_.max_combined_texture_image_units]); 464 new TextureUnit[gl_state_.max_combined_texture_image_units]);
684 465
685 program_info_manager_.reset(ProgramInfoManager::Create(sharing_resources_));
686 query_tracker_.reset(new QueryTracker(mapped_memory_.get())); 466 query_tracker_.reset(new QueryTracker(mapped_memory_.get()));
687 467
688 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 468 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
689 id_handlers_[id_namespaces::kBuffers]->MakeIds( 469 GetIdHandler(id_namespaces::kBuffers)->MakeIds(
690 kClientSideArrayId, arraysize(reserved_ids_), &reserved_ids_[0]); 470 this, kClientSideArrayId, arraysize(reserved_ids_), &reserved_ids_[0]);
691 471
692 client_side_buffer_helper_.reset(new ClientSideBufferHelper( 472 client_side_buffer_helper_.reset(new ClientSideBufferHelper(
693 gl_state_.max_vertex_attribs, 473 gl_state_.max_vertex_attribs,
694 reserved_ids_[0], 474 reserved_ids_[0],
695 reserved_ids_[1])); 475 reserved_ids_[1]));
696 #endif 476 #endif
697 477
698 return true; 478 return true;
699 } 479 }
700 480
701 GLES2Implementation::~GLES2Implementation() { 481 GLES2Implementation::~GLES2Implementation() {
702 // Make sure the queries are finished otherwise we'll delete the 482 // Make sure the queries are finished otherwise we'll delete the
703 // shared memory (mapped_memory_) which will free the memory used 483 // shared memory (mapped_memory_) which will free the memory used
704 // by the queries. The GPU process when validating that memory is still 484 // by the queries. The GPU process when validating that memory is still
705 // shared will fail and abort (ie, it will stop running). 485 // shared will fail and abort (ie, it will stop running).
706 Finish(); 486 Finish();
707 query_tracker_.reset(); 487 query_tracker_.reset();
708 488
709 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 489 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
710 DeleteBuffers(arraysize(reserved_ids_), &reserved_ids_[0]); 490 DeleteBuffers(arraysize(reserved_ids_), &reserved_ids_[0]);
711 #endif 491 #endif
712 for (int i = 0; i < id_namespaces::kNumIdNamespaces; ++i) { 492 // The share group needs to be able to use a command buffer to talk
713 id_handlers_[i].reset(); 493 // to service if it's destroyed so set one for it then release the reference.
714 } 494 // If it's destroyed it will use this GLES2Implemenation.
495 share_group_->SetGLES2ImplementationForDestruction(this);
496 share_group_ = NULL;
715 // Make sure the commands make it the service. 497 // Make sure the commands make it the service.
716 Finish(); 498 Finish();
717 } 499 }
718 500
501 GLuint GLES2Implementation::MakeTextureId() {
502 GLuint id;
503 GetIdHandler(id_namespaces::kTextures)->MakeIds(this, 0, 1, &id);
504 return id;
505 }
506
507 void GLES2Implementation::FreeTextureId(GLuint id) {
508 GetIdHandler(id_namespaces::kTextures)->FreeIds(this, 1, &id);
509 }
510
511 IdHandlerInterface* GLES2Implementation::GetIdHandler(int namespace_id) const {
512 return share_group_->GetIdHandler(namespace_id);
513 }
514
719 void* GLES2Implementation::GetResultBuffer() { 515 void* GLES2Implementation::GetResultBuffer() {
720 return transfer_buffer_->GetResultBuffer(); 516 return transfer_buffer_->GetResultBuffer();
721 } 517 }
722 518
723 int32 GLES2Implementation::GetResultShmId() { 519 int32 GLES2Implementation::GetResultShmId() {
724 return transfer_buffer_->GetShmId(); 520 return transfer_buffer_->GetShmId();
725 } 521 }
726 522
727 uint32 GLES2Implementation::GetResultShmOffset() { 523 uint32 GLES2Implementation::GetResultShmOffset() {
728 return transfer_buffer_->GetResultOffset(); 524 return transfer_buffer_->GetResultOffset();
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 case GL_MAX_VERTEX_UNIFORM_VECTORS: 750 case GL_MAX_VERTEX_UNIFORM_VECTORS:
955 *params = gl_state_.max_vertex_uniform_vectors; 751 *params = gl_state_.max_vertex_uniform_vectors;
956 return true; 752 return true;
957 case GL_NUM_COMPRESSED_TEXTURE_FORMATS: 753 case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
958 *params = gl_state_.num_compressed_texture_formats; 754 *params = gl_state_.num_compressed_texture_formats;
959 return true; 755 return true;
960 case GL_NUM_SHADER_BINARY_FORMATS: 756 case GL_NUM_SHADER_BINARY_FORMATS:
961 *params = gl_state_.num_shader_binary_formats; 757 *params = gl_state_.num_shader_binary_formats;
962 return true; 758 return true;
963 case GL_ARRAY_BUFFER_BINDING: 759 case GL_ARRAY_BUFFER_BINDING:
964 if (bind_generates_resource_) { 760 if (share_group_->bind_generates_resource()) {
965 *params = bound_array_buffer_id_; 761 *params = bound_array_buffer_id_;
966 return true; 762 return true;
967 } 763 }
968 return false; 764 return false;
969 case GL_ELEMENT_ARRAY_BUFFER_BINDING: 765 case GL_ELEMENT_ARRAY_BUFFER_BINDING:
970 if (bind_generates_resource_) { 766 if (share_group_->bind_generates_resource()) {
971 *params = bound_element_array_buffer_id_; 767 *params = bound_element_array_buffer_id_;
972 return true; 768 return true;
973 } 769 }
974 return false; 770 return false;
975 case GL_ACTIVE_TEXTURE: 771 case GL_ACTIVE_TEXTURE:
976 *params = active_texture_unit_ + GL_TEXTURE0; 772 *params = active_texture_unit_ + GL_TEXTURE0;
977 return true; 773 return true;
978 case GL_TEXTURE_BINDING_2D: 774 case GL_TEXTURE_BINDING_2D:
979 if (bind_generates_resource_) { 775 if (share_group_->bind_generates_resource()) {
980 *params = texture_units_[active_texture_unit_].bound_texture_2d; 776 *params = texture_units_[active_texture_unit_].bound_texture_2d;
981 return true; 777 return true;
982 } 778 }
983 return false; 779 return false;
984 case GL_TEXTURE_BINDING_CUBE_MAP: 780 case GL_TEXTURE_BINDING_CUBE_MAP:
985 if (bind_generates_resource_) { 781 if (share_group_->bind_generates_resource()) {
986 *params = texture_units_[active_texture_unit_].bound_texture_cube_map; 782 *params = texture_units_[active_texture_unit_].bound_texture_cube_map;
987 return true; 783 return true;
988 } 784 }
989 return false; 785 return false;
990 case GL_FRAMEBUFFER_BINDING: 786 case GL_FRAMEBUFFER_BINDING:
991 if (bind_generates_resource_) { 787 if (share_group_->bind_generates_resource()) {
992 *params = bound_framebuffer_; 788 *params = bound_framebuffer_;
993 return true; 789 return true;
994 } 790 }
995 return false; 791 return false;
996 case GL_RENDERBUFFER_BINDING: 792 case GL_RENDERBUFFER_BINDING:
997 if (bind_generates_resource_) { 793 if (share_group_->bind_generates_resource()) {
998 *params = bound_renderbuffer_; 794 *params = bound_renderbuffer_;
999 return true; 795 return true;
1000 } 796 }
1001 return false; 797 return false;
1002 default: 798 default:
1003 return false; 799 return false;
1004 } 800 }
1005 } 801 }
1006 802
1007 bool GLES2Implementation::GetBooleanvHelper(GLenum pname, GLboolean* params) { 803 bool GLES2Implementation::GetBooleanvHelper(GLenum pname, GLboolean* params) {
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 WaitForCmd(); 1064 WaitForCmd();
1269 result->CopyResult(ptr); 1065 result->CopyResult(ptr);
1270 GPU_CLIENT_LOG_CODE_BLOCK({ 1066 GPU_CLIENT_LOG_CODE_BLOCK({
1271 for (int32 i = 0; i < result->GetNumResults(); ++i) { 1067 for (int32 i = 0; i < result->GetNumResults(); ++i) {
1272 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); 1068 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
1273 } 1069 }
1274 }); 1070 });
1275 } 1071 }
1276 1072
1277 bool GLES2Implementation::DeleteProgramHelper(GLuint program) { 1073 bool GLES2Implementation::DeleteProgramHelper(GLuint program) {
1278 if (!id_handlers_[id_namespaces::kProgramsAndShaders]->FreeIds(1, &program)) { 1074 if (!GetIdHandler(id_namespaces::kProgramsAndShaders)->FreeIds(
1075 this, 1, &program)) {
1279 SetGLError( 1076 SetGLError(
1280 GL_INVALID_VALUE, 1077 GL_INVALID_VALUE,
1281 "glDeleteProgram: id not created by this context."); 1078 "glDeleteProgram: id not created by this context.");
1282 return false; 1079 return false;
1283 } 1080 }
1284 program_info_manager_->DeleteInfo(program); 1081 share_group_->program_info_manager()->DeleteInfo(program);
1285 helper_->DeleteProgram(program); 1082 helper_->DeleteProgram(program);
1286 return true; 1083 return true;
1287 } 1084 }
1288 1085
1289 bool GLES2Implementation::DeleteShaderHelper(GLuint shader) { 1086 bool GLES2Implementation::DeleteShaderHelper(GLuint shader) {
1290 if (!id_handlers_[id_namespaces::kProgramsAndShaders]->FreeIds(1, &shader)) { 1087 if (!GetIdHandler(id_namespaces::kProgramsAndShaders)->FreeIds(
1088 this, 1, &shader)) {
1291 SetGLError( 1089 SetGLError(
1292 GL_INVALID_VALUE, 1090 GL_INVALID_VALUE,
1293 "glDeleteShader: id not created by this context."); 1091 "glDeleteShader: id not created by this context.");
1294 return false; 1092 return false;
1295 } 1093 }
1296 program_info_manager_->DeleteInfo(shader); 1094 share_group_->program_info_manager()->DeleteInfo(shader);
1297 helper_->DeleteShader(shader); 1095 helper_->DeleteShader(shader);
1298 return true; 1096 return true;
1299 } 1097 }
1300 1098
1301 GLint GLES2Implementation::GetAttribLocationHelper( 1099 GLint GLES2Implementation::GetAttribLocationHelper(
1302 GLuint program, const char* name) { 1100 GLuint program, const char* name) {
1303 typedef GetAttribLocationBucket::Result Result; 1101 typedef GetAttribLocationBucket::Result Result;
1304 Result* result = GetResultAs<Result*>(); 1102 Result* result = GetResultAs<Result*>();
1305 if (!result) { 1103 if (!result) {
1306 return -1; 1104 return -1;
1307 } 1105 }
1308 *result = -1; 1106 *result = -1;
1309 SetBucketAsCString(kResultBucketId, name); 1107 SetBucketAsCString(kResultBucketId, name);
1310 helper_->GetAttribLocationBucket( 1108 helper_->GetAttribLocationBucket(
1311 program, kResultBucketId, GetResultShmId(), GetResultShmOffset()); 1109 program, kResultBucketId, GetResultShmId(), GetResultShmOffset());
1312 WaitForCmd(); 1110 WaitForCmd();
1313 helper_->SetBucketSize(kResultBucketId, 0); 1111 helper_->SetBucketSize(kResultBucketId, 0);
1314 return *result; 1112 return *result;
1315 } 1113 }
1316 1114
1317 GLint GLES2Implementation::GetAttribLocation( 1115 GLint GLES2Implementation::GetAttribLocation(
1318 GLuint program, const char* name) { 1116 GLuint program, const char* name) {
1319 GPU_CLIENT_SINGLE_THREAD_CHECK(); 1117 GPU_CLIENT_SINGLE_THREAD_CHECK();
1320 GPU_CLIENT_LOG("[" << this << "] glGetAttribLocation(" << program 1118 GPU_CLIENT_LOG("[" << this << "] glGetAttribLocation(" << program
1321 << ", " << name << ")"); 1119 << ", " << name << ")");
1322 TRACE_EVENT0("gpu", "GLES2::GetAttribLocation"); 1120 TRACE_EVENT0("gpu", "GLES2::GetAttribLocation");
1323 GLint loc = program_info_manager_->GetAttribLocation(this, program, name); 1121 GLint loc = share_group_->program_info_manager()->GetAttribLocation(
1122 this, program, name);
1324 GPU_CLIENT_LOG("returned " << loc); 1123 GPU_CLIENT_LOG("returned " << loc);
1325 return loc; 1124 return loc;
1326 } 1125 }
1327 1126
1328 GLint GLES2Implementation::GetUniformLocationHelper( 1127 GLint GLES2Implementation::GetUniformLocationHelper(
1329 GLuint program, const char* name) { 1128 GLuint program, const char* name) {
1330 typedef GetUniformLocationBucket::Result Result; 1129 typedef GetUniformLocationBucket::Result Result;
1331 Result* result = GetResultAs<Result*>(); 1130 Result* result = GetResultAs<Result*>();
1332 if (!result) { 1131 if (!result) {
1333 return -1; 1132 return -1;
1334 } 1133 }
1335 *result = -1; 1134 *result = -1;
1336 SetBucketAsCString(kResultBucketId, name); 1135 SetBucketAsCString(kResultBucketId, name);
1337 helper_->GetUniformLocationBucket(program, kResultBucketId, 1136 helper_->GetUniformLocationBucket(program, kResultBucketId,
1338 GetResultShmId(), GetResultShmOffset()); 1137 GetResultShmId(), GetResultShmOffset());
1339 WaitForCmd(); 1138 WaitForCmd();
1340 helper_->SetBucketSize(kResultBucketId, 0); 1139 helper_->SetBucketSize(kResultBucketId, 0);
1341 return *result; 1140 return *result;
1342 } 1141 }
1343 1142
1344 GLint GLES2Implementation::GetUniformLocation( 1143 GLint GLES2Implementation::GetUniformLocation(
1345 GLuint program, const char* name) { 1144 GLuint program, const char* name) {
1346 GPU_CLIENT_SINGLE_THREAD_CHECK(); 1145 GPU_CLIENT_SINGLE_THREAD_CHECK();
1347 GPU_CLIENT_LOG("[" << this << "] glGetUniformLocation(" << program 1146 GPU_CLIENT_LOG("[" << this << "] glGetUniformLocation(" << program
1348 << ", " << name << ")"); 1147 << ", " << name << ")");
1349 TRACE_EVENT0("gpu", "GLES2::GetUniformLocation"); 1148 TRACE_EVENT0("gpu", "GLES2::GetUniformLocation");
1350 GLint loc = program_info_manager_->GetUniformLocation(this, program, name); 1149 GLint loc = share_group_->program_info_manager()->GetUniformLocation(
1150 this, program, name);
1351 GPU_CLIENT_LOG("returned " << loc); 1151 GPU_CLIENT_LOG("returned " << loc);
1352 return loc; 1152 return loc;
1353 } 1153 }
1354 1154
1355 bool GLES2Implementation::GetProgramivHelper( 1155 bool GLES2Implementation::GetProgramivHelper(
1356 GLuint program, GLenum pname, GLint* params) { 1156 GLuint program, GLenum pname, GLint* params) {
1357 return program_info_manager_->GetProgramiv(this, program, pname, params); 1157 return share_group_->program_info_manager()->GetProgramiv(
1158 this, program, pname, params);
1358 } 1159 }
1359 1160
1360 void GLES2Implementation::LinkProgram(GLuint program) { 1161 void GLES2Implementation::LinkProgram(GLuint program) {
1361 GPU_CLIENT_SINGLE_THREAD_CHECK(); 1162 GPU_CLIENT_SINGLE_THREAD_CHECK();
1362 GPU_CLIENT_LOG("[" << this << "] glLinkProgram(" << program << ")"); 1163 GPU_CLIENT_LOG("[" << this << "] glLinkProgram(" << program << ")");
1363 helper_->LinkProgram(program); 1164 helper_->LinkProgram(program);
1364 program_info_manager_->CreateInfo(program); 1165 share_group_->program_info_manager()->CreateInfo(program);
1365 } 1166 }
1366 1167
1367 void GLES2Implementation::ShaderBinary( 1168 void GLES2Implementation::ShaderBinary(
1368 GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, 1169 GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary,
1369 GLsizei length) { 1170 GLsizei length) {
1370 GPU_CLIENT_SINGLE_THREAD_CHECK(); 1171 GPU_CLIENT_SINGLE_THREAD_CHECK();
1371 GPU_CLIENT_LOG("[" << this << "] glShaderBinary(" << n << ", " 1172 GPU_CLIENT_LOG("[" << this << "] glShaderBinary(" << n << ", "
1372 << static_cast<const void*>(shaders) << ", " 1173 << static_cast<const void*>(shaders) << ", "
1373 << GLES2Util::GetStringEnum(binaryformat) << ", " 1174 << GLES2Util::GetStringEnum(binaryformat) << ", "
1374 << static_cast<const void*>(binary) << ", " 1175 << static_cast<const void*>(binary) << ", "
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1946 << program << ", " << index << ", " << bufsize << ", " 1747 << program << ", " << index << ", " << bufsize << ", "
1947 << static_cast<const void*>(length) << ", " 1748 << static_cast<const void*>(length) << ", "
1948 << static_cast<const void*>(size) << ", " 1749 << static_cast<const void*>(size) << ", "
1949 << static_cast<const void*>(type) << ", " 1750 << static_cast<const void*>(type) << ", "
1950 << static_cast<const void*>(name) << ", "); 1751 << static_cast<const void*>(name) << ", ");
1951 if (bufsize < 0) { 1752 if (bufsize < 0) {
1952 SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib: bufsize < 0"); 1753 SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib: bufsize < 0");
1953 return; 1754 return;
1954 } 1755 }
1955 TRACE_EVENT0("gpu", "GLES2::GetActiveAttrib"); 1756 TRACE_EVENT0("gpu", "GLES2::GetActiveAttrib");
1956 bool success = program_info_manager_->GetActiveAttrib( 1757 bool success = share_group_->program_info_manager()->GetActiveAttrib(
1957 this, program, index, bufsize, length, size, type, name); 1758 this, program, index, bufsize, length, size, type, name);
1958 if (success) { 1759 if (success) {
1959 if (size) { 1760 if (size) {
1960 GPU_CLIENT_LOG(" size: " << *size); 1761 GPU_CLIENT_LOG(" size: " << *size);
1961 } 1762 }
1962 if (type) { 1763 if (type) {
1963 GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type)); 1764 GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type));
1964 } 1765 }
1965 if (name) { 1766 if (name) {
1966 GPU_CLIENT_LOG(" name: " << name); 1767 GPU_CLIENT_LOG(" name: " << name);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 << program << ", " << index << ", " << bufsize << ", " 1817 << program << ", " << index << ", " << bufsize << ", "
2017 << static_cast<const void*>(length) << ", " 1818 << static_cast<const void*>(length) << ", "
2018 << static_cast<const void*>(size) << ", " 1819 << static_cast<const void*>(size) << ", "
2019 << static_cast<const void*>(type) << ", " 1820 << static_cast<const void*>(type) << ", "
2020 << static_cast<const void*>(name) << ", "); 1821 << static_cast<const void*>(name) << ", ");
2021 if (bufsize < 0) { 1822 if (bufsize < 0) {
2022 SetGLError(GL_INVALID_VALUE, "glGetActiveUniform: bufsize < 0"); 1823 SetGLError(GL_INVALID_VALUE, "glGetActiveUniform: bufsize < 0");
2023 return; 1824 return;
2024 } 1825 }
2025 TRACE_EVENT0("gpu", "GLES2::GetActiveUniform"); 1826 TRACE_EVENT0("gpu", "GLES2::GetActiveUniform");
2026 bool success = program_info_manager_->GetActiveUniform( 1827 bool success = share_group_->program_info_manager()->GetActiveUniform(
2027 this, program, index, bufsize, length, size, type, name); 1828 this, program, index, bufsize, length, size, type, name);
2028 if (success) { 1829 if (success) {
2029 if (size) { 1830 if (size) {
2030 GPU_CLIENT_LOG(" size: " << *size); 1831 GPU_CLIENT_LOG(" size: " << *size);
2031 } 1832 }
2032 if (type) { 1833 if (type) {
2033 GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type)); 1834 GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type));
2034 } 1835 }
2035 if (name) { 1836 if (name) {
2036 GPU_CLIENT_LOG(" name: " << name); 1837 GPU_CLIENT_LOG(" name: " << name);
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
2336 bound_array_buffer_id_ = buffer; 2137 bound_array_buffer_id_ = buffer;
2337 break; 2138 break;
2338 case GL_ELEMENT_ARRAY_BUFFER: 2139 case GL_ELEMENT_ARRAY_BUFFER:
2339 bound_element_array_buffer_id_ = buffer; 2140 bound_element_array_buffer_id_ = buffer;
2340 break; 2141 break;
2341 default: 2142 default:
2342 break; 2143 break;
2343 } 2144 }
2344 // TODO(gman): There's a bug here. If the target is invalid the ID will not be 2145 // TODO(gman): There's a bug here. If the target is invalid the ID will not be
2345 // used even though it's marked it as used here. 2146 // used even though it's marked it as used here.
2346 id_handlers_[id_namespaces::kBuffers]->MarkAsUsedForBind(buffer); 2147 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind(buffer);
2347 } 2148 }
2348 2149
2349 void GLES2Implementation::BindFramebufferHelper( 2150 void GLES2Implementation::BindFramebufferHelper(
2350 GLenum target, GLuint framebuffer) { 2151 GLenum target, GLuint framebuffer) {
2351 // TODO(gman): See note #1 above. 2152 // TODO(gman): See note #1 above.
2352 switch (target) { 2153 switch (target) {
2353 case GL_FRAMEBUFFER: 2154 case GL_FRAMEBUFFER:
2354 bound_framebuffer_ = framebuffer; 2155 bound_framebuffer_ = framebuffer;
2355 break; 2156 break;
2356 default: 2157 default:
2357 break; 2158 break;
2358 } 2159 }
2359 // TODO(gman): There's a bug here. If the target is invalid the ID will not be 2160 // TODO(gman): There's a bug here. If the target is invalid the ID will not be
2360 // used even though it's marked it as used here. 2161 // used even though it's marked it as used here.
2361 id_handlers_[id_namespaces::kFramebuffers]->MarkAsUsedForBind(framebuffer); 2162 GetIdHandler(id_namespaces::kFramebuffers)->MarkAsUsedForBind(framebuffer);
2362 } 2163 }
2363 2164
2364 void GLES2Implementation::BindRenderbufferHelper( 2165 void GLES2Implementation::BindRenderbufferHelper(
2365 GLenum target, GLuint renderbuffer) { 2166 GLenum target, GLuint renderbuffer) {
2366 // TODO(gman): See note #1 above. 2167 // TODO(gman): See note #1 above.
2367 switch (target) { 2168 switch (target) {
2368 case GL_RENDERBUFFER: 2169 case GL_RENDERBUFFER:
2369 bound_renderbuffer_ = renderbuffer; 2170 bound_renderbuffer_ = renderbuffer;
2370 break; 2171 break;
2371 default: 2172 default:
2372 break; 2173 break;
2373 } 2174 }
2374 // TODO(gman): There's a bug here. If the target is invalid the ID will not be 2175 // TODO(gman): There's a bug here. If the target is invalid the ID will not be
2375 // used even though it's marked it as used here. 2176 // used even though it's marked it as used here.
2376 id_handlers_[id_namespaces::kRenderbuffers]->MarkAsUsedForBind(renderbuffer); 2177 GetIdHandler(id_namespaces::kRenderbuffers)->MarkAsUsedForBind(renderbuffer);
2377 } 2178 }
2378 2179
2379 void GLES2Implementation::BindTextureHelper(GLenum target, GLuint texture) { 2180 void GLES2Implementation::BindTextureHelper(GLenum target, GLuint texture) {
2380 // TODO(gman): See note #1 above. 2181 // TODO(gman): See note #1 above.
2381 TextureUnit& unit = texture_units_[active_texture_unit_]; 2182 TextureUnit& unit = texture_units_[active_texture_unit_];
2382 switch (target) { 2183 switch (target) {
2383 case GL_TEXTURE_2D: 2184 case GL_TEXTURE_2D:
2384 unit.bound_texture_2d = texture; 2185 unit.bound_texture_2d = texture;
2385 break; 2186 break;
2386 case GL_TEXTURE_CUBE_MAP: 2187 case GL_TEXTURE_CUBE_MAP:
2387 unit.bound_texture_cube_map = texture; 2188 unit.bound_texture_cube_map = texture;
2388 break; 2189 break;
2389 default: 2190 default:
2390 break; 2191 break;
2391 } 2192 }
2392 // TODO(gman): There's a bug here. If the target is invalid the ID will not be 2193 // TODO(gman): There's a bug here. If the target is invalid the ID will not be
2393 // used. even though it's marked it as used here. 2194 // used. even though it's marked it as used here.
2394 id_handlers_[id_namespaces::kTextures]->MarkAsUsedForBind(texture); 2195 GetIdHandler(id_namespaces::kTextures)->MarkAsUsedForBind(texture);
2395 } 2196 }
2396 2197
2397 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 2198 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
2398 bool GLES2Implementation::IsBufferReservedId(GLuint id) { 2199 bool GLES2Implementation::IsBufferReservedId(GLuint id) {
2399 for (size_t ii = 0; ii < arraysize(reserved_ids_); ++ii) { 2200 for (size_t ii = 0; ii < arraysize(reserved_ids_); ++ii) {
2400 if (id == reserved_ids_[ii]) { 2201 if (id == reserved_ids_[ii]) {
2401 return true; 2202 return true;
2402 } 2203 }
2403 } 2204 }
2404 return false; 2205 return false;
2405 } 2206 }
2406 #else 2207 #else
2407 bool GLES2Implementation::IsBufferReservedId(GLuint /* id */) { 2208 bool GLES2Implementation::IsBufferReservedId(GLuint /* id */) {
2408 return false; 2209 return false;
2409 } 2210 }
2410 #endif 2211 #endif
2411 2212
2412 void GLES2Implementation::DeleteBuffersHelper( 2213 void GLES2Implementation::DeleteBuffersHelper(
2413 GLsizei n, const GLuint* buffers) { 2214 GLsizei n, const GLuint* buffers) {
2414 if (!id_handlers_[id_namespaces::kBuffers]->FreeIds(n, buffers)) { 2215 if (!GetIdHandler(id_namespaces::kBuffers)->FreeIds(this, n, buffers)) {
2415 SetGLError( 2216 SetGLError(
2416 GL_INVALID_VALUE, 2217 GL_INVALID_VALUE,
2417 "glDeleteBuffers: id not created by this context."); 2218 "glDeleteBuffers: id not created by this context.");
2418 return; 2219 return;
2419 } 2220 }
2420 for (GLsizei ii = 0; ii < n; ++ii) { 2221 for (GLsizei ii = 0; ii < n; ++ii) {
2421 if (buffers[ii] == bound_array_buffer_id_) { 2222 if (buffers[ii] == bound_array_buffer_id_) {
2422 bound_array_buffer_id_ = 0; 2223 bound_array_buffer_id_ = 0;
2423 } 2224 }
2424 if (buffers[ii] == bound_element_array_buffer_id_) { 2225 if (buffers[ii] == bound_element_array_buffer_id_) {
2425 bound_element_array_buffer_id_ = 0; 2226 bound_element_array_buffer_id_ = 0;
2426 } 2227 }
2427 } 2228 }
2428 helper_->DeleteBuffersImmediate(n, buffers); 2229 helper_->DeleteBuffersImmediate(n, buffers);
2429 } 2230 }
2430 2231
2431 void GLES2Implementation::DeleteFramebuffersHelper( 2232 void GLES2Implementation::DeleteFramebuffersHelper(
2432 GLsizei n, const GLuint* framebuffers) { 2233 GLsizei n, const GLuint* framebuffers) {
2433 if (!id_handlers_[id_namespaces::kFramebuffers]->FreeIds(n, framebuffers)) { 2234 if (!GetIdHandler(id_namespaces::kFramebuffers)->FreeIds(
2235 this, n, framebuffers)) {
2434 SetGLError( 2236 SetGLError(
2435 GL_INVALID_VALUE, 2237 GL_INVALID_VALUE,
2436 "glDeleteFramebuffers: id not created by this context."); 2238 "glDeleteFramebuffers: id not created by this context.");
2437 return; 2239 return;
2438 } 2240 }
2439 for (GLsizei ii = 0; ii < n; ++ii) { 2241 for (GLsizei ii = 0; ii < n; ++ii) {
2440 if (framebuffers[ii] == bound_framebuffer_) { 2242 if (framebuffers[ii] == bound_framebuffer_) {
2441 bound_framebuffer_ = 0; 2243 bound_framebuffer_ = 0;
2442 } 2244 }
2443 } 2245 }
2444 helper_->DeleteFramebuffersImmediate(n, framebuffers); 2246 helper_->DeleteFramebuffersImmediate(n, framebuffers);
2445 } 2247 }
2446 2248
2447 void GLES2Implementation::DeleteRenderbuffersHelper( 2249 void GLES2Implementation::DeleteRenderbuffersHelper(
2448 GLsizei n, const GLuint* renderbuffers) { 2250 GLsizei n, const GLuint* renderbuffers) {
2449 if (!id_handlers_[id_namespaces::kRenderbuffers]->FreeIds(n, renderbuffers)) { 2251 if (!GetIdHandler(id_namespaces::kRenderbuffers)->FreeIds(
2252 this, n, renderbuffers)) {
2450 SetGLError( 2253 SetGLError(
2451 GL_INVALID_VALUE, 2254 GL_INVALID_VALUE,
2452 "glDeleteRenderbuffers: id not created by this context."); 2255 "glDeleteRenderbuffers: id not created by this context.");
2453 return; 2256 return;
2454 } 2257 }
2455 for (GLsizei ii = 0; ii < n; ++ii) { 2258 for (GLsizei ii = 0; ii < n; ++ii) {
2456 if (renderbuffers[ii] == bound_renderbuffer_) { 2259 if (renderbuffers[ii] == bound_renderbuffer_) {
2457 bound_renderbuffer_ = 0; 2260 bound_renderbuffer_ = 0;
2458 } 2261 }
2459 } 2262 }
2460 helper_->DeleteRenderbuffersImmediate(n, renderbuffers); 2263 helper_->DeleteRenderbuffersImmediate(n, renderbuffers);
2461 } 2264 }
2462 2265
2463 void GLES2Implementation::DeleteTexturesHelper( 2266 void GLES2Implementation::DeleteTexturesHelper(
2464 GLsizei n, const GLuint* textures) { 2267 GLsizei n, const GLuint* textures) {
2465 if (!id_handlers_[id_namespaces::kTextures]->FreeIds(n, textures)) { 2268 if (!GetIdHandler(id_namespaces::kTextures)->FreeIds(
2269 this, n, textures)) {
2466 SetGLError( 2270 SetGLError(
2467 GL_INVALID_VALUE, 2271 GL_INVALID_VALUE,
2468 "glDeleteTextures: id not created by this context."); 2272 "glDeleteTextures: id not created by this context.");
2469 return; 2273 return;
2470 } 2274 }
2471 for (GLsizei ii = 0; ii < n; ++ii) { 2275 for (GLsizei ii = 0; ii < n; ++ii) {
2472 for (GLint tt = 0; tt < gl_state_.max_combined_texture_image_units; ++tt) { 2276 for (GLint tt = 0; tt < gl_state_.max_combined_texture_image_units; ++tt) {
2473 TextureUnit& unit = texture_units_[active_texture_unit_]; 2277 TextureUnit& unit = texture_units_[active_texture_unit_];
2474 if (textures[ii] == unit.bound_texture_2d) { 2278 if (textures[ii] == unit.bound_texture_2d) {
2475 unit.bound_texture_2d = 0; 2279 unit.bound_texture_2d = 0;
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
2984 helper_->PostSubBufferCHROMIUM(x, y, width, height); 2788 helper_->PostSubBufferCHROMIUM(x, y, width, height);
2985 helper_->CommandBufferHelper::Flush(); 2789 helper_->CommandBufferHelper::Flush();
2986 if (swap_buffers_tokens_.size() > kMaxSwapBuffers + 1) { 2790 if (swap_buffers_tokens_.size() > kMaxSwapBuffers + 1) {
2987 helper_->WaitForToken(swap_buffers_tokens_.front()); 2791 helper_->WaitForToken(swap_buffers_tokens_.front());
2988 swap_buffers_tokens_.pop(); 2792 swap_buffers_tokens_.pop();
2989 } 2793 }
2990 } 2794 }
2991 2795
2992 void GLES2Implementation::DeleteQueriesEXTHelper( 2796 void GLES2Implementation::DeleteQueriesEXTHelper(
2993 GLsizei n, const GLuint* queries) { 2797 GLsizei n, const GLuint* queries) {
2994 if (!id_handlers_[id_namespaces::kQueries]->FreeIds(n, queries)) { 2798 if (!GetIdHandler(id_namespaces::kQueries)->FreeIds(
2799 this, n, queries)) {
2995 SetGLError( 2800 SetGLError(
2996 GL_INVALID_VALUE, 2801 GL_INVALID_VALUE,
2997 "glDeleteTextures: id not created by this context."); 2802 "glDeleteTextures: id not created by this context.");
2998 return; 2803 return;
2999 } 2804 }
3000 // When you delete a query you can't mark its memory as unused until it's 2805 // When you delete a query you can't mark its memory as unused until it's
3001 // completed. 2806 // completed.
3002 // Note: If you don't do this you won't mess up the service but you will mess 2807 // Note: If you don't do this you won't mess up the service but you will mess
3003 // up yourself. 2808 // up yourself.
3004 2809
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
3258 helper_->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); 3063 helper_->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
3259 } 3064 }
3260 #else 3065 #else
3261 helper_->DrawElementsInstancedANGLE( 3066 helper_->DrawElementsInstancedANGLE(
3262 mode, count, type, ToGLuint(indices), primcount); 3067 mode, count, type, ToGLuint(indices), primcount);
3263 #endif 3068 #endif
3264 } 3069 }
3265 3070
3266 } // namespace gles2 3071 } // namespace gles2
3267 } // namespace gpu 3072 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.h ('k') | gpu/command_buffer/client/gles2_implementation_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698