diff options
Diffstat (limited to 'gpu/command_buffer/service')
11 files changed, 503 insertions, 97 deletions
diff --git a/gpu/command_buffer/service/context_state.cc b/gpu/command_buffer/service/context_state.cc index 5c5da82..13c56b4 100644 --- a/gpu/command_buffer/service/context_state.cc +++ b/gpu/command_buffer/service/context_state.cc @@ -81,6 +81,113 @@ TextureUnit::TextureUnit() TextureUnit::~TextureUnit() { } +bool Vec4::Equal(const Vec4& other) const { + if (type_ != other.type_) + return false; + switch (type_) { + case kFloat: + for (size_t ii = 0; ii < 4; ++ii) { + if (v_[ii].float_value != other.v_[ii].float_value) + return false; + } + break; + case kInt: + for (size_t ii = 0; ii < 4; ++ii) { + if (v_[ii].int_value != other.v_[ii].int_value) + return false; + } + break; + case kUInt: + for (size_t ii = 0; ii < 4; ++ii) { + if (v_[ii].uint_value != other.v_[ii].uint_value) + return false; + } + break; + } + return true; +} + +template <> +void Vec4::GetValues<GLfloat>(GLfloat* values) const { + DCHECK(values); + switch (type_) { + case kFloat: + for (size_t ii = 0; ii < 4; ++ii) + values[ii] = v_[ii].float_value; + break; + case kInt: + for (size_t ii = 0; ii < 4; ++ii) + values[ii] = static_cast<GLfloat>(v_[ii].int_value); + break; + case kUInt: + for (size_t ii = 0; ii < 4; ++ii) + values[ii] = static_cast<GLfloat>(v_[ii].uint_value); + break; + } +} + +template <> +void Vec4::GetValues<GLint>(GLint* values) const { + DCHECK(values); + switch (type_) { + case kFloat: + for (size_t ii = 0; ii < 4; ++ii) + values[ii] = static_cast<GLint>(v_[ii].float_value); + break; + case kInt: + for (size_t ii = 0; ii < 4; ++ii) + values[ii] = v_[ii].int_value; + break; + case kUInt: + for (size_t ii = 0; ii < 4; ++ii) + values[ii] = static_cast<GLint>(v_[ii].uint_value); + break; + } +} + +template<> +void Vec4::GetValues<GLuint>(GLuint* values) const { + DCHECK(values); + switch (type_) { + case kFloat: + for (size_t ii = 0; ii < 4; ++ii) + values[ii] = static_cast<GLuint>(v_[ii].float_value); + break; + case kInt: + for (size_t ii = 0; ii < 4; ++ii) + values[ii] = static_cast<GLuint>(v_[ii].int_value); + break; + case kUInt: + for (size_t ii = 0; ii < 4; ++ii) + values[ii] = v_[ii].uint_value; + break; + } +} + +template <> +void Vec4::SetValues<GLfloat>(const GLfloat* values) { + DCHECK(values); + for (size_t ii = 0; ii < 4; ++ii) + v_[ii].float_value = values[ii]; + type_ = kFloat; +} + +template <> +void Vec4::SetValues<GLint>(const GLint* values) { + DCHECK(values); + for (size_t ii = 0; ii < 4; ++ii) + v_[ii].int_value = values[ii]; + type_ = kInt; +} + +template <> +void Vec4::SetValues<GLuint>(const GLuint* values) { + DCHECK(values); + for (size_t ii = 0; ii < 4; ++ii) + v_[ii].uint_value = values[ii]; + type_ = kUInt; +} + ContextState::ContextState(FeatureInfo* feature_info, ErrorStateClient* error_state_client, Logger* logger) @@ -185,7 +292,29 @@ void ContextState::RestoreActiveTextureUnitBinding(unsigned int target) const { void ContextState::RestoreVertexAttribValues() const { for (size_t attrib = 0; attrib < vertex_attrib_manager->num_attribs(); ++attrib) { - glVertexAttrib4fv(attrib, attrib_values[attrib].v); + switch (attrib_values[attrib].type()) { + case Vec4::kFloat: + { + GLfloat v[4]; + attrib_values[attrib].GetValues(v); + glVertexAttrib4fv(attrib, v); + } + break; + case Vec4::kInt: + { + GLint v[4]; + attrib_values[attrib].GetValues(v); + glVertexAttribI4iv(attrib, v); + } + break; + case Vec4::kUInt: + { + GLuint v[4]; + attrib_values[attrib].GetValues(v); + glVertexAttribI4uiv(attrib, v); + } + break; + } } } diff --git a/gpu/command_buffer/service/context_state.h b/gpu/command_buffer/service/context_state.h index 32bef4c..166a906 100644 --- a/gpu/command_buffer/service/context_state.h +++ b/gpu/command_buffer/service/context_state.h @@ -101,16 +101,59 @@ struct GPU_EXPORT TextureUnit { } }; -struct Vec4 { +class GPU_EXPORT Vec4 { + public: + enum DataType { + kFloat, + kInt, + kUInt, + }; + Vec4() { - v[0] = 0.0f; - v[1] = 0.0f; - v[2] = 0.0f; - v[3] = 1.0f; + v_[0].float_value = 0.0f; + v_[1].float_value = 0.0f; + v_[2].float_value = 0.0f; + v_[3].float_value = 1.0f; + type_ = kFloat; + } + + template <typename T> + void GetValues(T* values) const; + + template <typename T> + void SetValues(const T* values); + + DataType type() const { + return type_; } - float v[4]; + + bool Equal(const Vec4& other) const; + + private: + union ValueUnion { + GLfloat float_value; + GLint int_value; + GLuint uint_value; + }; + + ValueUnion v_[4]; + DataType type_; }; +template <> +GPU_EXPORT void Vec4::GetValues<GLfloat>(GLfloat* values) const; +template <> +GPU_EXPORT void Vec4::GetValues<GLint>(GLint* values) const; +template <> +GPU_EXPORT void Vec4::GetValues<GLuint>(GLuint* values) const; + +template <> +GPU_EXPORT void Vec4::SetValues<GLfloat>(const GLfloat* values); +template <> +GPU_EXPORT void Vec4::SetValues<GLint>(const GLint* values); +template <> +GPU_EXPORT void Vec4::SetValues<GLuint>(const GLuint* values); + struct GPU_EXPORT ContextState { ContextState(FeatureInfo* feature_info, ErrorStateClient* error_state_client, diff --git a/gpu/command_buffer/service/context_state_unittest.cc b/gpu/command_buffer/service/context_state_unittest.cc new file mode 100644 index 0000000..5a835de --- /dev/null +++ b/gpu/command_buffer/service/context_state_unittest.cc @@ -0,0 +1,86 @@ +// Copyright (c) 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "gpu/command_buffer/service/context_state.h" + +#include "testing/gtest/include/gtest/gtest.h" + +namespace gpu { +namespace gles2 { + +TEST(ContextStateVec4Test, DefaultValues) { + Vec4 v; + EXPECT_EQ(Vec4::kFloat, v.type()); + GLfloat f[4]; + v.GetValues(f); + EXPECT_EQ(0.f, f[0]); + EXPECT_EQ(0.f, f[1]); + EXPECT_EQ(0.f, f[2]); + EXPECT_EQ(1.f, f[3]); +} + +TEST(ContextStateVec4Test, SetGetFloatValues) { + Vec4 v; + + const GLfloat kFloatValues[4] = { 2.f, 3.f, 4.f, 5.f }; + v.SetValues(kFloatValues); + EXPECT_EQ(Vec4::kFloat, v.type()); + GLfloat fv[4]; + v.GetValues(fv); + for (size_t ii = 0; ii < 4; ++ii) { + EXPECT_EQ(kFloatValues[ii], fv[ii]); + } +} + +TEST(ContextStateVec4Test, SetGetIntValues) { + Vec4 v; + + const GLint kIntValues[4] = { 2, 3, -4, 5 }; + v.SetValues(kIntValues); + EXPECT_EQ(Vec4::kInt, v.type()); + GLint iv[4]; + v.GetValues(iv); + for (size_t ii = 0; ii < 4; ++ii) { + EXPECT_EQ(kIntValues[ii], iv[ii]); + } +} + +TEST(ContextStateVec4Test, SetGetUIntValues) { + Vec4 v; + + const GLuint kUIntValues[4] = { 2, 3, 4, 5 }; + v.SetValues(kUIntValues); + EXPECT_EQ(Vec4::kUInt, v.type()); + GLuint uiv[4]; + v.GetValues(uiv); + for (size_t ii = 0; ii < 4; ++ii) { + EXPECT_EQ(kUIntValues[ii], uiv[ii]); + } +} + +TEST(ContextStateVec4Test, Equal) { + Vec4 v1, v2; + + const GLint kIntValues[4] = { 2, 3, 4, 5 }; + const GLuint kUIntValues[4] = { 2, 3, 4, 5 }; + + v1.SetValues(kIntValues); + v2.SetValues(kUIntValues); + EXPECT_FALSE(v1.Equal(v2)); + EXPECT_FALSE(v2.Equal(v1)); + + v2.SetValues(kIntValues); + EXPECT_TRUE(v1.Equal(v2)); + EXPECT_TRUE(v2.Equal(v1)); + + const GLint kIntValues2[4] = { 2, 3, 4, 6 }; + v2.SetValues(kIntValues2); + EXPECT_FALSE(v1.Equal(v2)); + EXPECT_FALSE(v2.Equal(v1)); +} + +} // namespace gles2 +} // namespace gpu + + diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 884566d..6cef78f 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -173,6 +173,14 @@ static gfx::OverlayTransform GetGFXOverlayTransform(GLenum plane_transform) { } } +struct Vec4f { + explicit Vec4f(const Vec4& data) { + data.GetValues(v); + } + + GLfloat v[4]; +}; + } // namespace class GLES2DecoderImpl; @@ -1472,8 +1480,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); @@ -2466,11 +2478,6 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) validation_fbo_(0) { DCHECK(group); - attrib_0_value_.v[0] = 0.0f; - attrib_0_value_.v[1] = 0.0f; - attrib_0_value_.v[2] = 0.0f; - attrib_0_value_.v[3] = 1.0f; - // The shader translator is used for WebGL even when running on EGL // because additional restrictions are needed (like only enabling // GL_OES_standard_derivatives on demand). It is used for the unit @@ -6852,7 +6859,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 +6885,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.Equal(attrib_0_value_)))){ + // 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 +7603,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 +7628,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 +7673,46 @@ 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]; + case GL_CURRENT_VERTEX_ATTRIB: + state_.attrib_values[index].GetValues(params); 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( @@ -7717,11 +7721,7 @@ bool GLES2DecoderImpl::SetVertexAttribValue( LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "index out of range"); return false; } - Vec4& v = state_.attrib_values[index]; - v.v[0] = value[0]; - v.v[1] = value[1]; - v.v[2] = value[2]; - v.v[3] = value[3]; + state_.attrib_values[index].SetValues(value); return true; } diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h index 27a7f41..c68b8a5 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h @@ -2070,6 +2070,74 @@ error::Error GLES2DecoderImpl::HandleGetVertexAttribiv( return error::kNoError; } +error::Error GLES2DecoderImpl::HandleGetVertexAttribIiv( + uint32_t immediate_data_size, + const void* cmd_data) { + if (!unsafe_es3_apis_enabled()) + return error::kUnknownCommand; + const gles2::cmds::GetVertexAttribIiv& c = + *static_cast<const gles2::cmds::GetVertexAttribIiv*>(cmd_data); + (void)c; + GLuint index = static_cast<GLuint>(c.index); + GLenum pname = static_cast<GLenum>(c.pname); + typedef cmds::GetVertexAttribIiv::Result Result; + GLsizei num_values = 0; + GetNumValuesReturnedForGLGet(pname, &num_values); + Result* result = GetSharedMemoryAs<Result*>( + c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values)); + GLint* params = result ? result->GetData() : NULL; + if (params == NULL) { + return error::kOutOfBounds; + } + LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribIiv"); + // Check that the client initialized the result. + if (result->size != 0) { + return error::kInvalidArguments; + } + DoGetVertexAttribIiv(index, pname, params); + GLenum error = glGetError(); + if (error == GL_NO_ERROR) { + result->SetNumResults(num_values); + } else { + LOCAL_SET_GL_ERROR(error, "GetVertexAttribIiv", ""); + } + return error::kNoError; +} + +error::Error GLES2DecoderImpl::HandleGetVertexAttribIuiv( + uint32_t immediate_data_size, + const void* cmd_data) { + if (!unsafe_es3_apis_enabled()) + return error::kUnknownCommand; + const gles2::cmds::GetVertexAttribIuiv& c = + *static_cast<const gles2::cmds::GetVertexAttribIuiv*>(cmd_data); + (void)c; + GLuint index = static_cast<GLuint>(c.index); + GLenum pname = static_cast<GLenum>(c.pname); + typedef cmds::GetVertexAttribIuiv::Result Result; + GLsizei num_values = 0; + GetNumValuesReturnedForGLGet(pname, &num_values); + Result* result = GetSharedMemoryAs<Result*>( + c.params_shm_id, c.params_shm_offset, Result::ComputeSize(num_values)); + GLuint* params = result ? result->GetData() : NULL; + if (params == NULL) { + return error::kOutOfBounds; + } + LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribIuiv"); + // Check that the client initialized the result. + if (result->size != 0) { + return error::kInvalidArguments; + } + DoGetVertexAttribIuiv(index, pname, params); + GLenum error = glGetError(); + if (error == GL_NO_ERROR) { + result->SetNumResults(num_values); + } else { + LOCAL_SET_GL_ERROR(error, "GetVertexAttribIuiv", ""); + } + return error::kNoError; +} + error::Error GLES2DecoderImpl::HandleHint(uint32_t immediate_data_size, const void* cmd_data) { const gles2::cmds::Hint& c = *static_cast<const gles2::cmds::Hint*>(cmd_data); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc index 5c242be..2b471b97 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc @@ -456,12 +456,6 @@ void GLES2DecoderTestBase::SpecializedSetup<cmds::UniformMatrix2fvImmediate, 0>( }; template <> -void GLES2DecoderTestBase::SpecializedSetup<cmds::UniformMatrix3fvImmediate, 0>( - bool /* valid */) { - SetupShaderForUniform(GL_FLOAT_MAT3); -}; - -template <> void GLES2DecoderTestBase::SpecializedSetup<cmds::TexParameterf, 0>( bool /* valid */) { DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); @@ -511,6 +505,32 @@ void GLES2DecoderTestBase::SpecializedSetup<cmds::GetVertexAttribfv, 0>( } }; +template <> +void GLES2DecoderTestBase::SpecializedSetup<cmds::GetVertexAttribIiv, 0>( + bool valid) { + DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); + DoVertexAttribPointer(1, 1, GL_FLOAT, 0, 0); + if (valid) { + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); + } +}; + +template <> +void GLES2DecoderTestBase::SpecializedSetup<cmds::GetVertexAttribIuiv, 0>( + bool valid) { + DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); + DoVertexAttribPointer(1, 1, GL_FLOAT, 0, 0); + if (valid) { + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); + } +}; + #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h" diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h index f79567a..d21613b 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h @@ -443,6 +443,42 @@ TEST_P(GLES2DecoderTest2, GetVertexAttribivInvalidArgs2_1) { EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(0u, result->size); } + +TEST_P(GLES2DecoderTest2, GetVertexAttribIivValidArgs) { + SpecializedSetup<cmds::GetVertexAttribIiv, 0>(true); + typedef cmds::GetVertexAttribIiv::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); + result->size = 0; + cmds::GetVertexAttribIiv cmd; + cmd.Init(1, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, shared_memory_id_, + shared_memory_offset_); + decoder_->set_unsafe_es3_apis_enabled(true); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( + GL_VERTEX_ATTRIB_ARRAY_NORMALIZED), + result->GetNumResults()); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); + decoder_->set_unsafe_es3_apis_enabled(false); + EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); +} + +TEST_P(GLES2DecoderTest2, GetVertexAttribIuivValidArgs) { + SpecializedSetup<cmds::GetVertexAttribIuiv, 0>(true); + typedef cmds::GetVertexAttribIuiv::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); + result->size = 0; + cmds::GetVertexAttribIuiv cmd; + cmd.Init(1, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, shared_memory_id_, + shared_memory_offset_); + decoder_->set_unsafe_es3_apis_enabled(true); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( + GL_VERTEX_ATTRIB_ARRAY_NORMALIZED), + result->GetNumResults()); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); + decoder_->set_unsafe_es3_apis_enabled(false); + EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); +} // TODO(gman): GetVertexAttribPointerv TEST_P(GLES2DecoderTest2, HintValidArgs) { @@ -1613,37 +1649,4 @@ TEST_P(GLES2DecoderTest2, UniformMatrix2x4fvImmediateValidArgs) { decoder_->set_unsafe_es3_apis_enabled(false); EXPECT_EQ(error::kUnknownCommand, ExecuteImmediateCmd(cmd, sizeof(temp))); } - -TEST_P(GLES2DecoderTest2, UniformMatrix3fvImmediateValidArgs) { - cmds::UniformMatrix3fvImmediate& cmd = - *GetImmediateAs<cmds::UniformMatrix3fvImmediate>(); - EXPECT_CALL(*gl_, - UniformMatrix3fv(1, 2, false, reinterpret_cast<GLfloat*>( - ImmediateDataAddress(&cmd)))); - SpecializedSetup<cmds::UniformMatrix3fvImmediate, 0>(true); - GLfloat temp[9 * 2] = { - 0, - }; - cmd.Init(1, 2, &temp[0]); - EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); -} - -TEST_P(GLES2DecoderTest2, UniformMatrix3x2fvImmediateValidArgs) { - cmds::UniformMatrix3x2fvImmediate& cmd = - *GetImmediateAs<cmds::UniformMatrix3x2fvImmediate>(); - EXPECT_CALL(*gl_, - UniformMatrix3x2fv(1, 2, false, reinterpret_cast<GLfloat*>( - ImmediateDataAddress(&cmd)))); - SpecializedSetup<cmds::UniformMatrix3x2fvImmediate, 0>(true); - GLfloat temp[6 * 2] = { - 0, - }; - cmd.Init(1, 2, &temp[0]); - decoder_->set_unsafe_es3_apis_enabled(true); - EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); - decoder_->set_unsafe_es3_apis_enabled(false); - EXPECT_EQ(error::kUnknownCommand, ExecuteImmediateCmd(cmd, sizeof(temp))); -} #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_2_AUTOGEN_H_ diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3.cc index 1413c31..b705f60 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3.cc @@ -37,6 +37,12 @@ class GLES2DecoderTest3 : public GLES2DecoderTestBase { INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderTest3, ::testing::Bool()); template <> +void GLES2DecoderTestBase::SpecializedSetup<cmds::UniformMatrix3fvImmediate, 0>( + bool /* valid */) { + SetupShaderForUniform(GL_FLOAT_MAT3); +}; + +template <> void GLES2DecoderTestBase::SpecializedSetup<cmds::UniformMatrix4fvImmediate, 0>( bool /* valid */) { SetupShaderForUniform(GL_FLOAT_MAT4); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h index 3927010..e09d540 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h @@ -12,6 +12,39 @@ #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_3_AUTOGEN_H_ #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_3_AUTOGEN_H_ +TEST_P(GLES2DecoderTest3, UniformMatrix3fvImmediateValidArgs) { + cmds::UniformMatrix3fvImmediate& cmd = + *GetImmediateAs<cmds::UniformMatrix3fvImmediate>(); + EXPECT_CALL(*gl_, + UniformMatrix3fv(1, 2, false, reinterpret_cast<GLfloat*>( + ImmediateDataAddress(&cmd)))); + SpecializedSetup<cmds::UniformMatrix3fvImmediate, 0>(true); + GLfloat temp[9 * 2] = { + 0, + }; + cmd.Init(1, 2, &temp[0]); + EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); +} + +TEST_P(GLES2DecoderTest3, UniformMatrix3x2fvImmediateValidArgs) { + cmds::UniformMatrix3x2fvImmediate& cmd = + *GetImmediateAs<cmds::UniformMatrix3x2fvImmediate>(); + EXPECT_CALL(*gl_, + UniformMatrix3x2fv(1, 2, false, reinterpret_cast<GLfloat*>( + ImmediateDataAddress(&cmd)))); + SpecializedSetup<cmds::UniformMatrix3x2fvImmediate, 0>(true); + GLfloat temp[6 * 2] = { + 0, + }; + cmd.Init(1, 2, &temp[0]); + decoder_->set_unsafe_es3_apis_enabled(true); + EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); + decoder_->set_unsafe_es3_apis_enabled(false); + EXPECT_EQ(error::kUnknownCommand, ExecuteImmediateCmd(cmd, sizeof(temp))); +} + TEST_P(GLES2DecoderTest3, UniformMatrix3x4fvImmediateValidArgs) { cmds::UniformMatrix3x4fvImmediate& cmd = *GetImmediateAs<cmds::UniformMatrix3x4fvImmediate>(); diff --git a/gpu/command_buffer/service/vertex_attrib_manager.cc b/gpu/command_buffer/service/vertex_attrib_manager.cc index 8725c4f..b7ead54 100644 --- a/gpu/command_buffer/service/vertex_attrib_manager.cc +++ b/gpu/command_buffer/service/vertex_attrib_manager.cc @@ -35,6 +35,7 @@ VertexAttrib::VertexAttrib() gl_stride_(0), real_stride_(16), divisor_(0), + integer_(GL_FALSE), is_client_side_array_(false), list_(NULL) { } diff --git a/gpu/command_buffer/service/vertex_attrib_manager.h b/gpu/command_buffer/service/vertex_attrib_manager.h index 73fa480..b5425e0 100644 --- a/gpu/command_buffer/service/vertex_attrib_manager.h +++ b/gpu/command_buffer/service/vertex_attrib_manager.h @@ -65,6 +65,10 @@ class GPU_EXPORT VertexAttrib { return divisor_; } + GLboolean integer() const { + return integer_; + } + bool enabled() const { return enabled_; } @@ -118,6 +122,10 @@ class GPU_EXPORT VertexAttrib { divisor_ = divisor; } + void SetInteger(GLboolean integer) { + integer_ = integer; + } + void Unbind(Buffer* buffer); // The index of this attrib. @@ -147,6 +155,8 @@ class GPU_EXPORT VertexAttrib { GLsizei divisor_; + GLboolean integer_; + // Will be true if this was assigned to a client side array. bool is_client_side_array_; @@ -218,6 +228,13 @@ class GPU_EXPORT VertexAttribManager : } } + void SetInteger(GLuint index, GLboolean integer) { + VertexAttrib* attrib = GetVertexAttrib(index); + if (attrib) { + attrib->SetInteger(integer); + } + } + void SetElementArrayBuffer(Buffer* buffer); Buffer* element_array_buffer() const { return element_array_buffer_.get(); } |