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

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

Issue 1836603002: gpu: Pull some variables onto the stack in the decoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « gpu/command_buffer/service/common_decoder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8940 matching lines...) Expand 10 before | Expand all | Expand 10 after
8951 } 8951 }
8952 8952
8953 error::Error GLES2DecoderImpl::HandleVertexAttribIPointer( 8953 error::Error GLES2DecoderImpl::HandleVertexAttribIPointer(
8954 uint32_t immediate_data_size, 8954 uint32_t immediate_data_size,
8955 const void* cmd_data) { 8955 const void* cmd_data) {
8956 if (!unsafe_es3_apis_enabled()) 8956 if (!unsafe_es3_apis_enabled())
8957 return error::kUnknownCommand; 8957 return error::kUnknownCommand;
8958 const gles2::cmds::VertexAttribIPointer& c = 8958 const gles2::cmds::VertexAttribIPointer& c =
8959 *static_cast<const gles2::cmds::VertexAttribIPointer*>(cmd_data); 8959 *static_cast<const gles2::cmds::VertexAttribIPointer*>(cmd_data);
8960 8960
8961 GLsizei offset = c.offset;
8961 if (!state_.bound_array_buffer.get() || 8962 if (!state_.bound_array_buffer.get() ||
8962 state_.bound_array_buffer->IsDeleted()) { 8963 state_.bound_array_buffer->IsDeleted()) {
8963 if (state_.vertex_attrib_manager.get() == 8964 if (state_.vertex_attrib_manager.get() ==
8964 state_.default_vertex_attrib_manager.get()) { 8965 state_.default_vertex_attrib_manager.get()) {
8965 LOCAL_SET_GL_ERROR( 8966 LOCAL_SET_GL_ERROR(
8966 GL_INVALID_OPERATION, 8967 GL_INVALID_OPERATION,
8967 "glVertexAttribIPointer", "no array buffer bound"); 8968 "glVertexAttribIPointer", "no array buffer bound");
8968 return error::kNoError; 8969 return error::kNoError;
8969 } else if (c.offset != 0) { 8970 } else if (offset != 0) {
8970 LOCAL_SET_GL_ERROR( 8971 LOCAL_SET_GL_ERROR(
8971 GL_INVALID_OPERATION, 8972 GL_INVALID_OPERATION,
8972 "glVertexAttribIPointer", "client side arrays are not allowed"); 8973 "glVertexAttribIPointer", "client side arrays are not allowed");
8973 return error::kNoError; 8974 return error::kNoError;
8974 } 8975 }
8975 } 8976 }
8976 8977
8977 GLuint indx = c.indx; 8978 GLuint indx = c.indx;
8978 GLint size = c.size; 8979 GLint size = c.size;
8979 GLenum type = c.type; 8980 GLenum type = c.type;
8980 GLsizei stride = c.stride; 8981 GLsizei stride = c.stride;
8981 GLsizei offset = c.offset;
8982 const void* ptr = reinterpret_cast<const void*>(offset); 8982 const void* ptr = reinterpret_cast<const void*>(offset);
8983 if (!validators_->vertex_attrib_i_type.IsValid(type)) { 8983 if (!validators_->vertex_attrib_i_type.IsValid(type)) {
8984 LOCAL_SET_GL_ERROR_INVALID_ENUM("glVertexAttribIPointer", type, "type"); 8984 LOCAL_SET_GL_ERROR_INVALID_ENUM("glVertexAttribIPointer", type, "type");
8985 return error::kNoError; 8985 return error::kNoError;
8986 } 8986 }
8987 if (size < 1 || size > 4) { 8987 if (size < 1 || size > 4) {
8988 LOCAL_SET_GL_ERROR( 8988 LOCAL_SET_GL_ERROR(
8989 GL_INVALID_VALUE, "glVertexAttribIPointer", "size GL_INVALID_VALUE"); 8989 GL_INVALID_VALUE, "glVertexAttribIPointer", "size GL_INVALID_VALUE");
8990 return error::kNoError; 8990 return error::kNoError;
8991 } 8991 }
(...skipping 4150 matching lines...) Expand 10 before | Expand all | Expand 10 after
13142 uint32_t immediate_data_size, 13142 uint32_t immediate_data_size,
13143 const void* cmd_data) { 13143 const void* cmd_data) {
13144 const gles2::cmds::WaitSyncTokenCHROMIUM& c = 13144 const gles2::cmds::WaitSyncTokenCHROMIUM& c =
13145 *static_cast<const gles2::cmds::WaitSyncTokenCHROMIUM*>(cmd_data); 13145 *static_cast<const gles2::cmds::WaitSyncTokenCHROMIUM*>(cmd_data);
13146 13146
13147 const gpu::CommandBufferNamespace kMinNamespaceId = 13147 const gpu::CommandBufferNamespace kMinNamespaceId =
13148 gpu::CommandBufferNamespace::INVALID; 13148 gpu::CommandBufferNamespace::INVALID;
13149 const gpu::CommandBufferNamespace kMaxNamespaceId = 13149 const gpu::CommandBufferNamespace kMaxNamespaceId =
13150 gpu::CommandBufferNamespace::NUM_COMMAND_BUFFER_NAMESPACES; 13150 gpu::CommandBufferNamespace::NUM_COMMAND_BUFFER_NAMESPACES;
13151 13151
13152 const gpu::CommandBufferNamespace namespace_id = 13152 gpu::CommandBufferNamespace namespace_id =
13153 ((c.namespace_id >= static_cast<int32_t>(kMinNamespaceId)) && 13153 static_cast<gpu::CommandBufferNamespace>(c.namespace_id);
13154 (c.namespace_id < static_cast<int32_t>(kMaxNamespaceId))) 13154 if ((namespace_id < static_cast<int32_t>(kMinNamespaceId)) &&
13155 ? static_cast<gpu::CommandBufferNamespace>(c.namespace_id) 13155 (namespace_id >= static_cast<int32_t>(kMaxNamespaceId))) {
13156 : gpu::CommandBufferNamespace::INVALID; 13156 namespace_id = gpu::CommandBufferNamespace::INVALID;
13157 }
13157 const CommandBufferId command_buffer_id = 13158 const CommandBufferId command_buffer_id =
13158 CommandBufferId::FromUnsafeValue(c.command_buffer_id()); 13159 CommandBufferId::FromUnsafeValue(c.command_buffer_id());
13159 const uint64_t release = c.release_count(); 13160 const uint64_t release = c.release_count();
13160 if (wait_fence_sync_callback_.is_null()) 13161 if (wait_fence_sync_callback_.is_null())
13161 return error::kNoError; 13162 return error::kNoError;
13162 13163
13163 return wait_fence_sync_callback_.Run(namespace_id, command_buffer_id, release) 13164 return wait_fence_sync_callback_.Run(namespace_id, command_buffer_id, release)
13164 ? error::kNoError 13165 ? error::kNoError
13165 : error::kDeferCommandUntilLater; 13166 : error::kDeferCommandUntilLater;
13166 } 13167 }
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after
14483 "mailbox[0]", static_cast<unsigned char>(data[0])); 14484 "mailbox[0]", static_cast<unsigned char>(data[0]));
14484 14485
14485 ProduceTextureRef("glProduceTextureDirectCHROMIUM", GetTexture(client_id), 14486 ProduceTextureRef("glProduceTextureDirectCHROMIUM", GetTexture(client_id),
14486 target, data); 14487 target, data);
14487 } 14488 }
14488 14489
14489 void GLES2DecoderImpl::ProduceTextureRef(const char* func_name, 14490 void GLES2DecoderImpl::ProduceTextureRef(const char* func_name,
14490 TextureRef* texture_ref, 14491 TextureRef* texture_ref,
14491 GLenum target, 14492 GLenum target,
14492 const GLbyte* data) { 14493 const GLbyte* data) {
14493 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); 14494 const Mailbox mailbox = *reinterpret_cast<const Mailbox*>(data);
14494 DLOG_IF(ERROR, !mailbox.Verify()) << func_name << " was passed a " 14495 DLOG_IF(ERROR, !mailbox.Verify()) << func_name << " was passed a "
14495 "mailbox that was not generated by " 14496 "mailbox that was not generated by "
14496 "GenMailboxCHROMIUM."; 14497 "GenMailboxCHROMIUM.";
14497 14498
14498 if (!texture_ref) { 14499 if (!texture_ref) {
14499 LOCAL_SET_GL_ERROR( 14500 LOCAL_SET_GL_ERROR(
14500 GL_INVALID_OPERATION, func_name, "unknown texture for target"); 14501 GL_INVALID_OPERATION, func_name, "unknown texture for target");
14501 return; 14502 return;
14502 } 14503 }
14503 14504
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
15077 uint32_t immediate_data_size, const void* cmd_data) { 15078 uint32_t immediate_data_size, const void* cmd_data) {
15078 if (!unsafe_es3_apis_enabled()) { 15079 if (!unsafe_es3_apis_enabled()) {
15079 return error::kUnknownCommand; 15080 return error::kUnknownCommand;
15080 } 15081 }
15081 const gles2::cmds::MapBufferRange& c = 15082 const gles2::cmds::MapBufferRange& c =
15082 *static_cast<const gles2::cmds::MapBufferRange*>(cmd_data); 15083 *static_cast<const gles2::cmds::MapBufferRange*>(cmd_data);
15083 GLenum target = static_cast<GLenum>(c.target); 15084 GLenum target = static_cast<GLenum>(c.target);
15084 GLbitfield access = static_cast<GLbitfield>(c.access); 15085 GLbitfield access = static_cast<GLbitfield>(c.access);
15085 GLintptr offset = static_cast<GLintptr>(c.offset); 15086 GLintptr offset = static_cast<GLintptr>(c.offset);
15086 GLsizeiptr size = static_cast<GLsizeiptr>(c.size); 15087 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
15088 uint32_t data_shm_id = static_cast<uint32_t>(c.data_shm_id);
15087 15089
15088 typedef cmds::MapBufferRange::Result Result; 15090 typedef cmds::MapBufferRange::Result Result;
15089 Result* result = GetSharedMemoryAs<Result*>( 15091 Result* result = GetSharedMemoryAs<Result*>(
15090 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 15092 c.result_shm_id, c.result_shm_offset, sizeof(*result));
15091 if (!result) { 15093 if (!result) {
15092 return error::kOutOfBounds; 15094 return error::kOutOfBounds;
15093 } 15095 }
15094 if (*result != 0) { 15096 if (*result != 0) {
15095 *result = 0; 15097 *result = 0;
15096 return error::kInvalidArguments; 15098 return error::kInvalidArguments;
15097 } 15099 }
15098 int8_t* mem = 15100 int8_t* mem =
15099 GetSharedMemoryAs<int8_t*>(c.data_shm_id, c.data_shm_offset, size); 15101 GetSharedMemoryAs<int8_t*>(data_shm_id, c.data_shm_offset, size);
15100 if (!mem) { 15102 if (!mem) {
15101 return error::kOutOfBounds; 15103 return error::kOutOfBounds;
15102 } 15104 }
15103 15105
15104 GLbitfield mask = GL_MAP_INVALIDATE_BUFFER_BIT; 15106 GLbitfield mask = GL_MAP_INVALIDATE_BUFFER_BIT;
15105 if ((access & mask) == mask) { 15107 if ((access & mask) == mask) {
15106 // TODO(zmo): To be on the safe side, always map 15108 // TODO(zmo): To be on the safe side, always map
15107 // GL_MAP_INVALIDATE_BUFFER_BIT to GL_MAP_INVALIDATE_RANGE_BIT. 15109 // GL_MAP_INVALIDATE_BUFFER_BIT to GL_MAP_INVALIDATE_RANGE_BIT.
15108 access = (access & ~GL_MAP_INVALIDATE_BUFFER_BIT); 15110 access = (access & ~GL_MAP_INVALIDATE_BUFFER_BIT);
15109 access = (access | GL_MAP_INVALIDATE_RANGE_BIT); 15111 access = (access | GL_MAP_INVALIDATE_RANGE_BIT);
(...skipping 11 matching lines...) Expand all
15121 (access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) { 15123 (access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) {
15122 access = (access | GL_MAP_READ_BIT); 15124 access = (access | GL_MAP_READ_BIT);
15123 } 15125 }
15124 void* ptr = glMapBufferRange(target, offset, size, access); 15126 void* ptr = glMapBufferRange(target, offset, size, access);
15125 if (ptr == nullptr) { 15127 if (ptr == nullptr) {
15126 return error::kNoError; 15128 return error::kNoError;
15127 } 15129 }
15128 Buffer* buffer = buffer_manager()->GetBufferInfoForTarget(&state_, target); 15130 Buffer* buffer = buffer_manager()->GetBufferInfoForTarget(&state_, target);
15129 DCHECK(buffer); 15131 DCHECK(buffer);
15130 buffer->SetMappedRange(offset, size, access, ptr, 15132 buffer->SetMappedRange(offset, size, access, ptr,
15131 GetSharedMemoryBuffer(c.data_shm_id)); 15133 GetSharedMemoryBuffer(data_shm_id));
15132 if ((access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) { 15134 if ((access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) {
15133 memcpy(mem, ptr, size); 15135 memcpy(mem, ptr, size);
15134 } 15136 }
15135 *result = 1; 15137 *result = 1;
15136 return error::kNoError; 15138 return error::kNoError;
15137 } 15139 }
15138 15140
15139 error::Error GLES2DecoderImpl::HandleUnmapBuffer( 15141 error::Error GLES2DecoderImpl::HandleUnmapBuffer(
15140 uint32_t immediate_data_size, const void* cmd_data) { 15142 uint32_t immediate_data_size, const void* cmd_data) {
15141 if (!unsafe_es3_apis_enabled()) { 15143 if (!unsafe_es3_apis_enabled()) {
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
16333 } 16335 }
16334 16336
16335 // Include the auto-generated part of this file. We split this because it means 16337 // Include the auto-generated part of this file. We split this because it means
16336 // we can easily edit the non-auto generated parts right here in this file 16338 // we can easily edit the non-auto generated parts right here in this file
16337 // instead of having to edit some template or the code generator. 16339 // instead of having to edit some template or the code generator.
16338 #include "base/macros.h" 16340 #include "base/macros.h"
16339 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 16341 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
16340 16342
16341 } // namespace gles2 16343 } // namespace gles2
16342 } // namespace gpu 16344 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/common_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698