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

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

Issue 2379203002: implement getBufferSubDataAsync prototype (Closed)
Patch Set: small clarification Created 4 years, 2 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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 } 366 }
367 367
368 void GLES2Implementation::FreeEverything() { 368 void GLES2Implementation::FreeEverything() {
369 WaitForCmd(); 369 WaitForCmd();
370 query_tracker_->Shrink(); 370 query_tracker_->Shrink();
371 FreeUnusedSharedMemory(); 371 FreeUnusedSharedMemory();
372 transfer_buffer_->Free(); 372 transfer_buffer_->Free();
373 helper_->FreeRingBuffer(); 373 helper_->FreeRingBuffer();
374 } 374 }
375 375
376 void GLES2Implementation::FreeSharedMemory(void* mem) {
377 mapped_memory_->FreePendingToken(mem, helper_->InsertToken());
378 }
379
376 void GLES2Implementation::RunIfContextNotLost(const base::Closure& callback) { 380 void GLES2Implementation::RunIfContextNotLost(const base::Closure& callback) {
377 if (!lost_context_callback_run_) 381 if (!lost_context_callback_run_)
378 callback.Run(); 382 callback.Run();
379 } 383 }
380 384
381 void GLES2Implementation::SignalSyncToken(const gpu::SyncToken& sync_token, 385 void GLES2Implementation::SignalSyncToken(const gpu::SyncToken& sync_token,
382 const base::Closure& callback) { 386 const base::Closure& callback) {
383 if (sync_token.HasData() && 387 if (sync_token.HasData() &&
384 (sync_token.verified_flush() || 388 (sync_token.verified_flush() ||
385 gpu_control_->CanWaitUnverifiedSyncToken(&sync_token))) { 389 gpu_control_->CanWaitUnverifiedSyncToken(&sync_token))) {
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetAttribLocation(" << program 1637 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetAttribLocation(" << program
1634 << ", " << name << ")"); 1638 << ", " << name << ")");
1635 TRACE_EVENT0("gpu", "GLES2::GetAttribLocation"); 1639 TRACE_EVENT0("gpu", "GLES2::GetAttribLocation");
1636 GLint loc = share_group_->program_info_manager()->GetAttribLocation( 1640 GLint loc = share_group_->program_info_manager()->GetAttribLocation(
1637 this, program, name); 1641 this, program, name);
1638 GPU_CLIENT_LOG("returned " << loc); 1642 GPU_CLIENT_LOG("returned " << loc);
1639 CheckGLError(); 1643 CheckGLError();
1640 return loc; 1644 return loc;
1641 } 1645 }
1642 1646
1647 void* GLES2Implementation::GetBufferSubDataAsyncCHROMIUM(
1648 GLenum target, GLintptr offset, GLsizeiptr size) {
1649 const char* name = "glGetBufferSubDataAsyncCHROMIUM";
1650 GPU_CLIENT_SINGLE_THREAD_CHECK();
1651 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] " << name << "("
1652 << GLES2Util::GetStringEnum(target) << ", " << offset << ", "
1653 << size << ")");
1654 switch (target) {
1655 case GL_ARRAY_BUFFER:
1656 case GL_ELEMENT_ARRAY_BUFFER:
1657 case GL_COPY_READ_BUFFER:
1658 case GL_COPY_WRITE_BUFFER:
1659 case GL_PIXEL_PACK_BUFFER:
1660 case GL_PIXEL_UNPACK_BUFFER:
1661 case GL_TRANSFORM_FEEDBACK_BUFFER:
1662 case GL_UNIFORM_BUFFER:
1663 break;
1664 default:
1665 SetGLError(GL_INVALID_ENUM, name, "invalid target");
1666 return nullptr;
1667 }
1668
1669 GLuint buffer = GetBoundBufferHelper(target);
1670 if (buffer == 0) {
1671 SetGLError(GL_INVALID_OPERATION, name, "no buffer bound");
1672 return nullptr;
1673 }
1674
1675 if (!ValidateSize("glMapBufferRange", size) ||
1676 !ValidateOffset("glMapBufferRange", offset)) {
1677 SetGLError(GL_INVALID_VALUE, name, "invalid size/offset");
1678 return nullptr;
1679 }
1680
1681 int32_t shm_id;
1682 unsigned int shm_offset;
1683 void* shm_ptr = mapped_memory_->Alloc(size, &shm_id, &shm_offset);
1684 if (!shm_ptr) {
1685 SetGLError(GL_OUT_OF_MEMORY, name, "out of memory");
1686 return nullptr;
1687 }
1688
1689 helper_->GetBufferSubDataAsyncCHROMIUM(target, offset, size,
1690 shm_id, shm_offset);
1691
1692 return shm_ptr;
1693 }
1694
1643 GLint GLES2Implementation::GetUniformLocationHelper( 1695 GLint GLES2Implementation::GetUniformLocationHelper(
1644 GLuint program, const char* name) { 1696 GLuint program, const char* name) {
1645 typedef cmds::GetUniformLocation::Result Result; 1697 typedef cmds::GetUniformLocation::Result Result;
1646 Result* result = GetResultAs<Result*>(); 1698 Result* result = GetResultAs<Result*>();
1647 if (!result) { 1699 if (!result) {
1648 return -1; 1700 return -1;
1649 } 1701 }
1650 *result = -1; 1702 *result = -1;
1651 SetBucketAsCString(kResultBucketId, name); 1703 SetBucketAsCString(kResultBucketId, name);
1652 helper_->GetUniformLocation(program, kResultBucketId, 1704 helper_->GetUniformLocation(program, kResultBucketId,
(...skipping 5300 matching lines...) Expand 10 before | Expand all | Expand 10 after
6953 cached_extensions_.clear(); 7005 cached_extensions_.clear();
6954 } 7006 }
6955 7007
6956 // Include the auto-generated part of this file. We split this because it means 7008 // Include the auto-generated part of this file. We split this because it means
6957 // we can easily edit the non-auto generated parts right here in this file 7009 // we can easily edit the non-auto generated parts right here in this file
6958 // instead of having to edit some template or the code generator. 7010 // instead of having to edit some template or the code generator.
6959 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 7011 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
6960 7012
6961 } // namespace gles2 7013 } // namespace gles2
6962 } // namespace gpu 7014 } // 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