| Index: gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| index 670782ecb6243bb97252cfe4918b8eb3cc585274..cf8688ef98e6b96f10cae1d0d527c836d49f84cf 100644
|
| --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| @@ -1790,6 +1790,10 @@ class GLES2DecoderImpl : public GLES2Decoder, public ErrorStateClient {
|
| // false if pname is unknown.
|
| bool GetNumValuesReturnedForGLGet(GLenum pname, GLsizei* num_values);
|
|
|
| + // Checks if the type of an attribute set by vertexAttrib API match
|
| + // the type of corresponding attribute in vertex shader.
|
| + bool AttribsTypeMatch();
|
| +
|
| // Checks if the current program and vertex attributes are valid for drawing.
|
| bool IsDrawValid(
|
| const char* function_name, GLuint max_vertex_accessed, bool instanced,
|
| @@ -9035,6 +9039,16 @@ void GLES2DecoderImpl::RestoreStateForSimulatedFixedAttribs() {
|
| : 0);
|
| }
|
|
|
| +bool GLES2DecoderImpl::AttribsTypeMatch() {
|
| + uint32_t mask = state_.current_program->vertex_input_written_mask() |
|
| + state_.vertex_attrib_manager->attrib_written_mask();
|
| + if ((mask | state_.current_program->vertex_input_type_mask()) ==
|
| + (mask | state_.vertex_attrib_manager->attrib_base_type_mask())) {
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| error::Error GLES2DecoderImpl::DoDrawArrays(
|
| const char* function_name,
|
| bool instanced,
|
| @@ -9081,6 +9095,12 @@ error::Error GLES2DecoderImpl::DoDrawArrays(
|
| return error::kNoError;
|
| }
|
|
|
| + if (!AttribsTypeMatch()) {
|
| + LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
|
| + "vertexAttrib function must match shader attrib type");
|
| + return error::kNoError;
|
| + }
|
| +
|
| GLuint max_vertex_accessed = first + count - 1;
|
| if (IsDrawValid(function_name, max_vertex_accessed, instanced, primcount)) {
|
| if (!ClearUnclearedTextures()) {
|
| @@ -9204,6 +9224,12 @@ error::Error GLES2DecoderImpl::DoDrawElements(const char* function_name,
|
| return error::kNoError;
|
| }
|
|
|
| + if (!AttribsTypeMatch()) {
|
| + LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
|
| + "vertexAttrib function must match shader attrib type");
|
| + return error::kNoError;
|
| + }
|
| +
|
| GLuint max_vertex_accessed;
|
| Buffer* element_array_buffer =
|
| state_.vertex_attrib_manager->element_array_buffer();
|
| @@ -9797,6 +9823,8 @@ bool GLES2DecoderImpl::SetVertexAttribValue(
|
| void GLES2DecoderImpl::DoVertexAttrib1f(GLuint index, GLfloat v0) {
|
| GLfloat v[4] = { v0, 0.0f, 0.0f, 1.0f, };
|
| if (SetVertexAttribValue("glVertexAttrib1f", index, v)) {
|
| + state_.vertex_attrib_manager->UpdateAttribBaseTypeAndMask(
|
| + index, SHADER_VARIABLE_FLOAT);
|
| glVertexAttrib1f(index, v0);
|
| }
|
| }
|
| @@ -9804,6 +9832,8 @@ void GLES2DecoderImpl::DoVertexAttrib1f(GLuint index, GLfloat v0) {
|
| void GLES2DecoderImpl::DoVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1) {
|
| GLfloat v[4] = { v0, v1, 0.0f, 1.0f, };
|
| if (SetVertexAttribValue("glVertexAttrib2f", index, v)) {
|
| + state_.vertex_attrib_manager->UpdateAttribBaseTypeAndMask(
|
| + index, SHADER_VARIABLE_FLOAT);
|
| glVertexAttrib2f(index, v0, v1);
|
| }
|
| }
|
| @@ -9812,6 +9842,8 @@ void GLES2DecoderImpl::DoVertexAttrib3f(
|
| GLuint index, GLfloat v0, GLfloat v1, GLfloat v2) {
|
| GLfloat v[4] = { v0, v1, v2, 1.0f, };
|
| if (SetVertexAttribValue("glVertexAttrib3f", index, v)) {
|
| + state_.vertex_attrib_manager->UpdateAttribBaseTypeAndMask(
|
| + index, SHADER_VARIABLE_FLOAT);
|
| glVertexAttrib3f(index, v0, v1, v2);
|
| }
|
| }
|
| @@ -9820,6 +9852,8 @@ void GLES2DecoderImpl::DoVertexAttrib4f(
|
| GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
|
| GLfloat v[4] = { v0, v1, v2, v3, };
|
| if (SetVertexAttribValue("glVertexAttrib4f", index, v)) {
|
| + state_.vertex_attrib_manager->UpdateAttribBaseTypeAndMask(
|
| + index, SHADER_VARIABLE_FLOAT);
|
| glVertexAttrib4f(index, v0, v1, v2, v3);
|
| }
|
| }
|
| @@ -9827,6 +9861,8 @@ void GLES2DecoderImpl::DoVertexAttrib4f(
|
| void GLES2DecoderImpl::DoVertexAttrib1fv(GLuint index, const GLfloat* v) {
|
| GLfloat t[4] = { v[0], 0.0f, 0.0f, 1.0f, };
|
| if (SetVertexAttribValue("glVertexAttrib1fv", index, t)) {
|
| + state_.vertex_attrib_manager->UpdateAttribBaseTypeAndMask(
|
| + index, SHADER_VARIABLE_FLOAT);
|
| glVertexAttrib1fv(index, v);
|
| }
|
| }
|
| @@ -9834,6 +9870,8 @@ void GLES2DecoderImpl::DoVertexAttrib1fv(GLuint index, const GLfloat* v) {
|
| void GLES2DecoderImpl::DoVertexAttrib2fv(GLuint index, const GLfloat* v) {
|
| GLfloat t[4] = { v[0], v[1], 0.0f, 1.0f, };
|
| if (SetVertexAttribValue("glVertexAttrib2fv", index, t)) {
|
| + state_.vertex_attrib_manager->UpdateAttribBaseTypeAndMask(
|
| + index, SHADER_VARIABLE_FLOAT);
|
| glVertexAttrib2fv(index, v);
|
| }
|
| }
|
| @@ -9841,12 +9879,16 @@ void GLES2DecoderImpl::DoVertexAttrib2fv(GLuint index, const GLfloat* v) {
|
| void GLES2DecoderImpl::DoVertexAttrib3fv(GLuint index, const GLfloat* v) {
|
| GLfloat t[4] = { v[0], v[1], v[2], 1.0f, };
|
| if (SetVertexAttribValue("glVertexAttrib3fv", index, t)) {
|
| + state_.vertex_attrib_manager->UpdateAttribBaseTypeAndMask(
|
| + index, SHADER_VARIABLE_FLOAT);
|
| glVertexAttrib3fv(index, v);
|
| }
|
| }
|
|
|
| void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) {
|
| if (SetVertexAttribValue("glVertexAttrib4fv", index, v)) {
|
| + state_.vertex_attrib_manager->UpdateAttribBaseTypeAndMask(
|
| + index, SHADER_VARIABLE_FLOAT);
|
| glVertexAttrib4fv(index, v);
|
| }
|
| }
|
| @@ -9855,12 +9897,16 @@ void GLES2DecoderImpl::DoVertexAttribI4i(
|
| GLuint index, GLint v0, GLint v1, GLint v2, GLint v3) {
|
| GLint v[4] = { v0, v1, v2, v3 };
|
| if (SetVertexAttribValue("glVertexAttribI4i", index, v)) {
|
| + state_.vertex_attrib_manager->UpdateAttribBaseTypeAndMask(
|
| + index, SHADER_VARIABLE_INT);
|
| glVertexAttribI4i(index, v0, v1, v2, v3);
|
| }
|
| }
|
|
|
| void GLES2DecoderImpl::DoVertexAttribI4iv(GLuint index, const GLint* v) {
|
| if (SetVertexAttribValue("glVertexAttribI4iv", index, v)) {
|
| + state_.vertex_attrib_manager->UpdateAttribBaseTypeAndMask(
|
| + index, SHADER_VARIABLE_INT);
|
| glVertexAttribI4iv(index, v);
|
| }
|
| }
|
| @@ -9869,12 +9915,16 @@ void GLES2DecoderImpl::DoVertexAttribI4ui(
|
| GLuint index, GLuint v0, GLuint v1, GLuint v2, GLuint v3) {
|
| GLuint v[4] = { v0, v1, v2, v3 };
|
| if (SetVertexAttribValue("glVertexAttribI4ui", index, v)) {
|
| + state_.vertex_attrib_manager->UpdateAttribBaseTypeAndMask(
|
| + index, SHADER_VARIABLE_UINT);
|
| glVertexAttribI4ui(index, v0, v1, v2, v3);
|
| }
|
| }
|
|
|
| void GLES2DecoderImpl::DoVertexAttribI4uiv(GLuint index, const GLuint* v) {
|
| if (SetVertexAttribValue("glVertexAttribI4uiv", index, v)) {
|
| + state_.vertex_attrib_manager->UpdateAttribBaseTypeAndMask(
|
| + index, SHADER_VARIABLE_UINT);
|
| glVertexAttribI4uiv(index, v);
|
| }
|
| }
|
| @@ -9954,6 +10004,9 @@ error::Error GLES2DecoderImpl::HandleVertexAttribIPointer(
|
| return error::kNoError;
|
| }
|
| GLsizei group_size = GLES2Util::GetGroupSizeForBufferType(size, type);
|
| + GLenum base_type = (type == GL_BYTE || type == GL_SHORT || type == GL_INT) ?
|
| + SHADER_VARIABLE_INT : SHADER_VARIABLE_UINT;
|
| + state_.vertex_attrib_manager->UpdateAttribBaseTypeAndMask(indx, base_type);
|
| state_.vertex_attrib_manager
|
| ->SetAttribInfo(indx,
|
| state_.bound_array_buffer.get(),
|
| @@ -10048,6 +10101,8 @@ error::Error GLES2DecoderImpl::HandleVertexAttribPointer(
|
| return error::kNoError;
|
| }
|
| GLsizei group_size = GLES2Util::GetGroupSizeForBufferType(size, type);
|
| + state_.vertex_attrib_manager->UpdateAttribBaseTypeAndMask(
|
| + indx, SHADER_VARIABLE_FLOAT);
|
| state_.vertex_attrib_manager
|
| ->SetAttribInfo(indx,
|
| state_.bound_array_buffer.get(),
|
|
|