| OLD | NEW |
| 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 8890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8901 if (stride > 255) { | 8901 if (stride > 255) { |
| 8902 LOCAL_SET_GL_ERROR( | 8902 LOCAL_SET_GL_ERROR( |
| 8903 GL_INVALID_VALUE, "glVertexAttribIPointer", "stride > 255"); | 8903 GL_INVALID_VALUE, "glVertexAttribIPointer", "stride > 255"); |
| 8904 return error::kNoError; | 8904 return error::kNoError; |
| 8905 } | 8905 } |
| 8906 if (offset < 0) { | 8906 if (offset < 0) { |
| 8907 LOCAL_SET_GL_ERROR( | 8907 LOCAL_SET_GL_ERROR( |
| 8908 GL_INVALID_VALUE, "glVertexAttribIPointer", "offset < 0"); | 8908 GL_INVALID_VALUE, "glVertexAttribIPointer", "offset < 0"); |
| 8909 return error::kNoError; | 8909 return error::kNoError; |
| 8910 } | 8910 } |
| 8911 GLsizei component_size = | 8911 GLsizei type_size = GLES2Util::GetGLTypeSizeForBuffers(type); |
| 8912 GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type); | 8912 // type_size must be a power of two to use & as optimized modulo. |
| 8913 // component_size must be a power of two to use & as optimized modulo. | 8913 DCHECK(GLES2Util::IsPOT(type_size)); |
| 8914 DCHECK(GLES2Util::IsPOT(component_size)); | 8914 if (offset & (type_size - 1)) { |
| 8915 if (offset & (component_size - 1)) { | |
| 8916 LOCAL_SET_GL_ERROR( | 8915 LOCAL_SET_GL_ERROR( |
| 8917 GL_INVALID_OPERATION, | 8916 GL_INVALID_OPERATION, |
| 8918 "glVertexAttribIPointer", "offset not valid for type"); | 8917 "glVertexAttribIPointer", "offset not valid for type"); |
| 8919 return error::kNoError; | 8918 return error::kNoError; |
| 8920 } | 8919 } |
| 8921 if (stride & (component_size - 1)) { | 8920 if (stride & (type_size - 1)) { |
| 8922 LOCAL_SET_GL_ERROR( | 8921 LOCAL_SET_GL_ERROR( |
| 8923 GL_INVALID_OPERATION, | 8922 GL_INVALID_OPERATION, |
| 8924 "glVertexAttribIPointer", "stride not valid for type"); | 8923 "glVertexAttribIPointer", "stride not valid for type"); |
| 8925 return error::kNoError; | 8924 return error::kNoError; |
| 8926 } | 8925 } |
| 8926 GLsizei group_size = GLES2Util::GetGroupSizeForBufferType(size, type); |
| 8927 state_.vertex_attrib_manager | 8927 state_.vertex_attrib_manager |
| 8928 ->SetAttribInfo(indx, | 8928 ->SetAttribInfo(indx, |
| 8929 state_.bound_array_buffer.get(), | 8929 state_.bound_array_buffer.get(), |
| 8930 size, | 8930 size, |
| 8931 type, | 8931 type, |
| 8932 GL_FALSE, | 8932 GL_FALSE, |
| 8933 stride, | 8933 stride, |
| 8934 stride != 0 ? stride : component_size * size, | 8934 stride != 0 ? stride : group_size, |
| 8935 offset, | 8935 offset, |
| 8936 GL_TRUE); | 8936 GL_TRUE); |
| 8937 glVertexAttribIPointer(indx, size, type, stride, ptr); | 8937 glVertexAttribIPointer(indx, size, type, stride, ptr); |
| 8938 return error::kNoError; | 8938 return error::kNoError; |
| 8939 } | 8939 } |
| 8940 | 8940 |
| 8941 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( | 8941 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( |
| 8942 uint32_t immediate_data_size, | 8942 uint32_t immediate_data_size, |
| 8943 const void* cmd_data) { | 8943 const void* cmd_data) { |
| 8944 const gles2::cmds::VertexAttribPointer& c = | 8944 const gles2::cmds::VertexAttribPointer& c = |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8995 if (stride > 255) { | 8995 if (stride > 255) { |
| 8996 LOCAL_SET_GL_ERROR( | 8996 LOCAL_SET_GL_ERROR( |
| 8997 GL_INVALID_VALUE, "glVertexAttribPointer", "stride > 255"); | 8997 GL_INVALID_VALUE, "glVertexAttribPointer", "stride > 255"); |
| 8998 return error::kNoError; | 8998 return error::kNoError; |
| 8999 } | 8999 } |
| 9000 if (offset < 0) { | 9000 if (offset < 0) { |
| 9001 LOCAL_SET_GL_ERROR( | 9001 LOCAL_SET_GL_ERROR( |
| 9002 GL_INVALID_VALUE, "glVertexAttribPointer", "offset < 0"); | 9002 GL_INVALID_VALUE, "glVertexAttribPointer", "offset < 0"); |
| 9003 return error::kNoError; | 9003 return error::kNoError; |
| 9004 } | 9004 } |
| 9005 GLsizei component_size = | 9005 GLsizei type_size = GLES2Util::GetGLTypeSizeForBuffers(type); |
| 9006 GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type); | 9006 // type_size must be a power of two to use & as optimized modulo. |
| 9007 // component_size must be a power of two to use & as optimized modulo. | 9007 DCHECK(GLES2Util::IsPOT(type_size)); |
| 9008 DCHECK(GLES2Util::IsPOT(component_size)); | 9008 if (offset & (type_size - 1)) { |
| 9009 if (offset & (component_size - 1)) { | |
| 9010 LOCAL_SET_GL_ERROR( | 9009 LOCAL_SET_GL_ERROR( |
| 9011 GL_INVALID_OPERATION, | 9010 GL_INVALID_OPERATION, |
| 9012 "glVertexAttribPointer", "offset not valid for type"); | 9011 "glVertexAttribPointer", "offset not valid for type"); |
| 9013 return error::kNoError; | 9012 return error::kNoError; |
| 9014 } | 9013 } |
| 9015 if (stride & (component_size - 1)) { | 9014 if (stride & (type_size - 1)) { |
| 9016 LOCAL_SET_GL_ERROR( | 9015 LOCAL_SET_GL_ERROR( |
| 9017 GL_INVALID_OPERATION, | 9016 GL_INVALID_OPERATION, |
| 9018 "glVertexAttribPointer", "stride not valid for type"); | 9017 "glVertexAttribPointer", "stride not valid for type"); |
| 9019 return error::kNoError; | 9018 return error::kNoError; |
| 9020 } | 9019 } |
| 9020 GLsizei group_size = GLES2Util::GetGroupSizeForBufferType(size, type); |
| 9021 state_.vertex_attrib_manager | 9021 state_.vertex_attrib_manager |
| 9022 ->SetAttribInfo(indx, | 9022 ->SetAttribInfo(indx, |
| 9023 state_.bound_array_buffer.get(), | 9023 state_.bound_array_buffer.get(), |
| 9024 size, | 9024 size, |
| 9025 type, | 9025 type, |
| 9026 normalized, | 9026 normalized, |
| 9027 stride, | 9027 stride, |
| 9028 stride != 0 ? stride : component_size * size, | 9028 stride != 0 ? stride : group_size, |
| 9029 offset, | 9029 offset, |
| 9030 GL_FALSE); | 9030 GL_FALSE); |
| 9031 // We support GL_FIXED natively on EGL/GLES2 implementations | 9031 // We support GL_FIXED natively on EGL/GLES2 implementations |
| 9032 if (type != GL_FIXED || feature_info_->gl_version_info().is_es) { | 9032 if (type != GL_FIXED || feature_info_->gl_version_info().is_es) { |
| 9033 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); | 9033 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); |
| 9034 } | 9034 } |
| 9035 return error::kNoError; | 9035 return error::kNoError; |
| 9036 } | 9036 } |
| 9037 | 9037 |
| 9038 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width, | 9038 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width, |
| (...skipping 6911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15950 } | 15950 } |
| 15951 | 15951 |
| 15952 // Include the auto-generated part of this file. We split this because it means | 15952 // Include the auto-generated part of this file. We split this because it means |
| 15953 // we can easily edit the non-auto generated parts right here in this file | 15953 // we can easily edit the non-auto generated parts right here in this file |
| 15954 // instead of having to edit some template or the code generator. | 15954 // instead of having to edit some template or the code generator. |
| 15955 #include "base/macros.h" | 15955 #include "base/macros.h" |
| 15956 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15956 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 15957 | 15957 |
| 15958 } // namespace gles2 | 15958 } // namespace gles2 |
| 15959 } // namespace gpu | 15959 } // namespace gpu |
| OLD | NEW |