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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 2379203002: implement getBufferSubDataAsync prototype (Closed)
Patch Set: address comments 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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 11402 matching lines...) Expand 10 before | Expand all | Expand 10 after
11413 return error::kInvalidArguments; 11413 return error::kInvalidArguments;
11414 } 11414 }
11415 std::string name_str; 11415 std::string name_str;
11416 if (!bucket->GetAsString(&name_str)) { 11416 if (!bucket->GetAsString(&name_str)) {
11417 return error::kInvalidArguments; 11417 return error::kInvalidArguments;
11418 } 11418 }
11419 return GetAttribLocationHelper( 11419 return GetAttribLocationHelper(
11420 c.program, c.location_shm_id, c.location_shm_offset, name_str); 11420 c.program, c.location_shm_id, c.location_shm_offset, name_str);
11421 } 11421 }
11422 11422
11423 error::Error GLES2DecoderImpl::HandleGetBufferSubDataAsyncCHROMIUM(
11424 uint32_t immediate_data_size,
11425 const volatile void* cmd_data) {
11426 if (!unsafe_es3_apis_enabled()) {
11427 return error::kUnknownCommand;
11428 }
11429 const volatile gles2::cmds::GetBufferSubDataAsyncCHROMIUM& c =
11430 *static_cast<const volatile gles2::cmds::GetBufferSubDataAsyncCHROMIUM*>(
11431 cmd_data);
11432 GLenum target = static_cast<GLenum>(c.target);
11433 GLintptr offset = static_cast<GLintptr>(c.offset);
11434 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
11435 uint32_t data_shm_id = static_cast<uint32_t>(c.data_shm_id);
11436
11437 int8_t* mem =
11438 GetSharedMemoryAs<int8_t*>(data_shm_id, c.data_shm_offset, size);
11439 if (!mem) {
11440 return error::kOutOfBounds;
11441 }
11442
11443 if (!validators_->buffer_target.IsValid(target)) {
11444 return error::kInvalidArguments;
11445 }
11446
11447 Buffer* buffer = buffer_manager()->GetBufferInfoForTarget(&state_, target);
11448 if (!buffer) {
11449 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetBufferSubDataAsyncCHROMIUM",
11450 "no buffer bound to target");
11451 return error::kNoError;
11452 }
11453 if (!buffer->CheckRange(offset, size)) {
11454 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glGetBufferSubDataAsyncCHROMIUM",
11455 "invalid range");
11456 return error::kNoError;
11457 }
11458
11459 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glGetBufferSubDataAsyncCHROMIUM");
11460
11461 void* ptr = glMapBufferRange(target, offset, size, GL_MAP_READ_BIT);
11462 if (ptr == nullptr) {
11463 return error::kInvalidArguments;
11464 }
11465 memcpy(mem, ptr, size);
11466 glUnmapBuffer(target);
11467
11468 GLenum error = LOCAL_PEEK_GL_ERROR("glGetBufferSubDataAsyncCHROMIUM");
11469 if (error != GL_NO_ERROR) {
11470 return error::kInvalidArguments;
11471 }
11472 return error::kNoError;
11473 }
11474
11423 error::Error GLES2DecoderImpl::GetUniformLocationHelper( 11475 error::Error GLES2DecoderImpl::GetUniformLocationHelper(
11424 GLuint client_id, 11476 GLuint client_id,
11425 uint32_t location_shm_id, 11477 uint32_t location_shm_id,
11426 uint32_t location_shm_offset, 11478 uint32_t location_shm_offset,
11427 const std::string& name_str) { 11479 const std::string& name_str) {
11428 if (!StringIsValidForGLES(name_str)) { 11480 if (!StringIsValidForGLES(name_str)) {
11429 LOCAL_SET_GL_ERROR( 11481 LOCAL_SET_GL_ERROR(
11430 GL_INVALID_VALUE, "glGetUniformLocation", "Invalid character"); 11482 GL_INVALID_VALUE, "glGetUniformLocation", "Invalid character");
11431 return error::kNoError; 11483 return error::kNoError;
11432 } 11484 }
(...skipping 6812 matching lines...) Expand 10 before | Expand all | Expand 10 after
18245 } 18297 }
18246 18298
18247 // Include the auto-generated part of this file. We split this because it means 18299 // Include the auto-generated part of this file. We split this because it means
18248 // we can easily edit the non-auto generated parts right here in this file 18300 // we can easily edit the non-auto generated parts right here in this file
18249 // instead of having to edit some template or the code generator. 18301 // instead of having to edit some template or the code generator.
18250 #include "base/macros.h" 18302 #include "base/macros.h"
18251 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 18303 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
18252 18304
18253 } // namespace gles2 18305 } // namespace gles2
18254 } // namespace gpu 18306 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698