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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 static const GLint kNumShaderBinaryFormats = 0; | 376 static const GLint kNumShaderBinaryFormats = 0; |
377 static const GLuint kStartId = 1024; | 377 static const GLuint kStartId = 1024; |
378 static const GLuint kBuffersStartId = | 378 static const GLuint kBuffersStartId = |
379 GLES2Implementation::kClientSideArrayId + 2 * kNumTestContexts; | 379 GLES2Implementation::kClientSideArrayId + 2 * kNumTestContexts; |
380 static const GLuint kFramebuffersStartId = 1; | 380 static const GLuint kFramebuffersStartId = 1; |
381 static const GLuint kProgramsAndShadersStartId = 1; | 381 static const GLuint kProgramsAndShadersStartId = 1; |
382 static const GLuint kRenderbuffersStartId = 1; | 382 static const GLuint kRenderbuffersStartId = 1; |
383 static const GLuint kTexturesStartId = 1; | 383 static const GLuint kTexturesStartId = 1; |
384 static const GLuint kQueriesStartId = 1; | 384 static const GLuint kQueriesStartId = 1; |
385 static const GLuint kVertexArraysStartId = 1; | 385 static const GLuint kVertexArraysStartId = 1; |
| 386 static const GLuint kValuebuffersStartId = 1; |
386 | 387 |
387 typedef MockTransferBuffer::ExpectedMemoryInfo ExpectedMemoryInfo; | 388 typedef MockTransferBuffer::ExpectedMemoryInfo ExpectedMemoryInfo; |
388 | 389 |
389 class TestContext { | 390 class TestContext { |
390 public: | 391 public: |
391 TestContext() : commands_(NULL), token_(0) {} | 392 TestContext() : commands_(NULL), token_(0) {} |
392 | 393 |
393 bool Initialize(ShareGroup* share_group, | 394 bool Initialize(ShareGroup* share_group, |
394 bool bind_generates_resource_client, | 395 bool bind_generates_resource_client, |
395 bool bind_generates_resource_service, | 396 bool bind_generates_resource_service, |
396 bool lose_context_when_out_of_memory) { | 397 bool lose_context_when_out_of_memory) { |
397 command_buffer_.reset(new StrictMock<MockClientCommandBuffer>()); | 398 command_buffer_.reset(new StrictMock<MockClientCommandBuffer>()); |
398 if (!command_buffer_->Initialize()) | 399 if (!command_buffer_->Initialize()) |
399 return false; | 400 return false; |
400 | 401 |
401 transfer_buffer_.reset( | 402 transfer_buffer_.reset( |
402 new MockTransferBuffer(command_buffer_.get(), | 403 new MockTransferBuffer(command_buffer_.get(), |
403 kTransferBufferSize, | 404 kTransferBufferSize, |
404 GLES2Implementation::kStartingOffset, | 405 GLES2Implementation::kStartingOffset, |
405 GLES2Implementation::kAlignment)); | 406 GLES2Implementation::kAlignment)); |
406 | 407 |
407 helper_.reset(new GLES2CmdHelper(command_buffer())); | 408 helper_.reset(new GLES2CmdHelper(command_buffer())); |
408 helper_->Initialize(kCommandBufferSizeBytes); | 409 helper_->Initialize(kCommandBufferSizeBytes); |
409 | 410 |
410 gpu_control_.reset(new StrictMock<MockClientGpuControl>()); | 411 gpu_control_.reset(new StrictMock<MockClientGpuControl>()); |
| 412 Capabilities capabilities; |
| 413 capabilities.VisitPrecisions( |
| 414 [](GLenum shader, GLenum type, |
| 415 Capabilities::ShaderPrecision* precision) { |
| 416 precision->min_range = 3; |
| 417 precision->max_range = 5; |
| 418 precision->precision = 7; |
| 419 }); |
| 420 capabilities.max_combined_texture_image_units = |
| 421 kMaxCombinedTextureImageUnits; |
| 422 capabilities.max_cube_map_texture_size = kMaxCubeMapTextureSize; |
| 423 capabilities.max_fragment_uniform_vectors = kMaxFragmentUniformVectors; |
| 424 capabilities.max_renderbuffer_size = kMaxRenderbufferSize; |
| 425 capabilities.max_texture_image_units = kMaxTextureImageUnits; |
| 426 capabilities.max_texture_size = kMaxTextureSize; |
| 427 capabilities.max_varying_vectors = kMaxVaryingVectors; |
| 428 capabilities.max_vertex_attribs = kMaxVertexAttribs; |
| 429 capabilities.max_vertex_texture_image_units = kMaxVertexTextureImageUnits; |
| 430 capabilities.max_vertex_uniform_vectors = kMaxVertexUniformVectors; |
| 431 capabilities.num_compressed_texture_formats = |
| 432 kNumCompressedTextureFormats; |
| 433 capabilities.num_shader_binary_formats = kNumShaderBinaryFormats; |
| 434 capabilities.bind_generates_resource_chromium = |
| 435 bind_generates_resource_service ? 1 : 0; |
411 EXPECT_CALL(*gpu_control_, GetCapabilities()) | 436 EXPECT_CALL(*gpu_control_, GetCapabilities()) |
412 .WillOnce(testing::Return(Capabilities())); | 437 .WillOnce(testing::Return(capabilities)); |
413 | |
414 GLES2Implementation::GLStaticState state; | |
415 GLES2Implementation::GLStaticState::IntState& int_state = state.int_state; | |
416 int_state.max_combined_texture_image_units = | |
417 kMaxCombinedTextureImageUnits; | |
418 int_state.max_cube_map_texture_size = kMaxCubeMapTextureSize; | |
419 int_state.max_fragment_uniform_vectors = kMaxFragmentUniformVectors; | |
420 int_state.max_renderbuffer_size = kMaxRenderbufferSize; | |
421 int_state.max_texture_image_units = kMaxTextureImageUnits; | |
422 int_state.max_texture_size = kMaxTextureSize; | |
423 int_state.max_varying_vectors = kMaxVaryingVectors; | |
424 int_state.max_vertex_attribs = kMaxVertexAttribs; | |
425 int_state.max_vertex_texture_image_units = kMaxVertexTextureImageUnits; | |
426 int_state.max_vertex_uniform_vectors = kMaxVertexUniformVectors; | |
427 int_state.num_compressed_texture_formats = kNumCompressedTextureFormats; | |
428 int_state.num_shader_binary_formats = kNumShaderBinaryFormats; | |
429 int_state.bind_generates_resource_chromium = | |
430 bind_generates_resource_service ? 1 : 0; | |
431 | |
432 // This just happens to work for now because IntState has 1 GLint per | |
433 // state. | |
434 // If IntState gets more complicated this code will need to get more | |
435 // complicated. | |
436 ExpectedMemoryInfo mem1 = transfer_buffer_->GetExpectedMemory( | |
437 sizeof(GLES2Implementation::GLStaticState::IntState) * 2 + | |
438 sizeof(cmds::GetShaderPrecisionFormat::Result) * 12); | |
439 | 438 |
440 { | 439 { |
441 InSequence sequence; | 440 InSequence sequence; |
442 | 441 |
443 EXPECT_CALL(*command_buffer_, OnFlush()) | |
444 .WillOnce(SetMemory(mem1.ptr + sizeof(int_state), int_state)) | |
445 .RetiresOnSaturation(); | |
446 GetNextToken(); // eat the token that starting up will use. | |
447 | |
448 const bool support_client_side_arrays = true; | 442 const bool support_client_side_arrays = true; |
449 gl_.reset(new GLES2Implementation(helper_.get(), | 443 gl_.reset(new GLES2Implementation(helper_.get(), |
450 share_group, | 444 share_group, |
451 transfer_buffer_.get(), | 445 transfer_buffer_.get(), |
452 bind_generates_resource_client, | 446 bind_generates_resource_client, |
453 lose_context_when_out_of_memory, | 447 lose_context_when_out_of_memory, |
454 support_client_side_arrays, | 448 support_client_side_arrays, |
455 gpu_control_.get())); | 449 gpu_control_.get())); |
456 | 450 |
457 if (!gl_->Initialize(kTransferBufferSize, | 451 if (!gl_->Initialize(kTransferBufferSize, |
458 kTransferBufferSize, | 452 kTransferBufferSize, |
459 kTransferBufferSize, | 453 kTransferBufferSize, |
460 GLES2Implementation::kNoLimit)) | 454 GLES2Implementation::kNoLimit)) |
461 return false; | 455 return false; |
462 } | 456 } |
463 | 457 |
464 EXPECT_CALL(*command_buffer_, OnFlush()).Times(1).RetiresOnSaturation(); | |
465 helper_->CommandBufferHelper::Finish(); | 458 helper_->CommandBufferHelper::Finish(); |
466 ::testing::Mock::VerifyAndClearExpectations(gl_.get()); | 459 ::testing::Mock::VerifyAndClearExpectations(gl_.get()); |
467 | 460 |
468 scoped_refptr<Buffer> ring_buffer = helper_->get_ring_buffer(); | 461 scoped_refptr<Buffer> ring_buffer = helper_->get_ring_buffer(); |
469 commands_ = static_cast<CommandBufferEntry*>(ring_buffer->memory()) + | 462 commands_ = static_cast<CommandBufferEntry*>(ring_buffer->memory()) + |
470 command_buffer()->GetPutOffset(); | 463 command_buffer()->GetPutOffset(); |
471 ClearCommands(); | 464 ClearCommands(); |
472 EXPECT_TRUE(transfer_buffer_->InSync()); | 465 EXPECT_TRUE(transfer_buffer_->InSync()); |
473 | 466 |
474 ::testing::Mock::VerifyAndClearExpectations(command_buffer()); | 467 ::testing::Mock::VerifyAndClearExpectations(command_buffer()); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 const GLint GLES2ImplementationTest::kNumCompressedTextureFormats; | 741 const GLint GLES2ImplementationTest::kNumCompressedTextureFormats; |
749 const GLint GLES2ImplementationTest::kNumShaderBinaryFormats; | 742 const GLint GLES2ImplementationTest::kNumShaderBinaryFormats; |
750 const GLuint GLES2ImplementationTest::kStartId; | 743 const GLuint GLES2ImplementationTest::kStartId; |
751 const GLuint GLES2ImplementationTest::kBuffersStartId; | 744 const GLuint GLES2ImplementationTest::kBuffersStartId; |
752 const GLuint GLES2ImplementationTest::kFramebuffersStartId; | 745 const GLuint GLES2ImplementationTest::kFramebuffersStartId; |
753 const GLuint GLES2ImplementationTest::kProgramsAndShadersStartId; | 746 const GLuint GLES2ImplementationTest::kProgramsAndShadersStartId; |
754 const GLuint GLES2ImplementationTest::kRenderbuffersStartId; | 747 const GLuint GLES2ImplementationTest::kRenderbuffersStartId; |
755 const GLuint GLES2ImplementationTest::kTexturesStartId; | 748 const GLuint GLES2ImplementationTest::kTexturesStartId; |
756 const GLuint GLES2ImplementationTest::kQueriesStartId; | 749 const GLuint GLES2ImplementationTest::kQueriesStartId; |
757 const GLuint GLES2ImplementationTest::kVertexArraysStartId; | 750 const GLuint GLES2ImplementationTest::kVertexArraysStartId; |
| 751 const GLuint GLES2ImplementationTest::kValuebuffersStartId; |
758 #endif | 752 #endif |
759 | 753 |
760 TEST_F(GLES2ImplementationTest, Basic) { | 754 TEST_F(GLES2ImplementationTest, Basic) { |
761 EXPECT_TRUE(gl_->share_group() != NULL); | 755 EXPECT_TRUE(gl_->share_group() != NULL); |
762 } | 756 } |
763 | 757 |
764 TEST_F(GLES2ImplementationTest, GetBucketContents) { | 758 TEST_F(GLES2ImplementationTest, GetBucketContents) { |
765 const uint32 kBucketId = GLES2Implementation::kResultBucketId; | 759 const uint32 kBucketId = GLES2Implementation::kResultBucketId; |
766 const uint32 kTestSize = MaxTransferBufferSize() + 32; | 760 const uint32 kTestSize = MaxTransferBufferSize() + 32; |
767 | 761 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 804 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
811 ASSERT_EQ(kTestSize, data.size()); | 805 ASSERT_EQ(kTestSize, data.size()); |
812 EXPECT_EQ(0, memcmp(expected_data, &data[0], data.size())); | 806 EXPECT_EQ(0, memcmp(expected_data, &data[0], data.size())); |
813 } | 807 } |
814 | 808 |
815 TEST_F(GLES2ImplementationTest, GetShaderPrecisionFormat) { | 809 TEST_F(GLES2ImplementationTest, GetShaderPrecisionFormat) { |
816 struct Cmds { | 810 struct Cmds { |
817 cmds::GetShaderPrecisionFormat cmd; | 811 cmds::GetShaderPrecisionFormat cmd; |
818 }; | 812 }; |
819 typedef cmds::GetShaderPrecisionFormat::Result Result; | 813 typedef cmds::GetShaderPrecisionFormat::Result Result; |
| 814 const unsigned kDummyType1 = 3; |
| 815 const unsigned kDummyType2 = 4; |
820 | 816 |
821 // The first call for mediump should trigger a command buffer request. | 817 // The first call for dummy type 1 should trigger a command buffer request. |
822 GLint range1[2] = {0, 0}; | 818 GLint range1[2] = {0, 0}; |
823 GLint precision1 = 0; | 819 GLint precision1 = 0; |
824 Cmds expected1; | 820 Cmds expected1; |
825 ExpectedMemoryInfo client_result1 = GetExpectedResultMemory(4); | 821 ExpectedMemoryInfo client_result1 = GetExpectedResultMemory(4); |
826 expected1.cmd.Init(GL_FRAGMENT_SHADER, GL_MEDIUM_FLOAT, | 822 expected1.cmd.Init(GL_FRAGMENT_SHADER, kDummyType1, client_result1.id, |
827 client_result1.id, client_result1.offset); | 823 client_result1.offset); |
828 Result server_result1 = {true, 14, 14, 10}; | 824 Result server_result1 = {true, 14, 14, 10}; |
829 EXPECT_CALL(*command_buffer(), OnFlush()) | 825 EXPECT_CALL(*command_buffer(), OnFlush()) |
830 .WillOnce(SetMemory(client_result1.ptr, server_result1)) | 826 .WillOnce(SetMemory(client_result1.ptr, server_result1)) |
831 .RetiresOnSaturation(); | 827 .RetiresOnSaturation(); |
832 gl_->GetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_MEDIUM_FLOAT, | 828 gl_->GetShaderPrecisionFormat(GL_FRAGMENT_SHADER, kDummyType1, range1, |
833 range1, &precision1); | 829 &precision1); |
834 const void* commands2 = GetPut(); | 830 const void* commands2 = GetPut(); |
835 EXPECT_NE(commands_, commands2); | 831 EXPECT_NE(commands_, commands2); |
836 EXPECT_EQ(0, memcmp(&expected1, commands_, sizeof(expected1))); | 832 EXPECT_EQ(0, memcmp(&expected1, commands_, sizeof(expected1))); |
837 EXPECT_EQ(range1[0], 14); | 833 EXPECT_EQ(range1[0], 14); |
838 EXPECT_EQ(range1[1], 14); | 834 EXPECT_EQ(range1[1], 14); |
839 EXPECT_EQ(precision1, 10); | 835 EXPECT_EQ(precision1, 10); |
840 | 836 |
841 // The second call for mediump should use the cached value and avoid | 837 // The second call for dummy type 1 should use the cached value and avoid |
842 // triggering a command buffer request, so we do not expect a call to | 838 // triggering a command buffer request, so we do not expect a call to |
843 // OnFlush() here. We do expect the results to be correct though. | 839 // OnFlush() here. We do expect the results to be correct though. |
844 GLint range2[2] = {0, 0}; | 840 GLint range2[2] = {0, 0}; |
845 GLint precision2 = 0; | 841 GLint precision2 = 0; |
846 gl_->GetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_MEDIUM_FLOAT, | 842 gl_->GetShaderPrecisionFormat(GL_FRAGMENT_SHADER, kDummyType1, range2, |
847 range2, &precision2); | 843 &precision2); |
848 const void* commands3 = GetPut(); | 844 const void* commands3 = GetPut(); |
849 EXPECT_EQ(commands2, commands3); | 845 EXPECT_EQ(commands2, commands3); |
850 EXPECT_EQ(range2[0], 14); | 846 EXPECT_EQ(range2[0], 14); |
851 EXPECT_EQ(range2[1], 14); | 847 EXPECT_EQ(range2[1], 14); |
852 EXPECT_EQ(precision2, 10); | 848 EXPECT_EQ(precision2, 10); |
853 | 849 |
854 // If we then make a request for highp, we should get another command | 850 // If we then make a request for dummy type 2, we should get another command |
855 // buffer request since it hasn't been cached yet. | 851 // buffer request since it hasn't been cached yet. |
856 GLint range3[2] = {0, 0}; | 852 GLint range3[2] = {0, 0}; |
857 GLint precision3 = 0; | 853 GLint precision3 = 0; |
858 Cmds expected3; | 854 Cmds expected3; |
859 ExpectedMemoryInfo result3 = GetExpectedResultMemory(4); | 855 ExpectedMemoryInfo result3 = GetExpectedResultMemory(4); |
860 expected3.cmd.Init(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, | 856 expected3.cmd.Init(GL_FRAGMENT_SHADER, kDummyType2, result3.id, |
861 result3.id, result3.offset); | 857 result3.offset); |
862 Result result3_source = {true, 62, 62, 16}; | 858 Result result3_source = {true, 62, 62, 16}; |
863 EXPECT_CALL(*command_buffer(), OnFlush()) | 859 EXPECT_CALL(*command_buffer(), OnFlush()) |
864 .WillOnce(SetMemory(result3.ptr, result3_source)) | 860 .WillOnce(SetMemory(result3.ptr, result3_source)) |
865 .RetiresOnSaturation(); | 861 .RetiresOnSaturation(); |
866 gl_->GetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, | 862 gl_->GetShaderPrecisionFormat(GL_FRAGMENT_SHADER, kDummyType2, range3, |
867 range3, &precision3); | 863 &precision3); |
868 const void* commands4 = GetPut(); | 864 const void* commands4 = GetPut(); |
869 EXPECT_NE(commands3, commands4); | 865 EXPECT_NE(commands3, commands4); |
870 EXPECT_EQ(0, memcmp(&expected3, commands3, sizeof(expected3))); | 866 EXPECT_EQ(0, memcmp(&expected3, commands3, sizeof(expected3))); |
871 EXPECT_EQ(range3[0], 62); | 867 EXPECT_EQ(range3[0], 62); |
872 EXPECT_EQ(range3[1], 62); | 868 EXPECT_EQ(range3[1], 62); |
873 EXPECT_EQ(precision3, 16); | 869 EXPECT_EQ(precision3, 16); |
| 870 |
| 871 // Any call for predefined types should use the cached value from the |
| 872 // Capabilities and avoid triggering a command buffer request, so we do not |
| 873 // expect a call to OnFlush() here. We do expect the results to be correct |
| 874 // though. |
| 875 GLint range4[2] = {0, 0}; |
| 876 GLint precision4 = 0; |
| 877 gl_->GetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_MEDIUM_FLOAT, range4, |
| 878 &precision4); |
| 879 const void* commands5 = GetPut(); |
| 880 EXPECT_EQ(commands4, commands5); |
| 881 EXPECT_EQ(range4[0], 3); |
| 882 EXPECT_EQ(range4[1], 5); |
| 883 EXPECT_EQ(precision4, 7); |
874 } | 884 } |
875 | 885 |
876 TEST_F(GLES2ImplementationTest, ShaderSource) { | 886 TEST_F(GLES2ImplementationTest, ShaderSource) { |
877 const uint32 kBucketId = GLES2Implementation::kResultBucketId; | 887 const uint32 kBucketId = GLES2Implementation::kResultBucketId; |
878 const GLuint kShaderId = 456; | 888 const GLuint kShaderId = 456; |
879 const char* kString1 = "foobar"; | 889 const char* kString1 = "foobar"; |
880 const char* kString2 = "barfoo"; | 890 const char* kString2 = "barfoo"; |
881 const size_t kString1Size = strlen(kString1); | 891 const size_t kString1Size = strlen(kString1); |
882 const size_t kString2Size = strlen(kString2); | 892 const size_t kString2Size = strlen(kString2); |
883 const size_t kString3Size = 1; // Want the NULL; | 893 const size_t kString3Size = 1; // Want the NULL; |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1940 kFormat, | 1950 kFormat, |
1941 kType, | 1951 kType, |
1942 GL_READ_ONLY); | 1952 GL_READ_ONLY); |
1943 EXPECT_TRUE(mem == NULL); | 1953 EXPECT_TRUE(mem == NULL); |
1944 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_ENUM), gl_->GetError()); | 1954 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_ENUM), gl_->GetError()); |
1945 const char* kPtr = "something"; | 1955 const char* kPtr = "something"; |
1946 gl_->UnmapTexSubImage2DCHROMIUM(kPtr); | 1956 gl_->UnmapTexSubImage2DCHROMIUM(kPtr); |
1947 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); | 1957 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); |
1948 } | 1958 } |
1949 | 1959 |
1950 TEST_F(GLES2ImplementationTest, GetMultipleIntegervCHROMIUMValidArgs) { | |
1951 const GLenum pnames[] = { | |
1952 GL_DEPTH_WRITEMASK, | |
1953 GL_COLOR_WRITEMASK, | |
1954 GL_STENCIL_WRITEMASK, | |
1955 }; | |
1956 const GLint num_results = 6; | |
1957 GLint results[num_results + 1]; | |
1958 struct Cmds { | |
1959 cmds::GetMultipleIntegervCHROMIUM get_multiple; | |
1960 cmd::SetToken set_token; | |
1961 }; | |
1962 const GLsizei kNumPnames = arraysize(pnames); | |
1963 const GLsizeiptr kResultsSize = num_results * sizeof(results[0]); | |
1964 const size_t kPNamesSize = kNumPnames * sizeof(pnames[0]); | |
1965 | |
1966 ExpectedMemoryInfo mem1 = GetExpectedMemory(kPNamesSize + kResultsSize); | |
1967 ExpectedMemoryInfo result1 = GetExpectedResultMemory( | |
1968 sizeof(cmds::GetError::Result)); | |
1969 | |
1970 const uint32 kPnamesOffset = mem1.offset; | |
1971 const uint32 kResultsOffset = mem1.offset + kPNamesSize; | |
1972 Cmds expected; | |
1973 expected.get_multiple.Init( | |
1974 mem1.id, kPnamesOffset, kNumPnames, | |
1975 mem1.id, kResultsOffset, kResultsSize); | |
1976 expected.set_token.Init(GetNextToken()); | |
1977 | |
1978 const GLint kSentinel = 0x12345678; | |
1979 memset(results, 0, sizeof(results)); | |
1980 results[num_results] = kSentinel; | |
1981 const GLint returned_results[] = { | |
1982 1, 0, 1, 0, 1, -1, | |
1983 }; | |
1984 // One call to flush to wait for results | |
1985 EXPECT_CALL(*command_buffer(), OnFlush()) | |
1986 .WillOnce(SetMemoryFromArray(mem1.ptr + kPNamesSize, | |
1987 returned_results, sizeof(returned_results))) | |
1988 .WillOnce(SetMemory(result1.ptr, GLuint(GL_NO_ERROR))) | |
1989 .RetiresOnSaturation(); | |
1990 | |
1991 gl_->GetMultipleIntegervCHROMIUM( | |
1992 &pnames[0], kNumPnames, &results[0], kResultsSize); | |
1993 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | |
1994 EXPECT_EQ(0, memcmp(&returned_results, results, sizeof(returned_results))); | |
1995 EXPECT_EQ(kSentinel, results[num_results]); | |
1996 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); | |
1997 } | |
1998 | |
1999 TEST_F(GLES2ImplementationTest, GetMultipleIntegervCHROMIUMBadArgs) { | |
2000 GLenum pnames[] = { | |
2001 GL_DEPTH_WRITEMASK, | |
2002 GL_COLOR_WRITEMASK, | |
2003 GL_STENCIL_WRITEMASK, | |
2004 }; | |
2005 const GLint num_results = 6; | |
2006 GLint results[num_results + 1]; | |
2007 const GLsizei kNumPnames = arraysize(pnames); | |
2008 const GLsizeiptr kResultsSize = num_results * sizeof(results[0]); | |
2009 | |
2010 ExpectedMemoryInfo result1 = | |
2011 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); | |
2012 ExpectedMemoryInfo result2 = | |
2013 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); | |
2014 ExpectedMemoryInfo result3 = | |
2015 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); | |
2016 ExpectedMemoryInfo result4 = | |
2017 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); | |
2018 | |
2019 // Calls to flush to wait for GetError | |
2020 EXPECT_CALL(*command_buffer(), OnFlush()) | |
2021 .WillOnce(SetMemory(result1.ptr, GLuint(GL_NO_ERROR))) | |
2022 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) | |
2023 .WillOnce(SetMemory(result3.ptr, GLuint(GL_NO_ERROR))) | |
2024 .WillOnce(SetMemory(result4.ptr, GLuint(GL_NO_ERROR))) | |
2025 .RetiresOnSaturation(); | |
2026 | |
2027 const GLint kSentinel = 0x12345678; | |
2028 memset(results, 0, sizeof(results)); | |
2029 results[num_results] = kSentinel; | |
2030 // try bad size. | |
2031 gl_->GetMultipleIntegervCHROMIUM( | |
2032 &pnames[0], kNumPnames, &results[0], kResultsSize + 1); | |
2033 EXPECT_TRUE(NoCommandsWritten()); | |
2034 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); | |
2035 EXPECT_EQ(0, results[0]); | |
2036 EXPECT_EQ(kSentinel, results[num_results]); | |
2037 // try bad size. | |
2038 ClearCommands(); | |
2039 gl_->GetMultipleIntegervCHROMIUM( | |
2040 &pnames[0], kNumPnames, &results[0], kResultsSize - 1); | |
2041 EXPECT_TRUE(NoCommandsWritten()); | |
2042 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); | |
2043 EXPECT_EQ(0, results[0]); | |
2044 EXPECT_EQ(kSentinel, results[num_results]); | |
2045 // try uncleared results. | |
2046 ClearCommands(); | |
2047 results[2] = 1; | |
2048 gl_->GetMultipleIntegervCHROMIUM( | |
2049 &pnames[0], kNumPnames, &results[0], kResultsSize); | |
2050 EXPECT_TRUE(NoCommandsWritten()); | |
2051 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); | |
2052 EXPECT_EQ(0, results[0]); | |
2053 EXPECT_EQ(kSentinel, results[num_results]); | |
2054 // try bad enum results. | |
2055 ClearCommands(); | |
2056 results[2] = 0; | |
2057 pnames[1] = GL_TRUE; | |
2058 gl_->GetMultipleIntegervCHROMIUM( | |
2059 &pnames[0], kNumPnames, &results[0], kResultsSize); | |
2060 EXPECT_TRUE(NoCommandsWritten()); | |
2061 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_ENUM), gl_->GetError()); | |
2062 EXPECT_EQ(0, results[0]); | |
2063 EXPECT_EQ(kSentinel, results[num_results]); | |
2064 } | |
2065 | |
2066 TEST_F(GLES2ImplementationTest, GetProgramInfoCHROMIUMGoodArgs) { | 1960 TEST_F(GLES2ImplementationTest, GetProgramInfoCHROMIUMGoodArgs) { |
2067 const uint32 kBucketId = GLES2Implementation::kResultBucketId; | 1961 const uint32 kBucketId = GLES2Implementation::kResultBucketId; |
2068 const GLuint kProgramId = 123; | 1962 const GLuint kProgramId = 123; |
2069 const char kBad = 0x12; | 1963 const char kBad = 0x12; |
2070 GLsizei size = 0; | 1964 GLsizei size = 0; |
2071 const Str7 kString = {"foobar"}; | 1965 const Str7 kString = {"foobar"}; |
2072 char buf[20]; | 1966 char buf[20]; |
2073 | 1967 |
2074 ExpectedMemoryInfo mem1 = | 1968 ExpectedMemoryInfo mem1 = |
2075 GetExpectedMemory(MaxTransferBufferSize()); | 1969 GetExpectedMemory(MaxTransferBufferSize()); |
(...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3405 ContextInitOptions init_options; | 3299 ContextInitOptions init_options; |
3406 init_options.bind_generates_resource_client = true; | 3300 init_options.bind_generates_resource_client = true; |
3407 init_options.bind_generates_resource_service = false; | 3301 init_options.bind_generates_resource_service = false; |
3408 EXPECT_FALSE(Initialize(init_options)); | 3302 EXPECT_FALSE(Initialize(init_options)); |
3409 } | 3303 } |
3410 | 3304 |
3411 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 3305 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" |
3412 | 3306 |
3413 } // namespace gles2 | 3307 } // namespace gles2 |
3414 } // namespace gpu | 3308 } // namespace gpu |
OLD | NEW |