diff options
author | zmo <zmo@chromium.org> | 2015-06-05 15:23:43 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-05 22:24:19 +0000 |
commit | 335fe5410aba7d27d0890aeb68e77a4bba840ccd (patch) | |
tree | 3be240179cb8568521807da15ea582b615dd6127 /gpu | |
parent | 5e3e1a5ef2862ff4058931c46564a0da5c995770 (diff) | |
download | chromium_src-335fe5410aba7d27d0890aeb68e77a4bba840ccd.zip chromium_src-335fe5410aba7d27d0890aeb68e77a4bba840ccd.tar.gz chromium_src-335fe5410aba7d27d0890aeb68e77a4bba840ccd.tar.bz2 |
Fine tuning glGetInternalformativ.
This is to make glRenderbufferStorageMultisample related tests working.
BUG=429053
TEST=gpu_unittests, newly added multisampled-renderbuffer-initialization.html
R=piman@chromium.org
Review URL: https://codereview.chromium.org/1165553003
Cr-Commit-Position: refs/heads/master@{#333152}
Diffstat (limited to 'gpu')
12 files changed, 210 insertions, 206 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index f64e6cf..ab60f0d 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -2725,8 +2725,12 @@ _FUNCTION_INFO = { 'unsafe': True }, 'GetInternalformativ': { - 'type': 'GETn', + 'type': 'Custom', + 'data_transfer_methods': ['shm'], 'result': ['SizedResult<GLint>'], + 'cmd_args': + 'GLenumRenderBufferTarget target, GLenumRenderBufferFormat format, ' + 'GLenumInternalFormatParameter pname, GLint* params', 'unsafe': True, }, 'GetMaxValueInBufferCHROMIUM': { @@ -6376,11 +6380,9 @@ class GETnHandler(TypeHandler): } """ else: - code = """ GLenum error = glGetError(); + code = """ GLenum error = LOCAL_PEEK_GL_ERROR("%(func_name)s"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "%(func_name)s", ""); } return error::kNoError; } diff --git a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h index ed087ba..875cb7e 100644 --- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h +++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h @@ -943,13 +943,12 @@ void GetIntegerv(GLenum pname, void GetInternalformativ(GLenum target, GLenum format, GLenum pname, - GLsizei bufSize, uint32_t params_shm_id, uint32_t params_shm_offset) { gles2::cmds::GetInternalformativ* c = GetCmdSpace<gles2::cmds::GetInternalformativ>(); if (c) { - c->Init(target, format, pname, bufSize, params_shm_id, params_shm_offset); + c->Init(target, format, pname, params_shm_id, params_shm_offset); } } diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 7708bc1..e859299 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -5685,6 +5685,51 @@ void GLES2Implementation::WaitSync( CheckGLError(); } +void GLES2Implementation::GetInternalformativ( + GLenum target, GLenum format, GLenum pname, + GLsizei buf_size, GLint* params) { + GPU_CLIENT_SINGLE_THREAD_CHECK(); + GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params); + GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetInternalformativ(" + << GLES2Util::GetStringRenderBufferTarget(target) << ", " + << GLES2Util::GetStringRenderBufferFormat(format) << ", " + << GLES2Util::GetStringInternalFormatParameter(pname) + << ", " << buf_size << ", " + << static_cast<const void*>(params) << ")"); + if (buf_size < 0) { + SetGLError(GL_INVALID_VALUE, "glGetInternalformativ", "bufSize < 0"); + return; + } + TRACE_EVENT0("gpu", "GLES2Implementation::GetInternalformativ"); + if (GetInternalformativHelper(target, format, pname, buf_size, params)) { + return; + } + typedef cmds::GetInternalformativ::Result Result; + Result* result = GetResultAs<Result*>(); + if (!result) { + return; + } + result->SetNumResults(0); + helper_->GetInternalformativ(target, format, pname, + GetResultShmId(), GetResultShmOffset()); + WaitForCmd(); + GPU_CLIENT_LOG_CODE_BLOCK({ + for (int32_t i = 0; i < result->GetNumResults(); ++i) { + GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); + } + }); + if (buf_size > 0 && params) { + GLint* data = result->GetData(); + if (buf_size >= result->GetNumResults()) { + buf_size = result->GetNumResults(); + } + for (GLsizei ii = 0; ii < buf_size; ++ii) { + params[ii] = data[ii]; + } + } + CheckGLError(); +} + // Include the auto-generated part of this file. We split this because it means // we can easily edit the non-auto generated parts right here in this file // instead of having to edit some template or the code generator. diff --git a/gpu/command_buffer/client/gles2_implementation_impl_autogen.h b/gpu/command_buffer/client/gles2_implementation_impl_autogen.h index 4f4ee32..e386b514 100644 --- a/gpu/command_buffer/client/gles2_implementation_impl_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_impl_autogen.h @@ -1103,44 +1103,6 @@ void GLES2Implementation::GetIntegerv(GLenum pname, GLint* params) { }); CheckGLError(); } -void GLES2Implementation::GetInternalformativ(GLenum target, - GLenum format, - GLenum pname, - GLsizei bufSize, - GLint* params) { - GPU_CLIENT_SINGLE_THREAD_CHECK(); - GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params); - GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetInternalformativ(" - << GLES2Util::GetStringRenderBufferTarget(target) << ", " - << GLES2Util::GetStringRenderBufferFormat(format) << ", " - << GLES2Util::GetStringInternalFormatParameter(pname) - << ", " << bufSize << ", " - << static_cast<const void*>(params) << ")"); - if (bufSize < 0) { - SetGLError(GL_INVALID_VALUE, "glGetInternalformativ", "bufSize < 0"); - return; - } - TRACE_EVENT0("gpu", "GLES2Implementation::GetInternalformativ"); - if (GetInternalformativHelper(target, format, pname, bufSize, params)) { - return; - } - typedef cmds::GetInternalformativ::Result Result; - Result* result = GetResultAs<Result*>(); - if (!result) { - return; - } - result->SetNumResults(0); - helper_->GetInternalformativ(target, format, pname, bufSize, GetResultShmId(), - GetResultShmOffset()); - WaitForCmd(); - result->CopyResult(params); - GPU_CLIENT_LOG_CODE_BLOCK({ - for (int32_t i = 0; i < result->GetNumResults(); ++i) { - GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); - } - }); - CheckGLError(); -} void GLES2Implementation::GetProgramiv(GLuint program, GLenum pname, GLint* params) { diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc index 0b02f94..db978e1 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc @@ -3744,6 +3744,27 @@ TEST_F(GLES2ImplementationTest, DeleteBuffersUnmapsDataStore) { EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); } +TEST_F(GLES2ImplementationTest, GetInternalformativ) { + const GLint kNumSampleCounts = 8; + struct Cmds { + cmds::GetInternalformativ cmd; + }; + typedef cmds::GetInternalformativ::Result::Type ResultType; + ResultType result = 0; + Cmds expected; + ExpectedMemoryInfo result1 = + GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType)); + expected.cmd.Init(123, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, + result1.id, result1.offset); + EXPECT_CALL(*command_buffer(), OnFlush()) + .WillOnce(SetMemory(result1.ptr, + SizedResultHelper<ResultType>(kNumSampleCounts))) + .RetiresOnSaturation(); + gl_->GetInternalformativ(123, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 1, &result); + EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); + EXPECT_EQ(static_cast<ResultType>(kNumSampleCounts), result); +} + TEST_F(GLES2ImplementationManualInitTest, LoseContextOnOOM) { ContextInitOptions init_options; init_options.lose_context_when_out_of_memory = true; diff --git a/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h b/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h index f30ab89..3d462c4 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h @@ -909,25 +909,7 @@ TEST_F(GLES2ImplementationTest, GetIntegerv) { EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); EXPECT_EQ(static_cast<ResultType>(1), result); } - -TEST_F(GLES2ImplementationTest, GetInternalformativ) { - struct Cmds { - cmds::GetInternalformativ cmd; - }; - typedef cmds::GetInternalformativ::Result::Type ResultType; - ResultType result = 0; - Cmds expected; - ExpectedMemoryInfo result1 = - GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType)); - expected.cmd.Init(123, GL_RGBA4, GL_NUM_SAMPLE_COUNTS, 4, result1.id, - result1.offset); - EXPECT_CALL(*command_buffer(), OnFlush()) - .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1))) - .RetiresOnSaturation(); - gl_->GetInternalformativ(123, GL_RGBA4, GL_NUM_SAMPLE_COUNTS, 4, &result); - EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); - EXPECT_EQ(static_cast<ResultType>(1), result); -} +// TODO(zmo): Implement unit test for GetInternalformativ TEST_F(GLES2ImplementationTest, GetProgramiv) { struct Cmds { diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h index c4204ac..e92c2d1 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h @@ -4624,14 +4624,12 @@ struct GetInternalformativ { void Init(GLenum _target, GLenum _format, GLenum _pname, - GLsizei _bufSize, uint32_t _params_shm_id, uint32_t _params_shm_offset) { SetHeader(); target = _target; format = _format; pname = _pname; - bufSize = _bufSize; params_shm_id = _params_shm_id; params_shm_offset = _params_shm_offset; } @@ -4640,11 +4638,10 @@ struct GetInternalformativ { GLenum _target, GLenum _format, GLenum _pname, - GLsizei _bufSize, uint32_t _params_shm_id, uint32_t _params_shm_offset) { - static_cast<ValueType*>(cmd)->Init(_target, _format, _pname, _bufSize, - _params_shm_id, _params_shm_offset); + static_cast<ValueType*>(cmd) + ->Init(_target, _format, _pname, _params_shm_id, _params_shm_offset); return NextCmdAddress<ValueType>(cmd); } @@ -4652,13 +4649,12 @@ struct GetInternalformativ { uint32_t target; uint32_t format; uint32_t pname; - int32_t bufSize; uint32_t params_shm_id; uint32_t params_shm_offset; }; -static_assert(sizeof(GetInternalformativ) == 28, - "size of GetInternalformativ should be 28"); +static_assert(sizeof(GetInternalformativ) == 24, + "size of GetInternalformativ should be 24"); static_assert(offsetof(GetInternalformativ, header) == 0, "offset of GetInternalformativ header should be 0"); static_assert(offsetof(GetInternalformativ, target) == 4, @@ -4667,12 +4663,10 @@ static_assert(offsetof(GetInternalformativ, format) == 8, "offset of GetInternalformativ format should be 8"); static_assert(offsetof(GetInternalformativ, pname) == 12, "offset of GetInternalformativ pname should be 12"); -static_assert(offsetof(GetInternalformativ, bufSize) == 16, - "offset of GetInternalformativ bufSize should be 16"); -static_assert(offsetof(GetInternalformativ, params_shm_id) == 20, - "offset of GetInternalformativ params_shm_id should be 20"); -static_assert(offsetof(GetInternalformativ, params_shm_offset) == 24, - "offset of GetInternalformativ params_shm_offset should be 24"); +static_assert(offsetof(GetInternalformativ, params_shm_id) == 16, + "offset of GetInternalformativ params_shm_id should be 16"); +static_assert(offsetof(GetInternalformativ, params_shm_offset) == 20, + "offset of GetInternalformativ params_shm_offset should be 20"); struct GetProgramiv { typedef GetProgramiv ValueType; diff --git a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h index a7ff6bd..8a9539d 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h @@ -1441,17 +1441,16 @@ TEST_F(GLES2FormatTest, GetInternalformativ) { cmds::GetInternalformativ& cmd = *GetBufferAs<cmds::GetInternalformativ>(); void* next_cmd = cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLenum>(12), - static_cast<GLenum>(13), static_cast<GLsizei>(14), - static_cast<uint32_t>(15), static_cast<uint32_t>(16)); + static_cast<GLenum>(13), static_cast<uint32_t>(14), + static_cast<uint32_t>(15)); EXPECT_EQ(static_cast<uint32_t>(cmds::GetInternalformativ::kCmdId), cmd.header.command); EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); EXPECT_EQ(static_cast<GLenum>(12), cmd.format); EXPECT_EQ(static_cast<GLenum>(13), cmd.pname); - EXPECT_EQ(static_cast<GLsizei>(14), cmd.bufSize); - EXPECT_EQ(static_cast<uint32_t>(15), cmd.params_shm_id); - EXPECT_EQ(static_cast<uint32_t>(16), cmd.params_shm_offset); + EXPECT_EQ(static_cast<uint32_t>(14), cmd.params_shm_id); + EXPECT_EQ(static_cast<uint32_t>(15), cmd.params_shm_offset); CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd)); } diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index a14f72e..9a37f37 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -13176,6 +13176,59 @@ error::Error GLES2DecoderImpl::HandleWaitSync( return error::kNoError; } +error::Error GLES2DecoderImpl::HandleGetInternalformativ( + uint32_t immediate_data_size, const void* cmd_data) { + if (!unsafe_es3_apis_enabled()) + return error::kUnknownCommand; + const gles2::cmds::GetInternalformativ& c = + *static_cast<const gles2::cmds::GetInternalformativ*>(cmd_data); + GLenum target = static_cast<GLenum>(c.target); + GLenum format = static_cast<GLenum>(c.format); + GLenum pname = static_cast<GLenum>(c.pname); + if (!validators_->render_buffer_target.IsValid(target)) { + LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetInternalformativ", target, "target"); + return error::kNoError; + } + if (!validators_->render_buffer_format.IsValid(format)) { + LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetInternalformativ", format, "format"); + return error::kNoError; + } + if (!validators_->internal_format_parameter.IsValid(pname)) { + LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetInternalformativ", pname, "pname"); + return error::kNoError; + } + typedef cmds::GetInternalformativ::Result Result; + GLsizei num_values = 0; + switch (pname) { + case GL_NUM_SAMPLE_COUNTS: + num_values = 1; + break; + case GL_SAMPLES: + { + GLint value = 0; + glGetInternalformativ(target, format, GL_NUM_SAMPLE_COUNTS, 1, &value); + num_values = static_cast<GLsizei>(value); + } + break; + default: + NOTREACHED(); + break; + } + 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; + } + // Check that the client initialized the result. + if (result->size != 0) { + return error::kInvalidArguments; + } + glGetInternalformativ(target, format, pname, num_values, params); + result->SetNumResults(num_values); + return error::kNoError; +} + error::Error GLES2DecoderImpl::HandleMapBufferRange( uint32_t immediate_data_size, const void* cmd_data) { if (!unsafe_es3_apis_enabled()) { diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h index 09d07c0..9c910a2 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h @@ -1381,11 +1381,9 @@ error::Error GLES2DecoderImpl::HandleGetBooleanv(uint32_t immediate_data_size, return error::kInvalidArguments; } DoGetBooleanv(pname, params); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetBooleanv"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetBooleanv", ""); } return error::kNoError; } @@ -1463,11 +1461,9 @@ error::Error GLES2DecoderImpl::HandleGetFloatv(uint32_t immediate_data_size, return error::kInvalidArguments; } DoGetFloatv(pname, params); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetFloatv"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetFloatv", ""); } return error::kNoError; } @@ -1512,11 +1508,9 @@ error::Error GLES2DecoderImpl::HandleGetFramebufferAttachmentParameteriv( return error::kInvalidArguments; } DoGetFramebufferAttachmentParameteriv(target, attachment, pname, params); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetFramebufferAttachmentParameteriv"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetFramebufferAttachmentParameteriv", ""); } return error::kNoError; } @@ -1544,11 +1538,9 @@ error::Error GLES2DecoderImpl::HandleGetInteger64v(uint32_t immediate_data_size, return error::kInvalidArguments; } DoGetInteger64v(pname, params); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetInteger64v"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetInteger64v", ""); } return error::kNoError; } @@ -1577,11 +1569,9 @@ error::Error GLES2DecoderImpl::HandleGetIntegeri_v(uint32_t immediate_data_size, return error::kInvalidArguments; } glGetIntegeri_v(pname, index, data); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetIntegeri_v"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetIntegeri_v", ""); } return error::kNoError; } @@ -1611,11 +1601,9 @@ error::Error GLES2DecoderImpl::HandleGetInteger64i_v( return error::kInvalidArguments; } glGetInteger64i_v(pname, index, data); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetInteger64i_v"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetInteger64i_v", ""); } return error::kNoError; } @@ -1645,47 +1633,9 @@ error::Error GLES2DecoderImpl::HandleGetIntegerv(uint32_t immediate_data_size, return error::kInvalidArguments; } DoGetIntegerv(pname, params); - GLenum error = glGetError(); - if (error == GL_NO_ERROR) { - result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetIntegerv", ""); - } - return error::kNoError; -} - -error::Error GLES2DecoderImpl::HandleGetInternalformativ( - uint32_t immediate_data_size, - const void* cmd_data) { - if (!unsafe_es3_apis_enabled()) - return error::kUnknownCommand; - const gles2::cmds::GetInternalformativ& c = - *static_cast<const gles2::cmds::GetInternalformativ*>(cmd_data); - (void)c; - GLenum target = static_cast<GLenum>(c.target); - GLenum format = static_cast<GLenum>(c.format); - GLenum pname = static_cast<GLenum>(c.pname); - GLsizei bufSize = static_cast<GLsizei>(c.bufSize); - typedef cmds::GetInternalformativ::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("GetInternalformativ"); - // Check that the client initialized the result. - if (result->size != 0) { - return error::kInvalidArguments; - } - glGetInternalformativ(target, format, pname, bufSize, params); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetIntegerv"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetInternalformativ", ""); } return error::kNoError; } @@ -1716,11 +1666,9 @@ error::Error GLES2DecoderImpl::HandleGetProgramiv(uint32_t immediate_data_size, return error::kInvalidArguments; } DoGetProgramiv(program, pname, params); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetProgramiv"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetProgramiv", ""); } return error::kNoError; } @@ -1758,11 +1706,9 @@ error::Error GLES2DecoderImpl::HandleGetRenderbufferParameteriv( return error::kInvalidArguments; } DoGetRenderbufferParameteriv(target, pname, params); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetRenderbufferParameteriv"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetRenderbufferParameteriv", ""); } return error::kNoError; } @@ -1797,11 +1743,9 @@ error::Error GLES2DecoderImpl::HandleGetSamplerParameterfv( return error::kNoError; } glGetSamplerParameterfv(sampler, pname, params); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetSamplerParameterfv"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetSamplerParameterfv", ""); } return error::kNoError; } @@ -1836,11 +1780,9 @@ error::Error GLES2DecoderImpl::HandleGetSamplerParameteriv( return error::kNoError; } glGetSamplerParameteriv(sampler, pname, params); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetSamplerParameteriv"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetSamplerParameteriv", ""); } return error::kNoError; } @@ -1871,11 +1813,9 @@ error::Error GLES2DecoderImpl::HandleGetShaderiv(uint32_t immediate_data_size, return error::kInvalidArguments; } DoGetShaderiv(shader, pname, params); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetShaderiv"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetShaderiv", ""); } return error::kNoError; } @@ -1909,11 +1849,9 @@ error::Error GLES2DecoderImpl::HandleGetSynciv(uint32_t immediate_data_size, return error::kNoError; } glGetSynciv(service_sync, pname, num_values, nullptr, values); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetSynciv"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetSynciv", ""); } return error::kNoError; } @@ -1949,11 +1887,9 @@ error::Error GLES2DecoderImpl::HandleGetTexParameterfv( return error::kInvalidArguments; } DoGetTexParameterfv(target, pname, params); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetTexParameterfv"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetTexParameterfv", ""); } return error::kNoError; } @@ -1989,11 +1925,9 @@ error::Error GLES2DecoderImpl::HandleGetTexParameteriv( return error::kInvalidArguments; } DoGetTexParameteriv(target, pname, params); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetTexParameteriv"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetTexParameteriv", ""); } return error::kNoError; } @@ -2025,11 +1959,9 @@ error::Error GLES2DecoderImpl::HandleGetVertexAttribfv( return error::kInvalidArguments; } DoGetVertexAttribfv(index, pname, params); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribfv"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetVertexAttribfv", ""); } return error::kNoError; } @@ -2061,11 +1993,9 @@ error::Error GLES2DecoderImpl::HandleGetVertexAttribiv( return error::kInvalidArguments; } DoGetVertexAttribiv(index, pname, params); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribiv"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetVertexAttribiv", ""); } return error::kNoError; } @@ -2095,11 +2025,9 @@ error::Error GLES2DecoderImpl::HandleGetVertexAttribIiv( return error::kInvalidArguments; } DoGetVertexAttribIiv(index, pname, params); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribIiv"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetVertexAttribIiv", ""); } return error::kNoError; } @@ -2129,11 +2057,9 @@ error::Error GLES2DecoderImpl::HandleGetVertexAttribIuiv( return error::kInvalidArguments; } DoGetVertexAttribIuiv(index, pname, params); - GLenum error = glGetError(); + GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribIuiv"); if (error == GL_NO_ERROR) { result->SetNumResults(num_values); - } else { - LOCAL_SET_GL_ERROR(error, "GetVertexAttribIuiv", ""); } return error::kNoError; } diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index 1dd2fdc..dee67f72 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -44,7 +44,6 @@ using ::testing::Pointee; using ::testing::Return; using ::testing::SaveArg; using ::testing::SetArrayArgument; -using ::testing::SetArgumentPointee; using ::testing::SetArgPointee; using ::testing::StrEq; using ::testing::StrictMock; @@ -282,7 +281,53 @@ TEST_P(GLES2DecoderTest, IsTexture) { EXPECT_FALSE(DoIsTexture(client_texture_id_)); } -TEST_P(GLES2DecoderTest, ClientWaitSyncValid) { +TEST_P(GLES3DecoderTest, GetInternalformativValidArgsSamples) { + const GLint kNumSampleCounts = 8; + typedef cmds::GetInternalformativ::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); + EXPECT_CALL(*gl_, GetInternalformativ(GL_RENDERBUFFER, GL_RGBA8, + GL_NUM_SAMPLE_COUNTS, 1, _)) + .WillOnce(SetArgPointee<4>(kNumSampleCounts)) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, GetInternalformativ(GL_RENDERBUFFER, GL_RGBA8, + GL_SAMPLES, kNumSampleCounts, + result->GetData())) + .Times(1) + .RetiresOnSaturation(); + result->size = 0; + cmds::GetInternalformativ cmd; + cmd.Init(GL_RENDERBUFFER, GL_RGBA8, GL_SAMPLES, + shared_memory_id_, shared_memory_offset_); + decoder_->set_unsafe_es3_apis_enabled(true); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(kNumSampleCounts, result->GetNumResults()); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); + decoder_->set_unsafe_es3_apis_enabled(false); + EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); +} + +TEST_P(GLES3DecoderTest, GetInternalformativValidArgsNumSampleCounts) { + const GLint kNumSampleCounts = 8; + typedef cmds::GetInternalformativ::Result Result; + Result* result = static_cast<Result*>(shared_memory_address_); + EXPECT_CALL(*gl_, GetInternalformativ(GL_RENDERBUFFER, GL_RGBA8, + GL_NUM_SAMPLE_COUNTS, 1, _)) + .WillOnce(SetArgPointee<4>(kNumSampleCounts)) + .RetiresOnSaturation(); + result->size = 0; + cmds::GetInternalformativ cmd; + cmd.Init(GL_RENDERBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, + shared_memory_id_, shared_memory_offset_); + decoder_->set_unsafe_es3_apis_enabled(true); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(1, result->GetNumResults()); + EXPECT_EQ(kNumSampleCounts, result->GetData()[0]); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); + decoder_->set_unsafe_es3_apis_enabled(false); + EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); +} + +TEST_P(GLES3DecoderTest, ClientWaitSyncValid) { typedef cmds::ClientWaitSync::Result Result; Result* result = static_cast<Result*>(shared_memory_address_); cmds::ClientWaitSync cmd; @@ -461,7 +506,7 @@ TEST_P(GLES2DecoderManualInitTest, BeginEndQueryEXT) { // Test valid parameters work. EXPECT_CALL(*gl_, GenQueries(1, _)) - .WillOnce(SetArgumentPointee<1>(kNewServiceId)) + .WillOnce(SetArgPointee<1>(kNewServiceId)) .RetiresOnSaturation(); EXPECT_CALL(*gl_, BeginQuery(GL_ANY_SAMPLES_PASSED_EXT, kNewServiceId)) .Times(1) @@ -552,7 +597,7 @@ static void CheckBeginEndQueryBadMemoryFails(GLES2DecoderTestBase* test, if (query_type.is_gl) { EXPECT_CALL(*gl, GenQueries(1, _)) - .WillOnce(SetArgumentPointee<1>(service_id)) + .WillOnce(SetArgPointee<1>(service_id)) .RetiresOnSaturation(); EXPECT_CALL(*gl, BeginQuery(query_type.type, service_id)) .Times(1) @@ -593,10 +638,10 @@ static void CheckBeginEndQueryBadMemoryFails(GLES2DecoderTestBase* test, if (query_type.is_gl) { EXPECT_CALL( *gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) - .WillOnce(SetArgumentPointee<2>(1)) + .WillOnce(SetArgPointee<2>(1)) .RetiresOnSaturation(); EXPECT_CALL(*gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_EXT, _)) - .WillOnce(SetArgumentPointee<2>(1)) + .WillOnce(SetArgPointee<2>(1)) .RetiresOnSaturation(); } if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h index 7881a55..32e1dcc 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h @@ -1552,31 +1552,7 @@ TEST_P(GLES2DecoderTest1, GetIntegervInvalidArgs1_1) { EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(0u, result->size); } - -TEST_P(GLES2DecoderTest1, GetInternalformativValidArgs) { - EXPECT_CALL(*gl_, GetError()) - .WillOnce(Return(GL_NO_ERROR)) - .WillOnce(Return(GL_NO_ERROR)) - .RetiresOnSaturation(); - SpecializedSetup<cmds::GetInternalformativ, 0>(true); - typedef cmds::GetInternalformativ::Result Result; - Result* result = static_cast<Result*>(shared_memory_address_); - EXPECT_CALL( - *gl_, GetInternalformativ(GL_RENDERBUFFER, GL_RGBA4, GL_NUM_SAMPLE_COUNTS, - 4, result->GetData())); - result->size = 0; - cmds::GetInternalformativ cmd; - cmd.Init(GL_RENDERBUFFER, GL_RGBA4, GL_NUM_SAMPLE_COUNTS, 4, - 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_NUM_SAMPLE_COUNTS), - result->GetNumResults()); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); - decoder_->set_unsafe_es3_apis_enabled(false); - EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); -} +// TODO(gman): GetInternalformativ TEST_P(GLES2DecoderTest1, GetProgramivValidArgs) { SpecializedSetup<cmds::GetProgramiv, 0>(true); |