| 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 <list> | 10 #include <list> |
| (...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1170 void DoUniformMatrix2fv( | 1170 void DoUniformMatrix2fv( |
| 1171 GLint fake_location, GLsizei count, GLboolean transpose, | 1171 GLint fake_location, GLsizei count, GLboolean transpose, |
| 1172 const GLfloat* value); | 1172 const GLfloat* value); |
| 1173 void DoUniformMatrix3fv( | 1173 void DoUniformMatrix3fv( |
| 1174 GLint fake_location, GLsizei count, GLboolean transpose, | 1174 GLint fake_location, GLsizei count, GLboolean transpose, |
| 1175 const GLfloat* value); | 1175 const GLfloat* value); |
| 1176 void DoUniformMatrix4fv( | 1176 void DoUniformMatrix4fv( |
| 1177 GLint fake_location, GLsizei count, GLboolean transpose, | 1177 GLint fake_location, GLsizei count, GLboolean transpose, |
| 1178 const GLfloat* value); | 1178 const GLfloat* value); |
| 1179 | 1179 |
| 1180 bool SetVertexAttribValue( |
| 1181 const char* function_name, GLuint index, const GLfloat* value); |
| 1182 |
| 1180 // Wrappers for glVertexAttrib?? | 1183 // Wrappers for glVertexAttrib?? |
| 1181 void DoVertexAttrib1f(GLuint index, GLfloat v0); | 1184 void DoVertexAttrib1f(GLuint index, GLfloat v0); |
| 1182 void DoVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1); | 1185 void DoVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1); |
| 1183 void DoVertexAttrib3f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2); | 1186 void DoVertexAttrib3f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2); |
| 1184 void DoVertexAttrib4f( | 1187 void DoVertexAttrib4f( |
| 1185 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); | 1188 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); |
| 1186 void DoVertexAttrib1fv(GLuint index, const GLfloat *v); | 1189 void DoVertexAttrib1fv(GLuint index, const GLfloat *v); |
| 1187 void DoVertexAttrib2fv(GLuint index, const GLfloat *v); | 1190 void DoVertexAttrib2fv(GLuint index, const GLfloat *v); |
| 1188 void DoVertexAttrib3fv(GLuint index, const GLfloat *v); | 1191 void DoVertexAttrib3fv(GLuint index, const GLfloat *v); |
| 1189 void DoVertexAttrib4fv(GLuint index, const GLfloat *v); | 1192 void DoVertexAttrib4fv(GLuint index, const GLfloat *v); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 bool unpack_premultiply_alpha_; | 1455 bool unpack_premultiply_alpha_; |
| 1453 bool unpack_unpremultiply_alpha_; | 1456 bool unpack_unpremultiply_alpha_; |
| 1454 | 1457 |
| 1455 // Default vertex attribs manager, used when no VAOs are bound. | 1458 // Default vertex attribs manager, used when no VAOs are bound. |
| 1456 VertexAttribManager::Ref default_vertex_attrib_manager_; | 1459 VertexAttribManager::Ref default_vertex_attrib_manager_; |
| 1457 | 1460 |
| 1458 // The buffer we bind to attrib 0 since OpenGL requires it (ES does not). | 1461 // The buffer we bind to attrib 0 since OpenGL requires it (ES does not). |
| 1459 GLuint attrib_0_buffer_id_; | 1462 GLuint attrib_0_buffer_id_; |
| 1460 | 1463 |
| 1461 // The value currently in attrib_0. | 1464 // The value currently in attrib_0. |
| 1462 VertexAttribManager::VertexAttribInfo::Vec4 attrib_0_value_; | 1465 Vec4 attrib_0_value_; |
| 1463 | 1466 |
| 1464 // Whether or not the attrib_0 buffer holds the attrib_0_value. | 1467 // Whether or not the attrib_0 buffer holds the attrib_0_value. |
| 1465 bool attrib_0_buffer_matches_value_; | 1468 bool attrib_0_buffer_matches_value_; |
| 1466 | 1469 |
| 1467 // The size of attrib 0. | 1470 // The size of attrib 0. |
| 1468 GLsizei attrib_0_size_; | 1471 GLsizei attrib_0_size_; |
| 1469 | 1472 |
| 1470 // The buffer used to simulate GL_FIXED attribs. | 1473 // The buffer used to simulate GL_FIXED attribs. |
| 1471 GLuint fixed_attrib_buffer_id_; | 1474 GLuint fixed_attrib_buffer_id_; |
| 1472 | 1475 |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2032 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " | 2035 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " |
| 2033 << "failed to initialize."; | 2036 << "failed to initialize."; |
| 2034 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. | 2037 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. |
| 2035 Destroy(true); | 2038 Destroy(true); |
| 2036 return false; | 2039 return false; |
| 2037 } | 2040 } |
| 2038 CHECK_GL_ERROR(); | 2041 CHECK_GL_ERROR(); |
| 2039 | 2042 |
| 2040 disallowed_features_ = disallowed_features; | 2043 disallowed_features_ = disallowed_features; |
| 2041 | 2044 |
| 2045 state_.attrib_values.resize(group_->max_vertex_attribs()); |
| 2042 default_vertex_attrib_manager_ = new VertexAttribManager(); | 2046 default_vertex_attrib_manager_ = new VertexAttribManager(); |
| 2043 default_vertex_attrib_manager_->Initialize(group_->max_vertex_attribs()); | 2047 default_vertex_attrib_manager_->Initialize(group_->max_vertex_attribs()); |
| 2044 | 2048 |
| 2045 // vertex_attrib_manager is set to default_vertex_attrib_manager_ by this call | 2049 // vertex_attrib_manager is set to default_vertex_attrib_manager_ by this call |
| 2046 DoBindVertexArrayOES(0); | 2050 DoBindVertexArrayOES(0); |
| 2047 | 2051 |
| 2048 query_manager_.reset(new QueryManager(this, feature_info_)); | 2052 query_manager_.reset(new QueryManager(this, feature_info_)); |
| 2049 vertex_array_manager_.reset(new VertexArrayManager()); | 2053 vertex_array_manager_.reset(new VertexArrayManager()); |
| 2050 | 2054 |
| 2051 util_.set_num_compressed_texture_formats( | 2055 util_.set_num_compressed_texture_formats( |
| (...skipping 3220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5272 // If it's enabled or it's not used then we don't need to do anything. | 5276 // If it's enabled or it's not used then we don't need to do anything. |
| 5273 bool attrib_0_used = | 5277 bool attrib_0_used = |
| 5274 state_.current_program->GetAttribInfoByLocation(0) != NULL; | 5278 state_.current_program->GetAttribInfoByLocation(0) != NULL; |
| 5275 if (info->enabled() && attrib_0_used) { | 5279 if (info->enabled() && attrib_0_used) { |
| 5276 return true; | 5280 return true; |
| 5277 } | 5281 } |
| 5278 | 5282 |
| 5279 // Make a buffer with a single repeated vec4 value enough to | 5283 // Make a buffer with a single repeated vec4 value enough to |
| 5280 // simulate the constant value that is supposed to be here. | 5284 // simulate the constant value that is supposed to be here. |
| 5281 // This is required to emulate GLES2 on GL. | 5285 // This is required to emulate GLES2 on GL. |
| 5282 typedef VertexAttribManager::VertexAttribInfo::Vec4 Vec4; | |
| 5283 | |
| 5284 GLuint num_vertices = max_vertex_accessed + 1; | 5286 GLuint num_vertices = max_vertex_accessed + 1; |
| 5285 uint32 size_needed = 0; | 5287 uint32 size_needed = 0; |
| 5286 | 5288 |
| 5287 if (num_vertices == 0 || | 5289 if (num_vertices == 0 || |
| 5288 !SafeMultiplyUint32(num_vertices, sizeof(Vec4), &size_needed) || | 5290 !SafeMultiplyUint32(num_vertices, sizeof(Vec4), &size_needed) || |
| 5289 size_needed > 0x7FFFFFFFU) { | 5291 size_needed > 0x7FFFFFFFU) { |
| 5290 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0"); | 5292 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0"); |
| 5291 return false; | 5293 return false; |
| 5292 } | 5294 } |
| 5293 | 5295 |
| 5294 PerformanceWarning( | 5296 PerformanceWarning( |
| 5295 "Attribute 0 is disabled. This has signficant performance penalty"); | 5297 "Attribute 0 is disabled. This has signficant performance penalty"); |
| 5296 | 5298 |
| 5297 CopyRealGLErrorsToWrapper(); | 5299 CopyRealGLErrorsToWrapper(); |
| 5298 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); | 5300 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); |
| 5299 | 5301 |
| 5300 bool new_buffer = static_cast<GLsizei>(size_needed) > attrib_0_size_; | 5302 bool new_buffer = static_cast<GLsizei>(size_needed) > attrib_0_size_; |
| 5301 if (new_buffer) { | 5303 if (new_buffer) { |
| 5302 glBufferData(GL_ARRAY_BUFFER, size_needed, NULL, GL_DYNAMIC_DRAW); | 5304 glBufferData(GL_ARRAY_BUFFER, size_needed, NULL, GL_DYNAMIC_DRAW); |
| 5303 GLenum error = glGetError(); | 5305 GLenum error = glGetError(); |
| 5304 if (error != GL_NO_ERROR) { | 5306 if (error != GL_NO_ERROR) { |
| 5305 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0"); | 5307 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0"); |
| 5306 return false; | 5308 return false; |
| 5307 } | 5309 } |
| 5308 } | 5310 } |
| 5311 |
| 5312 const Vec4& value = state_.attrib_values[0]; |
| 5309 if (new_buffer || | 5313 if (new_buffer || |
| 5310 (attrib_0_used && | 5314 (attrib_0_used && |
| 5311 (!attrib_0_buffer_matches_value_ || | 5315 (!attrib_0_buffer_matches_value_ || |
| 5312 (info->value().v[0] != attrib_0_value_.v[0] || | 5316 (value.v[0] != attrib_0_value_.v[0] || |
| 5313 info->value().v[1] != attrib_0_value_.v[1] || | 5317 value.v[1] != attrib_0_value_.v[1] || |
| 5314 info->value().v[2] != attrib_0_value_.v[2] || | 5318 value.v[2] != attrib_0_value_.v[2] || |
| 5315 info->value().v[3] != attrib_0_value_.v[3])))) { | 5319 value.v[3] != attrib_0_value_.v[3])))) { |
| 5316 std::vector<Vec4> temp(num_vertices, info->value()); | 5320 std::vector<Vec4> temp(num_vertices, value); |
| 5317 glBufferSubData(GL_ARRAY_BUFFER, 0, size_needed, &temp[0].v[0]); | 5321 glBufferSubData(GL_ARRAY_BUFFER, 0, size_needed, &temp[0].v[0]); |
| 5318 attrib_0_buffer_matches_value_ = true; | 5322 attrib_0_buffer_matches_value_ = true; |
| 5319 attrib_0_value_ = info->value(); | 5323 attrib_0_value_ = value; |
| 5320 attrib_0_size_ = size_needed; | 5324 attrib_0_size_ = size_needed; |
| 5321 } | 5325 } |
| 5322 | 5326 |
| 5323 glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL); | 5327 glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL); |
| 5324 | 5328 |
| 5325 if (info->divisor()) | 5329 if (info->divisor()) |
| 5326 glVertexAttribDivisorANGLE(0, 0); | 5330 glVertexAttribDivisorANGLE(0, 0); |
| 5327 | 5331 |
| 5328 *simulated = true; | 5332 *simulated = true; |
| 5329 return true; | 5333 return true; |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5991 break; | 5995 break; |
| 5992 case GL_VERTEX_ATTRIB_ARRAY_STRIDE: | 5996 case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
| 5993 *params = static_cast<GLfloat>(info->gl_stride()); | 5997 *params = static_cast<GLfloat>(info->gl_stride()); |
| 5994 break; | 5998 break; |
| 5995 case GL_VERTEX_ATTRIB_ARRAY_TYPE: | 5999 case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
| 5996 *params = static_cast<GLfloat>(info->type()); | 6000 *params = static_cast<GLfloat>(info->type()); |
| 5997 break; | 6001 break; |
| 5998 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: | 6002 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
| 5999 *params = static_cast<GLfloat>(info->normalized()); | 6003 *params = static_cast<GLfloat>(info->normalized()); |
| 6000 break; | 6004 break; |
| 6001 case GL_CURRENT_VERTEX_ATTRIB: | 6005 case GL_CURRENT_VERTEX_ATTRIB: { |
| 6002 params[0] = info->value().v[0]; | 6006 const Vec4& value = state_.attrib_values[index]; |
| 6003 params[1] = info->value().v[1]; | 6007 params[0] = value.v[0]; |
| 6004 params[2] = info->value().v[2]; | 6008 params[1] = value.v[1]; |
| 6005 params[3] = info->value().v[3]; | 6009 params[2] = value.v[2]; |
| 6010 params[3] = value.v[3]; |
| 6006 break; | 6011 break; |
| 6012 } |
| 6007 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: | 6013 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: |
| 6008 *params = static_cast<GLfloat>(info->divisor()); | 6014 *params = static_cast<GLfloat>(info->divisor()); |
| 6009 break; | 6015 break; |
| 6010 default: | 6016 default: |
| 6011 NOTREACHED(); | 6017 NOTREACHED(); |
| 6012 break; | 6018 break; |
| 6013 } | 6019 } |
| 6014 } | 6020 } |
| 6015 | 6021 |
| 6016 void GLES2DecoderImpl::DoGetVertexAttribiv( | 6022 void GLES2DecoderImpl::DoGetVertexAttribiv( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 6042 break; | 6048 break; |
| 6043 case GL_VERTEX_ATTRIB_ARRAY_TYPE: | 6049 case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
| 6044 *params = info->type(); | 6050 *params = info->type(); |
| 6045 break; | 6051 break; |
| 6046 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: | 6052 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
| 6047 *params = static_cast<GLint>(info->normalized()); | 6053 *params = static_cast<GLint>(info->normalized()); |
| 6048 break; | 6054 break; |
| 6049 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: | 6055 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: |
| 6050 *params = info->divisor(); | 6056 *params = info->divisor(); |
| 6051 break; | 6057 break; |
| 6052 case GL_CURRENT_VERTEX_ATTRIB: | 6058 case GL_CURRENT_VERTEX_ATTRIB: { |
| 6053 params[0] = static_cast<GLint>(info->value().v[0]); | 6059 const Vec4& value = state_.attrib_values[index]; |
| 6054 params[1] = static_cast<GLint>(info->value().v[1]); | 6060 params[0] = static_cast<GLint>(value.v[0]); |
| 6055 params[2] = static_cast<GLint>(info->value().v[2]); | 6061 params[1] = static_cast<GLint>(value.v[1]); |
| 6056 params[3] = static_cast<GLint>(info->value().v[3]); | 6062 params[2] = static_cast<GLint>(value.v[2]); |
| 6063 params[3] = static_cast<GLint>(value.v[3]); |
| 6057 break; | 6064 break; |
| 6065 } |
| 6058 default: | 6066 default: |
| 6059 NOTREACHED(); | 6067 NOTREACHED(); |
| 6060 break; | 6068 break; |
| 6061 } | 6069 } |
| 6062 } | 6070 } |
| 6063 | 6071 |
| 6072 bool GLES2DecoderImpl::SetVertexAttribValue( |
| 6073 const char* function_name, GLuint index, const GLfloat* value) { |
| 6074 if (index >= state_.attrib_values.size()) { |
| 6075 SetGLError(GL_INVALID_VALUE, function_name, "index out of range"); |
| 6076 return false; |
| 6077 } |
| 6078 Vec4& v = state_.attrib_values[index]; |
| 6079 v.v[0] = value[0]; |
| 6080 v.v[1] = value[1]; |
| 6081 v.v[2] = value[2]; |
| 6082 v.v[3] = value[3]; |
| 6083 return true; |
| 6084 } |
| 6085 |
| 6064 void GLES2DecoderImpl::DoVertexAttrib1f(GLuint index, GLfloat v0) { | 6086 void GLES2DecoderImpl::DoVertexAttrib1f(GLuint index, GLfloat v0) { |
| 6065 VertexAttribManager::VertexAttribInfo* info = | 6087 GLfloat v[4] = { v0, 0.0f, 0.0f, 1.0f, }; |
| 6066 state_.vertex_attrib_manager->GetVertexAttribInfo(index); | 6088 if (SetVertexAttribValue("glVertexAttrib1f", index, v)) { |
| 6067 if (!info) { | 6089 glVertexAttrib1f(index, v0); |
| 6068 SetGLError(GL_INVALID_VALUE, "glVertexAttrib1f", "index out of range"); | |
| 6069 return; | |
| 6070 } | 6090 } |
| 6071 VertexAttribManager::VertexAttribInfo::Vec4 value; | |
| 6072 value.v[0] = v0; | |
| 6073 value.v[1] = 0.0f; | |
| 6074 value.v[2] = 0.0f; | |
| 6075 value.v[3] = 1.0f; | |
| 6076 info->set_value(value); | |
| 6077 glVertexAttrib1f(index, v0); | |
| 6078 } | 6091 } |
| 6079 | 6092 |
| 6080 void GLES2DecoderImpl::DoVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1) { | 6093 void GLES2DecoderImpl::DoVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1) { |
| 6081 VertexAttribManager::VertexAttribInfo* info = | 6094 GLfloat v[4] = { v0, v1, 0.0f, 1.0f, }; |
| 6082 state_.vertex_attrib_manager->GetVertexAttribInfo(index); | 6095 if (SetVertexAttribValue("glVertexAttrib2f", index, v)) { |
| 6083 if (!info) { | 6096 glVertexAttrib2f(index, v0, v1); |
| 6084 SetGLError(GL_INVALID_VALUE, "glVertexAttrib2f", "index out of range"); | |
| 6085 return; | |
| 6086 } | 6097 } |
| 6087 VertexAttribManager::VertexAttribInfo::Vec4 value; | |
| 6088 value.v[0] = v0; | |
| 6089 value.v[1] = v1; | |
| 6090 value.v[2] = 0.0f; | |
| 6091 value.v[3] = 1.0f; | |
| 6092 info->set_value(value); | |
| 6093 glVertexAttrib2f(index, v0, v1); | |
| 6094 } | 6098 } |
| 6095 | 6099 |
| 6096 void GLES2DecoderImpl::DoVertexAttrib3f( | 6100 void GLES2DecoderImpl::DoVertexAttrib3f( |
| 6097 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2) { | 6101 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2) { |
| 6098 VertexAttribManager::VertexAttribInfo* info = | 6102 GLfloat v[4] = { v0, v1, v2, 1.0f, }; |
| 6099 state_.vertex_attrib_manager->GetVertexAttribInfo(index); | 6103 if (SetVertexAttribValue("glVertexAttrib3f", index, v)) { |
| 6100 if (!info) { | 6104 glVertexAttrib3f(index, v0, v1, v2); |
| 6101 SetGLError(GL_INVALID_VALUE, "glVertexAttrib3f", "index out of range"); | |
| 6102 return; | |
| 6103 } | 6105 } |
| 6104 VertexAttribManager::VertexAttribInfo::Vec4 value; | |
| 6105 value.v[0] = v0; | |
| 6106 value.v[1] = v1; | |
| 6107 value.v[2] = v2; | |
| 6108 value.v[3] = 1.0f; | |
| 6109 info->set_value(value); | |
| 6110 glVertexAttrib3f(index, v0, v1, v2); | |
| 6111 } | 6106 } |
| 6112 | 6107 |
| 6113 void GLES2DecoderImpl::DoVertexAttrib4f( | 6108 void GLES2DecoderImpl::DoVertexAttrib4f( |
| 6114 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) { | 6109 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) { |
| 6115 VertexAttribManager::VertexAttribInfo* info = | 6110 GLfloat v[4] = { v0, v1, v2, v3, }; |
| 6116 state_.vertex_attrib_manager->GetVertexAttribInfo(index); | 6111 if (SetVertexAttribValue("glVertexAttrib4f", index, v)) { |
| 6117 if (!info) { | 6112 glVertexAttrib4f(index, v0, v1, v2, v3); |
| 6118 SetGLError(GL_INVALID_VALUE, "glVertexAttrib4f", "index out of range"); | |
| 6119 return; | |
| 6120 } | 6113 } |
| 6121 VertexAttribManager::VertexAttribInfo::Vec4 value; | |
| 6122 value.v[0] = v0; | |
| 6123 value.v[1] = v1; | |
| 6124 value.v[2] = v2; | |
| 6125 value.v[3] = v3; | |
| 6126 info->set_value(value); | |
| 6127 glVertexAttrib4f(index, v0, v1, v2, v3); | |
| 6128 } | 6114 } |
| 6129 | 6115 |
| 6130 void GLES2DecoderImpl::DoVertexAttrib1fv(GLuint index, const GLfloat* v) { | 6116 void GLES2DecoderImpl::DoVertexAttrib1fv(GLuint index, const GLfloat* v) { |
| 6131 VertexAttribManager::VertexAttribInfo* info = | 6117 GLfloat t[4] = { v[0], 0.0f, 0.0f, 1.0f, }; |
| 6132 state_.vertex_attrib_manager->GetVertexAttribInfo(index); | 6118 if (SetVertexAttribValue("glVertexAttrib1fv", index, t)) { |
| 6133 if (!info) { | 6119 glVertexAttrib1fv(index, v); |
| 6134 SetGLError(GL_INVALID_VALUE, "glVertexAttrib1fv", "index out of range"); | |
| 6135 return; | |
| 6136 } | 6120 } |
| 6137 VertexAttribManager::VertexAttribInfo::Vec4 value; | |
| 6138 value.v[0] = v[0]; | |
| 6139 value.v[1] = 0.0f; | |
| 6140 value.v[2] = 0.0f; | |
| 6141 value.v[3] = 1.0f; | |
| 6142 info->set_value(value); | |
| 6143 glVertexAttrib1fv(index, v); | |
| 6144 } | 6121 } |
| 6145 | 6122 |
| 6146 void GLES2DecoderImpl::DoVertexAttrib2fv(GLuint index, const GLfloat* v) { | 6123 void GLES2DecoderImpl::DoVertexAttrib2fv(GLuint index, const GLfloat* v) { |
| 6147 VertexAttribManager::VertexAttribInfo* info = | 6124 GLfloat t[4] = { v[0], v[1], 0.0f, 1.0f, }; |
| 6148 state_.vertex_attrib_manager->GetVertexAttribInfo(index); | 6125 if (SetVertexAttribValue("glVertexAttrib2fv", index, t)) { |
| 6149 if (!info) { | 6126 glVertexAttrib2fv(index, v); |
| 6150 SetGLError(GL_INVALID_VALUE, "glVertexAttrib2fv", "index out of range"); | |
| 6151 return; | |
| 6152 } | 6127 } |
| 6153 VertexAttribManager::VertexAttribInfo::Vec4 value; | |
| 6154 value.v[0] = v[0]; | |
| 6155 value.v[1] = v[1]; | |
| 6156 value.v[2] = 0.0f; | |
| 6157 value.v[3] = 1.0f; | |
| 6158 info->set_value(value); | |
| 6159 glVertexAttrib2fv(index, v); | |
| 6160 } | 6128 } |
| 6161 | 6129 |
| 6162 void GLES2DecoderImpl::DoVertexAttrib3fv(GLuint index, const GLfloat* v) { | 6130 void GLES2DecoderImpl::DoVertexAttrib3fv(GLuint index, const GLfloat* v) { |
| 6163 VertexAttribManager::VertexAttribInfo* info = | 6131 GLfloat t[4] = { v[0], v[1], v[2], 1.0f, }; |
| 6164 state_.vertex_attrib_manager->GetVertexAttribInfo(index); | 6132 if (SetVertexAttribValue("glVertexAttrib3fv", index, t)) { |
| 6165 if (!info) { | 6133 glVertexAttrib3fv(index, v); |
| 6166 SetGLError(GL_INVALID_VALUE, "glVertexAttrib3fv", "index out of range"); | |
| 6167 return; | |
| 6168 } | 6134 } |
| 6169 VertexAttribManager::VertexAttribInfo::Vec4 value; | |
| 6170 value.v[0] = v[0]; | |
| 6171 value.v[1] = v[1]; | |
| 6172 value.v[2] = v[2]; | |
| 6173 value.v[3] = 1.0f; | |
| 6174 info->set_value(value); | |
| 6175 glVertexAttrib3fv(index, v); | |
| 6176 } | 6135 } |
| 6177 | 6136 |
| 6178 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { | 6137 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { |
| 6179 VertexAttribManager::VertexAttribInfo* info = | 6138 if (SetVertexAttribValue("glVertexAttrib4fv", index, v)) { |
| 6180 state_.vertex_attrib_manager->GetVertexAttribInfo(index); | 6139 glVertexAttrib4fv(index, v); |
| 6181 if (!info) { | |
| 6182 SetGLError(GL_INVALID_VALUE, "glVertexAttrib4fv", "index out of range"); | |
| 6183 return; | |
| 6184 } | 6140 } |
| 6185 VertexAttribManager::VertexAttribInfo::Vec4 value; | |
| 6186 value.v[0] = v[0]; | |
| 6187 value.v[1] = v[1]; | |
| 6188 value.v[2] = v[2]; | |
| 6189 value.v[3] = v[3]; | |
| 6190 info->set_value(value); | |
| 6191 glVertexAttrib4fv(index, v); | |
| 6192 } | 6141 } |
| 6193 | 6142 |
| 6194 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( | 6143 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( |
| 6195 uint32 immediate_data_size, const gles2::VertexAttribPointer& c) { | 6144 uint32 immediate_data_size, const gles2::VertexAttribPointer& c) { |
| 6196 | 6145 |
| 6197 if (!state_.bound_array_buffer || state_.bound_array_buffer->IsDeleted()) { | 6146 if (!state_.bound_array_buffer || state_.bound_array_buffer->IsDeleted()) { |
| 6198 if (state_.vertex_attrib_manager == default_vertex_attrib_manager_) { | 6147 if (state_.vertex_attrib_manager == default_vertex_attrib_manager_) { |
| 6199 SetGLError(GL_INVALID_VALUE, | 6148 SetGLError(GL_INVALID_VALUE, |
| 6200 "glVertexAttribPointer", "no array buffer bound"); | 6149 "glVertexAttribPointer", "no array buffer bound"); |
| 6201 return error::kNoError; | 6150 return error::kNoError; |
| (...skipping 3171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9373 gpu_trace_stack_.pop(); | 9322 gpu_trace_stack_.pop(); |
| 9374 } | 9323 } |
| 9375 | 9324 |
| 9376 // Include the auto-generated part of this file. We split this because it means | 9325 // Include the auto-generated part of this file. We split this because it means |
| 9377 // we can easily edit the non-auto generated parts right here in this file | 9326 // we can easily edit the non-auto generated parts right here in this file |
| 9378 // instead of having to edit some template or the code generator. | 9327 // instead of having to edit some template or the code generator. |
| 9379 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 9328 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 9380 | 9329 |
| 9381 } // namespace gles2 | 9330 } // namespace gles2 |
| 9382 } // namespace gpu | 9331 } // namespace gpu |
| OLD | NEW |