OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Tests for GLES2Implementation. | 5 // Tests for GLES2Implementation. |
6 | 6 |
7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 static const GLint kMaxFragmentUniformVectors = 16; | 371 static const GLint kMaxFragmentUniformVectors = 16; |
372 static const GLint kMaxRenderbufferSize = 64; | 372 static const GLint kMaxRenderbufferSize = 64; |
373 static const GLint kMaxTextureImageUnits = 8; | 373 static const GLint kMaxTextureImageUnits = 8; |
374 static const GLint kMaxTextureSize = 128; | 374 static const GLint kMaxTextureSize = 128; |
375 static const GLint kMaxVaryingVectors = 8; | 375 static const GLint kMaxVaryingVectors = 8; |
376 static const GLint kMaxVertexAttribs = 8; | 376 static const GLint kMaxVertexAttribs = 8; |
377 static const GLint kMaxVertexTextureImageUnits = 0; | 377 static const GLint kMaxVertexTextureImageUnits = 0; |
378 static const GLint kMaxVertexUniformVectors = 128; | 378 static const GLint kMaxVertexUniformVectors = 128; |
379 static const GLint kNumCompressedTextureFormats = 0; | 379 static const GLint kNumCompressedTextureFormats = 0; |
380 static const GLint kNumShaderBinaryFormats = 0; | 380 static const GLint kNumShaderBinaryFormats = 0; |
| 381 static const GLuint kMaxTransformFeedbackSeparateAttribs = 4; |
| 382 static const GLuint kMaxUniformBufferBindings = 36; |
381 static const GLuint kStartId = 1024; | 383 static const GLuint kStartId = 1024; |
382 static const GLuint kBuffersStartId = | 384 static const GLuint kBuffersStartId = |
383 GLES2Implementation::kClientSideArrayId + 2 * kNumTestContexts; | 385 GLES2Implementation::kClientSideArrayId + 2 * kNumTestContexts; |
384 static const GLuint kFramebuffersStartId = 1; | 386 static const GLuint kFramebuffersStartId = 1; |
385 static const GLuint kProgramsAndShadersStartId = 1; | 387 static const GLuint kProgramsAndShadersStartId = 1; |
386 static const GLuint kRenderbuffersStartId = 1; | 388 static const GLuint kRenderbuffersStartId = 1; |
387 static const GLuint kSamplersStartId = 1; | 389 static const GLuint kSamplersStartId = 1; |
388 static const GLuint kTexturesStartId = 1; | 390 static const GLuint kTexturesStartId = 1; |
389 static const GLuint kTransformFeedbacksStartId = 1; | 391 static const GLuint kTransformFeedbacksStartId = 1; |
390 static const GLuint kQueriesStartId = 1; | 392 static const GLuint kQueriesStartId = 1; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 capabilities.max_renderbuffer_size = kMaxRenderbufferSize; | 434 capabilities.max_renderbuffer_size = kMaxRenderbufferSize; |
433 capabilities.max_texture_image_units = kMaxTextureImageUnits; | 435 capabilities.max_texture_image_units = kMaxTextureImageUnits; |
434 capabilities.max_texture_size = kMaxTextureSize; | 436 capabilities.max_texture_size = kMaxTextureSize; |
435 capabilities.max_varying_vectors = kMaxVaryingVectors; | 437 capabilities.max_varying_vectors = kMaxVaryingVectors; |
436 capabilities.max_vertex_attribs = kMaxVertexAttribs; | 438 capabilities.max_vertex_attribs = kMaxVertexAttribs; |
437 capabilities.max_vertex_texture_image_units = kMaxVertexTextureImageUnits; | 439 capabilities.max_vertex_texture_image_units = kMaxVertexTextureImageUnits; |
438 capabilities.max_vertex_uniform_vectors = kMaxVertexUniformVectors; | 440 capabilities.max_vertex_uniform_vectors = kMaxVertexUniformVectors; |
439 capabilities.num_compressed_texture_formats = | 441 capabilities.num_compressed_texture_formats = |
440 kNumCompressedTextureFormats; | 442 kNumCompressedTextureFormats; |
441 capabilities.num_shader_binary_formats = kNumShaderBinaryFormats; | 443 capabilities.num_shader_binary_formats = kNumShaderBinaryFormats; |
| 444 capabilities.max_transform_feedback_separate_attribs = |
| 445 kMaxTransformFeedbackSeparateAttribs; |
| 446 capabilities.max_uniform_buffer_bindings = kMaxUniformBufferBindings; |
442 capabilities.bind_generates_resource_chromium = | 447 capabilities.bind_generates_resource_chromium = |
443 bind_generates_resource_service ? 1 : 0; | 448 bind_generates_resource_service ? 1 : 0; |
444 EXPECT_CALL(*gpu_control_, GetCapabilities()) | 449 EXPECT_CALL(*gpu_control_, GetCapabilities()) |
445 .WillOnce(testing::Return(capabilities)); | 450 .WillOnce(testing::Return(capabilities)); |
446 | 451 |
447 { | 452 { |
448 InSequence sequence; | 453 InSequence sequence; |
449 | 454 |
450 const bool support_client_side_arrays = true; | 455 const bool support_client_side_arrays = true; |
451 gl_.reset(new GLES2Implementation(helper_.get(), | 456 gl_.reset(new GLES2Implementation(helper_.get(), |
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2012 gl_->GetProgramInfoCHROMIUM(kProgramId, -1, &size, &buf); | 2017 gl_->GetProgramInfoCHROMIUM(kProgramId, -1, &size, &buf); |
2013 EXPECT_TRUE(NoCommandsWritten()); | 2018 EXPECT_TRUE(NoCommandsWritten()); |
2014 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); | 2019 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); |
2015 ClearCommands(); | 2020 ClearCommands(); |
2016 // try no size ptr. | 2021 // try no size ptr. |
2017 gl_->GetProgramInfoCHROMIUM(kProgramId, sizeof(buf), NULL, &buf); | 2022 gl_->GetProgramInfoCHROMIUM(kProgramId, sizeof(buf), NULL, &buf); |
2018 EXPECT_TRUE(NoCommandsWritten()); | 2023 EXPECT_TRUE(NoCommandsWritten()); |
2019 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); | 2024 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); |
2020 } | 2025 } |
2021 | 2026 |
| 2027 TEST_F(GLES2ImplementationTest, GetUniformBlocksCHROMIUMGoodArgs) { |
| 2028 const uint32 kBucketId = GLES2Implementation::kResultBucketId; |
| 2029 const GLuint kProgramId = 123; |
| 2030 const char kBad = 0x12; |
| 2031 GLsizei size = 0; |
| 2032 const Str7 kString = {"foobar"}; |
| 2033 char buf[20]; |
| 2034 |
| 2035 ExpectedMemoryInfo mem1 = |
| 2036 GetExpectedMemory(MaxTransferBufferSize()); |
| 2037 ExpectedMemoryInfo result1 = |
| 2038 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); |
| 2039 ExpectedMemoryInfo result2 = |
| 2040 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 2041 |
| 2042 memset(buf, kBad, sizeof(buf)); |
| 2043 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 2044 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))), |
| 2045 SetMemory(mem1.ptr, kString))) |
| 2046 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) |
| 2047 .RetiresOnSaturation(); |
| 2048 |
| 2049 struct Cmds { |
| 2050 cmd::SetBucketSize set_bucket_size1; |
| 2051 cmds::GetUniformBlocksCHROMIUM get_uniform_blocks; |
| 2052 cmd::GetBucketStart get_bucket_start; |
| 2053 cmd::SetToken set_token1; |
| 2054 cmd::SetBucketSize set_bucket_size2; |
| 2055 }; |
| 2056 Cmds expected; |
| 2057 expected.set_bucket_size1.Init(kBucketId, 0); |
| 2058 expected.get_uniform_blocks.Init(kProgramId, kBucketId); |
| 2059 expected.get_bucket_start.Init( |
| 2060 kBucketId, result1.id, result1.offset, |
| 2061 MaxTransferBufferSize(), mem1.id, mem1.offset); |
| 2062 expected.set_token1.Init(GetNextToken()); |
| 2063 expected.set_bucket_size2.Init(kBucketId, 0); |
| 2064 gl_->GetUniformBlocksCHROMIUM(kProgramId, sizeof(buf), &size, &buf); |
| 2065 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2066 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); |
| 2067 EXPECT_EQ(sizeof(kString), static_cast<size_t>(size)); |
| 2068 EXPECT_STREQ(kString.str, buf); |
| 2069 EXPECT_EQ(buf[sizeof(kString)], kBad); |
| 2070 } |
| 2071 |
| 2072 TEST_F(GLES2ImplementationTest, GetUniformBlocksCHROMIUMBadArgs) { |
| 2073 const uint32 kBucketId = GLES2Implementation::kResultBucketId; |
| 2074 const GLuint kProgramId = 123; |
| 2075 GLsizei size = 0; |
| 2076 const Str7 kString = {"foobar"}; |
| 2077 char buf[20]; |
| 2078 |
| 2079 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); |
| 2080 ExpectedMemoryInfo result1 = |
| 2081 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); |
| 2082 ExpectedMemoryInfo result2 = |
| 2083 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 2084 ExpectedMemoryInfo result3 = |
| 2085 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 2086 ExpectedMemoryInfo result4 = |
| 2087 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 2088 |
| 2089 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 2090 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))), |
| 2091 SetMemory(mem1.ptr, kString))) |
| 2092 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) |
| 2093 .WillOnce(SetMemory(result3.ptr, GLuint(GL_NO_ERROR))) |
| 2094 .WillOnce(SetMemory(result4.ptr, GLuint(GL_NO_ERROR))) |
| 2095 .RetiresOnSaturation(); |
| 2096 |
| 2097 // try bufsize not big enough. |
| 2098 struct Cmds { |
| 2099 cmd::SetBucketSize set_bucket_size1; |
| 2100 cmds::GetUniformBlocksCHROMIUM get_uniform_blocks; |
| 2101 cmd::GetBucketStart get_bucket_start; |
| 2102 cmd::SetToken set_token1; |
| 2103 cmd::SetBucketSize set_bucket_size2; |
| 2104 }; |
| 2105 Cmds expected; |
| 2106 expected.set_bucket_size1.Init(kBucketId, 0); |
| 2107 expected.get_uniform_blocks.Init(kProgramId, kBucketId); |
| 2108 expected.get_bucket_start.Init( |
| 2109 kBucketId, result1.id, result1.offset, |
| 2110 MaxTransferBufferSize(), mem1.id, mem1.offset); |
| 2111 expected.set_token1.Init(GetNextToken()); |
| 2112 expected.set_bucket_size2.Init(kBucketId, 0); |
| 2113 gl_->GetUniformBlocksCHROMIUM(kProgramId, 6, &size, &buf); |
| 2114 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2115 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), gl_->GetError()); |
| 2116 ClearCommands(); |
| 2117 |
| 2118 // try bad bufsize |
| 2119 gl_->GetUniformBlocksCHROMIUM(kProgramId, -1, &size, &buf); |
| 2120 EXPECT_TRUE(NoCommandsWritten()); |
| 2121 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); |
| 2122 ClearCommands(); |
| 2123 // try no size ptr. |
| 2124 gl_->GetUniformBlocksCHROMIUM(kProgramId, sizeof(buf), NULL, &buf); |
| 2125 EXPECT_TRUE(NoCommandsWritten()); |
| 2126 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); |
| 2127 } |
| 2128 |
2022 // Test that things are cached | 2129 // Test that things are cached |
2023 TEST_F(GLES2ImplementationTest, GetIntegerCacheRead) { | 2130 TEST_F(GLES2ImplementationTest, GetIntegerCacheRead) { |
2024 struct PNameValue { | 2131 struct PNameValue { |
2025 GLenum pname; | 2132 GLenum pname; |
2026 GLint expected; | 2133 GLint expected; |
2027 }; | 2134 }; |
2028 const PNameValue pairs[] = { | 2135 const PNameValue pairs[] = { |
2029 {GL_ACTIVE_TEXTURE, GL_TEXTURE0, }, | 2136 {GL_ACTIVE_TEXTURE, GL_TEXTURE0, }, |
2030 {GL_TEXTURE_BINDING_2D, 0, }, | 2137 {GL_TEXTURE_BINDING_2D, 0, }, |
2031 {GL_TEXTURE_BINDING_CUBE_MAP, 0, }, | 2138 {GL_TEXTURE_BINDING_CUBE_MAP, 0, }, |
(...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3536 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) { | 3643 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) { |
3537 ContextInitOptions init_options; | 3644 ContextInitOptions init_options; |
3538 init_options.transfer_buffer_initialize_fail = true; | 3645 init_options.transfer_buffer_initialize_fail = true; |
3539 EXPECT_FALSE(Initialize(init_options)); | 3646 EXPECT_FALSE(Initialize(init_options)); |
3540 } | 3647 } |
3541 | 3648 |
3542 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 3649 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" |
3543 | 3650 |
3544 } // namespace gles2 | 3651 } // namespace gles2 |
3545 } // namespace gpu | 3652 } // namespace gpu |
OLD | NEW |