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 1548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1559 void DoUniformMatrix2fv( | 1559 void DoUniformMatrix2fv( |
1560 GLint fake_location, GLsizei count, GLboolean transpose, | 1560 GLint fake_location, GLsizei count, GLboolean transpose, |
1561 const GLfloat* value); | 1561 const GLfloat* value); |
1562 void DoUniformMatrix3fv( | 1562 void DoUniformMatrix3fv( |
1563 GLint fake_location, GLsizei count, GLboolean transpose, | 1563 GLint fake_location, GLsizei count, GLboolean transpose, |
1564 const GLfloat* value); | 1564 const GLfloat* value); |
1565 void DoUniformMatrix4fv( | 1565 void DoUniformMatrix4fv( |
1566 GLint fake_location, GLsizei count, GLboolean transpose, | 1566 GLint fake_location, GLsizei count, GLboolean transpose, |
1567 const GLfloat* value); | 1567 const GLfloat* value); |
1568 | 1568 |
| 1569 template <typename T> |
1569 bool SetVertexAttribValue( | 1570 bool SetVertexAttribValue( |
1570 const char* function_name, GLuint index, const GLfloat* value); | 1571 const char* function_name, GLuint index, const T* value); |
1571 | 1572 |
1572 // Wrappers for glVertexAttrib?? | 1573 // Wrappers for glVertexAttrib?? |
1573 void DoVertexAttrib1f(GLuint index, GLfloat v0); | 1574 void DoVertexAttrib1f(GLuint index, GLfloat v0); |
1574 void DoVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1); | 1575 void DoVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1); |
1575 void DoVertexAttrib3f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2); | 1576 void DoVertexAttrib3f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2); |
1576 void DoVertexAttrib4f( | 1577 void DoVertexAttrib4f( |
1577 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); | 1578 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); |
1578 void DoVertexAttrib1fv(GLuint index, const GLfloat *v); | 1579 void DoVertexAttrib1fv(GLuint index, const GLfloat* v); |
1579 void DoVertexAttrib2fv(GLuint index, const GLfloat *v); | 1580 void DoVertexAttrib2fv(GLuint index, const GLfloat* v); |
1580 void DoVertexAttrib3fv(GLuint index, const GLfloat *v); | 1581 void DoVertexAttrib3fv(GLuint index, const GLfloat* v); |
1581 void DoVertexAttrib4fv(GLuint index, const GLfloat *v); | 1582 void DoVertexAttrib4fv(GLuint index, const GLfloat* v); |
| 1583 void DoVertexAttribI4i(GLuint index, GLint v0, GLint v1, GLint v2, GLint v3); |
| 1584 void DoVertexAttribI4iv(GLuint index, const GLint* v); |
| 1585 void DoVertexAttribI4ui( |
| 1586 GLuint index, GLuint v0, GLuint v1, GLuint v2, GLuint v3); |
| 1587 void DoVertexAttribI4uiv(GLuint index, const GLuint* v); |
1582 | 1588 |
1583 // Wrapper for glViewport | 1589 // Wrapper for glViewport |
1584 void DoViewport(GLint x, GLint y, GLsizei width, GLsizei height); | 1590 void DoViewport(GLint x, GLint y, GLsizei width, GLsizei height); |
1585 | 1591 |
1586 // Wrapper for glUseProgram | 1592 // Wrapper for glUseProgram |
1587 void DoUseProgram(GLuint program); | 1593 void DoUseProgram(GLuint program); |
1588 | 1594 |
1589 // Wrapper for glValidateProgram. | 1595 // Wrapper for glValidateProgram. |
1590 void DoValidateProgram(GLuint program_client_id); | 1596 void DoValidateProgram(GLuint program_client_id); |
1591 | 1597 |
(...skipping 6116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7708 void GLES2DecoderImpl::DoGetVertexAttribIiv( | 7714 void GLES2DecoderImpl::DoGetVertexAttribIiv( |
7709 GLuint index, GLenum pname, GLint* params) { | 7715 GLuint index, GLenum pname, GLint* params) { |
7710 DoGetVertexAttribImpl<GLint>(index, pname, params); | 7716 DoGetVertexAttribImpl<GLint>(index, pname, params); |
7711 } | 7717 } |
7712 | 7718 |
7713 void GLES2DecoderImpl::DoGetVertexAttribIuiv( | 7719 void GLES2DecoderImpl::DoGetVertexAttribIuiv( |
7714 GLuint index, GLenum pname, GLuint* params) { | 7720 GLuint index, GLenum pname, GLuint* params) { |
7715 DoGetVertexAttribImpl<GLuint>(index, pname, params); | 7721 DoGetVertexAttribImpl<GLuint>(index, pname, params); |
7716 } | 7722 } |
7717 | 7723 |
| 7724 template <typename T> |
7718 bool GLES2DecoderImpl::SetVertexAttribValue( | 7725 bool GLES2DecoderImpl::SetVertexAttribValue( |
7719 const char* function_name, GLuint index, const GLfloat* value) { | 7726 const char* function_name, GLuint index, const T* value) { |
7720 if (index >= state_.attrib_values.size()) { | 7727 if (index >= state_.attrib_values.size()) { |
7721 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "index out of range"); | 7728 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "index out of range"); |
7722 return false; | 7729 return false; |
7723 } | 7730 } |
7724 state_.attrib_values[index].SetValues(value); | 7731 state_.attrib_values[index].SetValues(value); |
7725 return true; | 7732 return true; |
7726 } | 7733 } |
7727 | 7734 |
7728 void GLES2DecoderImpl::DoVertexAttrib1f(GLuint index, GLfloat v0) { | 7735 void GLES2DecoderImpl::DoVertexAttrib1f(GLuint index, GLfloat v0) { |
7729 GLfloat v[4] = { v0, 0.0f, 0.0f, 1.0f, }; | 7736 GLfloat v[4] = { v0, 0.0f, 0.0f, 1.0f, }; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7775 glVertexAttrib3fv(index, v); | 7782 glVertexAttrib3fv(index, v); |
7776 } | 7783 } |
7777 } | 7784 } |
7778 | 7785 |
7779 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { | 7786 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { |
7780 if (SetVertexAttribValue("glVertexAttrib4fv", index, v)) { | 7787 if (SetVertexAttribValue("glVertexAttrib4fv", index, v)) { |
7781 glVertexAttrib4fv(index, v); | 7788 glVertexAttrib4fv(index, v); |
7782 } | 7789 } |
7783 } | 7790 } |
7784 | 7791 |
| 7792 void GLES2DecoderImpl::DoVertexAttribI4i( |
| 7793 GLuint index, GLint v0, GLint v1, GLint v2, GLint v3) { |
| 7794 GLint v[4] = { v0, v1, v2, v3 }; |
| 7795 if (SetVertexAttribValue("glVertexAttribI4i", index, v)) { |
| 7796 glVertexAttribI4i(index, v0, v1, v2, v3); |
| 7797 } |
| 7798 } |
| 7799 |
| 7800 void GLES2DecoderImpl::DoVertexAttribI4iv(GLuint index, const GLint* v) { |
| 7801 if (SetVertexAttribValue("glVertexAttribI4iv", index, v)) { |
| 7802 glVertexAttribI4iv(index, v); |
| 7803 } |
| 7804 } |
| 7805 |
| 7806 void GLES2DecoderImpl::DoVertexAttribI4ui( |
| 7807 GLuint index, GLuint v0, GLuint v1, GLuint v2, GLuint v3) { |
| 7808 GLuint v[4] = { v0, v1, v2, v3 }; |
| 7809 if (SetVertexAttribValue("glVertexAttribI4ui", index, v)) { |
| 7810 glVertexAttribI4ui(index, v0, v1, v2, v3); |
| 7811 } |
| 7812 } |
| 7813 |
| 7814 void GLES2DecoderImpl::DoVertexAttribI4uiv(GLuint index, const GLuint* v) { |
| 7815 if (SetVertexAttribValue("glVertexAttribI4uiv", index, v)) { |
| 7816 glVertexAttribI4uiv(index, v); |
| 7817 } |
| 7818 } |
| 7819 |
7785 error::Error GLES2DecoderImpl::HandleVertexAttribIPointer( | 7820 error::Error GLES2DecoderImpl::HandleVertexAttribIPointer( |
7786 uint32 immediate_data_size, | 7821 uint32 immediate_data_size, |
7787 const void* cmd_data) { | 7822 const void* cmd_data) { |
7788 if (!unsafe_es3_apis_enabled()) | 7823 if (!unsafe_es3_apis_enabled()) |
7789 return error::kUnknownCommand; | 7824 return error::kUnknownCommand; |
7790 const gles2::cmds::VertexAttribIPointer& c = | 7825 const gles2::cmds::VertexAttribIPointer& c = |
7791 *static_cast<const gles2::cmds::VertexAttribIPointer*>(cmd_data); | 7826 *static_cast<const gles2::cmds::VertexAttribIPointer*>(cmd_data); |
7792 | 7827 |
7793 if (!state_.bound_array_buffer.get() || | 7828 if (!state_.bound_array_buffer.get() || |
7794 state_.bound_array_buffer->IsDeleted()) { | 7829 state_.bound_array_buffer->IsDeleted()) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7857 return error::kNoError; | 7892 return error::kNoError; |
7858 } | 7893 } |
7859 state_.vertex_attrib_manager | 7894 state_.vertex_attrib_manager |
7860 ->SetAttribInfo(indx, | 7895 ->SetAttribInfo(indx, |
7861 state_.bound_array_buffer.get(), | 7896 state_.bound_array_buffer.get(), |
7862 size, | 7897 size, |
7863 type, | 7898 type, |
7864 GL_FALSE, | 7899 GL_FALSE, |
7865 stride, | 7900 stride, |
7866 stride != 0 ? stride : component_size * size, | 7901 stride != 0 ? stride : component_size * size, |
7867 offset); | 7902 offset, |
| 7903 GL_TRUE); |
7868 glVertexAttribIPointer(indx, size, type, stride, ptr); | 7904 glVertexAttribIPointer(indx, size, type, stride, ptr); |
7869 return error::kNoError; | 7905 return error::kNoError; |
7870 } | 7906 } |
7871 | 7907 |
7872 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( | 7908 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( |
7873 uint32 immediate_data_size, | 7909 uint32 immediate_data_size, |
7874 const void* cmd_data) { | 7910 const void* cmd_data) { |
7875 const gles2::cmds::VertexAttribPointer& c = | 7911 const gles2::cmds::VertexAttribPointer& c = |
7876 *static_cast<const gles2::cmds::VertexAttribPointer*>(cmd_data); | 7912 *static_cast<const gles2::cmds::VertexAttribPointer*>(cmd_data); |
7877 | 7913 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7943 return error::kNoError; | 7979 return error::kNoError; |
7944 } | 7980 } |
7945 state_.vertex_attrib_manager | 7981 state_.vertex_attrib_manager |
7946 ->SetAttribInfo(indx, | 7982 ->SetAttribInfo(indx, |
7947 state_.bound_array_buffer.get(), | 7983 state_.bound_array_buffer.get(), |
7948 size, | 7984 size, |
7949 type, | 7985 type, |
7950 normalized, | 7986 normalized, |
7951 stride, | 7987 stride, |
7952 stride != 0 ? stride : component_size * size, | 7988 stride != 0 ? stride : component_size * size, |
7953 offset); | 7989 offset, |
| 7990 GL_FALSE); |
7954 // We support GL_FIXED natively on EGL/GLES2 implementations | 7991 // We support GL_FIXED natively on EGL/GLES2 implementations |
7955 if (type != GL_FIXED || feature_info_->gl_version_info().is_es) { | 7992 if (type != GL_FIXED || feature_info_->gl_version_info().is_es) { |
7956 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); | 7993 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); |
7957 } | 7994 } |
7958 return error::kNoError; | 7995 return error::kNoError; |
7959 } | 7996 } |
7960 | 7997 |
7961 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width, | 7998 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width, |
7962 GLsizei height) { | 7999 GLsizei height) { |
7963 state_.viewport_x = x; | 8000 state_.viewport_x = x; |
(...skipping 5179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13143 } | 13180 } |
13144 } | 13181 } |
13145 | 13182 |
13146 // Include the auto-generated part of this file. We split this because it means | 13183 // Include the auto-generated part of this file. We split this because it means |
13147 // we can easily edit the non-auto generated parts right here in this file | 13184 // we can easily edit the non-auto generated parts right here in this file |
13148 // instead of having to edit some template or the code generator. | 13185 // instead of having to edit some template or the code generator. |
13149 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 13186 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
13150 | 13187 |
13151 } // namespace gles2 | 13188 } // namespace gles2 |
13152 } // namespace gpu | 13189 } // namespace gpu |
OLD | NEW |