| Index: gpu/command_buffer/client/gles2_implementation.cc
|
| diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
|
| index 31d94f18dfd8af2f4a494ed000d5b98b8192c4f9..5635f2678a20595343d402764cf997a6b3385f72 100644
|
| --- a/gpu/command_buffer/client/gles2_implementation.cc
|
| +++ b/gpu/command_buffer/client/gles2_implementation.cc
|
| @@ -103,10 +103,6 @@ GLES2Implementation::GLES2Implementation(
|
| bound_uniform_buffer_(0),
|
| bound_pixel_pack_transfer_buffer_id_(0),
|
| bound_pixel_unpack_transfer_buffer_id_(0),
|
| - async_upload_token_(0),
|
| - async_upload_sync_(NULL),
|
| - async_upload_sync_shm_id_(0),
|
| - async_upload_sync_shm_offset_(0),
|
| error_bits_(0),
|
| debug_(false),
|
| lose_context_when_out_of_memory_(lose_context_when_out_of_memory),
|
| @@ -158,15 +154,7 @@ bool GLES2Implementation::Initialize(
|
| return false;
|
| }
|
|
|
| - mapped_memory_.reset(
|
| - new MappedMemoryManager(
|
| - helper_,
|
| - base::Bind(&GLES2Implementation::PollAsyncUploads,
|
| - // The mapped memory manager is owned by |this| here, and
|
| - // since its destroyed before before we destroy ourselves
|
| - // we don't need extra safety measures for this closure.
|
| - base::Unretained(this)),
|
| - mapped_memory_limit));
|
| + mapped_memory_.reset(new MappedMemoryManager(helper_, mapped_memory_limit));
|
|
|
| unsigned chunk_size = 2 * 1024 * 1024;
|
| if (mapped_memory_limit != kNoLimit) {
|
| @@ -252,13 +240,6 @@ GLES2Implementation::~GLES2Implementation() {
|
|
|
| buffer_tracker_.reset();
|
|
|
| - FreeAllAsyncUploadBuffers();
|
| -
|
| - if (async_upload_sync_) {
|
| - mapped_memory_->Free(async_upload_sync_);
|
| - async_upload_sync_ = NULL;
|
| - }
|
| -
|
| // Make sure the commands make it the service.
|
| WaitForCmd();
|
| }
|
| @@ -300,7 +281,6 @@ void GLES2Implementation::FreeUnusedSharedMemory() {
|
| }
|
|
|
| void GLES2Implementation::FreeEverything() {
|
| - FreeAllAsyncUploadBuffers();
|
| WaitForCmd();
|
| query_tracker_->Shrink();
|
| FreeUnusedSharedMemory();
|
| @@ -1965,17 +1945,8 @@ void GLES2Implementation::BufferSubData(
|
|
|
| void GLES2Implementation::RemoveTransferBuffer(BufferTracker::Buffer* buffer) {
|
| int32 token = buffer->last_usage_token();
|
| - uint32 async_token = buffer->last_async_upload_token();
|
|
|
| - if (async_token) {
|
| - if (HasAsyncUploadTokenPassed(async_token)) {
|
| - buffer_tracker_->Free(buffer);
|
| - } else {
|
| - detached_async_upload_memory_.push_back(
|
| - std::make_pair(buffer->address(), async_token));
|
| - buffer_tracker_->Unmanage(buffer);
|
| - }
|
| - } else if (token) {
|
| + if (token) {
|
| if (helper_->HasTokenPassed(token))
|
| buffer_tracker_->Free(buffer);
|
| else
|
| @@ -4912,7 +4883,6 @@ void GLES2Implementation::BeginQueryEXT(GLenum target, GLuint id) {
|
| switch (target) {
|
| case GL_COMMANDS_ISSUED_CHROMIUM:
|
| case GL_LATENCY_QUERY_CHROMIUM:
|
| - case GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM:
|
| case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM:
|
| case GL_GET_ERROR_QUERY_CHROMIUM:
|
| break;
|
| @@ -5314,12 +5284,6 @@ void* GLES2Implementation::MapBufferCHROMIUM(GLuint target, GLenum access) {
|
| return NULL;
|
| }
|
| break;
|
| - case GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM:
|
| - if (access != GL_WRITE_ONLY) {
|
| - SetGLError(GL_INVALID_ENUM, "glMapBufferCHROMIUM", "bad access mode");
|
| - return NULL;
|
| - }
|
| - break;
|
| default:
|
| SetGLError(
|
| GL_INVALID_ENUM, "glMapBufferCHROMIUM", "invalid target");
|
| @@ -5340,10 +5304,6 @@ void* GLES2Implementation::MapBufferCHROMIUM(GLuint target, GLenum access) {
|
| return NULL;
|
| }
|
| // Here we wait for previous transfer operations to be finished.
|
| - // TODO(hubbe): AsyncTex(Sub)Image2dCHROMIUM does not currently work
|
| - // with this method of synchronization. Until this is fixed,
|
| - // MapBufferCHROMIUM will not block even if the transfer is not ready
|
| - // for these calls.
|
| if (buffer->last_usage_token()) {
|
| helper_->WaitForToken(buffer->last_usage_token());
|
| buffer->set_last_usage_token(0);
|
| @@ -5380,207 +5340,6 @@ GLboolean GLES2Implementation::UnmapBufferCHROMIUM(GLuint target) {
|
| return true;
|
| }
|
|
|
| -bool GLES2Implementation::EnsureAsyncUploadSync() {
|
| - if (async_upload_sync_)
|
| - return true;
|
| -
|
| - int32 shm_id;
|
| - unsigned int shm_offset;
|
| - void* mem = mapped_memory_->Alloc(sizeof(AsyncUploadSync),
|
| - &shm_id,
|
| - &shm_offset);
|
| - if (!mem)
|
| - return false;
|
| -
|
| - async_upload_sync_shm_id_ = shm_id;
|
| - async_upload_sync_shm_offset_ = shm_offset;
|
| - async_upload_sync_ = static_cast<AsyncUploadSync*>(mem);
|
| - async_upload_sync_->Reset();
|
| -
|
| - return true;
|
| -}
|
| -
|
| -uint32 GLES2Implementation::NextAsyncUploadToken() {
|
| - async_upload_token_++;
|
| - if (async_upload_token_ == 0)
|
| - async_upload_token_++;
|
| - return async_upload_token_;
|
| -}
|
| -
|
| -void GLES2Implementation::PollAsyncUploads() {
|
| - if (!async_upload_sync_)
|
| - return;
|
| -
|
| - if (helper_->IsContextLost()) {
|
| - DetachedAsyncUploadMemoryList::iterator it =
|
| - detached_async_upload_memory_.begin();
|
| - while (it != detached_async_upload_memory_.end()) {
|
| - mapped_memory_->Free(it->first);
|
| - it = detached_async_upload_memory_.erase(it);
|
| - }
|
| - return;
|
| - }
|
| -
|
| - DetachedAsyncUploadMemoryList::iterator it =
|
| - detached_async_upload_memory_.begin();
|
| - while (it != detached_async_upload_memory_.end()) {
|
| - if (HasAsyncUploadTokenPassed(it->second)) {
|
| - mapped_memory_->Free(it->first);
|
| - it = detached_async_upload_memory_.erase(it);
|
| - } else {
|
| - break;
|
| - }
|
| - }
|
| -}
|
| -
|
| -void GLES2Implementation::FreeAllAsyncUploadBuffers() {
|
| - // Free all completed unmanaged async uploads buffers.
|
| - PollAsyncUploads();
|
| -
|
| - // Synchronously free rest of the unmanaged async upload buffers.
|
| - if (!detached_async_upload_memory_.empty()) {
|
| - WaitAllAsyncTexImage2DCHROMIUMHelper();
|
| - WaitForCmd();
|
| - PollAsyncUploads();
|
| - }
|
| -}
|
| -
|
| -void GLES2Implementation::AsyncTexImage2DCHROMIUM(
|
| - GLenum target, GLint level, GLenum internalformat, GLsizei width,
|
| - GLsizei height, GLint border, GLenum format, GLenum type,
|
| - const void* pixels) {
|
| - GPU_CLIENT_SINGLE_THREAD_CHECK();
|
| - GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexImage2D("
|
| - << GLES2Util::GetStringTextureTarget(target) << ", "
|
| - << level << ", "
|
| - << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", "
|
| - << width << ", " << height << ", " << border << ", "
|
| - << GLES2Util::GetStringTextureFormat(format) << ", "
|
| - << GLES2Util::GetStringPixelType(type) << ", "
|
| - << static_cast<const void*>(pixels) << ")");
|
| - if (level < 0 || height < 0 || width < 0) {
|
| - SetGLError(GL_INVALID_VALUE, "glTexImage2D", "dimension < 0");
|
| - return;
|
| - }
|
| - if (border != 0) {
|
| - SetGLError(GL_INVALID_VALUE, "glTexImage2D", "border != 0");
|
| - return;
|
| - }
|
| - uint32 size;
|
| - uint32 unpadded_row_size;
|
| - uint32 padded_row_size;
|
| - if (!GLES2Util::ComputeImageDataSizes(
|
| - width, height, 1, format, type, unpack_alignment_, &size,
|
| - &unpadded_row_size, &padded_row_size)) {
|
| - SetGLError(GL_INVALID_VALUE, "glTexImage2D", "image size too large");
|
| - return;
|
| - }
|
| -
|
| - // If there's no data/buffer just issue the AsyncTexImage2D
|
| - if (!pixels && !bound_pixel_unpack_transfer_buffer_id_) {
|
| - helper_->AsyncTexImage2DCHROMIUM(
|
| - target, level, internalformat, width, height, format, type,
|
| - 0, 0, 0, 0, 0);
|
| - return;
|
| - }
|
| -
|
| - if (!EnsureAsyncUploadSync()) {
|
| - SetGLError(GL_OUT_OF_MEMORY, "glTexImage2D", "out of memory");
|
| - return;
|
| - }
|
| -
|
| - // Otherwise, async uploads require a transfer buffer to be bound.
|
| - // TODO(hubbe): Make MapBufferCHROMIUM block if someone tries to re-use
|
| - // the buffer before the transfer is finished. (Currently such
|
| - // synchronization has to be handled manually.)
|
| - GLuint offset = ToGLuint(pixels);
|
| - BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
|
| - bound_pixel_unpack_transfer_buffer_id_,
|
| - "glAsyncTexImage2DCHROMIUM", offset, size);
|
| - if (buffer && buffer->shm_id() != -1) {
|
| - uint32 async_token = NextAsyncUploadToken();
|
| - buffer->set_last_async_upload_token(async_token);
|
| - helper_->AsyncTexImage2DCHROMIUM(
|
| - target, level, internalformat, width, height, format, type,
|
| - buffer->shm_id(), buffer->shm_offset() + offset,
|
| - async_token,
|
| - async_upload_sync_shm_id_, async_upload_sync_shm_offset_);
|
| - }
|
| -}
|
| -
|
| -void GLES2Implementation::AsyncTexSubImage2DCHROMIUM(
|
| - GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
|
| - GLsizei height, GLenum format, GLenum type, const void* pixels) {
|
| - GPU_CLIENT_SINGLE_THREAD_CHECK();
|
| - GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glAsyncTexSubImage2DCHROMIUM("
|
| - << GLES2Util::GetStringTextureTarget(target) << ", "
|
| - << level << ", "
|
| - << xoffset << ", " << yoffset << ", "
|
| - << width << ", " << height << ", "
|
| - << GLES2Util::GetStringTextureFormat(format) << ", "
|
| - << GLES2Util::GetStringPixelType(type) << ", "
|
| - << static_cast<const void*>(pixels) << ")");
|
| - if (level < 0 || height < 0 || width < 0) {
|
| - SetGLError(
|
| - GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "dimension < 0");
|
| - return;
|
| - }
|
| -
|
| - uint32 size;
|
| - uint32 unpadded_row_size;
|
| - uint32 padded_row_size;
|
| - if (!GLES2Util::ComputeImageDataSizes(
|
| - width, height, 1, format, type, unpack_alignment_, &size,
|
| - &unpadded_row_size, &padded_row_size)) {
|
| - SetGLError(
|
| - GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "size to large");
|
| - return;
|
| - }
|
| -
|
| - if (!EnsureAsyncUploadSync()) {
|
| - SetGLError(GL_OUT_OF_MEMORY, "glTexImage2D", "out of memory");
|
| - return;
|
| - }
|
| -
|
| - // Async uploads require a transfer buffer to be bound.
|
| - // TODO(hubbe): Make MapBufferCHROMIUM block if someone tries to re-use
|
| - // the buffer before the transfer is finished. (Currently such
|
| - // synchronization has to be handled manually.)
|
| - GLuint offset = ToGLuint(pixels);
|
| - BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
|
| - bound_pixel_unpack_transfer_buffer_id_,
|
| - "glAsyncTexSubImage2DCHROMIUM", offset, size);
|
| - if (buffer && buffer->shm_id() != -1) {
|
| - uint32 async_token = NextAsyncUploadToken();
|
| - buffer->set_last_async_upload_token(async_token);
|
| - helper_->AsyncTexSubImage2DCHROMIUM(
|
| - target, level, xoffset, yoffset, width, height, format, type,
|
| - buffer->shm_id(), buffer->shm_offset() + offset,
|
| - async_token,
|
| - async_upload_sync_shm_id_, async_upload_sync_shm_offset_);
|
| - }
|
| -}
|
| -
|
| -void GLES2Implementation::WaitAsyncTexImage2DCHROMIUM(GLenum target) {
|
| - GPU_CLIENT_SINGLE_THREAD_CHECK();
|
| - GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glWaitAsyncTexImage2DCHROMIUM("
|
| - << GLES2Util::GetStringTextureTarget(target) << ")");
|
| - helper_->WaitAsyncTexImage2DCHROMIUM(target);
|
| - CheckGLError();
|
| -}
|
| -
|
| -void GLES2Implementation::WaitAllAsyncTexImage2DCHROMIUMHelper() {
|
| - helper_->WaitAllAsyncTexImage2DCHROMIUM();
|
| -}
|
| -
|
| -void GLES2Implementation::WaitAllAsyncTexImage2DCHROMIUM() {
|
| - GPU_CLIENT_SINGLE_THREAD_CHECK();
|
| - GPU_CLIENT_LOG("[" << GetLogPrefix()
|
| - << "] glWaitAllAsyncTexImage2DCHROMIUM()");
|
| - WaitAllAsyncTexImage2DCHROMIUMHelper();
|
| - CheckGLError();
|
| -}
|
| -
|
| GLuint GLES2Implementation::InsertSyncPointCHROMIUM() {
|
| GPU_CLIENT_SINGLE_THREAD_CHECK();
|
| GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glInsertSyncPointCHROMIUM");
|
|
|