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 <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 7686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7697 | 7697 |
7698 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { | 7698 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { |
7699 if (SetVertexAttribValue("glVertexAttrib4fv", index, v)) { | 7699 if (SetVertexAttribValue("glVertexAttrib4fv", index, v)) { |
7700 glVertexAttrib4fv(index, v); | 7700 glVertexAttrib4fv(index, v); |
7701 } | 7701 } |
7702 } | 7702 } |
7703 | 7703 |
7704 error::Error GLES2DecoderImpl::HandleVertexAttribIPointer( | 7704 error::Error GLES2DecoderImpl::HandleVertexAttribIPointer( |
7705 uint32 immediate_data_size, | 7705 uint32 immediate_data_size, |
7706 const void* cmd_data) { | 7706 const void* cmd_data) { |
7707 // TODO(zmo): Unsafe ES3 API, missing states update. | |
7708 if (!unsafe_es3_apis_enabled()) | 7707 if (!unsafe_es3_apis_enabled()) |
7709 return error::kUnknownCommand; | 7708 return error::kUnknownCommand; |
7710 const gles2::cmds::VertexAttribIPointer& c = | 7709 const gles2::cmds::VertexAttribIPointer& c = |
7711 *static_cast<const gles2::cmds::VertexAttribIPointer*>(cmd_data); | 7710 *static_cast<const gles2::cmds::VertexAttribIPointer*>(cmd_data); |
| 7711 |
| 7712 if (!state_.bound_array_buffer.get() || |
| 7713 state_.bound_array_buffer->IsDeleted()) { |
| 7714 if (state_.vertex_attrib_manager.get() == |
| 7715 state_.default_vertex_attrib_manager.get()) { |
| 7716 LOCAL_SET_GL_ERROR( |
| 7717 GL_INVALID_VALUE, "glVertexAttribIPointer", "no array buffer bound"); |
| 7718 return error::kNoError; |
| 7719 } else if (c.offset != 0) { |
| 7720 LOCAL_SET_GL_ERROR( |
| 7721 GL_INVALID_VALUE, |
| 7722 "glVertexAttribIPointer", "client side arrays are not allowed"); |
| 7723 return error::kNoError; |
| 7724 } |
| 7725 } |
| 7726 |
7712 GLuint indx = c.indx; | 7727 GLuint indx = c.indx; |
7713 GLint size = c.size; | 7728 GLint size = c.size; |
7714 GLenum type = c.type; | 7729 GLenum type = c.type; |
7715 GLsizei stride = c.stride; | 7730 GLsizei stride = c.stride; |
7716 GLsizei offset = c.offset; | 7731 GLsizei offset = c.offset; |
7717 const void* ptr = reinterpret_cast<const void*>(offset); | 7732 const void* ptr = reinterpret_cast<const void*>(offset); |
| 7733 if (!validators_->vertex_attrib_i_type.IsValid(type)) { |
| 7734 LOCAL_SET_GL_ERROR_INVALID_ENUM("glVertexAttribIPointer", type, "type"); |
| 7735 return error::kNoError; |
| 7736 } |
| 7737 if (!validators_->vertex_attrib_size.IsValid(size)) { |
| 7738 LOCAL_SET_GL_ERROR( |
| 7739 GL_INVALID_VALUE, "glVertexAttribIPointer", "size GL_INVALID_VALUE"); |
| 7740 return error::kNoError; |
| 7741 } |
| 7742 if (indx >= group_->max_vertex_attribs()) { |
| 7743 LOCAL_SET_GL_ERROR( |
| 7744 GL_INVALID_VALUE, "glVertexAttribIPointer", "index out of range"); |
| 7745 return error::kNoError; |
| 7746 } |
| 7747 if (stride < 0) { |
| 7748 LOCAL_SET_GL_ERROR( |
| 7749 GL_INVALID_VALUE, "glVertexAttribIPointer", "stride < 0"); |
| 7750 return error::kNoError; |
| 7751 } |
| 7752 if (stride > 255) { |
| 7753 LOCAL_SET_GL_ERROR( |
| 7754 GL_INVALID_VALUE, "glVertexAttribIPointer", "stride > 255"); |
| 7755 return error::kNoError; |
| 7756 } |
| 7757 if (offset < 0) { |
| 7758 LOCAL_SET_GL_ERROR( |
| 7759 GL_INVALID_VALUE, "glVertexAttribIPointer", "offset < 0"); |
| 7760 return error::kNoError; |
| 7761 } |
| 7762 GLsizei component_size = |
| 7763 GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type); |
| 7764 // component_size must be a power of two to use & as optimized modulo. |
| 7765 DCHECK(GLES2Util::IsPOT(component_size)); |
| 7766 if (offset & (component_size - 1)) { |
| 7767 LOCAL_SET_GL_ERROR( |
| 7768 GL_INVALID_OPERATION, |
| 7769 "glVertexAttribIPointer", "offset not valid for type"); |
| 7770 return error::kNoError; |
| 7771 } |
| 7772 if (stride & (component_size - 1)) { |
| 7773 LOCAL_SET_GL_ERROR( |
| 7774 GL_INVALID_OPERATION, |
| 7775 "glVertexAttribIPointer", "stride not valid for type"); |
| 7776 return error::kNoError; |
| 7777 } |
| 7778 state_.vertex_attrib_manager |
| 7779 ->SetAttribInfo(indx, |
| 7780 state_.bound_array_buffer.get(), |
| 7781 size, |
| 7782 type, |
| 7783 GL_FALSE, |
| 7784 stride, |
| 7785 stride != 0 ? stride : component_size * size, |
| 7786 offset); |
7718 glVertexAttribIPointer(indx, size, type, stride, ptr); | 7787 glVertexAttribIPointer(indx, size, type, stride, ptr); |
7719 return error::kNoError; | 7788 return error::kNoError; |
7720 } | 7789 } |
7721 | 7790 |
7722 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( | 7791 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( |
7723 uint32 immediate_data_size, | 7792 uint32 immediate_data_size, |
7724 const void* cmd_data) { | 7793 const void* cmd_data) { |
7725 const gles2::cmds::VertexAttribPointer& c = | 7794 const gles2::cmds::VertexAttribPointer& c = |
7726 *static_cast<const gles2::cmds::VertexAttribPointer*>(cmd_data); | 7795 *static_cast<const gles2::cmds::VertexAttribPointer*>(cmd_data); |
7727 | 7796 |
(...skipping 4893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12621 } | 12690 } |
12622 } | 12691 } |
12623 | 12692 |
12624 // Include the auto-generated part of this file. We split this because it means | 12693 // Include the auto-generated part of this file. We split this because it means |
12625 // we can easily edit the non-auto generated parts right here in this file | 12694 // we can easily edit the non-auto generated parts right here in this file |
12626 // instead of having to edit some template or the code generator. | 12695 // instead of having to edit some template or the code generator. |
12627 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 12696 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
12628 | 12697 |
12629 } // namespace gles2 | 12698 } // namespace gles2 |
12630 } // namespace gpu | 12699 } // namespace gpu |
OLD | NEW |