Chromium Code Reviews| 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 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1465 | 1465 |
| 1466 // Wrapper for glGetShaderiv | 1466 // Wrapper for glGetShaderiv |
| 1467 void DoGetShaderiv(GLuint shader, GLenum pname, GLint* params); | 1467 void DoGetShaderiv(GLuint shader, GLenum pname, GLint* params); |
| 1468 | 1468 |
| 1469 // Wrappers for glGetTexParameter. | 1469 // Wrappers for glGetTexParameter. |
| 1470 void DoGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params); | 1470 void DoGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params); |
| 1471 void DoGetTexParameteriv(GLenum target, GLenum pname, GLint* params); | 1471 void DoGetTexParameteriv(GLenum target, GLenum pname, GLint* params); |
| 1472 void InitTextureMaxAnisotropyIfNeeded(GLenum target, GLenum pname); | 1472 void InitTextureMaxAnisotropyIfNeeded(GLenum target, GLenum pname); |
| 1473 | 1473 |
| 1474 // Wrappers for glGetVertexAttrib. | 1474 // Wrappers for glGetVertexAttrib. |
| 1475 void DoGetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params); | 1475 template <typename T> |
| 1476 void DoGetVertexAttribiv(GLuint index, GLenum pname, GLint *params); | 1476 void DoGetVertexAttribImpl(GLuint index, GLenum pname, T* params); |
| 1477 void DoGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params); | |
| 1478 void DoGetVertexAttribiv(GLuint index, GLenum pname, GLint* params); | |
| 1479 void DoGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params); | |
| 1480 void DoGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params); | |
| 1477 | 1481 |
| 1478 // Wrappers for glIsXXX functions. | 1482 // Wrappers for glIsXXX functions. |
| 1479 bool DoIsEnabled(GLenum cap); | 1483 bool DoIsEnabled(GLenum cap); |
| 1480 bool DoIsBuffer(GLuint client_id); | 1484 bool DoIsBuffer(GLuint client_id); |
| 1481 bool DoIsFramebuffer(GLuint client_id); | 1485 bool DoIsFramebuffer(GLuint client_id); |
| 1482 bool DoIsProgram(GLuint client_id); | 1486 bool DoIsProgram(GLuint client_id); |
| 1483 bool DoIsRenderbuffer(GLuint client_id); | 1487 bool DoIsRenderbuffer(GLuint client_id); |
| 1484 bool DoIsShader(GLuint client_id); | 1488 bool DoIsShader(GLuint client_id); |
| 1485 bool DoIsTexture(GLuint client_id); | 1489 bool DoIsTexture(GLuint client_id); |
| 1486 bool DoIsVertexArrayOES(GLuint client_id); | 1490 bool DoIsVertexArrayOES(GLuint client_id); |
| (...skipping 6098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7585 program_client_id, "glValidateProgram"); | 7589 program_client_id, "glValidateProgram"); |
| 7586 if (!program) { | 7590 if (!program) { |
| 7587 return; | 7591 return; |
| 7588 } | 7592 } |
| 7589 program->Validate(); | 7593 program->Validate(); |
| 7590 } | 7594 } |
| 7591 | 7595 |
| 7592 void GLES2DecoderImpl::GetVertexAttribHelper( | 7596 void GLES2DecoderImpl::GetVertexAttribHelper( |
| 7593 const VertexAttrib* attrib, GLenum pname, GLint* params) { | 7597 const VertexAttrib* attrib, GLenum pname, GLint* params) { |
| 7594 switch (pname) { | 7598 switch (pname) { |
| 7595 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: { | 7599 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
| 7600 { | |
| 7596 Buffer* buffer = attrib->buffer(); | 7601 Buffer* buffer = attrib->buffer(); |
| 7597 if (buffer && !buffer->IsDeleted()) { | 7602 if (buffer && !buffer->IsDeleted()) { |
| 7598 GLuint client_id; | 7603 GLuint client_id; |
| 7599 buffer_manager()->GetClientId(buffer->service_id(), &client_id); | 7604 buffer_manager()->GetClientId(buffer->service_id(), &client_id); |
| 7600 *params = client_id; | 7605 *params = client_id; |
| 7601 } | 7606 } |
| 7602 break; | 7607 break; |
| 7603 } | 7608 } |
| 7604 case GL_VERTEX_ATTRIB_ARRAY_ENABLED: | 7609 case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
| 7605 *params = attrib->enabled(); | 7610 *params = attrib->enabled(); |
| 7606 break; | 7611 break; |
| 7607 case GL_VERTEX_ATTRIB_ARRAY_SIZE: | 7612 case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
| 7608 *params = attrib->size(); | 7613 *params = attrib->size(); |
| 7609 break; | 7614 break; |
| 7610 case GL_VERTEX_ATTRIB_ARRAY_STRIDE: | 7615 case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
| 7611 *params = attrib->gl_stride(); | 7616 *params = attrib->gl_stride(); |
| 7612 break; | 7617 break; |
| 7613 case GL_VERTEX_ATTRIB_ARRAY_TYPE: | 7618 case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
| 7614 *params = attrib->type(); | 7619 *params = attrib->type(); |
| 7615 break; | 7620 break; |
| 7616 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: | 7621 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
| 7617 *params = attrib->normalized(); | 7622 *params = attrib->normalized(); |
| 7618 break; | 7623 break; |
| 7619 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: | 7624 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 7620 *params = attrib->divisor(); | 7625 *params = attrib->divisor(); |
| 7621 break; | 7626 break; |
| 7627 case GL_VERTEX_ATTRIB_ARRAY_INTEGER: | |
| 7628 *params = attrib->integer(); | |
| 7629 break; | |
| 7622 default: | 7630 default: |
| 7623 NOTREACHED(); | 7631 NOTREACHED(); |
| 7624 break; | 7632 break; |
| 7625 } | 7633 } |
| 7626 } | 7634 } |
| 7627 | 7635 |
| 7628 void GLES2DecoderImpl::DoGetTexParameterfv( | 7636 void GLES2DecoderImpl::DoGetTexParameterfv( |
| 7629 GLenum target, GLenum pname, GLfloat* params) { | 7637 GLenum target, GLenum pname, GLfloat* params) { |
| 7630 InitTextureMaxAnisotropyIfNeeded(target, pname); | 7638 InitTextureMaxAnisotropyIfNeeded(target, pname); |
| 7631 glGetTexParameterfv(target, pname, params); | 7639 glGetTexParameterfv(target, pname, params); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 7651 if (!texture_ref) { | 7659 if (!texture_ref) { |
| 7652 LOCAL_SET_GL_ERROR( | 7660 LOCAL_SET_GL_ERROR( |
| 7653 GL_INVALID_OPERATION, | 7661 GL_INVALID_OPERATION, |
| 7654 "glGetTexParamter{fi}v", "unknown texture for target"); | 7662 "glGetTexParamter{fi}v", "unknown texture for target"); |
| 7655 return; | 7663 return; |
| 7656 } | 7664 } |
| 7657 Texture* texture = texture_ref->texture(); | 7665 Texture* texture = texture_ref->texture(); |
| 7658 texture->InitTextureMaxAnisotropyIfNeeded(target); | 7666 texture->InitTextureMaxAnisotropyIfNeeded(target); |
| 7659 } | 7667 } |
| 7660 | 7668 |
| 7661 void GLES2DecoderImpl::DoGetVertexAttribfv( | 7669 template <typename T> |
| 7662 GLuint index, GLenum pname, GLfloat* params) { | 7670 void GLES2DecoderImpl::DoGetVertexAttribImpl( |
| 7671 GLuint index, GLenum pname, T* params) { | |
| 7663 VertexAttrib* attrib = state_.vertex_attrib_manager->GetVertexAttrib(index); | 7672 VertexAttrib* attrib = state_.vertex_attrib_manager->GetVertexAttrib(index); |
| 7664 if (!attrib) { | 7673 if (!attrib) { |
| 7665 LOCAL_SET_GL_ERROR( | 7674 LOCAL_SET_GL_ERROR( |
| 7666 GL_INVALID_VALUE, "glGetVertexAttribfv", "index out of range"); | 7675 GL_INVALID_VALUE, "glGetVertexAttrib", "index out of range"); |
| 7667 return; | 7676 return; |
| 7668 } | 7677 } |
| 7669 switch (pname) { | 7678 switch (pname) { |
| 7670 case GL_CURRENT_VERTEX_ATTRIB: { | 7679 case GL_CURRENT_VERTEX_ATTRIB: { |
| 7671 const Vec4& value = state_.attrib_values[index]; | 7680 const Vec4& value = state_.attrib_values[index]; |
| 7672 params[0] = value.v[0]; | 7681 params[0] = static_cast<T>(value.v[0]); |
| 7673 params[1] = value.v[1]; | 7682 params[1] = static_cast<T>(value.v[1]); |
| 7674 params[2] = value.v[2]; | 7683 params[2] = static_cast<T>(value.v[2]); |
| 7675 params[3] = value.v[3]; | 7684 params[3] = static_cast<T>(value.v[3]); |
| 7676 break; | 7685 break; |
| 7677 } | 7686 } |
| 7678 default: { | 7687 default: { |
| 7679 GLint value = 0; | 7688 GLint value = 0; |
| 7680 GetVertexAttribHelper(attrib, pname, &value); | 7689 GetVertexAttribHelper(attrib, pname, &value); |
| 7681 *params = static_cast<GLfloat>(value); | 7690 *params = static_cast<T>(value); |
| 7682 break; | 7691 break; |
| 7683 } | 7692 } |
| 7684 } | 7693 } |
| 7685 } | 7694 } |
| 7686 | 7695 |
| 7696 void GLES2DecoderImpl::DoGetVertexAttribfv( | |
| 7697 GLuint index, GLenum pname, GLfloat* params) { | |
| 7698 DoGetVertexAttribImpl<GLfloat>(index, pname, params); | |
| 7699 } | |
| 7700 | |
| 7687 void GLES2DecoderImpl::DoGetVertexAttribiv( | 7701 void GLES2DecoderImpl::DoGetVertexAttribiv( |
| 7688 GLuint index, GLenum pname, GLint* params) { | 7702 GLuint index, GLenum pname, GLint* params) { |
| 7689 VertexAttrib* attrib = state_.vertex_attrib_manager->GetVertexAttrib(index); | 7703 DoGetVertexAttribImpl<GLint>(index, pname, params); |
| 7690 if (!attrib) { | 7704 } |
| 7691 LOCAL_SET_GL_ERROR( | 7705 |
| 7692 GL_INVALID_VALUE, "glGetVertexAttribiv", "index out of range"); | 7706 void GLES2DecoderImpl::DoGetVertexAttribIiv( |
| 7693 return; | 7707 GLuint index, GLenum pname, GLint* params) { |
| 7694 } | 7708 DoGetVertexAttribImpl<GLint>(index, pname, params); |
|
piman
2015/05/11 21:12:50
So, this is not quite right. DoVertexAttribI4i and
Zhenyao Mo
2015/05/12 23:57:45
per our discussion, use double as internal represe
| |
| 7695 switch (pname) { | 7709 } |
| 7696 case GL_CURRENT_VERTEX_ATTRIB: { | 7710 |
| 7697 const Vec4& value = state_.attrib_values[index]; | 7711 void GLES2DecoderImpl::DoGetVertexAttribIuiv( |
| 7698 params[0] = static_cast<GLint>(value.v[0]); | 7712 GLuint index, GLenum pname, GLuint* params) { |
| 7699 params[1] = static_cast<GLint>(value.v[1]); | 7713 DoGetVertexAttribImpl<GLuint>(index, pname, params); |
| 7700 params[2] = static_cast<GLint>(value.v[2]); | |
| 7701 params[3] = static_cast<GLint>(value.v[3]); | |
| 7702 break; | |
| 7703 } | |
| 7704 default: | |
| 7705 GetVertexAttribHelper(attrib, pname, params); | |
| 7706 break; | |
| 7707 } | |
| 7708 } | 7714 } |
| 7709 | 7715 |
| 7710 bool GLES2DecoderImpl::SetVertexAttribValue( | 7716 bool GLES2DecoderImpl::SetVertexAttribValue( |
| 7711 const char* function_name, GLuint index, const GLfloat* value) { | 7717 const char* function_name, GLuint index, const GLfloat* value) { |
| 7712 if (index >= state_.attrib_values.size()) { | 7718 if (index >= state_.attrib_values.size()) { |
| 7713 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "index out of range"); | 7719 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "index out of range"); |
| 7714 return false; | 7720 return false; |
| 7715 } | 7721 } |
| 7716 Vec4& v = state_.attrib_values[index]; | 7722 Vec4& v = state_.attrib_values[index]; |
| 7717 v.v[0] = value[0]; | 7723 v.v[0] = value[0]; |
| (...skipping 5421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13139 } | 13145 } |
| 13140 } | 13146 } |
| 13141 | 13147 |
| 13142 // Include the auto-generated part of this file. We split this because it means | 13148 // Include the auto-generated part of this file. We split this because it means |
| 13143 // we can easily edit the non-auto generated parts right here in this file | 13149 // we can easily edit the non-auto generated parts right here in this file |
| 13144 // instead of having to edit some template or the code generator. | 13150 // instead of having to edit some template or the code generator. |
| 13145 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 13151 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 13146 | 13152 |
| 13147 } // namespace gles2 | 13153 } // namespace gles2 |
| 13148 } // namespace gpu | 13154 } // namespace gpu |
| OLD | NEW |