diff options
author | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-09 17:59:34 +0000 |
---|---|---|
committer | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-09 17:59:34 +0000 |
commit | 6098b711dbc9d38459796a0aea769f5677ada3e5 (patch) | |
tree | f31e13842e0d3662a85b5d5eddf438c1ff1a21b5 /gpu | |
parent | f466a30ddd61518eb511aad85b71b2ccd231e4ee (diff) | |
download | chromium_src-6098b711dbc9d38459796a0aea769f5677ada3e5.zip chromium_src-6098b711dbc9d38459796a0aea769f5677ada3e5.tar.gz chromium_src-6098b711dbc9d38459796a0aea769f5677ada3e5.tar.bz2 |
Fixed GPU unit tests on Mac OS X.
- Fixed remaining issues with signed/unsigned comparisons, linkage of
constants, and unused variables.
- Fixed nasty bug where vtbl for GLES2Decoder was changing size during
compilation, causing bizarre test failures.
- Cleaned up AppKit warnings about no NSAutoreleasePool being present.
BUG=none
TEST=none (ran GPU unit tests on Mac OS X)
Review URL: http://codereview.chromium.org/594004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38473 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
10 files changed, 67 insertions, 28 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index 92fe5b9..5ca1243 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -886,7 +886,7 @@ _FUNCTION_INFO = { 'result': [ 'int32 success', 'int32 size', - 'int32 type', + 'uint32 type', ], }, 'GetActiveUniform': { @@ -898,7 +898,7 @@ _FUNCTION_INFO = { 'result': [ 'int32 success', 'int32 size', - 'int32 type', + 'uint32 type', ], }, 'GetAttachedShaders': { @@ -3081,8 +3081,11 @@ class Argument(object): """A class that represents a function argument.""" cmd_type_map_ = { + 'GLenum': 'uint32', 'GLint': 'int32', + 'GLintptr': 'int32', 'GLsizei': 'int32', + 'GLsizeiptr': 'int32', 'GLfloat': 'float', 'GLclampf': 'float', } diff --git a/gpu/command_buffer/client/cmd_buffer_helper_test.cc b/gpu/command_buffer/client/cmd_buffer_helper_test.cc index 7d12a3e..7006d7f 100644 --- a/gpu/command_buffer/client/cmd_buffer_helper_test.cc +++ b/gpu/command_buffer/client/cmd_buffer_helper_test.cc @@ -6,6 +6,7 @@ #include "base/at_exit.h" #include "base/message_loop.h" +#include "base/scoped_nsautorelease_pool.h" #include "gpu/command_buffer/client/cmd_buffer_helper.h" #include "gpu/command_buffer/service/mocks.h" #include "gpu/command_buffer/service/command_buffer_service.h" @@ -125,6 +126,7 @@ class CommandBufferHelperTest : public testing::Test { CommandBufferOffset get_helper_put() { return helper_->put_; } + base::ScopedNSAutoreleasePool autorelease_pool_; base::AtExitManager at_exit_manager_; MessageLoop message_loop_; scoped_ptr<AsyncAPIMock> api_mock_; diff --git a/gpu/command_buffer/client/fenced_allocator_test.cc b/gpu/command_buffer/client/fenced_allocator_test.cc index 2f98d32..8765635 100644 --- a/gpu/command_buffer/client/fenced_allocator_test.cc +++ b/gpu/command_buffer/client/fenced_allocator_test.cc @@ -6,6 +6,7 @@ #include "base/at_exit.h" #include "base/message_loop.h" +#include "base/scoped_nsautorelease_pool.h" #include "gpu/command_buffer/client/cmd_buffer_helper.h" #include "gpu/command_buffer/client/fenced_allocator.h" #include "gpu/command_buffer/service/cmd_buffer_engine.h" @@ -69,6 +70,7 @@ class BaseFencedAllocatorTest : public testing::Test { helper_.release(); } + base::ScopedNSAutoreleasePool autorelease_pool_; base::AtExitManager at_exit_manager_; MessageLoop message_loop_; scoped_ptr<AsyncAPIMock> api_mock_; diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h index d07c475..694060a 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h @@ -575,7 +575,7 @@ struct BufferData { gpu::CommandHeader header; uint32 target; - uint32 size; + int32 size; uint32 data_shm_id; uint32 data_shm_offset; uint32 usage; @@ -627,7 +627,7 @@ struct BufferDataImmediate { gpu::CommandHeader header; uint32 target; - uint32 size; + int32 size; uint32 usage; }; @@ -676,8 +676,8 @@ struct BufferSubData { gpu::CommandHeader header; uint32 target; - uint32 offset; - uint32 size; + int32 offset; + int32 size; uint32 data_shm_id; uint32 data_shm_offset; }; @@ -728,8 +728,8 @@ struct BufferSubDataImmediate { gpu::CommandHeader header; uint32 target; - uint32 offset; - uint32 size; + int32 offset; + int32 size; }; COMPILE_ASSERT(sizeof(BufferSubDataImmediate) == 16, @@ -2933,7 +2933,7 @@ struct GetActiveAttrib { struct Result { int32 success; int32 size; - int32 type; + uint32 type; }; static uint32 ComputeSize() { @@ -3002,7 +3002,7 @@ struct GetActiveUniform { struct Result { int32 success; int32 size; - int32 type; + uint32 type; }; static uint32 ComputeSize() { diff --git a/gpu/command_buffer/service/command_buffer_service_unittest.cc b/gpu/command_buffer/service/command_buffer_service_unittest.cc index ca1ba83..44ea9f2 100644 --- a/gpu/command_buffer/service/command_buffer_service_unittest.cc +++ b/gpu/command_buffer/service/command_buffer_service_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/scoped_nsautorelease_pool.h" #include "base/thread.h" #include "gpu/command_buffer/common/cmd_buffer_common.h" #include "gpu/command_buffer/service/command_buffer_service.h" @@ -39,6 +40,7 @@ class CommandBufferServiceTest : public testing::Test { return command_buffer_->GetState().error; } + base::ScopedNSAutoreleasePool autorelease_pool_; scoped_ptr<CommandBufferService> command_buffer_; }; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index adfea53..81c3a66 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -652,7 +652,7 @@ class GLES2DecoderImpl : public GLES2Decoder { virtual bool MakeCurrent(); virtual uint32 GetServiceIdForTesting(uint32 client_id); -#if !defined(UNIT_TEST) && defined(OS_MACOSX) +#if defined(OS_MACOSX) // Overridden from GLES2Decoder. virtual uint64 SetWindowSize(int32 width, int32 height); #endif @@ -1350,7 +1350,8 @@ bool GLES2DecoderImpl::InitGlew() { return true; } -#if !defined(UNIT_TEST) && defined(OS_MACOSX) +#if defined(OS_MACOSX) +#if !defined(UNIT_TEST) static void AddBooleanValue(CFMutableDictionaryRef dictionary, const CFStringRef key, bool value) { @@ -1364,8 +1365,12 @@ static void AddIntegerValue(CFMutableDictionaryRef dictionary, CFNumberRef number = CFNumberCreate(NULL, kCFNumberSInt32Type, &value); CFDictionaryAddValue(dictionary, key, number); } +#endif // !defined(UNIT_TEST) uint64 GLES2DecoderImpl::SetWindowSize(int32 width, int32 height) { +#if defined(UNIT_TEST) + return 0; +#else if (surface_width_ == width && surface_height_ == height) { // Return 0 to indicate to the caller that no new backing store // allocation occurred. @@ -1468,8 +1473,9 @@ uint64 GLES2DecoderImpl::SetWindowSize(int32 width, int32 height) { // the browser process side the identifier is reconstituted into an // IOSurface for on-screen rendering. return io_surface_support->IOSurfaceGetID(io_surface_); +#endif // !defined(UNIT_TEST) } -#endif // !defined(UNIT_TEST) && defined(OS_MACOSX) +#endif // defined(OS_MACOSX) void GLES2DecoderImpl::SetSwapBuffersCallback(Callback0::Type* callback) { swap_buffers_callback_.reset(callback); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h index 9e6b9c8..913c7fb 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder.h @@ -56,7 +56,7 @@ class GLES2Decoder : public CommonDecoder { HWND hwnd() const { return hwnd_; } -#elif !defined(UNIT_TEST) && defined(OS_MACOSX) +#elif defined(OS_MACOSX) virtual uint64 SetWindowSize(int32 width, int32 height) = 0; #endif diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h index fa60d41..27b15d1 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h @@ -22,6 +22,9 @@ class MockGLES2Decoder : public GLES2Decoder { .WillByDefault(testing::Return(true)); } +#if defined(OS_MACOSX) + MOCK_METHOD2(SetWindowSize, uint64(int32 width, int32 height)); +#endif MOCK_METHOD0(Initialize, bool()); MOCK_METHOD0(Destroy, void()); MOCK_METHOD0(MakeCurrent, bool()); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index 1b8d0e8..427f360 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -602,9 +602,33 @@ const int GLES2DecoderWithShaderTest::kOutOfRangeIndexRangeEnd; const char* GLES2DecoderWithShaderTest::kAttrib1Name = "attrib1"; const char* GLES2DecoderWithShaderTest::kAttrib2Name = "attrib2"; const char* GLES2DecoderWithShaderTest::kAttrib3Name = "attrib3"; +const GLint GLES2DecoderWithShaderTest::kAttrib1Size; +const GLint GLES2DecoderWithShaderTest::kAttrib2Size; +const GLint GLES2DecoderWithShaderTest::kAttrib3Size; +const GLint GLES2DecoderWithShaderTest::kAttrib1Location; +const GLint GLES2DecoderWithShaderTest::kAttrib2Location; +const GLint GLES2DecoderWithShaderTest::kAttrib3Location; +const GLenum GLES2DecoderWithShaderTest::kAttrib1Type; +const GLenum GLES2DecoderWithShaderTest::kAttrib2Type; +const GLenum GLES2DecoderWithShaderTest::kAttrib3Type; +const GLint GLES2DecoderWithShaderTest::kInvalidAttribLocation; +const GLint GLES2DecoderWithShaderTest::kBadAttribIndex; +const GLint GLES2DecoderWithShaderTest::kMaxUniformLength; const char* GLES2DecoderWithShaderTest::kUniform1Name = "uniform1"; const char* GLES2DecoderWithShaderTest::kUniform2Name = "uniform2"; const char* GLES2DecoderWithShaderTest::kUniform3Name = "uniform3"; +const GLint GLES2DecoderWithShaderTest::kUniform1Size; +const GLint GLES2DecoderWithShaderTest::kUniform2Size; +const GLint GLES2DecoderWithShaderTest::kUniform3Size; +const GLint GLES2DecoderWithShaderTest::kUniform1Location; +const GLint GLES2DecoderWithShaderTest::kUniform2Location; +const GLint GLES2DecoderWithShaderTest::kUniform2ElementLocation; +const GLint GLES2DecoderWithShaderTest::kUniform3Location; +const GLenum GLES2DecoderWithShaderTest::kUniform1Type; +const GLenum GLES2DecoderWithShaderTest::kUniform2Type; +const GLenum GLES2DecoderWithShaderTest::kUniform3Type; +const GLint GLES2DecoderWithShaderTest::kInvalidUniformLocation; +const GLint GLES2DecoderWithShaderTest::kBadUniformIndex; TEST_F(GLES2DecoderWithShaderTest, DrawArraysNoAttributesSucceeds) { EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) @@ -941,7 +965,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadProgramFails) { EXPECT_CALL(*gl_, GetUniformiv(_, _, _)) .Times(0); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); // Valid id that is not a program. The GL spec requires a different error for // this case. @@ -949,7 +973,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadProgramFails) { cmd.Init(client_texture_id_, kUniform2Location, kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); // Unlinked program EXPECT_CALL(*gl_, CreateProgram()) @@ -963,7 +987,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadProgramFails) { cmd.Init(kNewClientId, kUniform2Location, kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); } @@ -977,7 +1001,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadLocationFails) { EXPECT_CALL(*gl_, GetUniformiv(_, _, _)) .Times(0); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); } @@ -1028,7 +1052,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadProgramFails) { EXPECT_CALL(*gl_, GetUniformfv(_, _, _)) .Times(0); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); // Valid id that is not a program. The GL spec requires a different error for // this case. @@ -1036,7 +1060,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadProgramFails) { cmd.Init(client_texture_id_, kUniform2Location, kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); // Unlinked program EXPECT_CALL(*gl_, CreateProgram()) @@ -1050,7 +1074,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadProgramFails) { cmd.Init(kNewClientId, kUniform2Location, kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); } @@ -1064,7 +1088,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadLocationFails) { EXPECT_CALL(*gl_, GetUniformfv(_, _, _)) .Times(0); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); } @@ -1104,14 +1128,13 @@ TEST_F(GLES2DecoderWithShaderTest, GetAttachedShadersBadProgramFails) { cmd.Init(kInvalidClientId, shared_memory_id_, shared_memory_offset_, Result::ComputeSize(1)); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); } TEST_F(GLES2DecoderWithShaderTest, GetAttachedShadersBadSharedMemoryFails) { GetAttachedShaders cmd; typedef GetAttachedShaders::Result Result; - Result* result = static_cast<Result*>(shared_memory_address_); cmd.Init(client_program_id_, kInvalidSharedMemoryId, shared_memory_offset_, Result::ComputeSize(1)); EXPECT_CALL(*gl_, GetAttachedShaders(_, _, _, _)) @@ -1140,8 +1163,6 @@ TEST_F(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatSucceeds) { TEST_F(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatBadArgsFails) { GetShaderPrecisionFormat cmd; - typedef GetShaderPrecisionFormat::Result Result; - Result* result = static_cast<Result*>(shared_memory_address_); cmd.Init(GL_TEXTURE_2D, GL_HIGH_FLOAT, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); @@ -1155,8 +1176,6 @@ TEST_F(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatBadArgsFails) { TEST_F(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatBadSharedMemoryFails) { GetShaderPrecisionFormat cmd; - typedef GetShaderPrecisionFormat::Result Result; - Result* result = static_cast<Result*>(shared_memory_address_); cmd.Init(GL_VERTEX_SHADER, GL_HIGH_FLOAT, kInvalidSharedMemoryId, shared_memory_offset_); EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); diff --git a/gpu/command_buffer/service/gpu_processor_unittest.cc b/gpu/command_buffer/service/gpu_processor_unittest.cc index ec6f094..a71905c 100644 --- a/gpu/command_buffer/service/gpu_processor_unittest.cc +++ b/gpu/command_buffer/service/gpu_processor_unittest.cc @@ -4,6 +4,7 @@ #include "base/at_exit.h" #include "base/message_loop.h" +#include "base/scoped_nsautorelease_pool.h" #include "gpu/command_buffer/common/command_buffer_mock.h" #include "gpu/command_buffer/service/mocks.h" #include "gpu/command_buffer/service/gpu_processor.h" @@ -72,6 +73,7 @@ class GPUProcessorTest : public testing::Test { return command_buffer_->GetState().error; } + base::ScopedNSAutoreleasePool autorelease_pool_; base::AtExitManager at_exit_manager; MessageLoop message_loop; scoped_ptr<MockCommandBuffer> command_buffer_; |