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

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

Issue 1843663007: gpu: Pull some variables onto the stack in the decoder CQ_INCLUDE_TRYBOTS=tryserver.chromium.win:wi… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
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 8839 matching lines...) Expand 10 before | Expand all | Expand 10 after
8850 } 8850 }
8851 8851
8852 error::Error GLES2DecoderImpl::HandleVertexAttribIPointer( 8852 error::Error GLES2DecoderImpl::HandleVertexAttribIPointer(
8853 uint32_t immediate_data_size, 8853 uint32_t immediate_data_size,
8854 const void* cmd_data) { 8854 const void* cmd_data) {
8855 if (!unsafe_es3_apis_enabled()) 8855 if (!unsafe_es3_apis_enabled())
8856 return error::kUnknownCommand; 8856 return error::kUnknownCommand;
8857 const gles2::cmds::VertexAttribIPointer& c = 8857 const gles2::cmds::VertexAttribIPointer& c =
8858 *static_cast<const gles2::cmds::VertexAttribIPointer*>(cmd_data); 8858 *static_cast<const gles2::cmds::VertexAttribIPointer*>(cmd_data);
8859 8859
8860 GLsizei offset = c.offset;
8860 if (!state_.bound_array_buffer.get() || 8861 if (!state_.bound_array_buffer.get() ||
8861 state_.bound_array_buffer->IsDeleted()) { 8862 state_.bound_array_buffer->IsDeleted()) {
8862 if (state_.vertex_attrib_manager.get() == 8863 if (state_.vertex_attrib_manager.get() ==
8863 state_.default_vertex_attrib_manager.get()) { 8864 state_.default_vertex_attrib_manager.get()) {
8864 LOCAL_SET_GL_ERROR( 8865 LOCAL_SET_GL_ERROR(
8865 GL_INVALID_OPERATION, 8866 GL_INVALID_OPERATION,
8866 "glVertexAttribIPointer", "no array buffer bound"); 8867 "glVertexAttribIPointer", "no array buffer bound");
8867 return error::kNoError; 8868 return error::kNoError;
8868 } else if (c.offset != 0) { 8869 } else if (offset != 0) {
8869 LOCAL_SET_GL_ERROR( 8870 LOCAL_SET_GL_ERROR(
8870 GL_INVALID_OPERATION, 8871 GL_INVALID_OPERATION,
8871 "glVertexAttribIPointer", "client side arrays are not allowed"); 8872 "glVertexAttribIPointer", "client side arrays are not allowed");
8872 return error::kNoError; 8873 return error::kNoError;
8873 } 8874 }
8874 } 8875 }
8875 8876
8876 GLuint indx = c.indx; 8877 GLuint indx = c.indx;
8877 GLint size = c.size; 8878 GLint size = c.size;
8878 GLenum type = c.type; 8879 GLenum type = c.type;
8879 GLsizei stride = c.stride; 8880 GLsizei stride = c.stride;
8880 GLsizei offset = c.offset;
8881 const void* ptr = reinterpret_cast<const void*>(offset); 8881 const void* ptr = reinterpret_cast<const void*>(offset);
8882 if (!validators_->vertex_attrib_i_type.IsValid(type)) { 8882 if (!validators_->vertex_attrib_i_type.IsValid(type)) {
8883 LOCAL_SET_GL_ERROR_INVALID_ENUM("glVertexAttribIPointer", type, "type"); 8883 LOCAL_SET_GL_ERROR_INVALID_ENUM("glVertexAttribIPointer", type, "type");
8884 return error::kNoError; 8884 return error::kNoError;
8885 } 8885 }
8886 if (size < 1 || size > 4) { 8886 if (size < 1 || size > 4) {
8887 LOCAL_SET_GL_ERROR( 8887 LOCAL_SET_GL_ERROR(
8888 GL_INVALID_VALUE, "glVertexAttribIPointer", "size GL_INVALID_VALUE"); 8888 GL_INVALID_VALUE, "glVertexAttribIPointer", "size GL_INVALID_VALUE");
8889 return error::kNoError; 8889 return error::kNoError;
8890 } 8890 }
(...skipping 3937 matching lines...) Expand 10 before | Expand all | Expand 10 after
12828 uint32_t immediate_data_size, 12828 uint32_t immediate_data_size,
12829 const void* cmd_data) { 12829 const void* cmd_data) {
12830 const gles2::cmds::WaitSyncTokenCHROMIUM& c = 12830 const gles2::cmds::WaitSyncTokenCHROMIUM& c =
12831 *static_cast<const gles2::cmds::WaitSyncTokenCHROMIUM*>(cmd_data); 12831 *static_cast<const gles2::cmds::WaitSyncTokenCHROMIUM*>(cmd_data);
12832 12832
12833 const gpu::CommandBufferNamespace kMinNamespaceId = 12833 const gpu::CommandBufferNamespace kMinNamespaceId =
12834 gpu::CommandBufferNamespace::INVALID; 12834 gpu::CommandBufferNamespace::INVALID;
12835 const gpu::CommandBufferNamespace kMaxNamespaceId = 12835 const gpu::CommandBufferNamespace kMaxNamespaceId =
12836 gpu::CommandBufferNamespace::NUM_COMMAND_BUFFER_NAMESPACES; 12836 gpu::CommandBufferNamespace::NUM_COMMAND_BUFFER_NAMESPACES;
12837 12837
12838 const gpu::CommandBufferNamespace namespace_id = 12838 gpu::CommandBufferNamespace namespace_id =
12839 ((c.namespace_id >= static_cast<int32_t>(kMinNamespaceId)) && 12839 static_cast<gpu::CommandBufferNamespace>(c.namespace_id);
12840 (c.namespace_id < static_cast<int32_t>(kMaxNamespaceId))) 12840 if ((namespace_id < static_cast<int32_t>(kMinNamespaceId)) &&
12841 ? static_cast<gpu::CommandBufferNamespace>(c.namespace_id) 12841 (namespace_id >= static_cast<int32_t>(kMaxNamespaceId))) {
12842 : gpu::CommandBufferNamespace::INVALID; 12842 namespace_id = gpu::CommandBufferNamespace::INVALID;
12843 }
12843 const CommandBufferId command_buffer_id = 12844 const CommandBufferId command_buffer_id =
12844 CommandBufferId::FromUnsafeValue(c.command_buffer_id()); 12845 CommandBufferId::FromUnsafeValue(c.command_buffer_id());
12845 const uint64_t release = c.release_count(); 12846 const uint64_t release = c.release_count();
12846 if (wait_fence_sync_callback_.is_null()) 12847 if (wait_fence_sync_callback_.is_null())
12847 return error::kNoError; 12848 return error::kNoError;
12848 12849
12849 return wait_fence_sync_callback_.Run(namespace_id, command_buffer_id, release) 12850 return wait_fence_sync_callback_.Run(namespace_id, command_buffer_id, release)
12850 ? error::kNoError 12851 ? error::kNoError
12851 : error::kDeferCommandUntilLater; 12852 : error::kDeferCommandUntilLater;
12852 } 12853 }
(...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after
14165 "mailbox[0]", static_cast<unsigned char>(data[0])); 14166 "mailbox[0]", static_cast<unsigned char>(data[0]));
14166 14167
14167 ProduceTextureRef("glProduceTextureDirectCHROMIUM", GetTexture(client_id), 14168 ProduceTextureRef("glProduceTextureDirectCHROMIUM", GetTexture(client_id),
14168 target, data); 14169 target, data);
14169 } 14170 }
14170 14171
14171 void GLES2DecoderImpl::ProduceTextureRef(const char* func_name, 14172 void GLES2DecoderImpl::ProduceTextureRef(const char* func_name,
14172 TextureRef* texture_ref, 14173 TextureRef* texture_ref,
14173 GLenum target, 14174 GLenum target,
14174 const GLbyte* data) { 14175 const GLbyte* data) {
14175 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); 14176 const Mailbox mailbox = *reinterpret_cast<const Mailbox*>(data);
14176 DLOG_IF(ERROR, !mailbox.Verify()) << func_name << " was passed a " 14177 DLOG_IF(ERROR, !mailbox.Verify()) << func_name << " was passed a "
14177 "mailbox that was not generated by " 14178 "mailbox that was not generated by "
14178 "GenMailboxCHROMIUM."; 14179 "GenMailboxCHROMIUM.";
14179 14180
14180 if (!texture_ref) { 14181 if (!texture_ref) {
14181 LOCAL_SET_GL_ERROR( 14182 LOCAL_SET_GL_ERROR(
14182 GL_INVALID_OPERATION, func_name, "unknown texture for target"); 14183 GL_INVALID_OPERATION, func_name, "unknown texture for target");
14183 return; 14184 return;
14184 } 14185 }
14185 14186
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
14759 uint32_t immediate_data_size, const void* cmd_data) { 14760 uint32_t immediate_data_size, const void* cmd_data) {
14760 if (!unsafe_es3_apis_enabled()) { 14761 if (!unsafe_es3_apis_enabled()) {
14761 return error::kUnknownCommand; 14762 return error::kUnknownCommand;
14762 } 14763 }
14763 const gles2::cmds::MapBufferRange& c = 14764 const gles2::cmds::MapBufferRange& c =
14764 *static_cast<const gles2::cmds::MapBufferRange*>(cmd_data); 14765 *static_cast<const gles2::cmds::MapBufferRange*>(cmd_data);
14765 GLenum target = static_cast<GLenum>(c.target); 14766 GLenum target = static_cast<GLenum>(c.target);
14766 GLbitfield access = static_cast<GLbitfield>(c.access); 14767 GLbitfield access = static_cast<GLbitfield>(c.access);
14767 GLintptr offset = static_cast<GLintptr>(c.offset); 14768 GLintptr offset = static_cast<GLintptr>(c.offset);
14768 GLsizeiptr size = static_cast<GLsizeiptr>(c.size); 14769 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
14770 uint32_t data_shm_id = static_cast<uint32_t>(c.data_shm_id);
14769 14771
14770 typedef cmds::MapBufferRange::Result Result; 14772 typedef cmds::MapBufferRange::Result Result;
14771 Result* result = GetSharedMemoryAs<Result*>( 14773 Result* result = GetSharedMemoryAs<Result*>(
14772 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 14774 c.result_shm_id, c.result_shm_offset, sizeof(*result));
14773 if (!result) { 14775 if (!result) {
14774 return error::kOutOfBounds; 14776 return error::kOutOfBounds;
14775 } 14777 }
14776 if (*result != 0) { 14778 if (*result != 0) {
14777 *result = 0; 14779 *result = 0;
14778 return error::kInvalidArguments; 14780 return error::kInvalidArguments;
14779 } 14781 }
14780 int8_t* mem = 14782 int8_t* mem =
14781 GetSharedMemoryAs<int8_t*>(c.data_shm_id, c.data_shm_offset, size); 14783 GetSharedMemoryAs<int8_t*>(data_shm_id, c.data_shm_offset, size);
14782 if (!mem) { 14784 if (!mem) {
14783 return error::kOutOfBounds; 14785 return error::kOutOfBounds;
14784 } 14786 }
14785 14787
14786 GLbitfield mask = GL_MAP_INVALIDATE_BUFFER_BIT; 14788 GLbitfield mask = GL_MAP_INVALIDATE_BUFFER_BIT;
14787 if ((access & mask) == mask) { 14789 if ((access & mask) == mask) {
14788 // TODO(zmo): To be on the safe side, always map 14790 // TODO(zmo): To be on the safe side, always map
14789 // GL_MAP_INVALIDATE_BUFFER_BIT to GL_MAP_INVALIDATE_RANGE_BIT. 14791 // GL_MAP_INVALIDATE_BUFFER_BIT to GL_MAP_INVALIDATE_RANGE_BIT.
14790 access = (access & ~GL_MAP_INVALIDATE_BUFFER_BIT); 14792 access = (access & ~GL_MAP_INVALIDATE_BUFFER_BIT);
14791 access = (access | GL_MAP_INVALIDATE_RANGE_BIT); 14793 access = (access | GL_MAP_INVALIDATE_RANGE_BIT);
(...skipping 11 matching lines...) Expand all
14803 (access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) { 14805 (access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) {
14804 access = (access | GL_MAP_READ_BIT); 14806 access = (access | GL_MAP_READ_BIT);
14805 } 14807 }
14806 void* ptr = glMapBufferRange(target, offset, size, access); 14808 void* ptr = glMapBufferRange(target, offset, size, access);
14807 if (ptr == nullptr) { 14809 if (ptr == nullptr) {
14808 return error::kNoError; 14810 return error::kNoError;
14809 } 14811 }
14810 Buffer* buffer = buffer_manager()->GetBufferInfoForTarget(&state_, target); 14812 Buffer* buffer = buffer_manager()->GetBufferInfoForTarget(&state_, target);
14811 DCHECK(buffer); 14813 DCHECK(buffer);
14812 buffer->SetMappedRange(offset, size, access, ptr, 14814 buffer->SetMappedRange(offset, size, access, ptr,
14813 GetSharedMemoryBuffer(c.data_shm_id)); 14815 GetSharedMemoryBuffer(data_shm_id));
14814 if ((access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) { 14816 if ((access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) {
14815 memcpy(mem, ptr, size); 14817 memcpy(mem, ptr, size);
14816 } 14818 }
14817 *result = 1; 14819 *result = 1;
14818 return error::kNoError; 14820 return error::kNoError;
14819 } 14821 }
14820 14822
14821 error::Error GLES2DecoderImpl::HandleUnmapBuffer( 14823 error::Error GLES2DecoderImpl::HandleUnmapBuffer(
14822 uint32_t immediate_data_size, const void* cmd_data) { 14824 uint32_t immediate_data_size, const void* cmd_data) {
14823 if (!unsafe_es3_apis_enabled()) { 14825 if (!unsafe_es3_apis_enabled()) {
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
15946 } 15948 }
15947 15949
15948 // Include the auto-generated part of this file. We split this because it means 15950 // Include the auto-generated part of this file. We split this because it means
15949 // we can easily edit the non-auto generated parts right here in this file 15951 // we can easily edit the non-auto generated parts right here in this file
15950 // instead of having to edit some template or the code generator. 15952 // instead of having to edit some template or the code generator.
15951 #include "base/macros.h" 15953 #include "base/macros.h"
15952 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15954 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15953 15955
15954 } // namespace gles2 15956 } // namespace gles2
15955 } // namespace gpu 15957 } // 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