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 884566d142471f079e231acac8a0935f632c1a3f..c998e970f9757dc9c310e8919529e6c28529beef 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
@@ -173,6 +173,16 @@ static gfx::OverlayTransform GetGFXOverlayTransform(GLenum plane_transform) { |
} |
} |
+struct Vec4f { |
+ Vec4f(Vec4 data) { |
+ for (int ii = 0; ii < 4; ++ii) { |
+ v[ii] = static_cast<float>(data.v[ii]); |
+ } |
+ } |
+ |
+ float v[4]; |
+}; |
+ |
} // namespace |
class GLES2DecoderImpl; |
@@ -1472,8 +1482,12 @@ class GLES2DecoderImpl : public GLES2Decoder, |
void InitTextureMaxAnisotropyIfNeeded(GLenum target, GLenum pname); |
// Wrappers for glGetVertexAttrib. |
- void DoGetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params); |
- void DoGetVertexAttribiv(GLuint index, GLenum pname, GLint *params); |
+ template <typename T> |
+ void DoGetVertexAttribImpl(GLuint index, GLenum pname, T* params); |
+ void DoGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params); |
+ void DoGetVertexAttribiv(GLuint index, GLenum pname, GLint* params); |
+ void DoGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params); |
+ void DoGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params); |
// Wrappers for glIsXXX functions. |
bool DoIsEnabled(GLenum cap); |
@@ -6852,7 +6866,7 @@ bool GLES2DecoderImpl::SimulateAttrib0( |
uint32 size_needed = 0; |
if (num_vertices == 0 || |
- !SafeMultiplyUint32(num_vertices, sizeof(Vec4), &size_needed) || |
+ !SafeMultiplyUint32(num_vertices, sizeof(Vec4f), &size_needed) || |
size_needed > 0x7FFFFFFFU) { |
LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0"); |
return false; |
@@ -6878,12 +6892,12 @@ bool GLES2DecoderImpl::SimulateAttrib0( |
const Vec4& value = state_.attrib_values[0]; |
if (new_buffer || |
(attrib_0_used && |
- (!attrib_0_buffer_matches_value_ || |
- (value.v[0] != attrib_0_value_.v[0] || |
- value.v[1] != attrib_0_value_.v[1] || |
- value.v[2] != attrib_0_value_.v[2] || |
- value.v[3] != attrib_0_value_.v[3])))) { |
- std::vector<Vec4> temp(num_vertices, value); |
+ (!attrib_0_buffer_matches_value_ || value.v != attrib_0_value_.v))) { |
+ // TODO(zmo): This is not 100% correct because we might lose data when |
+ // casting to float type, but it is a corner case and once we migrate to |
+ // core profiles on desktop GL, it is no longer relevant. |
+ Vec4f fvalue(value); |
+ std::vector<Vec4f> temp(num_vertices, fvalue); |
glBufferSubData(GL_ARRAY_BUFFER, 0, size_needed, &temp[0].v[0]); |
attrib_0_buffer_matches_value_ = true; |
attrib_0_value_ = value; |
@@ -7596,7 +7610,8 @@ void GLES2DecoderImpl::DoValidateProgram(GLuint program_client_id) { |
void GLES2DecoderImpl::GetVertexAttribHelper( |
const VertexAttrib* attrib, GLenum pname, GLint* params) { |
switch (pname) { |
- case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: { |
+ case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
+ { |
Buffer* buffer = attrib->buffer(); |
if (buffer && !buffer->IsDeleted()) { |
GLuint client_id; |
@@ -7620,9 +7635,12 @@ void GLES2DecoderImpl::GetVertexAttribHelper( |
case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
*params = attrib->normalized(); |
break; |
- case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: |
+ case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
*params = attrib->divisor(); |
break; |
+ case GL_VERTEX_ATTRIB_ARRAY_INTEGER: |
+ *params = attrib->integer(); |
+ break; |
default: |
NOTREACHED(); |
break; |
@@ -7662,53 +7680,51 @@ void GLES2DecoderImpl::InitTextureMaxAnisotropyIfNeeded( |
texture->InitTextureMaxAnisotropyIfNeeded(target); |
} |
-void GLES2DecoderImpl::DoGetVertexAttribfv( |
- GLuint index, GLenum pname, GLfloat* params) { |
+template <typename T> |
+void GLES2DecoderImpl::DoGetVertexAttribImpl( |
+ GLuint index, GLenum pname, T* params) { |
VertexAttrib* attrib = state_.vertex_attrib_manager->GetVertexAttrib(index); |
if (!attrib) { |
LOCAL_SET_GL_ERROR( |
- GL_INVALID_VALUE, "glGetVertexAttribfv", "index out of range"); |
+ GL_INVALID_VALUE, "glGetVertexAttrib", "index out of range"); |
return; |
} |
switch (pname) { |
case GL_CURRENT_VERTEX_ATTRIB: { |
const Vec4& value = state_.attrib_values[index]; |
- params[0] = value.v[0]; |
- params[1] = value.v[1]; |
- params[2] = value.v[2]; |
- params[3] = value.v[3]; |
+ params[0] = static_cast<T>(value.v[0]); |
+ params[1] = static_cast<T>(value.v[1]); |
+ params[2] = static_cast<T>(value.v[2]); |
+ params[3] = static_cast<T>(value.v[3]); |
break; |
} |
default: { |
GLint value = 0; |
GetVertexAttribHelper(attrib, pname, &value); |
- *params = static_cast<GLfloat>(value); |
+ *params = static_cast<T>(value); |
break; |
} |
} |
} |
+void GLES2DecoderImpl::DoGetVertexAttribfv( |
+ GLuint index, GLenum pname, GLfloat* params) { |
+ DoGetVertexAttribImpl<GLfloat>(index, pname, params); |
+} |
+ |
void GLES2DecoderImpl::DoGetVertexAttribiv( |
GLuint index, GLenum pname, GLint* params) { |
- VertexAttrib* attrib = state_.vertex_attrib_manager->GetVertexAttrib(index); |
- if (!attrib) { |
- LOCAL_SET_GL_ERROR( |
- GL_INVALID_VALUE, "glGetVertexAttribiv", "index out of range"); |
- return; |
- } |
- switch (pname) { |
- case GL_CURRENT_VERTEX_ATTRIB: { |
- const Vec4& value = state_.attrib_values[index]; |
- params[0] = static_cast<GLint>(value.v[0]); |
- params[1] = static_cast<GLint>(value.v[1]); |
- params[2] = static_cast<GLint>(value.v[2]); |
- params[3] = static_cast<GLint>(value.v[3]); |
- break; |
- } |
- default: |
- GetVertexAttribHelper(attrib, pname, params); |
- break; |
- } |
+ DoGetVertexAttribImpl<GLint>(index, pname, params); |
+} |
+ |
+void GLES2DecoderImpl::DoGetVertexAttribIiv( |
+ GLuint index, GLenum pname, GLint* params) { |
+ DoGetVertexAttribImpl<GLint>(index, pname, params); |
+} |
+ |
+void GLES2DecoderImpl::DoGetVertexAttribIuiv( |
+ GLuint index, GLenum pname, GLuint* params) { |
+ DoGetVertexAttribImpl<GLuint>(index, pname, params); |
} |
bool GLES2DecoderImpl::SetVertexAttribValue( |