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

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

Issue 7765013: Revert 98504 - 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 // 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 <set>
10 #include <queue>
11 #include <GLES2/gl2ext.h> 9 #include <GLES2/gl2ext.h>
12 #include <GLES2/gles2_command_buffer.h> 10 #include <GLES2/gles2_command_buffer.h>
13 #include "../client/mapped_memory.h" 11 #include "../client/mapped_memory.h"
14 #include "../client/program_info_manager.h"
15 #include "../common/gles2_cmd_utils.h" 12 #include "../common/gles2_cmd_utils.h"
16 #include "../common/id_allocator.h" 13 #include "../common/id_allocator.h"
17 #include "../common/trace_event.h" 14 #include "../common/trace_event.h"
18 15
19 #if defined(__native_client__) && !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 16 #if defined(__native_client__) && !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
20 #define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS 17 #define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS
21 #endif 18 #endif
22 19
23 #if defined(GPU_CLIENT_DEBUG) 20 #if defined(GPU_CLIENT_DEBUG)
24 #include "ui/gfx/gl/gl_switches.h" 21 #include "ui/gfx/gl/gl_switches.h"
(...skipping 22 matching lines...) Expand all
47 } 44 }
48 } else { 45 } else {
49 for (GLsizei ii = 0; ii < n; ++ii) { 46 for (GLsizei ii = 0; ii < n; ++ii) {
50 ids[ii] = id_allocator_.AllocateIDAtOrAbove(id_offset); 47 ids[ii] = id_allocator_.AllocateIDAtOrAbove(id_offset);
51 id_offset = ids[ii] + 1; 48 id_offset = ids[ii] + 1;
52 } 49 }
53 } 50 }
54 } 51 }
55 52
56 // Overridden from IdHandlerInterface. 53 // Overridden from IdHandlerInterface.
57 virtual bool FreeIds(GLsizei n, const GLuint* ids) { 54 virtual void FreeIds(GLsizei n, const GLuint* ids) {
58 for (GLsizei ii = 0; ii < n; ++ii) { 55 for (GLsizei ii = 0; ii < n; ++ii) {
59 id_allocator_.FreeID(ids[ii]); 56 id_allocator_.FreeID(ids[ii]);
60 } 57 }
61 return true;
62 } 58 }
63 59
64 // Overridden from IdHandlerInterface. 60 // Overridden from IdHandlerInterface.
65 virtual bool MarkAsUsedForBind(GLuint id) { 61 virtual bool MarkAsUsedForBind(GLuint id) {
66 return id == 0 ? true : id_allocator_.MarkAsUsed(id); 62 return id == 0 ? true : id_allocator_.MarkAsUsed(id);
67 } 63 }
68 private: 64 private:
69 IdAllocator id_allocator_; 65 IdAllocator id_allocator_;
70 }; 66 };
71 67
72 // An id handler for non-shared ids that are never reused. 68 // An id handler for non-shared ids that are never reused.
73 class NonSharedNonReusedIdHandler : public IdHandlerInterface { 69 class NonSharedNonReusedIdHandler : public IdHandlerInterface {
74 public: 70 public:
75 NonSharedNonReusedIdHandler() : last_id_(0) { } 71 NonSharedNonReusedIdHandler() : last_id_(0) { }
76 virtual ~NonSharedNonReusedIdHandler() { } 72 virtual ~NonSharedNonReusedIdHandler() { }
77 73
78 // Overridden from IdHandlerInterface. 74 // Overridden from IdHandlerInterface.
79 virtual void MakeIds(GLuint id_offset, GLsizei n, GLuint* ids) { 75 virtual void MakeIds(GLuint id_offset, GLsizei n, GLuint* ids) {
80 for (GLsizei ii = 0; ii < n; ++ii) { 76 for (GLsizei ii = 0; ii < n; ++ii) {
81 ids[ii] = ++last_id_ + id_offset; 77 ids[ii] = ++last_id_ + id_offset;
82 } 78 }
83 } 79 }
84 80
85 // Overridden from IdHandlerInterface. 81 // Overridden from IdHandlerInterface.
86 virtual bool FreeIds(GLsizei /* n */, const GLuint* /* ids */) { 82 virtual void FreeIds(GLsizei /* n */, const GLuint* /* ids */) {
87 // Ids are never freed. 83 // Ids are never freed.
88 return true;
89 } 84 }
90 85
91 // Overridden from IdHandlerInterface. 86 // Overridden from IdHandlerInterface.
92 virtual bool MarkAsUsedForBind(GLuint /* id */) { 87 virtual bool MarkAsUsedForBind(GLuint /* id */) {
93 // This is only used for Shaders and Programs which have no bind. 88 // This is only used for Shaders and Programs which have no bind.
94 return false; 89 return false;
95 } 90 }
96 91
97 private: 92 private:
98 GLuint last_id_; 93 GLuint last_id_;
99 }; 94 };
100 95
101 // An id handler for shared ids. 96 // An id handler for shared ids.
102 class SharedIdHandler : public IdHandlerInterface { 97 class SharedIdHandler : public IdHandlerInterface {
103 public: 98 public:
104 SharedIdHandler( 99 SharedIdHandler(
105 GLES2Implementation* gles2, 100 GLES2Implementation* gles2,
106 id_namespaces::IdNamespaces id_namespace) 101 id_namespaces::IdNamespaces id_namespace)
107 : gles2_(gles2), 102 : gles2_(gles2),
108 id_namespace_(id_namespace) { 103 id_namespace_(id_namespace) {
109 } 104 }
110 105
111 virtual ~SharedIdHandler() { } 106 virtual ~SharedIdHandler() { }
112 107
113 virtual void MakeIds(GLuint id_offset, GLsizei n, GLuint* ids) { 108 virtual void MakeIds(GLuint id_offset, GLsizei n, GLuint* ids) {
114 gles2_->GenSharedIdsCHROMIUM(id_namespace_, id_offset, n, ids); 109 gles2_->GenSharedIdsCHROMIUM(id_namespace_, id_offset, n, ids);
115 } 110 }
116 111
117 virtual bool FreeIds(GLsizei n, const GLuint* ids) { 112 virtual void FreeIds(GLsizei n, const GLuint* ids) {
118 gles2_->DeleteSharedIdsCHROMIUM(id_namespace_, n, ids); 113 gles2_->DeleteSharedIdsCHROMIUM(id_namespace_, n, ids);
119 return true;
120 } 114 }
121 115
122 virtual bool MarkAsUsedForBind(GLuint /* id */) { 116 virtual bool MarkAsUsedForBind(GLuint) { // NOLINT
123 // This has no meaning for shared resources. 117 // This has no meaning for shared resources.
124 return true; 118 return true;
125 } 119 }
126 120
127 private: 121 private:
128 GLES2Implementation* gles2_; 122 GLES2Implementation* gles2_;
129 id_namespaces::IdNamespaces id_namespace_; 123 id_namespaces::IdNamespaces id_namespace_;
130 }; 124 };
131 125
132 // An id handler for shared ids that requires ids are made before using and
133 // that only the context that created the id can delete it.
134 // Assumes the service will enforce that non made ids generate an error.
135 class StrictSharedIdHandler : public IdHandlerInterface {
136 public:
137 StrictSharedIdHandler(
138 GLES2Implementation* gles2,
139 id_namespaces::IdNamespaces id_namespace)
140 : gles2_(gles2),
141 id_namespace_(id_namespace) {
142 }
143
144 virtual ~StrictSharedIdHandler() { }
145
146 virtual void MakeIds(GLuint id_offset, GLsizei n, GLuint* ids) {
147 for (GLsizei ii = 0; ii < n; ++ii) {
148 ids[ii] = GetId(id_offset);
149 }
150 }
151
152 virtual bool FreeIds(GLsizei n, const GLuint* ids) {
153 // OpenGL sematics. If any id is bad none of them get freed.
154 for (GLsizei ii = 0; ii < n; ++ii) {
155 GLuint id = ids[ii];
156 if (id != 0) {
157 ResourceIdSet::iterator it = used_ids_.find(id);
158 if (it == used_ids_.end()) {
159 return false;
160 }
161 }
162 }
163 for (GLsizei ii = 0; ii < n; ++ii) {
164 GLuint id = ids[ii];
165 if (id != 0) {
166 ResourceIdSet::iterator it = used_ids_.find(id);
167 if (it != used_ids_.end()) {
168 used_ids_.erase(it);
169 free_ids_.push(id);
170 }
171 }
172 }
173 return true;
174 }
175
176 virtual bool MarkAsUsedForBind(GLuint /* id */) {
177 // This has no meaning for shared resources.
178 return true;
179 }
180
181 private:
182 static const GLsizei kNumIdsToGet = 2048;
183 typedef std::queue<GLuint> ResourceIdQueue;
184 typedef std::set<GLuint> ResourceIdSet;
185
186 GLuint GetId(GLuint id_offset) {
187 if (free_ids_.empty()) {
188 GLuint ids[kNumIdsToGet];
189 gles2_->GenSharedIdsCHROMIUM(id_namespace_, id_offset, kNumIdsToGet, ids);
190 for (GLsizei ii = 0; ii < kNumIdsToGet; ++ii) {
191 free_ids_.push(ids[ii]);
192 }
193 }
194 GLuint id = free_ids_.front();
195 free_ids_.pop();
196 used_ids_.insert(id);
197 return id;
198 }
199
200 bool FreeId(GLuint id) {
201 ResourceIdSet::iterator it = used_ids_.find(id);
202 if (it == used_ids_.end()) {
203 return false;
204 }
205 used_ids_.erase(it);
206 free_ids_.push(id);
207 return true;
208 }
209
210 GLES2Implementation* gles2_;
211 id_namespaces::IdNamespaces id_namespace_;
212 ResourceIdSet used_ids_;
213 ResourceIdQueue free_ids_;
214 };
215
216 #ifndef _MSC_VER
217 const GLsizei StrictSharedIdHandler::kNumIdsToGet;
218 #endif
219
220 static GLsizei RoundUpToMultipleOf4(GLsizei size) { 126 static GLsizei RoundUpToMultipleOf4(GLsizei size) {
221 return (size + 3) & ~3; 127 return (size + 3) & ~3;
222 } 128 }
223 129
224 // This class tracks VertexAttribPointers and helps emulate client side buffers. 130 // This class tracks VertexAttribPointers and helps emulate client side buffers.
225 // 131 //
226 // The way client side buffers work is we shadow all the Vertex Attribs so we 132 // The way client side buffers work is we shadow all the Vertex Attribs so we
227 // know which ones are pointing to client side buffers. 133 // know which ones are pointing to client side buffers.
228 // 134 //
229 // At Draw time, for any attribs pointing to client side buffers we copy them 135 // At Draw time, for any attribs pointing to client side buffers we copy them
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 #endif 428 #endif
523 429
524 COMPILE_ASSERT(gpu::kInvalidResource == 0, 430 COMPILE_ASSERT(gpu::kInvalidResource == 0,
525 INVALID_RESOURCE_NOT_0_AS_GL_EXPECTS); 431 INVALID_RESOURCE_NOT_0_AS_GL_EXPECTS);
526 432
527 GLES2Implementation::GLES2Implementation( 433 GLES2Implementation::GLES2Implementation(
528 GLES2CmdHelper* helper, 434 GLES2CmdHelper* helper,
529 size_t transfer_buffer_size, 435 size_t transfer_buffer_size,
530 void* transfer_buffer, 436 void* transfer_buffer,
531 int32 transfer_buffer_id, 437 int32 transfer_buffer_id,
532 bool share_resources, 438 bool share_resources)
533 bool bind_generates_resource)
534 : helper_(helper), 439 : helper_(helper),
535 transfer_buffer_( 440 transfer_buffer_(
536 kStartingOffset, 441 kStartingOffset,
537 transfer_buffer_size - kStartingOffset, 442 transfer_buffer_size - kStartingOffset,
538 helper, 443 helper,
539 static_cast<char*>(transfer_buffer) + kStartingOffset), 444 static_cast<char*>(transfer_buffer) + kStartingOffset),
540 transfer_buffer_id_(transfer_buffer_id), 445 transfer_buffer_id_(transfer_buffer_id),
541 pack_alignment_(4), 446 pack_alignment_(4),
542 unpack_alignment_(4), 447 unpack_alignment_(4),
543 unpack_flip_y_(false), 448 unpack_flip_y_(false),
544 active_texture_unit_(0), 449 active_texture_unit_(0),
545 bound_framebuffer_(0), 450 bound_framebuffer_(0),
546 bound_renderbuffer_(0), 451 bound_renderbuffer_(0),
547 bound_array_buffer_id_(0), 452 bound_array_buffer_id_(0),
548 bound_element_array_buffer_id_(0), 453 bound_element_array_buffer_id_(0),
549 client_side_array_id_(0), 454 client_side_array_id_(0),
550 client_side_element_array_id_(0), 455 client_side_element_array_id_(0),
551 error_bits_(0), 456 error_bits_(0),
552 debug_(false), 457 debug_(false),
553 sharing_resources_(share_resources), 458 sharing_resources_(share_resources) {
554 bind_generates_resource_(bind_generates_resource) {
555 GPU_CLIENT_LOG_CODE_BLOCK({ 459 GPU_CLIENT_LOG_CODE_BLOCK({
556 debug_ = CommandLine::ForCurrentProcess()->HasSwitch( 460 debug_ = CommandLine::ForCurrentProcess()->HasSwitch(
557 switches::kEnableGPUClientLogging); 461 switches::kEnableGPUClientLogging);
558 }); 462 });
559 463
560 // Allocate space for simple GL results. 464 // Allocate space for simple GL results.
561 result_buffer_ = transfer_buffer; 465 result_buffer_ = transfer_buffer;
562 result_shm_offset_ = 0; 466 result_shm_offset_ = 0;
563 memset(&reserved_ids_, 0, sizeof(reserved_ids_)); 467 memset(&reserved_ids_, 0, sizeof(reserved_ids_));
564 468
565 mapped_memory_.reset(new MappedMemoryManager(helper_)); 469 mapped_memory_.reset(new MappedMemoryManager(helper_));
566 470
567 if (share_resources) { 471 if (share_resources) {
568 if (!bind_generates_resource) { 472 buffer_id_handler_.reset(
569 buffer_id_handler_.reset( 473 new SharedIdHandler(this, id_namespaces::kBuffers));
570 new StrictSharedIdHandler(this, id_namespaces::kBuffers)); 474 framebuffer_id_handler_.reset(
571 framebuffer_id_handler_.reset( 475 new SharedIdHandler(this, id_namespaces::kFramebuffers));
572 new StrictSharedIdHandler(this, id_namespaces::kFramebuffers)); 476 renderbuffer_id_handler_.reset(
573 renderbuffer_id_handler_.reset( 477 new SharedIdHandler(this, id_namespaces::kRenderbuffers));
574 new StrictSharedIdHandler(this, id_namespaces::kRenderbuffers)); 478 program_and_shader_id_handler_.reset(
575 program_and_shader_id_handler_.reset( 479 new SharedIdHandler(this, id_namespaces::kProgramsAndShaders));
576 new StrictSharedIdHandler(this, id_namespaces::kProgramsAndShaders)); 480 texture_id_handler_.reset(
577 texture_id_handler_.reset( 481 new SharedIdHandler(this, id_namespaces::kTextures));
578 new StrictSharedIdHandler(this, id_namespaces::kTextures));
579 } else {
580 buffer_id_handler_.reset(
581 new SharedIdHandler(this, id_namespaces::kBuffers));
582 framebuffer_id_handler_.reset(
583 new SharedIdHandler(this, id_namespaces::kFramebuffers));
584 renderbuffer_id_handler_.reset(
585 new SharedIdHandler(this, id_namespaces::kRenderbuffers));
586 program_and_shader_id_handler_.reset(
587 new SharedIdHandler(this, id_namespaces::kProgramsAndShaders));
588 texture_id_handler_.reset(
589 new SharedIdHandler(this, id_namespaces::kTextures));
590 }
591 } else { 482 } else {
592 buffer_id_handler_.reset(new NonSharedIdHandler()); 483 buffer_id_handler_.reset(new NonSharedIdHandler());
593 framebuffer_id_handler_.reset(new NonSharedIdHandler()); 484 framebuffer_id_handler_.reset(new NonSharedIdHandler());
594 renderbuffer_id_handler_.reset(new NonSharedIdHandler()); 485 renderbuffer_id_handler_.reset(new NonSharedIdHandler());
595 program_and_shader_id_handler_.reset(new NonSharedNonReusedIdHandler()); 486 program_and_shader_id_handler_.reset(new NonSharedNonReusedIdHandler());
596 texture_id_handler_.reset(new NonSharedIdHandler()); 487 texture_id_handler_.reset(new NonSharedIdHandler());
597 } 488 }
598 489
599 static const GLenum pnames[] = { 490 static const GLenum pnames[] = {
600 GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, 491 GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
(...skipping 15 matching lines...) Expand all
616 util_.set_num_shader_binary_formats( 507 util_.set_num_shader_binary_formats(
617 gl_state_.num_shader_binary_formats); 508 gl_state_.num_shader_binary_formats);
618 509
619 GetMultipleIntegervCHROMIUM( 510 GetMultipleIntegervCHROMIUM(
620 pnames, arraysize(pnames), &gl_state_.max_combined_texture_image_units, 511 pnames, arraysize(pnames), &gl_state_.max_combined_texture_image_units,
621 sizeof(gl_state_)); 512 sizeof(gl_state_));
622 513
623 texture_units_.reset( 514 texture_units_.reset(
624 new TextureUnit[gl_state_.max_combined_texture_image_units]); 515 new TextureUnit[gl_state_.max_combined_texture_image_units]);
625 516
626 program_info_manager_.reset(ProgramInfoManager::Create(sharing_resources_));
627
628 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 517 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
629 buffer_id_handler_->MakeIds( 518 buffer_id_handler_->MakeIds(
630 kClientSideArrayId, arraysize(reserved_ids_), &reserved_ids_[0]); 519 kClientSideArrayId, arraysize(reserved_ids_), &reserved_ids_[0]);
631 520
632 client_side_buffer_helper_.reset(new ClientSideBufferHelper( 521 client_side_buffer_helper_.reset(new ClientSideBufferHelper(
633 gl_state_.max_vertex_attribs, 522 gl_state_.max_vertex_attribs,
634 reserved_ids_[0], 523 reserved_ids_[0],
635 reserved_ids_[1])); 524 reserved_ids_[1]));
636 #endif 525 #endif
637 } 526 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 case GL_MAX_VERTEX_UNIFORM_VECTORS: 695 case GL_MAX_VERTEX_UNIFORM_VECTORS:
807 *params = gl_state_.max_vertex_uniform_vectors; 696 *params = gl_state_.max_vertex_uniform_vectors;
808 return true; 697 return true;
809 case GL_NUM_COMPRESSED_TEXTURE_FORMATS: 698 case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
810 *params = gl_state_.num_compressed_texture_formats; 699 *params = gl_state_.num_compressed_texture_formats;
811 return true; 700 return true;
812 case GL_NUM_SHADER_BINARY_FORMATS: 701 case GL_NUM_SHADER_BINARY_FORMATS:
813 *params = gl_state_.num_shader_binary_formats; 702 *params = gl_state_.num_shader_binary_formats;
814 return true; 703 return true;
815 case GL_ARRAY_BUFFER_BINDING: 704 case GL_ARRAY_BUFFER_BINDING:
816 if (bind_generates_resource_) { 705 *params = bound_array_buffer_id_;
817 *params = bound_array_buffer_id_; 706 return true;
818 return true;
819 }
820 return false;
821 case GL_ELEMENT_ARRAY_BUFFER_BINDING: 707 case GL_ELEMENT_ARRAY_BUFFER_BINDING:
822 if (bind_generates_resource_) { 708 *params = bound_element_array_buffer_id_;
823 *params = bound_element_array_buffer_id_; 709 return true;
824 return true;
825 }
826 return false;
827 case GL_ACTIVE_TEXTURE: 710 case GL_ACTIVE_TEXTURE:
828 *params = active_texture_unit_ + GL_TEXTURE0; 711 *params = active_texture_unit_ + GL_TEXTURE0;
829 return true; 712 return true;
830 case GL_TEXTURE_BINDING_2D: 713 case GL_TEXTURE_BINDING_2D:
831 if (bind_generates_resource_) { 714 *params = texture_units_[active_texture_unit_].bound_texture_2d;
832 *params = texture_units_[active_texture_unit_].bound_texture_2d; 715 return true;
833 return true;
834 }
835 return false;
836 case GL_TEXTURE_BINDING_CUBE_MAP: 716 case GL_TEXTURE_BINDING_CUBE_MAP:
837 if (bind_generates_resource_) { 717 *params = texture_units_[active_texture_unit_].bound_texture_cube_map;
838 *params = texture_units_[active_texture_unit_].bound_texture_cube_map; 718 return true;
839 return true;
840 }
841 return false;
842 case GL_FRAMEBUFFER_BINDING: 719 case GL_FRAMEBUFFER_BINDING:
843 if (bind_generates_resource_) { 720 *params = bound_framebuffer_;
844 *params = bound_framebuffer_; 721 return true;
845 return true;
846 }
847 return false;
848 case GL_RENDERBUFFER_BINDING: 722 case GL_RENDERBUFFER_BINDING:
849 if (bind_generates_resource_) { 723 *params = bound_renderbuffer_;
850 *params = bound_renderbuffer_; 724 return true;
851 return true;
852 }
853 return false;
854 default: 725 default:
855 return false; 726 return false;
856 } 727 }
857 } 728 }
858 729
859 bool GLES2Implementation::GetBooleanvHelper(GLenum pname, GLboolean* params) { 730 bool GLES2Implementation::GetBooleanvHelper(GLenum pname, GLboolean* params) {
860 // TODO(gman): Make this handle pnames that return more than 1 value. 731 // TODO(gman): Make this handle pnames that return more than 1 value.
861 GLint value; 732 GLint value;
862 if (!GetHelper(pname, &value)) { 733 if (!GetHelper(pname, &value)) {
863 return false; 734 return false;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 GLuint namespace_id, GLuint id_offset, GLsizei n, GLuint* ids) { 847 GLuint namespace_id, GLuint id_offset, GLsizei n, GLuint* ids) {
977 GPU_CLIENT_LOG("[" << this << "] glGenSharedIdsCHROMIUMTextures(" 848 GPU_CLIENT_LOG("[" << this << "] glGenSharedIdsCHROMIUMTextures("
978 << namespace_id << ", " << id_offset << ", " << n << ", " << 849 << namespace_id << ", " << id_offset << ", " << n << ", " <<
979 static_cast<void*>(ids) << ")"); 850 static_cast<void*>(ids) << ")");
980 GPU_CLIENT_LOG_CODE_BLOCK({ 851 GPU_CLIENT_LOG_CODE_BLOCK({
981 for (GLsizei i = 0; i < n; ++i) { 852 for (GLsizei i = 0; i < n; ++i) {
982 GPU_CLIENT_LOG(" " << i << ": " << ids[i]); 853 GPU_CLIENT_LOG(" " << i << ": " << ids[i]);
983 } 854 }
984 }); 855 });
985 TRACE_EVENT0("gpu", "GLES2::GenSharedIdsCHROMIUM"); 856 TRACE_EVENT0("gpu", "GLES2::GenSharedIdsCHROMIUM");
986 GLsizei max_size = transfer_buffer_.GetLargestFreeOrPendingSize(); 857 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n);
987 GLsizei max_num_per = max_size / sizeof(ids[0]); 858 helper_->GenSharedIdsCHROMIUM(namespace_id, id_offset, n,
988 while (n) { 859 transfer_buffer_id_,
989 GLsizei num = std::min(n, max_num_per); 860 transfer_buffer_.GetOffset(id_buffer));
990 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(num); 861 WaitForCmd();
991 helper_->GenSharedIdsCHROMIUM( 862 memcpy(ids, id_buffer, sizeof(*ids) * n);
992 namespace_id, id_offset, num, 863 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken());
993 transfer_buffer_id_,
994 transfer_buffer_.GetOffset(id_buffer));
995 WaitForCmd();
996 memcpy(ids, id_buffer, sizeof(*ids) * num);
997 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken());
998 n -= num;
999 ids += num;
1000 }
1001 } 864 }
1002 865
1003 void GLES2Implementation::DeleteSharedIdsCHROMIUM( 866 void GLES2Implementation::DeleteSharedIdsCHROMIUM(
1004 GLuint namespace_id, GLsizei n, const GLuint* ids) { 867 GLuint namespace_id, GLsizei n, const GLuint* ids) {
1005 GPU_CLIENT_LOG("[" << this << "] glDeleteSharedIdsCHROMIUM(" 868 GPU_CLIENT_LOG("[" << this << "] glDeleteSharedIdsCHROMIUM("
1006 << namespace_id << ", " << n << ", " 869 << namespace_id << ", " << n << ", "
1007 << static_cast<const void*>(ids) << ")"); 870 << static_cast<const void*>(ids) << ")");
1008 GPU_CLIENT_LOG_CODE_BLOCK({ 871 GPU_CLIENT_LOG_CODE_BLOCK({
1009 for (GLsizei i = 0; i < n; ++i) { 872 for (GLsizei i = 0; i < n; ++i) {
1010 GPU_CLIENT_LOG(" " << i << ": " << ids[i]); 873 GPU_CLIENT_LOG(" " << i << ": " << ids[i]);
1011 } 874 }
1012 }); 875 });
1013 TRACE_EVENT0("gpu", "GLES2::DeleteSharedIdsCHROMIUM"); 876 TRACE_EVENT0("gpu", "GLES2::DeleteSharedIdsCHROMIUM");
1014 GLsizei max_size = transfer_buffer_.GetLargestFreeOrPendingSize(); 877 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n);
1015 GLsizei max_num_per = max_size / sizeof(ids[0]); 878 memcpy(id_buffer, ids, sizeof(*ids) * n);
1016 while (n) { 879 helper_->DeleteSharedIdsCHROMIUM(namespace_id, n,
1017 GLsizei num = std::min(n, max_num_per); 880 transfer_buffer_id_,
1018 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(num); 881 transfer_buffer_.GetOffset(id_buffer));
1019 memcpy(id_buffer, ids, sizeof(*ids) * num); 882 WaitForCmd();
1020 helper_->DeleteSharedIdsCHROMIUM( 883 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken());
1021 namespace_id, num,
1022 transfer_buffer_id_,
1023 transfer_buffer_.GetOffset(id_buffer));
1024 WaitForCmd();
1025 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken());
1026 n -= num;
1027 ids += num;
1028 }
1029 } 884 }
1030 885
1031 void GLES2Implementation::RegisterSharedIdsCHROMIUM( 886 void GLES2Implementation::RegisterSharedIdsCHROMIUM(
1032 GLuint namespace_id, GLsizei n, const GLuint* ids) { 887 GLuint namespace_id, GLsizei n, const GLuint* ids) {
1033 GPU_CLIENT_LOG("[" << this << "] glRegisterSharedIdsCHROMIUM(" 888 GPU_CLIENT_LOG("[" << this << "] glRegisterSharedIdsCHROMIUM("
1034 << namespace_id << ", " << n << ", " 889 << namespace_id << ", " << n << ", "
1035 << static_cast<const void*>(ids) << ")"); 890 << static_cast<const void*>(ids) << ")");
1036 GPU_CLIENT_LOG_CODE_BLOCK({ 891 GPU_CLIENT_LOG_CODE_BLOCK({
1037 for (GLsizei i = 0; i < n; ++i) { 892 for (GLsizei i = 0; i < n; ++i) {
1038 GPU_CLIENT_LOG(" " << i << ": " << ids[i]); 893 GPU_CLIENT_LOG(" " << i << ": " << ids[i]);
1039 } 894 }
1040 }); 895 });
1041 TRACE_EVENT0("gpu", "GLES2::RegisterSharedIdsCHROMIUM"); 896 TRACE_EVENT0("gpu", "GLES2::RegisterSharedIdsCHROMIUM");
1042 GLsizei max_size = transfer_buffer_.GetLargestFreeOrPendingSize(); 897 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n);
1043 GLsizei max_num_per = max_size / sizeof(ids[0]); 898 memcpy(id_buffer, ids, sizeof(*ids) * n);
1044 while (n) { 899 helper_->RegisterSharedIdsCHROMIUM(namespace_id, n,
1045 GLsizei num = std::min(n, max_num_per); 900 transfer_buffer_id_,
1046 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n); 901 transfer_buffer_.GetOffset(id_buffer));
1047 memcpy(id_buffer, ids, sizeof(*ids) * n); 902 WaitForCmd();
1048 helper_->RegisterSharedIdsCHROMIUM( 903 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken());
1049 namespace_id, n,
1050 transfer_buffer_id_,
1051 transfer_buffer_.GetOffset(id_buffer));
1052 WaitForCmd();
1053 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken());
1054 n -= num;
1055 ids += num;
1056 }
1057 } 904 }
1058 905
1059 void GLES2Implementation::BindAttribLocation( 906 void GLES2Implementation::BindAttribLocation(
1060 GLuint program, GLuint index, const char* name) { 907 GLuint program, GLuint index, const char* name) {
1061 GPU_CLIENT_LOG("[" << this << "] glBindAttribLocation(" << program << ", " 908 GPU_CLIENT_LOG("[" << this << "] glBindAttribLocation(" << program << ", "
1062 << index << ", " << name << ")"); 909 << index << ", " << name << ")");
1063 SetBucketAsString(kResultBucketId, name); 910 SetBucketAsString(kResultBucketId, name);
1064 helper_->BindAttribLocationBucket(program, index, kResultBucketId); 911 helper_->BindAttribLocationBucket(program, index, kResultBucketId);
1065 helper_->SetBucketSize(kResultBucketId, 0); 912 helper_->SetBucketSize(kResultBucketId, 0);
1066 } 913 }
(...skipping 19 matching lines...) Expand all
1086 index, pname, result_shm_id(), result_shm_offset()); 933 index, pname, result_shm_id(), result_shm_offset());
1087 WaitForCmd(); 934 WaitForCmd();
1088 result->CopyResult(ptr); 935 result->CopyResult(ptr);
1089 GPU_CLIENT_LOG_CODE_BLOCK({ 936 GPU_CLIENT_LOG_CODE_BLOCK({
1090 for (int32 i = 0; i < result->GetNumResults(); ++i) { 937 for (int32 i = 0; i < result->GetNumResults(); ++i) {
1091 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); 938 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
1092 } 939 }
1093 }); 940 });
1094 } 941 }
1095 942
1096 bool GLES2Implementation::DeleteProgramHelper(GLuint program) {
1097 if (!program_and_shader_id_handler_->FreeIds(1, &program)) {
1098 SetGLError(
1099 GL_INVALID_VALUE,
1100 "glDeleteProgram: id not created by this context.");
1101 return false;
1102 }
1103 program_info_manager_->DeleteInfo(program);
1104 helper_->DeleteProgram(program);
1105 Flush();
1106 return true;
1107 }
1108
1109 bool GLES2Implementation::DeleteShaderHelper(GLuint shader) {
1110 if (!program_and_shader_id_handler_->FreeIds(1, &shader)) {
1111 SetGLError(
1112 GL_INVALID_VALUE,
1113 "glDeleteShader: id not created by this context.");
1114 return false;
1115 }
1116 program_info_manager_->DeleteInfo(shader);
1117 helper_->DeleteShader(shader);
1118 Flush();
1119 return true;
1120 }
1121
1122 GLint GLES2Implementation::GetAttribLocationHelper(
1123 GLuint program, const char* name) {
1124 typedef GetAttribLocationBucket::Result Result;
1125 Result* result = GetResultAs<Result*>();
1126 *result = -1;
1127 SetBucketAsCString(kResultBucketId, name);
1128 helper_->GetAttribLocationBucket(
1129 program, kResultBucketId, result_shm_id(), result_shm_offset());
1130 WaitForCmd();
1131 helper_->SetBucketSize(kResultBucketId, 0);
1132 return *result;
1133 }
1134
1135 GLint GLES2Implementation::GetAttribLocation( 943 GLint GLES2Implementation::GetAttribLocation(
1136 GLuint program, const char* name) { 944 GLuint program, const char* name) {
1137 GPU_CLIENT_LOG("[" << this << "] glGetAttribLocation(" << program 945 GPU_CLIENT_LOG("[" << this << "] glGetAttribLocation(" << program
1138 << ", " << name << ")"); 946 << ", " << name << ")");
1139 TRACE_EVENT0("gpu", "GLES2::GetAttribLocation"); 947 TRACE_EVENT0("gpu", "GLES2::GetAttribLocation");
1140 GLint loc = program_info_manager_->GetAttribLocation(this, program, name); 948 typedef GetAttribLocationBucket::Result Result;
1141 GPU_CLIENT_LOG("returned " << loc); 949 Result* result = GetResultAs<Result*>();
1142 return loc; 950 *result = -1;
951 SetBucketAsCString(kResultBucketId, name);
952 helper_->GetAttribLocationBucket(program, kResultBucketId,
953 result_shm_id(), result_shm_offset());
954 WaitForCmd();
955 helper_->SetBucketSize(kResultBucketId, 0);
956 GPU_CLIENT_LOG("returned " << *result);
957 return *result;
1143 } 958 }
1144 959
1145 GLint GLES2Implementation::GetUniformLocationHelper( 960 GLint GLES2Implementation::GetUniformLocation(
1146 GLuint program, const char* name) { 961 GLuint program, const char* name) {
962 GPU_CLIENT_LOG("[" << this << "] glGetUniformLocation(" << program
963 << ", " << name << ")");
964 TRACE_EVENT0("gpu", "GLES2::GetUniformLocation");
1147 typedef GetUniformLocationBucket::Result Result; 965 typedef GetUniformLocationBucket::Result Result;
1148 Result* result = GetResultAs<Result*>(); 966 Result* result = GetResultAs<Result*>();
1149 *result = -1; 967 *result = -1;
1150 SetBucketAsCString(kResultBucketId, name); 968 SetBucketAsCString(kResultBucketId, name);
1151 helper_->GetUniformLocationBucket(program, kResultBucketId, 969 helper_->GetUniformLocationBucket(program, kResultBucketId,
1152 result_shm_id(), result_shm_offset()); 970 result_shm_id(), result_shm_offset());
1153 WaitForCmd(); 971 WaitForCmd();
1154 helper_->SetBucketSize(kResultBucketId, 0); 972 helper_->SetBucketSize(kResultBucketId, 0);
973 GPU_CLIENT_LOG("returned " << *result);
1155 return *result; 974 return *result;
1156 } 975 }
1157 976
1158 GLint GLES2Implementation::GetUniformLocation(
1159 GLuint program, const char* name) {
1160 GPU_CLIENT_LOG("[" << this << "] glGetUniformLocation(" << program
1161 << ", " << name << ")");
1162 TRACE_EVENT0("gpu", "GLES2::GetUniformLocation");
1163 GLint loc = program_info_manager_->GetUniformLocation(this, program, name);
1164 GPU_CLIENT_LOG("returned " << loc);
1165 return loc;
1166 }
1167
1168 bool GLES2Implementation::GetProgramivHelper(
1169 GLuint program, GLenum pname, GLint* params) {
1170 return program_info_manager_->GetProgramiv(this, program, pname, params);
1171 }
1172
1173 void GLES2Implementation::LinkProgram(GLuint program) {
1174 GPU_CLIENT_LOG("[" << this << "] glLinkProgram(" << program << ")");
1175 helper_->LinkProgram(program);
1176 program_info_manager_->CreateInfo(program);
1177 }
1178 977
1179 void GLES2Implementation::ShaderBinary( 978 void GLES2Implementation::ShaderBinary(
1180 GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, 979 GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary,
1181 GLsizei length) { 980 GLsizei length) {
1182 GPU_CLIENT_LOG("[" << this << "] glShaderBinary(" << n << ", " 981 GPU_CLIENT_LOG("[" << this << "] glShaderBinary(" << n << ", "
1183 << static_cast<const void*>(shaders) << ", " 982 << static_cast<const void*>(shaders) << ", "
1184 << GLES2Util::GetStringEnum(binaryformat) << ", " 983 << GLES2Util::GetStringEnum(binaryformat) << ", "
1185 << static_cast<const void*>(binary) << ", " 984 << static_cast<const void*>(binary) << ", "
1186 << length << ")"); 985 << length << ")");
1187 if (n < 0) { 986 if (n < 0) {
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 row_source += part_size; 1420 row_source += part_size;
1622 temp_xoffset += num_pixels; 1421 temp_xoffset += num_pixels;
1623 temp_width -= num_pixels; 1422 temp_width -= num_pixels;
1624 } 1423 }
1625 ++yoffset; 1424 ++yoffset;
1626 source += padded_row_size; 1425 source += padded_row_size;
1627 } 1426 }
1628 } 1427 }
1629 } 1428 }
1630 1429
1631 bool GLES2Implementation::GetActiveAttribHelper( 1430 void GLES2Implementation::GetActiveAttrib(
1632 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, 1431 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
1633 GLenum* type, char* name) { 1432 GLenum* type, char* name) {
1634 // Clear the bucket so if the command fails nothing will be in it. 1433 GPU_CLIENT_LOG("[" << this << "] glGetActiveAttrib("
1434 << program << ", " << index << ", " << bufsize << ", "
1435 << static_cast<const void*>(length) << ", "
1436 << static_cast<const void*>(size) << ", "
1437 << static_cast<const void*>(type) << ", "
1438 << static_cast<const void*>(name) << ", ");
1439 if (bufsize < 0) {
1440 SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib: bufsize < 0");
1441 return;
1442 }
1443 TRACE_EVENT0("gpu", "GLES2::GetActiveAttrib");
1444 // Clear the bucket so if we the command fails nothing will be in it.
1635 helper_->SetBucketSize(kResultBucketId, 0); 1445 helper_->SetBucketSize(kResultBucketId, 0);
1636 typedef gles2::GetActiveAttrib::Result Result; 1446 typedef gles2::GetActiveAttrib::Result Result;
1637 Result* result = static_cast<Result*>(result_buffer_); 1447 Result* result = static_cast<Result*>(result_buffer_);
1638 // Set as failed so if the command fails we'll recover. 1448 // Set as failed so if the command fails we'll recover.
1639 result->success = false; 1449 result->success = false;
1640 helper_->GetActiveAttrib(program, index, kResultBucketId, 1450 helper_->GetActiveAttrib(program, index, kResultBucketId,
1641 result_shm_id(), result_shm_offset()); 1451 result_shm_id(), result_shm_offset());
1642 WaitForCmd(); 1452 WaitForCmd();
1643 if (result->success) { 1453 if (result->success) {
1644 if (size) { 1454 if (size) {
1645 *size = result->size; 1455 *size = result->size;
1456 GPU_CLIENT_LOG(" size: " << *size);
1646 } 1457 }
1647 if (type) { 1458 if (type) {
1648 *type = result->type; 1459 *type = result->type;
1460 GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type));
1649 } 1461 }
1650 if (length || name) { 1462 if (length || name) {
1651 std::vector<int8> str; 1463 std::vector<int8> str;
1652 GetBucketContents(kResultBucketId, &str); 1464 GetBucketContents(kResultBucketId, &str);
1653 GLsizei max_size = std::min(static_cast<size_t>(bufsize) - 1, 1465 GLsizei max_size = std::min(static_cast<size_t>(bufsize) - 1,
1654 std::max(static_cast<size_t>(0), 1466 std::max(static_cast<size_t>(0),
1655 str.size() - 1)); 1467 str.size() - 1));
1656 if (length) { 1468 if (length) {
1657 *length = max_size; 1469 *length = max_size;
1658 } 1470 }
1659 if (name && bufsize > 0) { 1471 if (name && bufsize > 0) {
1660 memcpy(name, &str[0], max_size); 1472 memcpy(name, &str[0], max_size);
1661 name[max_size] = '\0'; 1473 name[max_size] = '\0';
1474 GPU_CLIENT_LOG(" name: " << name);
1662 } 1475 }
1663 } 1476 }
1664 } 1477 }
1665 return result->success != 0;
1666 } 1478 }
1667 1479
1668 void GLES2Implementation::GetActiveAttrib( 1480 void GLES2Implementation::GetActiveUniform(
1669 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, 1481 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
1670 GLenum* type, char* name) { 1482 GLenum* type, char* name) {
1671 GPU_CLIENT_LOG("[" << this << "] glGetActiveAttrib(" 1483 GPU_CLIENT_LOG("[" << this << "] glGetActiveUniform("
1672 << program << ", " << index << ", " << bufsize << ", " 1484 << program << ", " << index << ", " << bufsize << ", "
1673 << static_cast<const void*>(length) << ", " 1485 << static_cast<const void*>(length) << ", "
1674 << static_cast<const void*>(size) << ", " 1486 << static_cast<const void*>(size) << ", "
1675 << static_cast<const void*>(type) << ", " 1487 << static_cast<const void*>(type) << ", "
1676 << static_cast<const void*>(name) << ", "); 1488 << static_cast<const void*>(name) << ", ");
1677 if (bufsize < 0) { 1489 if (bufsize < 0) {
1678 SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib: bufsize < 0"); 1490 SetGLError(GL_INVALID_VALUE, "glGetActiveUniform: bufsize < 0");
1679 return; 1491 return;
1680 } 1492 }
1681 TRACE_EVENT0("gpu", "GLES2::GetActiveAttrib"); 1493 TRACE_EVENT0("gpu", "GLES2::GetActiveUniform");
1682 bool success = program_info_manager_->GetActiveAttrib( 1494 // Clear the bucket so if we the command fails nothing will be in it.
1683 this, program, index, bufsize, length, size, type, name);
1684 if (success) {
1685 if (size) {
1686 GPU_CLIENT_LOG(" size: " << *size);
1687 }
1688 if (type) {
1689 GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type));
1690 }
1691 if (name) {
1692 GPU_CLIENT_LOG(" name: " << name);
1693 }
1694 }
1695 }
1696
1697 bool GLES2Implementation::GetActiveUniformHelper(
1698 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
1699 GLenum* type, char* name) {
1700 // Clear the bucket so if the command fails nothing will be in it.
1701 helper_->SetBucketSize(kResultBucketId, 0); 1495 helper_->SetBucketSize(kResultBucketId, 0);
1702 typedef gles2::GetActiveUniform::Result Result; 1496 typedef gles2::GetActiveUniform::Result Result;
1703 Result* result = static_cast<Result*>(result_buffer_); 1497 Result* result = static_cast<Result*>(result_buffer_);
1704 // Set as failed so if the command fails we'll recover. 1498 // Set as failed so if the command fails we'll recover.
1705 result->success = false; 1499 result->success = false;
1706 helper_->GetActiveUniform(program, index, kResultBucketId, 1500 helper_->GetActiveUniform(program, index, kResultBucketId,
1707 result_shm_id(), result_shm_offset()); 1501 result_shm_id(), result_shm_offset());
1708 WaitForCmd(); 1502 WaitForCmd();
1709 if (result->success) { 1503 if (result->success) {
1710 if (size) { 1504 if (size) {
1711 *size = result->size; 1505 *size = result->size;
1506 GPU_CLIENT_LOG(" size: " << *size);
1712 } 1507 }
1713 if (type) { 1508 if (type) {
1714 *type = result->type; 1509 *type = result->type;
1510 GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type));
1715 } 1511 }
1716 if (length || name) { 1512 if (length || name) {
1717 std::vector<int8> str; 1513 std::vector<int8> str;
1718 GetBucketContents(kResultBucketId, &str); 1514 GetBucketContents(kResultBucketId, &str);
1719 GLsizei max_size = std::min(static_cast<size_t>(bufsize) - 1, 1515 GLsizei max_size = std::min(static_cast<size_t>(bufsize) - 1,
1720 std::max(static_cast<size_t>(0), 1516 std::max(static_cast<size_t>(0),
1721 str.size() - 1)); 1517 str.size() - 1));
1722 if (length) { 1518 if (length) {
1723 *length = max_size; 1519 *length = max_size;
1724 } 1520 }
1725 if (name && bufsize > 0) { 1521 if (name && bufsize > 0) {
1726 memcpy(name, &str[0], max_size); 1522 memcpy(name, &str[0], max_size);
1727 name[max_size] = '\0'; 1523 name[max_size] = '\0';
1524 GPU_CLIENT_LOG(" name: " << name);
1728 } 1525 }
1729 } 1526 }
1730 } 1527 }
1731 return result->success != 0;
1732 }
1733
1734 void GLES2Implementation::GetActiveUniform(
1735 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
1736 GLenum* type, char* name) {
1737 GPU_CLIENT_LOG("[" << this << "] glGetActiveUniform("
1738 << program << ", " << index << ", " << bufsize << ", "
1739 << static_cast<const void*>(length) << ", "
1740 << static_cast<const void*>(size) << ", "
1741 << static_cast<const void*>(type) << ", "
1742 << static_cast<const void*>(name) << ", ");
1743 if (bufsize < 0) {
1744 SetGLError(GL_INVALID_VALUE, "glGetActiveUniform: bufsize < 0");
1745 return;
1746 }
1747 TRACE_EVENT0("gpu", "GLES2::GetActiveUniform");
1748 bool success = program_info_manager_->GetActiveUniform(
1749 this, program, index, bufsize, length, size, type, name);
1750 if (success) {
1751 if (size) {
1752 GPU_CLIENT_LOG(" size: " << *size);
1753 }
1754 if (type) {
1755 GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type));
1756 }
1757 if (name) {
1758 GPU_CLIENT_LOG(" name: " << name);
1759 }
1760 }
1761 } 1528 }
1762 1529
1763 void GLES2Implementation::GetAttachedShaders( 1530 void GLES2Implementation::GetAttachedShaders(
1764 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { 1531 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) {
1765 GPU_CLIENT_LOG("[" << this << "] glGetAttachedShaders(" 1532 GPU_CLIENT_LOG("[" << this << "] glGetAttachedShaders("
1766 << program << ", " << maxcount << ", " 1533 << program << ", " << maxcount << ", "
1767 << static_cast<const void*>(count) << ", " 1534 << static_cast<const void*>(count) << ", "
1768 << static_cast<const void*>(shaders) << ", "); 1535 << static_cast<const void*>(shaders) << ", ");
1769 if (maxcount < 0) { 1536 if (maxcount < 0) {
1770 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders: maxcount < 0"); 1537 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders: maxcount < 0");
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 return false; 1893 return false;
2127 } 1894 }
2128 #else 1895 #else
2129 bool GLES2Implementation::IsBufferReservedId(GLuint /* id */) { 1896 bool GLES2Implementation::IsBufferReservedId(GLuint /* id */) {
2130 return false; 1897 return false;
2131 } 1898 }
2132 #endif 1899 #endif
2133 1900
2134 void GLES2Implementation::DeleteBuffersHelper( 1901 void GLES2Implementation::DeleteBuffersHelper(
2135 GLsizei n, const GLuint* buffers) { 1902 GLsizei n, const GLuint* buffers) {
2136 if (!buffer_id_handler_->FreeIds(n, buffers)) { 1903 buffer_id_handler_->FreeIds(n, buffers);
2137 SetGLError(
2138 GL_INVALID_VALUE,
2139 "glDeleteBuffers: id not created by this context.");
2140 return;
2141 }
2142 for (GLsizei ii = 0; ii < n; ++ii) { 1904 for (GLsizei ii = 0; ii < n; ++ii) {
2143 if (buffers[ii] == bound_array_buffer_id_) { 1905 if (buffers[ii] == bound_array_buffer_id_) {
2144 bound_array_buffer_id_ = 0; 1906 bound_array_buffer_id_ = 0;
2145 } 1907 }
2146 if (buffers[ii] == bound_element_array_buffer_id_) { 1908 if (buffers[ii] == bound_element_array_buffer_id_) {
2147 bound_element_array_buffer_id_ = 0; 1909 bound_element_array_buffer_id_ = 0;
2148 } 1910 }
2149 } 1911 }
2150 helper_->DeleteBuffersImmediate(n, buffers);
2151 Flush();
2152 } 1912 }
2153 1913
2154 void GLES2Implementation::DeleteFramebuffersHelper( 1914 void GLES2Implementation::DeleteFramebuffersHelper(
2155 GLsizei n, const GLuint* framebuffers) { 1915 GLsizei n, const GLuint* framebuffers) {
2156 if (!framebuffer_id_handler_->FreeIds(n, framebuffers)) { 1916 framebuffer_id_handler_->FreeIds(n, framebuffers);
2157 SetGLError(
2158 GL_INVALID_VALUE,
2159 "glDeleteFramebuffers: id not created by this context.");
2160 return;
2161 }
2162 for (GLsizei ii = 0; ii < n; ++ii) { 1917 for (GLsizei ii = 0; ii < n; ++ii) {
2163 if (framebuffers[ii] == bound_framebuffer_) { 1918 if (framebuffers[ii] == bound_framebuffer_) {
2164 bound_framebuffer_ = 0; 1919 bound_framebuffer_ = 0;
2165 } 1920 }
2166 } 1921 }
2167 helper_->DeleteFramebuffersImmediate(n, framebuffers);
2168 Flush();
2169 } 1922 }
2170 1923
2171 void GLES2Implementation::DeleteRenderbuffersHelper( 1924 void GLES2Implementation::DeleteRenderbuffersHelper(
2172 GLsizei n, const GLuint* renderbuffers) { 1925 GLsizei n, const GLuint* renderbuffers) {
2173 if (!renderbuffer_id_handler_->FreeIds(n, renderbuffers)) { 1926 renderbuffer_id_handler_->FreeIds(n, renderbuffers);
2174 SetGLError(
2175 GL_INVALID_VALUE,
2176 "glDeleteRenderbuffers: id not created by this context.");
2177 return;
2178 }
2179 for (GLsizei ii = 0; ii < n; ++ii) { 1927 for (GLsizei ii = 0; ii < n; ++ii) {
2180 if (renderbuffers[ii] == bound_renderbuffer_) { 1928 if (renderbuffers[ii] == bound_renderbuffer_) {
2181 bound_renderbuffer_ = 0; 1929 bound_renderbuffer_ = 0;
2182 } 1930 }
2183 } 1931 }
2184 helper_->DeleteRenderbuffersImmediate(n, renderbuffers);
2185 Flush();
2186 } 1932 }
2187 1933
2188 void GLES2Implementation::DeleteTexturesHelper( 1934 void GLES2Implementation::DeleteTexturesHelper(
2189 GLsizei n, const GLuint* textures) { 1935 GLsizei n, const GLuint* textures) {
2190 if (!texture_id_handler_->FreeIds(n, textures)) { 1936 texture_id_handler_->FreeIds(n, textures);
2191 SetGLError(
2192 GL_INVALID_VALUE,
2193 "glDeleteTextures: id not created by this context.");
2194 return;
2195 }
2196 for (GLsizei ii = 0; ii < n; ++ii) { 1937 for (GLsizei ii = 0; ii < n; ++ii) {
2197 for (GLint tt = 0; tt < gl_state_.max_combined_texture_image_units; ++tt) { 1938 for (GLint tt = 0; tt < gl_state_.max_combined_texture_image_units; ++tt) {
2198 TextureUnit& unit = texture_units_[active_texture_unit_]; 1939 TextureUnit& unit = texture_units_[active_texture_unit_];
2199 if (textures[ii] == unit.bound_texture_2d) { 1940 if (textures[ii] == unit.bound_texture_2d) {
2200 unit.bound_texture_2d = 0; 1941 unit.bound_texture_2d = 0;
2201 } 1942 }
2202 if (textures[ii] == unit.bound_texture_cube_map) { 1943 if (textures[ii] == unit.bound_texture_cube_map) {
2203 unit.bound_texture_cube_map = 0; 1944 unit.bound_texture_cube_map = 0;
2204 } 1945 }
2205 } 1946 }
2206 } 1947 }
2207 helper_->DeleteTexturesImmediate(n, textures);
2208 Flush();
2209 } 1948 }
2210 1949
2211 void GLES2Implementation::DisableVertexAttribArray(GLuint index) { 1950 void GLES2Implementation::DisableVertexAttribArray(GLuint index) {
2212 GPU_CLIENT_LOG( 1951 GPU_CLIENT_LOG(
2213 "[" << this << "] glDisableVertexAttribArray(" << index << ")"); 1952 "[" << this << "] glDisableVertexAttribArray(" << index << ")");
2214 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 1953 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
2215 client_side_buffer_helper_->SetAttribEnable(index, false); 1954 client_side_buffer_helper_->SetAttribEnable(index, false);
2216 #endif 1955 #endif
2217 helper_->DisableVertexAttribArray(index); 1956 helper_->DisableVertexAttribArray(index);
2218 } 1957 }
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
2575 // TODO(gman): We should be able to free without a token. 2314 // TODO(gman): We should be able to free without a token.
2576 transfer_buffer_.FreePendingToken(buffer, helper_->InsertToken()); 2315 transfer_buffer_.FreePendingToken(buffer, helper_->InsertToken());
2577 GPU_CLIENT_LOG(" returned"); 2316 GPU_CLIENT_LOG(" returned");
2578 GPU_CLIENT_LOG_CODE_BLOCK({ 2317 GPU_CLIENT_LOG_CODE_BLOCK({
2579 for (int i = 0; i < num_results; ++i) { 2318 for (int i = 0; i < num_results; ++i) {
2580 GPU_CLIENT_LOG(" " << i << ": " << (results[i])); 2319 GPU_CLIENT_LOG(" " << i << ": " << (results[i]));
2581 } 2320 }
2582 }); 2321 });
2583 } 2322 }
2584 2323
2585 void GLES2Implementation::GetProgramInfoCHROMIUMHelper(
2586 GLuint program, std::vector<int8>* result) {
2587 GPU_DCHECK(result);
2588 // Clear the bucket so if the command fails nothing will be in it.
2589 helper_->SetBucketSize(kResultBucketId, 0);
2590 helper_->GetProgramInfoCHROMIUM(program, kResultBucketId);
2591 GetBucketContents(kResultBucketId, result);
2592 }
2593
2594 void GLES2Implementation::GetProgramInfoCHROMIUM( 2324 void GLES2Implementation::GetProgramInfoCHROMIUM(
2595 GLuint program, GLsizei bufsize, GLsizei* size, void* info) { 2325 GLuint program, GLsizei bufsize, GLsizei* size, void* info) {
2596 if (bufsize < 0) { 2326 if (bufsize < 0) {
2597 SetGLError(GL_INVALID_VALUE, "glProgramInfoCHROMIUM: bufsize less than 0."); 2327 SetGLError(GL_INVALID_VALUE, "glProgramInfoCHROMIUM: bufsize less than 0.");
2598 return; 2328 return;
2599 } 2329 }
2600 if (size == NULL) { 2330 if (size == NULL) {
2601 SetGLError(GL_INVALID_VALUE, "glProgramInfoCHROMIUM: size is null."); 2331 SetGLError(GL_INVALID_VALUE, "glProgramInfoCHROMIUM: size is null.");
2602 return; 2332 return;
2603 } 2333 }
2604 // Make sure they've set size to 0 else the value will be undefined on 2334 // Make sure they've set size to 0 else the value will be undefined on
2605 // lost context. 2335 // lost context.
2606 GPU_DCHECK(*size == 0); 2336 GPU_DCHECK(*size == 0);
2337 // Clear the bucket so if the command fails nothing will be in it.
2338 helper_->SetBucketSize(kResultBucketId, 0);
2339 helper_->GetProgramInfoCHROMIUM(program, kResultBucketId);
2607 std::vector<int8> result; 2340 std::vector<int8> result;
2608 GetProgramInfoCHROMIUMHelper(program, &result); 2341 GetBucketContents(kResultBucketId, &result);
2609 if (result.empty()) { 2342 if (result.size() == 0) {
2610 return; 2343 return;
2611 } 2344 }
2612 *size = result.size(); 2345 *size = result.size();
2613 if (!info) { 2346 if (!info) {
2614 return; 2347 return;
2615 } 2348 }
2616 if (static_cast<size_t>(bufsize) < result.size()) { 2349 if (static_cast<size_t>(bufsize) < result.size()) {
2617 SetGLError(GL_INVALID_OPERATION, 2350 SetGLError(GL_INVALID_OPERATION,
2618 "glProgramInfoCHROMIUM: bufsize is too small for result."); 2351 "glProgramInfoCHROMIUM: bufsize is too small for result.");
2619 return; 2352 return;
2620 } 2353 }
2621 memcpy(info, &result[0], result.size()); 2354 memcpy(info, &result[0], result.size());
2622 } 2355 }
2623 2356
2624 } // namespace gles2 2357 } // namespace gles2
2625 } // namespace gpu 2358 } // namespace gpu
2626
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