diff options
Diffstat (limited to 'gpu')
-rwxr-xr-x | gpu/command_buffer/build_gles2_cmd_buffer.py | 3 | ||||
-rw-r--r-- | gpu/command_buffer/service/error_state.cc | 24 | ||||
-rw-r--r-- | gpu/command_buffer/service/error_state.h | 22 | ||||
-rw-r--r-- | gpu/command_buffer/service/error_state_mock.h | 9 | ||||
-rw-r--r-- | gpu/command_buffer/service/framebuffer_manager_unittest.cc | 28 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.cc | 22 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h | 28 | ||||
-rw-r--r-- | gpu/command_buffer/service/test_helper.cc | 6 | ||||
-rw-r--r-- | gpu/command_buffer/service/test_helper.h | 2 | ||||
-rw-r--r-- | gpu/command_buffer/service/texture_manager.cc | 59 | ||||
-rw-r--r-- | gpu/command_buffer/service/texture_manager.h | 13 | ||||
-rw-r--r-- | gpu/command_buffer/service/texture_manager_unittest.cc | 14 |
12 files changed, 161 insertions, 69 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index a65de47..c8bd8da 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -2030,7 +2030,6 @@ _FUNCTION_INFO = { }, 'TexParameterf': { 'decoder_func': 'DoTexParameterf', - 'gl_test_func': 'glTexParameteri', 'valid_args': { '2': 'GL_NEAREST' }, @@ -2047,7 +2046,7 @@ _FUNCTION_INFO = { 'data_value': 'GL_NEAREST', 'count': 1, 'decoder_func': 'DoTexParameterfv', - 'gl_test_func': 'glTexParameteri', + 'gl_test_func': 'glTexParameterf', 'first_element_only': True, }, 'TexParameteriv': { diff --git a/gpu/command_buffer/service/error_state.cc b/gpu/command_buffer/service/error_state.cc index 524ea4f..3468c7e 100644 --- a/gpu/command_buffer/service/error_state.cc +++ b/gpu/command_buffer/service/error_state.cc @@ -33,13 +33,20 @@ class ErrorStateImpl : public ErrorState { const char* function_name, unsigned int value, const char* label) OVERRIDE; - virtual void SetGLErrorInvalidParam( + virtual void SetGLErrorInvalidParami( const char* filename, int line, unsigned int error, const char* function_name, unsigned int pname, int param) OVERRIDE; + virtual void SetGLErrorInvalidParamf( + const char* filename, + int line, + unsigned int error, + const char* function_name, + unsigned int pname, + float param) OVERRIDE; virtual unsigned int PeekGLError( const char* filename, int line, const char* function_name) OVERRIDE; @@ -131,7 +138,7 @@ void ErrorStateImpl::SetGLErrorInvalidEnum( GLES2Util::GetStringEnum(value)).c_str()); } -void ErrorStateImpl::SetGLErrorInvalidParam( +void ErrorStateImpl::SetGLErrorInvalidParami( const char* filename, int line, unsigned int error, @@ -152,6 +159,19 @@ void ErrorStateImpl::SetGLErrorInvalidParam( } } +void ErrorStateImpl::SetGLErrorInvalidParamf( + const char* filename, + int line, + unsigned int error, + const char* function_name, + unsigned int pname, float param) { + SetGLError( + filename, line, error, function_name, + (std::string("trying to set ") + + GLES2Util::GetStringEnum(pname) + " to " + + base::StringPrintf("%G", param)).c_str()); +} + void ErrorStateImpl::CopyRealGLErrorsToWrapper( const char* filename, int line, const char* function_name) { GLenum error; diff --git a/gpu/command_buffer/service/error_state.h b/gpu/command_buffer/service/error_state.h index 507b738..c4ef691 100644 --- a/gpu/command_buffer/service/error_state.h +++ b/gpu/command_buffer/service/error_state.h @@ -31,10 +31,17 @@ class Logger; __FILE__, __LINE__, function_name, value, label) // Use to synthesize a GL error on the error_state for an invalid enum based -// parameter. Will attempt to expand the parameter to a string. -#define ERRORSTATE_SET_GL_ERROR_INVALID_PARAM( \ +// integer parameter. Will attempt to expand the parameter to a string. +#define ERRORSTATE_SET_GL_ERROR_INVALID_PARAMI( \ error_state, error, function_name, pname, param) \ - error_state->SetGLErrorInvalidParam( \ + error_state->SetGLErrorInvalidParami( \ + __FILE__, __LINE__, error, function_name, pname, param) + +// Use to synthesize a GL error on the error_state for an invalid enum based +// float parameter. Will attempt to expand the parameter to a string. +#define ERRORSTATE_SET_GL_ERROR_INVALID_PARAMF( \ + error_state, error, function_name, pname, param) \ + error_state->SetGLErrorInvalidParamf( \ __FILE__, __LINE__, error, function_name, pname, param) // Use to move all pending error to the wrapper so on your next GL call @@ -69,13 +76,20 @@ class GPU_EXPORT ErrorState { const char* function_name, unsigned int value, const char* label) = 0; - virtual void SetGLErrorInvalidParam( + virtual void SetGLErrorInvalidParami( const char* filename, int line, unsigned int error, const char* function_name, unsigned int pname, int param) = 0; + virtual void SetGLErrorInvalidParamf( + const char* filename, + int line, + unsigned int error, + const char* function_name, + unsigned int pname, + float param) = 0; // Gets the GLError and stores it in our wrapper. Effectively // this lets us peek at the error without losing it. diff --git a/gpu/command_buffer/service/error_state_mock.h b/gpu/command_buffer/service/error_state_mock.h index 00bed9a..e418ca5 100644 --- a/gpu/command_buffer/service/error_state_mock.h +++ b/gpu/command_buffer/service/error_state_mock.h @@ -25,13 +25,20 @@ class MockErrorState : public ErrorState { MOCK_METHOD5(SetGLErrorInvalidEnum, void( const char* filename, int line, const char* function_name, unsigned value, const char* label)); - MOCK_METHOD6(SetGLErrorInvalidParam, void( + MOCK_METHOD6(SetGLErrorInvalidParami, void( const char* filename, int line, unsigned error, const char* function_name, unsigned pname, int param)); + MOCK_METHOD6(SetGLErrorInvalidParamf, void( + const char* filename, + int line, + unsigned error, + const char* function_name, + unsigned pname, + float param)); MOCK_METHOD3(PeekGLError, unsigned( const char* file, int line, const char* filename)); MOCK_METHOD3(CopyRealGLErrorsToWrapper, void( diff --git a/gpu/command_buffer/service/framebuffer_manager_unittest.cc b/gpu/command_buffer/service/framebuffer_manager_unittest.cc index ba123dd..5046e0b 100644 --- a/gpu/command_buffer/service/framebuffer_manager_unittest.cc +++ b/gpu/command_buffer/service/framebuffer_manager_unittest.cc @@ -838,13 +838,13 @@ TEST_F(FramebufferInfoTest, GetStatus) { framebuffer_->GetStatus(texture_manager_.get(), GL_READ_FRAMEBUFFER); // Check changing the format calls CheckFramebuffferStatus. - TestHelper::SetTexParameterWithExpectations(gl_.get(), - error_state_.get(), - texture_manager_.get(), - texture2.get(), - GL_TEXTURE_WRAP_S, - GL_CLAMP_TO_EDGE, - GL_NO_ERROR); + TestHelper::SetTexParameteriWithExpectations(gl_.get(), + error_state_.get(), + texture_manager_.get(), + texture2.get(), + GL_TEXTURE_WRAP_S, + GL_CLAMP_TO_EDGE, + GL_NO_ERROR); EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER)) .WillOnce(Return(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT)) @@ -862,13 +862,13 @@ TEST_F(FramebufferInfoTest, GetStatus) { .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) .RetiresOnSaturation(); } - TestHelper::SetTexParameterWithExpectations(gl_.get(), - error_state_.get(), - texture_manager_.get(), - texture2.get(), - GL_TEXTURE_WRAP_S, - GL_REPEAT, - GL_NO_ERROR); + TestHelper::SetTexParameteriWithExpectations(gl_.get(), + error_state_.get(), + texture_manager_.get(), + texture2.get(), + GL_TEXTURE_WRAP_S, + GL_REPEAT, + GL_NO_ERROR); framebuffer_->GetStatus(texture_manager_.get(), GL_READ_FRAMEBUFFER); // Check Unbinding does not call CheckFramebufferStatus diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 8555617..74ca454 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -3098,25 +3098,25 @@ void GLES2DecoderImpl::UpdateParentTextureInfo() { GL_RGBA, GL_UNSIGNED_BYTE, true); - texture_manager()->SetParameter( + texture_manager()->SetParameteri( "UpdateParentTextureInfo", GetErrorState(), offscreen_saved_color_texture_info_.get(), GL_TEXTURE_MAG_FILTER, GL_NEAREST); - texture_manager()->SetParameter( + texture_manager()->SetParameteri( "UpdateParentTextureInfo", GetErrorState(), offscreen_saved_color_texture_info_.get(), GL_TEXTURE_MIN_FILTER, GL_NEAREST); - texture_manager()->SetParameter( + texture_manager()->SetParameteri( "UpdateParentTextureInfo", GetErrorState(), offscreen_saved_color_texture_info_.get(), GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - texture_manager()->SetParameter( + texture_manager()->SetParameteri( "UpdateParentTextureInfo", GetErrorState(), offscreen_saved_color_texture_info_.get(), @@ -5467,9 +5467,8 @@ void GLES2DecoderImpl::DoTexParameterf( return; } - texture_manager()->SetParameter( - "glTexParameterf", GetErrorState(), texture, pname, - static_cast<GLint>(param)); + texture_manager()->SetParameterf( + "glTexParameterf", GetErrorState(), texture, pname, param); } void GLES2DecoderImpl::DoTexParameteri( @@ -5481,7 +5480,7 @@ void GLES2DecoderImpl::DoTexParameteri( return; } - texture_manager()->SetParameter( + texture_manager()->SetParameteri( "glTexParameteri", GetErrorState(), texture, pname, param); } @@ -5494,9 +5493,8 @@ void GLES2DecoderImpl::DoTexParameterfv( return; } - texture_manager()->SetParameter( - "glTexParameterfv", GetErrorState(), texture, pname, - static_cast<GLint>(params[0])); + texture_manager()->SetParameterf( + "glTexParameterfv", GetErrorState(), texture, pname, *params); } void GLES2DecoderImpl::DoTexParameteriv( @@ -5509,7 +5507,7 @@ void GLES2DecoderImpl::DoTexParameteriv( return; } - texture_manager()->SetParameter( + texture_manager()->SetParameteri( "glTexParameteriv", GetErrorState(), texture, pname, *params); } 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 58de1404..bed0dbd 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 @@ -235,7 +235,7 @@ TEST_F(GLES2DecoderTest2, StencilOpSeparateValidArgs) { TEST_F(GLES2DecoderTest2, TexParameterfValidArgs) { EXPECT_CALL(*gl_, - TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)); + TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)); SpecializedSetup<cmds::TexParameterf, 0>(true); cmds::TexParameterf cmd; cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -244,7 +244,7 @@ TEST_F(GLES2DecoderTest2, TexParameterfValidArgs) { } TEST_F(GLES2DecoderTest2, TexParameterfInvalidArgs0_0) { - EXPECT_CALL(*gl_, TexParameteri(_, _, _)).Times(0); + EXPECT_CALL(*gl_, TexParameterf(_, _, _)).Times(0); SpecializedSetup<cmds::TexParameterf, 0>(false); cmds::TexParameterf cmd; cmd.Init(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -253,7 +253,7 @@ TEST_F(GLES2DecoderTest2, TexParameterfInvalidArgs0_0) { } TEST_F(GLES2DecoderTest2, TexParameterfInvalidArgs0_1) { - EXPECT_CALL(*gl_, TexParameteri(_, _, _)).Times(0); + EXPECT_CALL(*gl_, TexParameterf(_, _, _)).Times(0); SpecializedSetup<cmds::TexParameterf, 0>(false); cmds::TexParameterf cmd; cmd.Init(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -262,7 +262,7 @@ TEST_F(GLES2DecoderTest2, TexParameterfInvalidArgs0_1) { } TEST_F(GLES2DecoderTest2, TexParameterfInvalidArgs1_0) { - EXPECT_CALL(*gl_, TexParameteri(_, _, _)).Times(0); + EXPECT_CALL(*gl_, TexParameterf(_, _, _)).Times(0); SpecializedSetup<cmds::TexParameterf, 0>(false); cmds::TexParameterf cmd; cmd.Init(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_NEAREST); @@ -280,7 +280,7 @@ TEST_F(GLES2DecoderTest2, TexParameterfvValidArgs) { GetSharedMemoryAs<GLfloat*>()[0] = GL_NEAREST; EXPECT_CALL( *gl_, - TexParameteri(GL_TEXTURE_2D, + TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, *reinterpret_cast<const GLfloat*>(shared_memory_address_))); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); @@ -288,7 +288,7 @@ TEST_F(GLES2DecoderTest2, TexParameterfvValidArgs) { } TEST_F(GLES2DecoderTest2, TexParameterfvInvalidArgs0_0) { - EXPECT_CALL(*gl_, TexParameteri(_, _, _)).Times(0); + EXPECT_CALL(*gl_, TexParameterf(_, _, _)).Times(0); SpecializedSetup<cmds::TexParameterfv, 0>(false); cmds::TexParameterfv cmd; cmd.Init(GL_TEXTURE_1D, @@ -301,7 +301,7 @@ TEST_F(GLES2DecoderTest2, TexParameterfvInvalidArgs0_0) { } TEST_F(GLES2DecoderTest2, TexParameterfvInvalidArgs0_1) { - EXPECT_CALL(*gl_, TexParameteri(_, _, _)).Times(0); + EXPECT_CALL(*gl_, TexParameterf(_, _, _)).Times(0); SpecializedSetup<cmds::TexParameterfv, 0>(false); cmds::TexParameterfv cmd; cmd.Init(GL_TEXTURE_3D, @@ -314,7 +314,7 @@ TEST_F(GLES2DecoderTest2, TexParameterfvInvalidArgs0_1) { } TEST_F(GLES2DecoderTest2, TexParameterfvInvalidArgs1_0) { - EXPECT_CALL(*gl_, TexParameteri(_, _, _)).Times(0); + EXPECT_CALL(*gl_, TexParameterf(_, _, _)).Times(0); SpecializedSetup<cmds::TexParameterfv, 0>(false); cmds::TexParameterfv cmd; cmd.Init(GL_TEXTURE_2D, @@ -327,7 +327,7 @@ TEST_F(GLES2DecoderTest2, TexParameterfvInvalidArgs1_0) { } TEST_F(GLES2DecoderTest2, TexParameterfvInvalidArgs2_0) { - EXPECT_CALL(*gl_, TexParameteri(_, _, _)).Times(0); + EXPECT_CALL(*gl_, TexParameterf(_, _, _)).Times(0); SpecializedSetup<cmds::TexParameterfv, 0>(false); cmds::TexParameterfv cmd; cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, kInvalidSharedMemoryId, 0); @@ -336,7 +336,7 @@ TEST_F(GLES2DecoderTest2, TexParameterfvInvalidArgs2_0) { } TEST_F(GLES2DecoderTest2, TexParameterfvInvalidArgs2_1) { - EXPECT_CALL(*gl_, TexParameteri(_, _, _)).Times(0); + EXPECT_CALL(*gl_, TexParameterf(_, _, _)).Times(0); SpecializedSetup<cmds::TexParameterfv, 0>(false); cmds::TexParameterfv cmd; cmd.Init(GL_TEXTURE_2D, @@ -355,7 +355,7 @@ TEST_F(GLES2DecoderTest2, TexParameterfvImmediateValidArgs) { cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &temp[0]); EXPECT_CALL( *gl_, - TexParameteri(GL_TEXTURE_2D, + TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, *reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); @@ -365,7 +365,7 @@ TEST_F(GLES2DecoderTest2, TexParameterfvImmediateValidArgs) { TEST_F(GLES2DecoderTest2, TexParameterfvImmediateInvalidArgs0_0) { cmds::TexParameterfvImmediate& cmd = *GetImmediateAs<cmds::TexParameterfvImmediate>(); - EXPECT_CALL(*gl_, TexParameteri(_, _, _)).Times(0); + EXPECT_CALL(*gl_, TexParameterf(_, _, _)).Times(0); SpecializedSetup<cmds::TexParameterfvImmediate, 0>(false); GLfloat temp[1] = {GL_NEAREST, }; cmd.Init(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, &temp[0]); @@ -376,7 +376,7 @@ TEST_F(GLES2DecoderTest2, TexParameterfvImmediateInvalidArgs0_0) { TEST_F(GLES2DecoderTest2, TexParameterfvImmediateInvalidArgs0_1) { cmds::TexParameterfvImmediate& cmd = *GetImmediateAs<cmds::TexParameterfvImmediate>(); - EXPECT_CALL(*gl_, TexParameteri(_, _, _)).Times(0); + EXPECT_CALL(*gl_, TexParameterf(_, _, _)).Times(0); SpecializedSetup<cmds::TexParameterfvImmediate, 0>(false); GLfloat temp[1] = {GL_NEAREST, }; cmd.Init(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, &temp[0]); @@ -387,7 +387,7 @@ TEST_F(GLES2DecoderTest2, TexParameterfvImmediateInvalidArgs0_1) { TEST_F(GLES2DecoderTest2, TexParameterfvImmediateInvalidArgs1_0) { cmds::TexParameterfvImmediate& cmd = *GetImmediateAs<cmds::TexParameterfvImmediate>(); - EXPECT_CALL(*gl_, TexParameteri(_, _, _)).Times(0); + EXPECT_CALL(*gl_, TexParameterf(_, _, _)).Times(0); SpecializedSetup<cmds::TexParameterfvImmediate, 0>(false); GLfloat temp[1] = {GL_NEAREST, }; cmd.Init(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, &temp[0]); diff --git a/gpu/command_buffer/service/test_helper.cc b/gpu/command_buffer/service/test_helper.cc index c164eea..4e55dad 100644 --- a/gpu/command_buffer/service/test_helper.cc +++ b/gpu/command_buffer/service/test_helper.cc @@ -600,7 +600,7 @@ void TestHelper::DoBufferData( manager->DoBufferData(error_state, buffer, size, usage, data); } -void TestHelper::SetTexParameterWithExpectations( +void TestHelper::SetTexParameteriWithExpectations( ::gfx::MockGLInterface* gl, MockErrorState* error_state, TextureManager* manager, TextureRef* texture_ref, GLenum pname, GLint value, GLenum error) { @@ -616,11 +616,11 @@ void TestHelper::SetTexParameterWithExpectations( .Times(1) .RetiresOnSaturation(); } else { - EXPECT_CALL(*error_state, SetGLErrorInvalidParam(_, _, error, _, _, _)) + EXPECT_CALL(*error_state, SetGLErrorInvalidParami(_, _, error, _, _, _)) .Times(1) .RetiresOnSaturation(); } - manager->SetParameter("", error_state, texture_ref, pname, value); + manager->SetParameteri("", error_state, texture_ref, pname, value); } ScopedGLImplementationSetter::ScopedGLImplementationSetter( diff --git a/gpu/command_buffer/service/test_helper.h b/gpu/command_buffer/service/test_helper.h index 99041e7..b16f05f 100644 --- a/gpu/command_buffer/service/test_helper.h +++ b/gpu/command_buffer/service/test_helper.h @@ -98,7 +98,7 @@ class TestHelper { BufferManager* manager, Buffer* buffer, GLsizeiptr size, GLenum usage, const GLvoid* data, GLenum error); - static void SetTexParameterWithExpectations( + static void SetTexParameteriWithExpectations( ::gfx::MockGLInterface* gl, MockErrorState* error_state, TextureManager* manager, TextureRef* texture_ref, GLenum pname, GLint value, GLenum error); diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc index e090e0b..0975258 100644 --- a/gpu/command_buffer/service/texture_manager.cc +++ b/gpu/command_buffer/service/texture_manager.cc @@ -570,7 +570,7 @@ bool Texture::GetLevelType( return false; } -GLenum Texture::SetParameter( +GLenum Texture::SetParameteri( const FeatureInfo* feature_info, GLenum pname, GLint param) { DCHECK(feature_info); @@ -638,6 +638,31 @@ GLenum Texture::SetParameter( return GL_NO_ERROR; } +GLenum Texture::SetParameterf( + const FeatureInfo* feature_info, GLenum pname, GLfloat param) { + switch (pname) { + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + case GL_TEXTURE_POOL_CHROMIUM: + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + case GL_TEXTURE_USAGE_ANGLE: + { + GLint iparam = static_cast<GLint>(param); + return SetParameteri(feature_info, pname, iparam); + } + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + if (param < 1.f) { + return GL_INVALID_VALUE; + } + break; + default: + NOTREACHED(); + return GL_INVALID_ENUM; + } + return GL_NO_ERROR; +} + void Texture::Update(const FeatureInfo* feature_info) { // Update npot status. // Assume GL_TEXTURE_EXTERNAL_OES textures are npot, all others @@ -1081,20 +1106,20 @@ TextureRef* TextureManager::Consume( return ref.get(); } -void TextureManager::SetParameter( +void TextureManager::SetParameteri( const char* function_name, ErrorState* error_state, TextureRef* ref, GLenum pname, GLint param) { DCHECK(error_state); DCHECK(ref); Texture* texture = ref->texture(); - GLenum result = texture->SetParameter(feature_info_.get(), pname, param); + GLenum result = texture->SetParameteri(feature_info_.get(), pname, param); if (result != GL_NO_ERROR) { if (result == GL_INVALID_ENUM) { ERRORSTATE_SET_GL_ERROR_INVALID_ENUM( error_state, function_name, param, "param"); } else { - ERRORSTATE_SET_GL_ERROR_INVALID_PARAM( - error_state, result, function_name, pname, static_cast<GLint>(param)); + ERRORSTATE_SET_GL_ERROR_INVALID_PARAMI( + error_state, result, function_name, pname, param); } } else { // Texture tracking pools exist only for the command decoder, so @@ -1105,6 +1130,30 @@ void TextureManager::SetParameter( } } +void TextureManager::SetParameterf( + const char* function_name, ErrorState* error_state, + TextureRef* ref, GLenum pname, GLfloat param) { + DCHECK(error_state); + DCHECK(ref); + Texture* texture = ref->texture(); + GLenum result = texture->SetParameterf(feature_info_.get(), pname, param); + if (result != GL_NO_ERROR) { + if (result == GL_INVALID_ENUM) { + ERRORSTATE_SET_GL_ERROR_INVALID_ENUM( + error_state, function_name, param, "param"); + } else { + ERRORSTATE_SET_GL_ERROR_INVALID_PARAMF( + error_state, result, function_name, pname, param); + } + } else { + // Texture tracking pools exist only for the command decoder, so + // do not pass them on to the native GL implementation. + if (pname != GL_TEXTURE_POOL_CHROMIUM) { + glTexParameterf(texture->target(), pname, param); + } + } +} + bool TextureManager::MarkMipmapsGenerated(TextureRef* ref) { DCHECK(ref); Texture* texture = ref->texture(); diff --git a/gpu/command_buffer/service/texture_manager.h b/gpu/command_buffer/service/texture_manager.h index 2682e46..0b106fc 100644 --- a/gpu/command_buffer/service/texture_manager.h +++ b/gpu/command_buffer/service/texture_manager.h @@ -252,10 +252,12 @@ class GPU_EXPORT Texture { bool ClearLevel(GLES2Decoder* decoder, GLenum target, GLint level); // Sets a texture parameter. - // TODO(gman): Expand to SetParameteri,f,iv,fv + // TODO(gman): Expand to SetParameteriv,fv // Returns GL_NO_ERROR on success. Otherwise the error to generate. - GLenum SetParameter( + GLenum SetParameteri( const FeatureInfo* feature_info, GLenum pname, GLint param); + GLenum SetParameterf( + const FeatureInfo* feature_info, GLenum pname, GLfloat param); // Makes each of the mip levels as though they were generated. bool MarkMipmapsGenerated(const FeatureInfo* feature_info); @@ -576,10 +578,13 @@ class GPU_EXPORT TextureManager { // Sets a texture parameter of a Texture // Returns GL_NO_ERROR on success. Otherwise the error to generate. - // TODO(gman): Expand to SetParameteri,f,iv,fv - void SetParameter( + // TODO(gman): Expand to SetParameteriv,fv + void SetParameteri( const char* function_name, ErrorState* error_state, TextureRef* ref, GLenum pname, GLint param); + void SetParameterf( + const char* function_name, ErrorState* error_state, + TextureRef* ref, GLenum pname, GLfloat param); // Makes each of the mip levels as though they were generated. // Returns false if that's not allowed for the given texture. diff --git a/gpu/command_buffer/service/texture_manager_unittest.cc b/gpu/command_buffer/service/texture_manager_unittest.cc index 168a4fd..ae88a99 100644 --- a/gpu/command_buffer/service/texture_manager_unittest.cc +++ b/gpu/command_buffer/service/texture_manager_unittest.cc @@ -77,7 +77,7 @@ class TextureManagerTest : public testing::Test { void SetParameter( TextureRef* texture_ref, GLenum pname, GLint value, GLenum error) { - TestHelper::SetTexParameterWithExpectations( + TestHelper::SetTexParameteriWithExpectations( gl_.get(), error_state_.get(), manager_.get(), texture_ref, pname, value, error); } @@ -175,7 +175,7 @@ TEST_F(TextureManagerTest, TextureUsageExt) { // Check texture got created. TextureRef* texture_ref = manager.GetTexture(kClient1Id); ASSERT_TRUE(texture_ref != NULL); - TestHelper::SetTexParameterWithExpectations( + TestHelper::SetTexParameteriWithExpectations( gl_.get(), error_state_.get(), &manager, texture_ref, GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE,GL_NO_ERROR); EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_ATTACHMENT_ANGLE), @@ -390,7 +390,7 @@ class TextureTestBase : public testing::Test { void SetParameter( TextureRef* texture_ref, GLenum pname, GLint value, GLenum error) { - TestHelper::SetTexParameterWithExpectations( + TestHelper::SetTexParameteriWithExpectations( gl_.get(), error_state_.get(), manager_.get(), texture_ref, pname, value, error); } @@ -1094,11 +1094,11 @@ TEST_F(TextureTest, FloatNotLinear) { manager.SetLevelInfo(texture_ref, GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_FLOAT, true); EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture)); - TestHelper::SetTexParameterWithExpectations( + TestHelper::SetTexParameteriWithExpectations( gl_.get(), error_state_.get(), &manager, texture_ref, GL_TEXTURE_MAG_FILTER, GL_NEAREST, GL_NO_ERROR); EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture)); - TestHelper::SetTexParameterWithExpectations( + TestHelper::SetTexParameteriWithExpectations( gl_.get(), error_state_.get(), &manager, texture_ref, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST, GL_NO_ERROR); EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); @@ -1140,11 +1140,11 @@ TEST_F(TextureTest, HalfFloatNotLinear) { manager.SetLevelInfo(texture_ref, GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_HALF_FLOAT_OES, true); EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture)); - TestHelper::SetTexParameterWithExpectations( + TestHelper::SetTexParameteriWithExpectations( gl_.get(), error_state_.get(), &manager, texture_ref, GL_TEXTURE_MAG_FILTER, GL_NEAREST, GL_NO_ERROR); EXPECT_FALSE(TextureTestHelper::IsTextureComplete(texture)); - TestHelper::SetTexParameterWithExpectations( + TestHelper::SetTexParameteriWithExpectations( gl_.get(), error_state_.get(), &manager, texture_ref, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST, GL_NO_ERROR); EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); |