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

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

Issue 1186393004: gpu: Remove async texture uploads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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
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 "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 current_program_(0), 96 current_program_(0),
97 bound_array_buffer_(0), 97 bound_array_buffer_(0),
98 bound_copy_read_buffer_(0), 98 bound_copy_read_buffer_(0),
99 bound_copy_write_buffer_(0), 99 bound_copy_write_buffer_(0),
100 bound_pixel_pack_buffer_(0), 100 bound_pixel_pack_buffer_(0),
101 bound_pixel_unpack_buffer_(0), 101 bound_pixel_unpack_buffer_(0),
102 bound_transform_feedback_buffer_(0), 102 bound_transform_feedback_buffer_(0),
103 bound_uniform_buffer_(0), 103 bound_uniform_buffer_(0),
104 bound_pixel_pack_transfer_buffer_id_(0), 104 bound_pixel_pack_transfer_buffer_id_(0),
105 bound_pixel_unpack_transfer_buffer_id_(0), 105 bound_pixel_unpack_transfer_buffer_id_(0),
106 async_upload_token_(0),
107 async_upload_sync_(NULL),
108 async_upload_sync_shm_id_(0),
109 async_upload_sync_shm_offset_(0),
110 error_bits_(0), 106 error_bits_(0),
111 debug_(false), 107 debug_(false),
112 lose_context_when_out_of_memory_(lose_context_when_out_of_memory), 108 lose_context_when_out_of_memory_(lose_context_when_out_of_memory),
113 support_client_side_arrays_(support_client_side_arrays), 109 support_client_side_arrays_(support_client_side_arrays),
114 use_count_(0), 110 use_count_(0),
115 error_message_callback_(NULL), 111 error_message_callback_(NULL),
116 current_trace_stack_(0), 112 current_trace_stack_(0),
117 gpu_control_(gpu_control), 113 gpu_control_(gpu_control),
118 capabilities_(gpu_control->GetCapabilities()), 114 capabilities_(gpu_control->GetCapabilities()),
119 aggressively_free_resources_(false), 115 aggressively_free_resources_(false),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 if (!transfer_buffer_->Initialize( 147 if (!transfer_buffer_->Initialize(
152 starting_transfer_buffer_size, 148 starting_transfer_buffer_size,
153 kStartingOffset, 149 kStartingOffset,
154 min_transfer_buffer_size, 150 min_transfer_buffer_size,
155 max_transfer_buffer_size, 151 max_transfer_buffer_size,
156 kAlignment, 152 kAlignment,
157 kSizeToFlush)) { 153 kSizeToFlush)) {
158 return false; 154 return false;
159 } 155 }
160 156
161 mapped_memory_.reset( 157 mapped_memory_.reset(new MappedMemoryManager(helper_, mapped_memory_limit));
162 new MappedMemoryManager(
163 helper_,
164 base::Bind(&GLES2Implementation::PollAsyncUploads,
165 // The mapped memory manager is owned by |this| here, and
166 // since its destroyed before before we destroy ourselves
167 // we don't need extra safety measures for this closure.
168 base::Unretained(this)),
169 mapped_memory_limit));
170 158
171 unsigned chunk_size = 2 * 1024 * 1024; 159 unsigned chunk_size = 2 * 1024 * 1024;
172 if (mapped_memory_limit != kNoLimit) { 160 if (mapped_memory_limit != kNoLimit) {
173 // Use smaller chunks if the client is very memory conscientious. 161 // Use smaller chunks if the client is very memory conscientious.
174 chunk_size = std::min(mapped_memory_limit / 4, chunk_size); 162 chunk_size = std::min(mapped_memory_limit / 4, chunk_size);
175 } 163 }
176 mapped_memory_->set_chunk_size_multiple(chunk_size); 164 mapped_memory_->set_chunk_size_multiple(chunk_size);
177 165
178 GLStaticState::ShaderPrecisionMap* shader_precisions = 166 GLStaticState::ShaderPrecisionMap* shader_precisions =
179 &static_state_.shader_precisions; 167 &static_state_.shader_precisions;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 233
246 // Release remaining BufferRange mem; This is when a MapBufferRange() is 234 // Release remaining BufferRange mem; This is when a MapBufferRange() is
247 // called but not the UnmapBuffer() pair. 235 // called but not the UnmapBuffer() pair.
248 ClearMappedBufferRangeMap(); 236 ClearMappedBufferRangeMap();
249 237
250 // Release any per-context data in share group. 238 // Release any per-context data in share group.
251 share_group_->FreeContext(this); 239 share_group_->FreeContext(this);
252 240
253 buffer_tracker_.reset(); 241 buffer_tracker_.reset();
254 242
255 FreeAllAsyncUploadBuffers();
256
257 if (async_upload_sync_) {
258 mapped_memory_->Free(async_upload_sync_);
259 async_upload_sync_ = NULL;
260 }
261
262 // Make sure the commands make it the service. 243 // Make sure the commands make it the service.
263 WaitForCmd(); 244 WaitForCmd();
264 } 245 }
265 246
266 GLES2CmdHelper* GLES2Implementation::helper() const { 247 GLES2CmdHelper* GLES2Implementation::helper() const {
267 return helper_; 248 return helper_;
268 } 249 }
269 250
270 IdHandlerInterface* GLES2Implementation::GetIdHandler(int namespace_id) const { 251 IdHandlerInterface* GLES2Implementation::GetIdHandler(int namespace_id) const {
271 return share_group_->GetIdHandler(namespace_id); 252 return share_group_->GetIdHandler(namespace_id);
(...skipping 21 matching lines...) Expand all
293 274
294 uint32 GLES2Implementation::GetResultShmOffset() { 275 uint32 GLES2Implementation::GetResultShmOffset() {
295 return transfer_buffer_->GetResultOffset(); 276 return transfer_buffer_->GetResultOffset();
296 } 277 }
297 278
298 void GLES2Implementation::FreeUnusedSharedMemory() { 279 void GLES2Implementation::FreeUnusedSharedMemory() {
299 mapped_memory_->FreeUnused(); 280 mapped_memory_->FreeUnused();
300 } 281 }
301 282
302 void GLES2Implementation::FreeEverything() { 283 void GLES2Implementation::FreeEverything() {
303 FreeAllAsyncUploadBuffers();
304 WaitForCmd(); 284 WaitForCmd();
305 query_tracker_->Shrink(); 285 query_tracker_->Shrink();
306 FreeUnusedSharedMemory(); 286 FreeUnusedSharedMemory();
307 transfer_buffer_->Free(); 287 transfer_buffer_->Free();
308 helper_->FreeRingBuffer(); 288 helper_->FreeRingBuffer();
309 } 289 }
310 290
311 void GLES2Implementation::RunIfContextNotLost(const base::Closure& callback) { 291 void GLES2Implementation::RunIfContextNotLost(const base::Closure& callback) {
312 if (!helper_->IsContextLost()) 292 if (!helper_->IsContextLost())
313 callback.Run(); 293 callback.Run();
(...skipping 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBufferSubData(" 1938 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBufferSubData("
1959 << GLES2Util::GetStringBufferTarget(target) << ", " 1939 << GLES2Util::GetStringBufferTarget(target) << ", "
1960 << offset << ", " << size << ", " 1940 << offset << ", " << size << ", "
1961 << static_cast<const void*>(data) << ")"); 1941 << static_cast<const void*>(data) << ")");
1962 BufferSubDataHelper(target, offset, size, data); 1942 BufferSubDataHelper(target, offset, size, data);
1963 CheckGLError(); 1943 CheckGLError();
1964 } 1944 }
1965 1945
1966 void GLES2Implementation::RemoveTransferBuffer(BufferTracker::Buffer* buffer) { 1946 void GLES2Implementation::RemoveTransferBuffer(BufferTracker::Buffer* buffer) {
1967 int32 token = buffer->last_usage_token(); 1947 int32 token = buffer->last_usage_token();
1968 uint32 async_token = buffer->last_async_upload_token();
1969 1948
1970 if (async_token) { 1949 if (token) {
1971 if (HasAsyncUploadTokenPassed(async_token)) {
1972 buffer_tracker_->Free(buffer);
1973 } else {
1974 detached_async_upload_memory_.push_back(
1975 std::make_pair(buffer->address(), async_token));
1976 buffer_tracker_->Unmanage(buffer);
1977 }
1978 } else if (token) {
1979 if (helper_->HasTokenPassed(token)) 1950 if (helper_->HasTokenPassed(token))
1980 buffer_tracker_->Free(buffer); 1951 buffer_tracker_->Free(buffer);
1981 else 1952 else
1982 buffer_tracker_->FreePendingToken(buffer, token); 1953 buffer_tracker_->FreePendingToken(buffer, token);
1983 } else { 1954 } else {
1984 buffer_tracker_->Free(buffer); 1955 buffer_tracker_->Free(buffer);
1985 } 1956 }
1986 1957
1987 buffer_tracker_->RemoveBuffer(buffer->id()); 1958 buffer_tracker_->RemoveBuffer(buffer->id());
1988 } 1959 }
(...skipping 2916 matching lines...) Expand 10 before | Expand all | Expand 10 after
4905 4876
4906 void GLES2Implementation::BeginQueryEXT(GLenum target, GLuint id) { 4877 void GLES2Implementation::BeginQueryEXT(GLenum target, GLuint id) {
4907 GPU_CLIENT_SINGLE_THREAD_CHECK(); 4878 GPU_CLIENT_SINGLE_THREAD_CHECK();
4908 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] BeginQueryEXT(" 4879 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] BeginQueryEXT("
4909 << GLES2Util::GetStringQueryTarget(target) 4880 << GLES2Util::GetStringQueryTarget(target)
4910 << ", " << id << ")"); 4881 << ", " << id << ")");
4911 4882
4912 switch (target) { 4883 switch (target) {
4913 case GL_COMMANDS_ISSUED_CHROMIUM: 4884 case GL_COMMANDS_ISSUED_CHROMIUM:
4914 case GL_LATENCY_QUERY_CHROMIUM: 4885 case GL_LATENCY_QUERY_CHROMIUM:
4915 case GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM:
4916 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: 4886 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM:
4917 case GL_GET_ERROR_QUERY_CHROMIUM: 4887 case GL_GET_ERROR_QUERY_CHROMIUM:
4918 break; 4888 break;
4919 case GL_COMMANDS_COMPLETED_CHROMIUM: 4889 case GL_COMMANDS_COMPLETED_CHROMIUM:
4920 if (!capabilities_.sync_query) { 4890 if (!capabilities_.sync_query) {
4921 SetGLError( 4891 SetGLError(
4922 GL_INVALID_OPERATION, "glBeginQueryEXT", 4892 GL_INVALID_OPERATION, "glBeginQueryEXT",
4923 "not enabled for commands completed queries"); 4893 "not enabled for commands completed queries");
4924 return; 4894 return;
4925 } 4895 }
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
5307 GPU_CLIENT_SINGLE_THREAD_CHECK(); 5277 GPU_CLIENT_SINGLE_THREAD_CHECK();
5308 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glMapBufferCHROMIUM(" 5278 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glMapBufferCHROMIUM("
5309 << target << ", " << GLES2Util::GetStringEnum(access) << ")"); 5279 << target << ", " << GLES2Util::GetStringEnum(access) << ")");
5310 switch (target) { 5280 switch (target) {
5311 case GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM: 5281 case GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM:
5312 if (access != GL_READ_ONLY) { 5282 if (access != GL_READ_ONLY) {
5313 SetGLError(GL_INVALID_ENUM, "glMapBufferCHROMIUM", "bad access mode"); 5283 SetGLError(GL_INVALID_ENUM, "glMapBufferCHROMIUM", "bad access mode");
5314 return NULL; 5284 return NULL;
5315 } 5285 }
5316 break; 5286 break;
5317 case GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM:
5318 if (access != GL_WRITE_ONLY) {
5319 SetGLError(GL_INVALID_ENUM, "glMapBufferCHROMIUM", "bad access mode");
5320 return NULL;
5321 }
5322 break;
5323 default: 5287 default:
5324 SetGLError( 5288 SetGLError(
5325 GL_INVALID_ENUM, "glMapBufferCHROMIUM", "invalid target"); 5289 GL_INVALID_ENUM, "glMapBufferCHROMIUM", "invalid target");
5326 return NULL; 5290 return NULL;
5327 } 5291 }
5328 GLuint buffer_id; 5292 GLuint buffer_id;
5329 GetBoundPixelTransferBuffer(target, "glMapBufferCHROMIUM", &buffer_id); 5293 GetBoundPixelTransferBuffer(target, "glMapBufferCHROMIUM", &buffer_id);
5330 if (!buffer_id) { 5294 if (!buffer_id) {
5331 return NULL; 5295 return NULL;
5332 } 5296 }
5333 BufferTracker::Buffer* buffer = buffer_tracker_->GetBuffer(buffer_id); 5297 BufferTracker::Buffer* buffer = buffer_tracker_->GetBuffer(buffer_id);
5334 if (!buffer) { 5298 if (!buffer) {
5335 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "invalid buffer"); 5299 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "invalid buffer");
5336 return NULL; 5300 return NULL;
5337 } 5301 }
5338 if (buffer->mapped()) { 5302 if (buffer->mapped()) {
5339 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "already mapped"); 5303 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "already mapped");
5340 return NULL; 5304 return NULL;
5341 } 5305 }
5342 // Here we wait for previous transfer operations to be finished. 5306 // Here we wait for previous transfer operations to be finished.
5343 // TODO(hubbe): AsyncTex(Sub)Image2dCHROMIUM does not currently work
5344 // with this method of synchronization. Until this is fixed,
5345 // MapBufferCHROMIUM will not block even if the transfer is not ready
5346 // for these calls.
5347 if (buffer->last_usage_token()) { 5307 if (buffer->last_usage_token()) {
5348 helper_->WaitForToken(buffer->last_usage_token()); 5308 helper_->WaitForToken(buffer->last_usage_token());
5349 buffer->set_last_usage_token(0); 5309 buffer->set_last_usage_token(0);
5350 } 5310 }
5351 buffer->set_mapped(true); 5311 buffer->set_mapped(true);
5352 5312
5353 GPU_CLIENT_LOG(" returned " << buffer->address()); 5313 GPU_CLIENT_LOG(" returned " << buffer->address());
5354 CheckGLError(); 5314 CheckGLError();
5355 return buffer->address(); 5315 return buffer->address();
5356 } 5316 }
(...skipping 16 matching lines...) Expand all
5373 } 5333 }
5374 if (!buffer->mapped()) { 5334 if (!buffer->mapped()) {
5375 SetGLError(GL_INVALID_OPERATION, "glUnmapBufferCHROMIUM", "not mapped"); 5335 SetGLError(GL_INVALID_OPERATION, "glUnmapBufferCHROMIUM", "not mapped");
5376 return false; 5336 return false;
5377 } 5337 }
5378 buffer->set_mapped(false); 5338 buffer->set_mapped(false);
5379 CheckGLError(); 5339 CheckGLError();
5380 return true; 5340 return true;
5381 } 5341 }
5382 5342
5383 bool GLES2Implementation::EnsureAsyncUploadSync() {
5384 if (async_upload_sync_)
5385 return true;
5386
5387 int32 shm_id;
5388 unsigned int shm_offset;
5389 void* mem = mapped_memory_->Alloc(sizeof(AsyncUploadSync),
5390 &shm_id,
5391 &shm_offset);
5392 if (!mem)
5393 return false;
5394
5395 async_upload_sync_shm_id_ = shm_id;
5396 async_upload_sync_shm_offset_ = shm_offset;
5397 async_upload_sync_ = static_cast<AsyncUploadSync*>(mem);
5398 async_upload_sync_->Reset();
5399
5400 return true;
5401 }
5402
5403 uint32 GLES2Implementation::NextAsyncUploadToken() {
5404 async_upload_token_++;
5405 if (async_upload_token_ == 0)
5406 async_upload_token_++;
5407 return async_upload_token_;
5408 }
5409
5410 void GLES2Implementation::PollAsyncUploads() {
5411 if (!async_upload_sync_)
5412 return;
5413
5414 if (helper_->IsContextLost()) {
5415 DetachedAsyncUploadMemoryList::iterator it =
5416 detached_async_upload_memory_.begin();
5417 while (it != detached_async_upload_memory_.end()) {
5418 mapped_memory_->Free(it->first);
5419 it = detached_async_upload_memory_.erase(it);
5420 }
5421 return;
5422 }
5423
5424 DetachedAsyncUploadMemoryList::iterator it =
5425 detached_async_upload_memory_.begin();
5426 while (it != detached_async_upload_memory_.end()) {
5427 if (HasAsyncUploadTokenPassed(it->second)) {
5428 mapped_memory_->Free(it->first);
5429 it = detached_async_upload_memory_.erase(it);
5430 } else {
5431 break;
5432 }
5433 }
5434 }
5435
5436 void GLES2Implementation::FreeAllAsyncUploadBuffers() {
5437 // Free all completed unmanaged async uploads buffers.
5438 PollAsyncUploads();
5439
5440 // Synchronously free rest of the unmanaged async upload buffers.
5441 if (!detached_async_upload_memory_.empty()) {
5442 WaitAllAsyncTexImage2DCHROMIUMHelper();
5443 WaitForCmd();
5444 PollAsyncUploads();
5445 }
5446 }
5447
5448 void GLES2Implementation::AsyncTexImage2DCHROMIUM(
5449 GLenum target, GLint level, GLenum internalformat, GLsizei width,
5450 GLsizei height, GLint border, GLenum format, GLenum type,
5451 const void* pixels) {
5452 GPU_CLIENT_SINGLE_THREAD_CHECK();
5453 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexImage2D("
5454 << GLES2Util::GetStringTextureTarget(target) << ", "
5455 << level << ", "
5456 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", "
5457 << width << ", " << height << ", " << border << ", "
5458 << GLES2Util::GetStringTextureFormat(format) << ", "
5459 << GLES2Util::GetStringPixelType(type) << ", "
5460 << static_cast<const void*>(pixels) << ")");
5461 if (level < 0 || height < 0 || width < 0) {
5462 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "dimension < 0");
5463 return;
5464 }
5465 if (border != 0) {
5466 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "border != 0");
5467 return;
5468 }
5469 uint32 size;
5470 uint32 unpadded_row_size;
5471 uint32 padded_row_size;
5472 if (!GLES2Util::ComputeImageDataSizes(
5473 width, height, 1, format, type, unpack_alignment_, &size,
5474 &unpadded_row_size, &padded_row_size)) {
5475 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "image size too large");
5476 return;
5477 }
5478
5479 // If there's no data/buffer just issue the AsyncTexImage2D
5480 if (!pixels && !bound_pixel_unpack_transfer_buffer_id_) {
5481 helper_->AsyncTexImage2DCHROMIUM(
5482 target, level, internalformat, width, height, format, type,
5483 0, 0, 0, 0, 0);
5484 return;
5485 }
5486
5487 if (!EnsureAsyncUploadSync()) {
5488 SetGLError(GL_OUT_OF_MEMORY, "glTexImage2D", "out of memory");
5489 return;
5490 }
5491
5492 // Otherwise, async uploads require a transfer buffer to be bound.
5493 // TODO(hubbe): Make MapBufferCHROMIUM block if someone tries to re-use
5494 // the buffer before the transfer is finished. (Currently such
5495 // synchronization has to be handled manually.)
5496 GLuint offset = ToGLuint(pixels);
5497 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
5498 bound_pixel_unpack_transfer_buffer_id_,
5499 "glAsyncTexImage2DCHROMIUM", offset, size);
5500 if (buffer && buffer->shm_id() != -1) {
5501 uint32 async_token = NextAsyncUploadToken();
5502 buffer->set_last_async_upload_token(async_token);
5503 helper_->AsyncTexImage2DCHROMIUM(
5504 target, level, internalformat, width, height, format, type,
5505 buffer->shm_id(), buffer->shm_offset() + offset,
5506 async_token,
5507 async_upload_sync_shm_id_, async_upload_sync_shm_offset_);
5508 }
5509 }
5510
5511 void GLES2Implementation::AsyncTexSubImage2DCHROMIUM(
5512 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
5513 GLsizei height, GLenum format, GLenum type, const void* pixels) {
5514 GPU_CLIENT_SINGLE_THREAD_CHECK();
5515 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glAsyncTexSubImage2DCHROMIUM("
5516 << GLES2Util::GetStringTextureTarget(target) << ", "
5517 << level << ", "
5518 << xoffset << ", " << yoffset << ", "
5519 << width << ", " << height << ", "
5520 << GLES2Util::GetStringTextureFormat(format) << ", "
5521 << GLES2Util::GetStringPixelType(type) << ", "
5522 << static_cast<const void*>(pixels) << ")");
5523 if (level < 0 || height < 0 || width < 0) {
5524 SetGLError(
5525 GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "dimension < 0");
5526 return;
5527 }
5528
5529 uint32 size;
5530 uint32 unpadded_row_size;
5531 uint32 padded_row_size;
5532 if (!GLES2Util::ComputeImageDataSizes(
5533 width, height, 1, format, type, unpack_alignment_, &size,
5534 &unpadded_row_size, &padded_row_size)) {
5535 SetGLError(
5536 GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "size to large");
5537 return;
5538 }
5539
5540 if (!EnsureAsyncUploadSync()) {
5541 SetGLError(GL_OUT_OF_MEMORY, "glTexImage2D", "out of memory");
5542 return;
5543 }
5544
5545 // Async uploads require a transfer buffer to be bound.
5546 // TODO(hubbe): Make MapBufferCHROMIUM block if someone tries to re-use
5547 // the buffer before the transfer is finished. (Currently such
5548 // synchronization has to be handled manually.)
5549 GLuint offset = ToGLuint(pixels);
5550 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
5551 bound_pixel_unpack_transfer_buffer_id_,
5552 "glAsyncTexSubImage2DCHROMIUM", offset, size);
5553 if (buffer && buffer->shm_id() != -1) {
5554 uint32 async_token = NextAsyncUploadToken();
5555 buffer->set_last_async_upload_token(async_token);
5556 helper_->AsyncTexSubImage2DCHROMIUM(
5557 target, level, xoffset, yoffset, width, height, format, type,
5558 buffer->shm_id(), buffer->shm_offset() + offset,
5559 async_token,
5560 async_upload_sync_shm_id_, async_upload_sync_shm_offset_);
5561 }
5562 }
5563
5564 void GLES2Implementation::WaitAsyncTexImage2DCHROMIUM(GLenum target) {
5565 GPU_CLIENT_SINGLE_THREAD_CHECK();
5566 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glWaitAsyncTexImage2DCHROMIUM("
5567 << GLES2Util::GetStringTextureTarget(target) << ")");
5568 helper_->WaitAsyncTexImage2DCHROMIUM(target);
5569 CheckGLError();
5570 }
5571
5572 void GLES2Implementation::WaitAllAsyncTexImage2DCHROMIUMHelper() {
5573 helper_->WaitAllAsyncTexImage2DCHROMIUM();
5574 }
5575
5576 void GLES2Implementation::WaitAllAsyncTexImage2DCHROMIUM() {
5577 GPU_CLIENT_SINGLE_THREAD_CHECK();
5578 GPU_CLIENT_LOG("[" << GetLogPrefix()
5579 << "] glWaitAllAsyncTexImage2DCHROMIUM()");
5580 WaitAllAsyncTexImage2DCHROMIUMHelper();
5581 CheckGLError();
5582 }
5583
5584 GLuint GLES2Implementation::InsertSyncPointCHROMIUM() { 5343 GLuint GLES2Implementation::InsertSyncPointCHROMIUM() {
5585 GPU_CLIENT_SINGLE_THREAD_CHECK(); 5344 GPU_CLIENT_SINGLE_THREAD_CHECK();
5586 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glInsertSyncPointCHROMIUM"); 5345 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glInsertSyncPointCHROMIUM");
5587 helper_->CommandBufferHelper::Flush(); 5346 helper_->CommandBufferHelper::Flush();
5588 return gpu_control_->InsertSyncPoint(); 5347 return gpu_control_->InsertSyncPoint();
5589 } 5348 }
5590 5349
5591 GLuint GLES2Implementation::InsertFutureSyncPointCHROMIUM() { 5350 GLuint GLES2Implementation::InsertFutureSyncPointCHROMIUM() {
5592 GPU_CLIENT_SINGLE_THREAD_CHECK(); 5351 GPU_CLIENT_SINGLE_THREAD_CHECK();
5593 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glInsertFutureSyncPointCHROMIUM"); 5352 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glInsertFutureSyncPointCHROMIUM");
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
6121 CheckGLError(); 5880 CheckGLError();
6122 } 5881 }
6123 5882
6124 // Include the auto-generated part of this file. We split this because it means 5883 // Include the auto-generated part of this file. We split this because it means
6125 // we can easily edit the non-auto generated parts right here in this file 5884 // we can easily edit the non-auto generated parts right here in this file
6126 // instead of having to edit some template or the code generator. 5885 // instead of having to edit some template or the code generator.
6127 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 5886 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
6128 5887
6129 } // namespace gles2 5888 } // namespace gles2
6130 } // namespace gpu 5889 } // 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