diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-07 17:18:37 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-07 17:18:37 +0000 |
commit | 656dcaad7854f685618c39647cb1eda818a86d43 (patch) | |
tree | 078ed9a3a9c581a8ff2e2da2a79d6aefbb21d91f /gpu/command_buffer | |
parent | 3651cf802999c8ae4532a23db254e7249f45c589 (diff) | |
download | chromium_src-656dcaad7854f685618c39647cb1eda818a86d43.zip chromium_src-656dcaad7854f685618c39647cb1eda818a86d43.tar.gz chromium_src-656dcaad7854f685618c39647cb1eda818a86d43.tar.bz2 |
A few more changes for conformance tests.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/1985006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46699 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer')
12 files changed, 104 insertions, 23 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index b22a304..9b90b38 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -177,7 +177,7 @@ GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLintVer GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); // Non-GL commands. GL_APICALL void GL_APIENTRY glSwapBuffers (void); -GL_APICALL GLuint GL_APIENTRY glGetMaxValueInBuffer (GLidBuffer buffer_id, GLsizei count, GLenumIndexType type, GLuint offset); +GL_APICALL GLuint GL_APIENTRY glGetMaxValueInBuffer (GLidBuffer buffer_id, GLsizei count, GLenumGetMaxIndexType type, GLuint offset); GL_APICALL void GL_APIENTRY glGenSharedIds (GLuint namespace_id, GLuint id_offset, GLsizei n, GLuint* ids); GL_APICALL void GL_APIENTRY glDeleteSharedIds (GLuint namespace_id, GLsizei n, const GLuint* ids); GL_APICALL void GL_APIENTRY glRegisterSharedIds (GLuint namespace_id, GLsizei n, const GLuint* ids); @@ -671,6 +671,17 @@ _ENUM_LISTS = { 'GL_INT', ], }, + 'GetMaxIndexType': { + 'type': 'GLenum', + 'valid': [ + 'GL_UNSIGNED_BYTE', + 'GL_UNSIGNED_SHORT', + 'GL_UNSIGNED_INT', + ], + 'invalid': [ + 'GL_INT', + ], + }, 'Attachment': { 'type': 'GLenum', 'valid': [ diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc index ab60f0b..89180f2 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.cc +++ b/gpu/command_buffer/common/gles2_cmd_utils.cc @@ -423,6 +423,10 @@ size_t GLES2Util::GetGLTypeSizeForTexturesAndBuffers(uint32 type) { return sizeof(GLshort); // NOLINT case GL_UNSIGNED_SHORT: return sizeof(GLushort); // NOLINT + case GL_INT: + return sizeof(GLint); // NOLINT + case GL_UNSIGNED_INT: + return sizeof(GLuint); // NOLINT case GL_FLOAT: return sizeof(GLfloat); // NOLINT default: diff --git a/gpu/command_buffer/common/gles2_cmd_utils.h b/gpu/command_buffer/common/gles2_cmd_utils.h index 8099fe2..d85520e 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.h +++ b/gpu/command_buffer/common/gles2_cmd_utils.h @@ -80,6 +80,10 @@ class GLES2Util { static uint32 IndexToGLFaceTarget(int index); + static bool IsNPOT(uint32 value) { + return value > 0 && (value & (value - 1)) != 0; + } + private: int num_compressed_texture_formats_; }; diff --git a/gpu/command_buffer/service/buffer_manager.cc b/gpu/command_buffer/service/buffer_manager.cc index ab5ab8ac..6086819 100644 --- a/gpu/command_buffer/service/buffer_manager.cc +++ b/gpu/command_buffer/service/buffer_manager.cc @@ -114,6 +114,13 @@ bool BufferManager::BufferInfo::GetMaxValueForRange( } max_v = GetMaxValue<uint16>(shadow_.get(), offset, count); break; + case GL_UNSIGNED_INT: + // Check we are not accessing a non aligned address for a 4 byte value. + if ((offset & 3) != 0) { + return false; + } + max_v = GetMaxValue<uint32>(shadow_.get(), offset, count); + break; default: NOTREACHED(); // should never get here by validation. break; diff --git a/gpu/command_buffer/service/buffer_manager_unittest.cc b/gpu/command_buffer/service/buffer_manager_unittest.cc index 83a33fd..1c09ada 100644 --- a/gpu/command_buffer/service/buffer_manager_unittest.cc +++ b/gpu/command_buffer/service/buffer_manager_unittest.cc @@ -131,6 +131,40 @@ TEST_F(BufferManagerTest, GetMaxValueForRangeUint16) { EXPECT_FALSE(info->GetMaxValueForRange(20, 1, GL_UNSIGNED_SHORT, &max_value)); } +TEST_F(BufferManagerTest, GetMaxValueForRangeUint32) { + const GLuint kClientBufferId = 1; + const GLuint kServiceBufferId = 11; + const uint32 data[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; + const uint32 new_data[] = {100, 120, 110}; + manager_.CreateBufferInfo(kClientBufferId, kServiceBufferId); + BufferManager::BufferInfo* info = manager_.GetBufferInfo(kClientBufferId); + ASSERT_TRUE(info != NULL); + info->set_target(GL_ELEMENT_ARRAY_BUFFER); + info->SetSize(sizeof(data)); + EXPECT_TRUE(info->SetRange(0, sizeof(data), data)); + GLuint max_value; + // Check entire range succeeds. + EXPECT_TRUE(info->GetMaxValueForRange(0, 10, GL_UNSIGNED_INT, &max_value)); + EXPECT_EQ(10u, max_value); + // Check non aligned offsets fails for GL_UNSIGNED_INT. + EXPECT_FALSE(info->GetMaxValueForRange(1, 10, GL_UNSIGNED_INT, &max_value)); + EXPECT_FALSE(info->GetMaxValueForRange(2, 10, GL_UNSIGNED_INT, &max_value)); + EXPECT_FALSE(info->GetMaxValueForRange(3, 10, GL_UNSIGNED_INT, &max_value)); + // Check sub range succeeds. + EXPECT_TRUE(info->GetMaxValueForRange(16, 3, GL_UNSIGNED_INT, &max_value)); + EXPECT_EQ(6u, max_value); + // Check changing sub range succeeds. + EXPECT_TRUE(info->SetRange(16, sizeof(new_data), new_data)); + EXPECT_TRUE(info->GetMaxValueForRange(16, 3, GL_UNSIGNED_INT, &max_value)); + EXPECT_EQ(120u, max_value); + max_value = 0; + EXPECT_TRUE(info->GetMaxValueForRange(0, 10, GL_UNSIGNED_INT, &max_value)); + EXPECT_EQ(120u, max_value); + // Check out of range fails. + EXPECT_FALSE(info->GetMaxValueForRange(0, 11, GL_UNSIGNED_INT, &max_value)); + EXPECT_FALSE(info->GetMaxValueForRange(40, 1, GL_UNSIGNED_INT, &max_value)); +} + } // 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 93f28f9..2242736 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -1247,7 +1247,7 @@ bool GLES2DecoderImpl::Initialize(gfx::GLContext* context, // Make black textures for replacing non-renderable textures. black_2d_texture_id_ = ids[0]; black_cube_texture_id_ = ids[1]; - static int8 black[] = {0, 0, 0, 0}; + static int8 black[] = {0, 0, 0, 1}; glBindTexture(GL_TEXTURE_2D, black_2d_texture_id_); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, black); @@ -1972,6 +1972,10 @@ bool GLES2DecoderImpl::GetHelper( *params /= 4; return true; #endif + case GL_COMPRESSED_TEXTURE_FORMATS: + *num_written = 0; + // We don't support compressed textures. + return true; case GL_NUM_COMPRESSED_TEXTURE_FORMATS: *num_written = 1; *params = 0; // We don't support compressed textures. @@ -3072,7 +3076,6 @@ error::Error GLES2DecoderImpl::HandleReadPixels( return error::kNoError; } - glFinish(); if (x < 0 || y < 0 || max_x > max_size.width() || max_y > max_size.height()) { // The user requested an out of range area. Get the results 1 line // at a time. @@ -3154,7 +3157,7 @@ error::Error GLES2DecoderImpl::HandlePixelStorei( break; default: // Validation should have prevented us from getting here. - DCHECK(false); + NOTREACHED(); break; } return error::kNoError; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h index adb7321..29e6c52 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h @@ -2763,7 +2763,7 @@ error::Error GLES2DecoderImpl::HandleGetMaxValueInBuffer( SetGLError(GL_INVALID_VALUE, "glGetMaxValueInBuffer: count < 0"); return error::kNoError; } - if (!ValidateGLenumIndexType(type)) { + if (!ValidateGLenumGetMaxIndexType(type)) { SetGLError(GL_INVALID_ENUM, "glGetMaxValueInBuffer: type GL_INVALID_ENUM"); 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 859e4d3..759e54c 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -1317,7 +1317,6 @@ void GLES2DecoderTest::CheckReadPixelsOutOfRange( GLint read_end_y = std::max(0, std::min(kHeight, in_read_y + in_read_height)); GLint read_width = read_end_x - read_x; GLint read_height = read_end_y - read_y; - EXPECT_CALL(*gl_, Finish()).Times(1).RetiresOnSaturation(); if (read_width > 0 && read_height > 0) { for (GLint yy = read_y; yy < read_end_y; ++yy) { EXPECT_CALL( @@ -1400,7 +1399,6 @@ TEST_F(GLES2DecoderTest, ReadPixels) { .WillOnce(Return(GL_NO_ERROR)) .WillOnce(Return(GL_NO_ERROR)) .RetiresOnSaturation(); - EXPECT_CALL(*gl_, Finish()).Times(1).RetiresOnSaturation(); EXPECT_CALL( *gl_, ReadPixels(0, 0, kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, _)) .WillOnce(Invoke(&emu, &ReadPixelsEmulator::ReadPixels)); diff --git a/gpu/command_buffer/service/gles2_cmd_validation_autogen.h b/gpu/command_buffer/service/gles2_cmd_validation_autogen.h index b2368a2..203c6cb8 100644 --- a/gpu/command_buffer/service/gles2_cmd_validation_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_validation_autogen.h @@ -22,6 +22,7 @@ bool ValidateGLbooleanFalse(GLenum value); bool ValidateGLenumFrameBufferParameter(GLenum value); bool ValidateGLenumFrameBufferTarget(GLenum value); bool ValidateGLenumGLState(GLenum value); +bool ValidateGLenumGetMaxIndexType(GLenum value); bool ValidateGLenumHintMode(GLenum value); bool ValidateGLenumHintTarget(GLenum value); bool ValidateGLenumIndexType(GLenum value); diff --git a/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h b/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h index eed18cd..eb09130 100644 --- a/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h @@ -273,6 +273,17 @@ bool ValidateGLenumGLState(GLenum value) { } } +bool ValidateGLenumGetMaxIndexType(GLenum value) { + switch (value) { + case GL_UNSIGNED_BYTE: + case GL_UNSIGNED_SHORT: + case GL_UNSIGNED_INT: + return true; + default: + return false; + } +} + bool ValidateGLenumHintMode(GLenum value) { switch (value) { case GL_FASTEST: diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc index 326d2b3..e854faf 100644 --- a/gpu/command_buffer/service/texture_manager.cc +++ b/gpu/command_buffer/service/texture_manager.cc @@ -199,9 +199,9 @@ void TextureManager::TextureInfo::Update() { npot_ = false; for (size_t ii = 0; ii < level_infos_.size(); ++ii) { const TextureInfo::LevelInfo& info = level_infos_[ii][0]; - if (((info.width & (info.width - 1)) != 0) || - ((info.height & (info.height - 1)) != 0) || - ((info.depth & (info.depth - 1)) != 0)) { + if (GLES2Util::IsNPOT(info.width) || + GLES2Util::IsNPOT(info.height) || + GLES2Util::IsNPOT(info.depth)) { npot_ = true; break; } @@ -277,6 +277,26 @@ TextureManager::TextureManager( } } +bool TextureManager::ValidForTarget( + GLenum target, GLint level, + GLsizei width, GLsizei height, GLsizei depth) { + GLsizei max_size = MaxSizeForTarget(target); + return level >= 0 && + width >= 0 && + height >= 0 && + depth >= 0 && + level < MaxLevelsForTarget(target) && + width <= max_size && + height <= max_size && + depth <= max_size && + (level == 0 || + (!GLES2Util::IsNPOT(width) && + !GLES2Util::IsNPOT(height) && + !GLES2Util::IsNPOT(depth))) && + (target != GL_TEXTURE_CUBE_MAP || (width == height && depth == 1)) && + (target != GL_TEXTURE_2D || (depth == 1)); +} + TextureManager::TextureInfo* TextureManager::CreateTextureInfo( GLuint client_id, GLuint service_id) { TextureInfo::Ref info(new TextureInfo(service_id)); diff --git a/gpu/command_buffer/service/texture_manager.h b/gpu/command_buffer/service/texture_manager.h index 14da6c2..0759ac9 100644 --- a/gpu/command_buffer/service/texture_manager.h +++ b/gpu/command_buffer/service/texture_manager.h @@ -210,19 +210,7 @@ class TextureManager { // Checks if a dimensions are valid for a given target. bool ValidForTarget( GLenum target, GLint level, - GLsizei width, GLsizei height, GLsizei depth) { - GLsizei max_size = MaxSizeForTarget(target); - return level >= 0 && - width >= 0 && - height >= 0 && - depth >= 0 && - level < MaxLevelsForTarget(target) && - width <= max_size && - height <= max_size && - depth <= max_size && - (target != GL_TEXTURE_CUBE_MAP || (width == height && depth == 1)) && - (target != GL_TEXTURE_2D || (depth == 1)); - } + GLsizei width, GLsizei height, GLsizei depth); // Sets the TextureInfo's target // Parameters: |