OLD | NEW |
---|---|
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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
11 #include <map> | 11 #include <map> |
12 #include <stack> | 12 #include <stack> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/at_exit.h" | 16 #include "base/at_exit.h" |
17 #include "base/bind.h" | 17 #include "base/bind.h" |
18 #include "base/callback_helpers.h" | |
18 #include "base/command_line.h" | 19 #include "base/command_line.h" |
19 #include "base/debug/trace_event.h" | 20 #include "base/debug/trace_event.h" |
20 #include "base/debug/trace_event_synthetic_delay.h" | 21 #include "base/debug/trace_event_synthetic_delay.h" |
21 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
22 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
23 #include "base/strings/string_split.h" | 24 #include "base/strings/string_split.h" |
24 #include "build/build_config.h" | 25 #include "build/build_config.h" |
25 #define GLES2_GPU_SERVICE 1 | 26 #define GLES2_GPU_SERVICE 1 |
26 #include "gpu/command_buffer/common/debug_marker_manager.h" | 27 #include "gpu/command_buffer/common/debug_marker_manager.h" |
27 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 28 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
(...skipping 10255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10283 if (!texture_ref || | 10284 if (!texture_ref || |
10284 async_pixel_transfer_manager_->AsyncTransferIsInProgress(texture_ref)) { | 10285 async_pixel_transfer_manager_->AsyncTransferIsInProgress(texture_ref)) { |
10285 LOCAL_SET_GL_ERROR( | 10286 LOCAL_SET_GL_ERROR( |
10286 GL_INVALID_OPERATION, | 10287 GL_INVALID_OPERATION, |
10287 function_name, "transfer already in progress"); | 10288 function_name, "transfer already in progress"); |
10288 return false; | 10289 return false; |
10289 } | 10290 } |
10290 return true; | 10291 return true; |
10291 } | 10292 } |
10292 | 10293 |
10294 namespace { | |
10295 void UpdateAsyncUploadToken(AsyncUploadSync* sync, uint32 async_upload_token) { | |
10296 base::subtle::MemoryBarrier(); | |
epennerAtGoogle
2014/02/07 20:43:58
See my other comment on MemoryBarriers. Wouldn't h
| |
10297 sync->async_token = async_upload_token; | |
10298 } | |
10299 } | |
10300 | |
10293 error::Error GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM( | 10301 error::Error GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM( |
10294 uint32 immediate_data_size, const cmds::AsyncTexImage2DCHROMIUM& c) { | 10302 uint32 immediate_data_size, const cmds::AsyncTexImage2DCHROMIUM& c) { |
10295 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM"); | 10303 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM"); |
10296 GLenum target = static_cast<GLenum>(c.target); | 10304 GLenum target = static_cast<GLenum>(c.target); |
10297 GLint level = static_cast<GLint>(c.level); | 10305 GLint level = static_cast<GLint>(c.level); |
10298 // TODO(kloveless): Change HandleAsyncTexImage2DCHROMIUM command to use | 10306 // TODO(kloveless): Change HandleAsyncTexImage2DCHROMIUM command to use |
10299 // unsigned integer for internalformat. | 10307 // unsigned integer for internalformat. |
10300 GLenum internal_format = static_cast<GLenum>(c.internalformat); | 10308 GLenum internal_format = static_cast<GLenum>(c.internalformat); |
10301 GLsizei width = static_cast<GLsizei>(c.width); | 10309 GLsizei width = static_cast<GLsizei>(c.width); |
10302 GLsizei height = static_cast<GLsizei>(c.height); | 10310 GLsizei height = static_cast<GLsizei>(c.height); |
10303 GLint border = static_cast<GLint>(c.border); | 10311 GLint border = static_cast<GLint>(c.border); |
10304 GLenum format = static_cast<GLenum>(c.format); | 10312 GLenum format = static_cast<GLenum>(c.format); |
10305 GLenum type = static_cast<GLenum>(c.type); | 10313 GLenum type = static_cast<GLenum>(c.type); |
10306 uint32 pixels_shm_id = static_cast<uint32>(c.pixels_shm_id); | 10314 uint32 pixels_shm_id = static_cast<uint32>(c.pixels_shm_id); |
10307 uint32 pixels_shm_offset = static_cast<uint32>(c.pixels_shm_offset); | 10315 uint32 pixels_shm_offset = static_cast<uint32>(c.pixels_shm_offset); |
10308 uint32 pixels_size; | 10316 uint32 pixels_size; |
10317 uint32 async_upload_token = static_cast<uint32>(c.async_upload_token); | |
10318 uint32 sync_data_shm_id = static_cast<uint32>(c.sync_data_shm_id); | |
10319 uint32 sync_data_shm_offset = static_cast<uint32>(c.sync_data_shm_offset); | |
10320 | |
10321 base::ScopedClosureRunner scoped_completion_callback; | |
10322 if (async_upload_token) { | |
10323 AsyncUploadSync* sync = GetSharedMemoryAs<AsyncUploadSync*>( | |
10324 sync_data_shm_id, sync_data_shm_offset, sizeof(*sync)); | |
piman
2014/02/07 22:58:20
The shared memory backing the AsyncUploadSync coul
jadahl
2014/02/08 09:18:25
As epenner replied elsewhere, SafeSharedMemoryPool
epennerAtGoogle
2014/02/10 23:12:06
Bug for reference counting SharedMemory:
https://c
| |
10325 scoped_completion_callback.Reset(base::Bind( | |
10326 &AsyncPixelTransferManager::AsyncRun, | |
10327 base::Unretained(GetAsyncPixelTransferManager()), | |
10328 base::Bind(&UpdateAsyncUploadToken, | |
10329 sync, | |
10330 async_upload_token))); | |
10331 } | |
10309 | 10332 |
10310 // TODO(epenner): Move this and copies of this memory validation | 10333 // TODO(epenner): Move this and copies of this memory validation |
10311 // into ValidateTexImage2D step. | 10334 // into ValidateTexImage2D step. |
10312 if (!GLES2Util::ComputeImageDataSizes( | 10335 if (!GLES2Util::ComputeImageDataSizes( |
10313 width, height, format, type, state_.unpack_alignment, &pixels_size, NULL, | 10336 width, height, format, type, state_.unpack_alignment, &pixels_size, NULL, |
10314 NULL)) { | 10337 NULL)) { |
10315 return error::kOutOfBounds; | 10338 return error::kOutOfBounds; |
10316 } | 10339 } |
10317 const void* pixels = NULL; | 10340 const void* pixels = NULL; |
10318 if (pixels_shm_id != 0 || pixels_shm_offset != 0) { | 10341 if (pixels_shm_id != 0 || pixels_shm_offset != 0) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10393 uint32 immediate_data_size, const cmds::AsyncTexSubImage2DCHROMIUM& c) { | 10416 uint32 immediate_data_size, const cmds::AsyncTexSubImage2DCHROMIUM& c) { |
10394 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexSubImage2DCHROMIUM"); | 10417 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexSubImage2DCHROMIUM"); |
10395 GLenum target = static_cast<GLenum>(c.target); | 10418 GLenum target = static_cast<GLenum>(c.target); |
10396 GLint level = static_cast<GLint>(c.level); | 10419 GLint level = static_cast<GLint>(c.level); |
10397 GLint xoffset = static_cast<GLint>(c.xoffset); | 10420 GLint xoffset = static_cast<GLint>(c.xoffset); |
10398 GLint yoffset = static_cast<GLint>(c.yoffset); | 10421 GLint yoffset = static_cast<GLint>(c.yoffset); |
10399 GLsizei width = static_cast<GLsizei>(c.width); | 10422 GLsizei width = static_cast<GLsizei>(c.width); |
10400 GLsizei height = static_cast<GLsizei>(c.height); | 10423 GLsizei height = static_cast<GLsizei>(c.height); |
10401 GLenum format = static_cast<GLenum>(c.format); | 10424 GLenum format = static_cast<GLenum>(c.format); |
10402 GLenum type = static_cast<GLenum>(c.type); | 10425 GLenum type = static_cast<GLenum>(c.type); |
10426 uint32 async_upload_token = static_cast<uint32>(c.async_upload_token); | |
10427 uint32 sync_data_shm_id = static_cast<uint32>(c.sync_data_shm_id); | |
10428 uint32 sync_data_shm_offset = static_cast<uint32>(c.sync_data_shm_offset); | |
10429 | |
10430 base::ScopedClosureRunner scoped_completion_callback; | |
10431 if (async_upload_token) { | |
10432 AsyncUploadSync* sync = GetSharedMemoryAs<AsyncUploadSync*>( | |
10433 sync_data_shm_id, sync_data_shm_offset, sizeof(*sync)); | |
10434 scoped_completion_callback.Reset(base::Bind( | |
10435 &AsyncPixelTransferManager::AsyncRun, | |
10436 base::Unretained(GetAsyncPixelTransferManager()), | |
10437 base::Bind(&UpdateAsyncUploadToken, | |
10438 sync, | |
10439 async_upload_token))); | |
10440 } | |
10403 | 10441 |
10404 // TODO(epenner): Move this and copies of this memory validation | 10442 // TODO(epenner): Move this and copies of this memory validation |
10405 // into ValidateTexSubImage2D step. | 10443 // into ValidateTexSubImage2D step. |
10406 uint32 data_size; | 10444 uint32 data_size; |
10407 if (!GLES2Util::ComputeImageDataSizes( | 10445 if (!GLES2Util::ComputeImageDataSizes( |
10408 width, height, format, type, state_.unpack_alignment, &data_size, | 10446 width, height, format, type, state_.unpack_alignment, &data_size, |
10409 NULL, NULL)) { | 10447 NULL, NULL)) { |
10410 return error::kOutOfBounds; | 10448 return error::kOutOfBounds; |
10411 } | 10449 } |
10412 const void* pixels = GetSharedMemoryAs<const void*>( | 10450 const void* pixels = GetSharedMemoryAs<const void*>( |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10516 DoDidUseTexImageIfNeeded(texture, texture->target()); | 10554 DoDidUseTexImageIfNeeded(texture, texture->target()); |
10517 } | 10555 } |
10518 | 10556 |
10519 // Include the auto-generated part of this file. We split this because it means | 10557 // Include the auto-generated part of this file. We split this because it means |
10520 // we can easily edit the non-auto generated parts right here in this file | 10558 // we can easily edit the non-auto generated parts right here in this file |
10521 // instead of having to edit some template or the code generator. | 10559 // instead of having to edit some template or the code generator. |
10522 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10560 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10523 | 10561 |
10524 } // namespace gles2 | 10562 } // namespace gles2 |
10525 } // namespace gpu | 10563 } // namespace gpu |
OLD | NEW |