Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: gpu/command_buffer/client/gles2_implementation_unittest.cc

Issue 9999003: Optimize GetBucketContents (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <GLES2/gl2ext.h> 9 #include <GLES2/gl2ext.h>
10 #include "gpu/command_buffer/client/client_test_helper.h" 10 #include "gpu/command_buffer/client/client_test_helper.h"
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 439
440 int CheckError() { 440 int CheckError() {
441 ExpectedMemoryInfo result = 441 ExpectedMemoryInfo result =
442 GetExpectedResultMemory(sizeof(GetError::Result)); 442 GetExpectedResultMemory(sizeof(GetError::Result));
443 EXPECT_CALL(*command_buffer(), OnFlush()) 443 EXPECT_CALL(*command_buffer(), OnFlush())
444 .WillOnce(SetMemory(result.ptr, GLuint(GL_NO_ERROR))) 444 .WillOnce(SetMemory(result.ptr, GLuint(GL_NO_ERROR)))
445 .RetiresOnSaturation(); 445 .RetiresOnSaturation();
446 return gl_->GetError(); 446 return gl_->GetError();
447 } 447 }
448 448
449 bool GetBucketContents(uint32 bucket_id, std::vector<int8>* data) {
450 return gl_->GetBucketContents(bucket_id, data);
451 }
452
449 Sequence sequence_; 453 Sequence sequence_;
450 scoped_ptr<MockClientCommandBuffer> command_buffer_; 454 scoped_ptr<MockClientCommandBuffer> command_buffer_;
451 scoped_ptr<GLES2CmdHelper> helper_; 455 scoped_ptr<GLES2CmdHelper> helper_;
452 scoped_ptr<MockTransferBuffer> transfer_buffer_; 456 scoped_ptr<MockTransferBuffer> transfer_buffer_;
453 scoped_ptr<GLES2Implementation> gl_; 457 scoped_ptr<GLES2Implementation> gl_;
454 CommandBufferEntry* commands_; 458 CommandBufferEntry* commands_;
455 int token_; 459 int token_;
456 }; 460 };
457 461
458 void GLES2ImplementationTest::SetUp() { 462 void GLES2ImplementationTest::SetUp() {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 const GLuint GLES2ImplementationTest::kProgramsAndShadersStartId; 502 const GLuint GLES2ImplementationTest::kProgramsAndShadersStartId;
499 const GLuint GLES2ImplementationTest::kRenderbuffersStartId; 503 const GLuint GLES2ImplementationTest::kRenderbuffersStartId;
500 const GLuint GLES2ImplementationTest::kTexturesStartId; 504 const GLuint GLES2ImplementationTest::kTexturesStartId;
501 const GLuint GLES2ImplementationTest::kQueriesStartId; 505 const GLuint GLES2ImplementationTest::kQueriesStartId;
502 #endif 506 #endif
503 507
504 TEST_F(GLES2ImplementationTest, Basic) { 508 TEST_F(GLES2ImplementationTest, Basic) {
505 EXPECT_TRUE(gl_->share_group() != NULL); 509 EXPECT_TRUE(gl_->share_group() != NULL);
506 } 510 }
507 511
512 TEST_F(GLES2ImplementationTest, GetBucketContents) {
513 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
514 const uint32 kTestSize = MaxTransferBufferSize() + 32;
515
516 scoped_array<uint8> buf(new uint8 [kTestSize]);
517 uint8* expected_data = buf.get();
518 for (uint32 ii = 0; ii < kTestSize; ++ii) {
519 expected_data[ii] = ii * 3;
520 }
521
522 struct Cmds {
523 cmd::GetBucketStart get_bucket_start;
524 cmd::SetToken set_token1;
525 cmd::GetBucketData get_bucket_data;
526 cmd::SetToken set_token2;
527 cmd::SetBucketSize set_bucket_size2;
528 };
529
530 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize());
531 ExpectedMemoryInfo result1 = GetExpectedResultMemory(sizeof(uint32));
532 ExpectedMemoryInfo mem2 = GetExpectedMemory(
533 kTestSize - MaxTransferBufferSize());
534
535 Cmds expected;
536 expected.get_bucket_start.Init(
537 kBucketId, result1.id, result1.offset,
538 MaxTransferBufferSize(), mem1.id, mem1.offset);
539 expected.set_token1.Init(GetNextToken());
540 expected.get_bucket_data.Init(
541 kBucketId, MaxTransferBufferSize(),
542 kTestSize - MaxTransferBufferSize(), mem2.id, mem2.offset);
543 expected.set_bucket_size2.Init(kBucketId, 0);
544 expected.set_token2.Init(GetNextToken());
545
546 EXPECT_CALL(*command_buffer(), OnFlush())
547 .WillOnce(DoAll(
548 SetMemory(result1.ptr, kTestSize),
549 SetMemoryFromArray(
550 mem1.ptr, expected_data, MaxTransferBufferSize())))
551 .WillOnce(SetMemoryFromArray(
552 mem2.ptr, expected_data + MaxTransferBufferSize(),
553 kTestSize - MaxTransferBufferSize()))
554 .RetiresOnSaturation();
555
556 std::vector<int8> data;
557 GetBucketContents(kBucketId, &data);
558 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
559 ASSERT_EQ(kTestSize, data.size());
560 EXPECT_EQ(0, memcmp(expected_data, &data[0], data.size()));
561 }
562
508 TEST_F(GLES2ImplementationTest, ShaderSource) { 563 TEST_F(GLES2ImplementationTest, ShaderSource) {
509 const uint32 kBucketId = GLES2Implementation::kResultBucketId; 564 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
510 const GLuint kShaderId = 456; 565 const GLuint kShaderId = 456;
511 const char* kString1 = "foobar"; 566 const char* kString1 = "foobar";
512 const char* kString2 = "barfoo"; 567 const char* kString2 = "barfoo";
513 const size_t kString1Size = strlen(kString1); 568 const size_t kString1Size = strlen(kString1);
514 const size_t kString2Size = strlen(kString2); 569 const size_t kString2Size = strlen(kString2);
515 const size_t kString3Size = 1; // Want the NULL; 570 const size_t kString3Size = 1; // Want the NULL;
516 const size_t kSourceSize = kString1Size + kString2Size + kString3Size; 571 const size_t kSourceSize = kString1Size + kString2Size + kString3Size;
517 const size_t kPaddedString1Size = 572 const size_t kPaddedString1Size =
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 } 614 }
560 615
561 TEST_F(GLES2ImplementationTest, GetShaderSource) { 616 TEST_F(GLES2ImplementationTest, GetShaderSource) {
562 const uint32 kBucketId = GLES2Implementation::kResultBucketId; 617 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
563 const GLuint kShaderId = 456; 618 const GLuint kShaderId = 456;
564 const Str7 kString = {"foobar"}; 619 const Str7 kString = {"foobar"};
565 const char kBad = 0x12; 620 const char kBad = 0x12;
566 struct Cmds { 621 struct Cmds {
567 cmd::SetBucketSize set_bucket_size1; 622 cmd::SetBucketSize set_bucket_size1;
568 GetShaderSource get_shader_source; 623 GetShaderSource get_shader_source;
569 cmd::GetBucketSize get_bucket_size; 624 cmd::GetBucketStart get_bucket_start;
570 cmd::GetBucketData get_bucket_data;
571 cmd::SetToken set_token1; 625 cmd::SetToken set_token1;
572 cmd::SetBucketSize set_bucket_size2; 626 cmd::SetBucketSize set_bucket_size2;
573 }; 627 };
574 628
629 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize());
575 ExpectedMemoryInfo result1 = GetExpectedResultMemory(sizeof(uint32)); 630 ExpectedMemoryInfo result1 = GetExpectedResultMemory(sizeof(uint32));
576 ExpectedMemoryInfo mem1 = GetExpectedMemory(sizeof(kString));
577 631
578 Cmds expected; 632 Cmds expected;
579 expected.set_bucket_size1.Init(kBucketId, 0); 633 expected.set_bucket_size1.Init(kBucketId, 0);
580 expected.get_shader_source.Init(kShaderId, kBucketId); 634 expected.get_shader_source.Init(kShaderId, kBucketId);
581 expected.get_bucket_size.Init(kBucketId, result1.id, result1.offset); 635 expected.get_bucket_start.Init(
582 expected.get_bucket_data.Init( 636 kBucketId, result1.id, result1.offset,
583 kBucketId, 0, sizeof(kString), mem1.id, mem1.offset); 637 MaxTransferBufferSize(), mem1.id, mem1.offset);
584 expected.set_token1.Init(GetNextToken()); 638 expected.set_token1.Init(GetNextToken());
585 expected.set_bucket_size2.Init(kBucketId, 0); 639 expected.set_bucket_size2.Init(kBucketId, 0);
586 char buf[sizeof(kString) + 1]; 640 char buf[sizeof(kString) + 1];
587 memset(buf, kBad, sizeof(buf)); 641 memset(buf, kBad, sizeof(buf));
588 642
589 EXPECT_CALL(*command_buffer(), OnFlush()) 643 EXPECT_CALL(*command_buffer(), OnFlush())
590 .WillOnce(SetMemory(result1.ptr, uint32(sizeof(kString)))) 644 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))),
591 .WillOnce(SetMemory(mem1.ptr, kString)) 645 SetMemory(mem1.ptr, kString)))
592 .RetiresOnSaturation(); 646 .RetiresOnSaturation();
593 647
594 GLsizei length = 0; 648 GLsizei length = 0;
595 gl_->GetShaderSource(kShaderId, sizeof(buf), &length, buf); 649 gl_->GetShaderSource(kShaderId, sizeof(buf), &length, buf);
596 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 650 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
597 EXPECT_EQ(sizeof(kString) - 1, static_cast<size_t>(length)); 651 EXPECT_EQ(sizeof(kString) - 1, static_cast<size_t>(length));
598 EXPECT_STREQ(kString.str, buf); 652 EXPECT_STREQ(kString.str, buf);
599 EXPECT_EQ(buf[sizeof(kString)], kBad); 653 EXPECT_EQ(buf[sizeof(kString)], kBad);
600 } 654 }
601 655
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
1597 } 1651 }
1598 1652
1599 TEST_F(GLES2ImplementationTest, GetProgramInfoCHROMIUMGoodArgs) { 1653 TEST_F(GLES2ImplementationTest, GetProgramInfoCHROMIUMGoodArgs) {
1600 const uint32 kBucketId = GLES2Implementation::kResultBucketId; 1654 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
1601 const GLuint kProgramId = 123; 1655 const GLuint kProgramId = 123;
1602 const char kBad = 0x12; 1656 const char kBad = 0x12;
1603 GLsizei size = 0; 1657 GLsizei size = 0;
1604 const Str7 kString = {"foobar"}; 1658 const Str7 kString = {"foobar"};
1605 char buf[20]; 1659 char buf[20];
1606 1660
1661 ExpectedMemoryInfo mem1 =
1662 GetExpectedMemory(MaxTransferBufferSize());
1607 ExpectedMemoryInfo result1 = 1663 ExpectedMemoryInfo result1 =
1608 GetExpectedResultMemory(sizeof(cmd::GetBucketSize::Result)); 1664 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result));
1609 ExpectedMemoryInfo mem1 =
1610 GetExpectedMemory(sizeof(kString));
1611 ExpectedMemoryInfo result2 = 1665 ExpectedMemoryInfo result2 =
1612 GetExpectedResultMemory(sizeof(GetError::Result)); 1666 GetExpectedResultMemory(sizeof(GetError::Result));
1613 1667
1614 memset(buf, kBad, sizeof(buf)); 1668 memset(buf, kBad, sizeof(buf));
1615 EXPECT_CALL(*command_buffer(), OnFlush()) 1669 EXPECT_CALL(*command_buffer(), OnFlush())
1616 .WillOnce(SetMemory(result1.ptr, uint32(sizeof(kString)))) 1670 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))),
1617 .WillOnce(SetMemory(mem1.ptr, kString)) 1671 SetMemory(mem1.ptr, kString)))
1618 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) 1672 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR)))
1619 .RetiresOnSaturation(); 1673 .RetiresOnSaturation();
1620 1674
1621 struct Cmds { 1675 struct Cmds {
1622 cmd::SetBucketSize set_bucket_size1; 1676 cmd::SetBucketSize set_bucket_size1;
1623 GetProgramInfoCHROMIUM get_program_info; 1677 GetProgramInfoCHROMIUM get_program_info;
1624 cmd::GetBucketSize get_bucket_size; 1678 cmd::GetBucketStart get_bucket_start;
1625 cmd::GetBucketData get_bucket_data;
1626 cmd::SetToken set_token1; 1679 cmd::SetToken set_token1;
1627 cmd::SetBucketSize set_bucket_size2; 1680 cmd::SetBucketSize set_bucket_size2;
1628 }; 1681 };
1629 Cmds expected; 1682 Cmds expected;
1630 expected.set_bucket_size1.Init(kBucketId, 0); 1683 expected.set_bucket_size1.Init(kBucketId, 0);
1631 expected.get_program_info.Init(kProgramId, kBucketId); 1684 expected.get_program_info.Init(kProgramId, kBucketId);
1632 expected.get_bucket_size.Init(kBucketId, result1.id, result1.offset); 1685 expected.get_bucket_start.Init(
1633 expected.get_bucket_data.Init( 1686 kBucketId, result1.id, result1.offset,
1634 kBucketId, 0, sizeof(kString), mem1.id, mem1.offset); 1687 MaxTransferBufferSize(), mem1.id, mem1.offset);
1635 expected.set_token1.Init(GetNextToken()); 1688 expected.set_token1.Init(GetNextToken());
1636 expected.set_bucket_size2.Init(kBucketId, 0); 1689 expected.set_bucket_size2.Init(kBucketId, 0);
1637 gl_->GetProgramInfoCHROMIUM(kProgramId, sizeof(buf), &size, &buf); 1690 gl_->GetProgramInfoCHROMIUM(kProgramId, sizeof(buf), &size, &buf);
1638 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 1691 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1639 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); 1692 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError());
1640 EXPECT_EQ(sizeof(kString), static_cast<size_t>(size)); 1693 EXPECT_EQ(sizeof(kString), static_cast<size_t>(size));
1641 EXPECT_STREQ(kString.str, buf); 1694 EXPECT_STREQ(kString.str, buf);
1642 EXPECT_EQ(buf[sizeof(kString)], kBad); 1695 EXPECT_EQ(buf[sizeof(kString)], kBad);
1643 } 1696 }
1644 1697
1645 TEST_F(GLES2ImplementationTest, GetProgramInfoCHROMIUMBadArgs) { 1698 TEST_F(GLES2ImplementationTest, GetProgramInfoCHROMIUMBadArgs) {
1646 const uint32 kBucketId = GLES2Implementation::kResultBucketId; 1699 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
1647 const GLuint kProgramId = 123; 1700 const GLuint kProgramId = 123;
1648 GLsizei size = 0; 1701 GLsizei size = 0;
1649 const Str7 kString = {"foobar"}; 1702 const Str7 kString = {"foobar"};
1650 char buf[20]; 1703 char buf[20];
1651 1704
1705 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize());
1652 ExpectedMemoryInfo result1 = 1706 ExpectedMemoryInfo result1 =
1653 GetExpectedResultMemory(sizeof(cmd::GetBucketSize::Result)); 1707 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result));
1654 ExpectedMemoryInfo mem1 = GetExpectedMemory(sizeof(kString));
1655 ExpectedMemoryInfo result2 = 1708 ExpectedMemoryInfo result2 =
1656 GetExpectedResultMemory(sizeof(GetError::Result)); 1709 GetExpectedResultMemory(sizeof(GetError::Result));
1657 ExpectedMemoryInfo result3 = 1710 ExpectedMemoryInfo result3 =
1658 GetExpectedResultMemory(sizeof(GetError::Result)); 1711 GetExpectedResultMemory(sizeof(GetError::Result));
1659 ExpectedMemoryInfo result4 = 1712 ExpectedMemoryInfo result4 =
1660 GetExpectedResultMemory(sizeof(GetError::Result)); 1713 GetExpectedResultMemory(sizeof(GetError::Result));
1661 1714
1662 EXPECT_CALL(*command_buffer(), OnFlush()) 1715 EXPECT_CALL(*command_buffer(), OnFlush())
1663 .WillOnce(SetMemory(result1.ptr, uint32(sizeof(kString)))) 1716 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))),
1664 .WillOnce(SetMemory(mem1.ptr, kString)) 1717 SetMemory(mem1.ptr, kString)))
1665 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) 1718 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR)))
1666 .WillOnce(SetMemory(result3.ptr, GLuint(GL_NO_ERROR))) 1719 .WillOnce(SetMemory(result3.ptr, GLuint(GL_NO_ERROR)))
1667 .WillOnce(SetMemory(result4.ptr, GLuint(GL_NO_ERROR))) 1720 .WillOnce(SetMemory(result4.ptr, GLuint(GL_NO_ERROR)))
1668 .RetiresOnSaturation(); 1721 .RetiresOnSaturation();
1669 1722
1670 // try bufsize not big enough. 1723 // try bufsize not big enough.
1671 struct Cmds { 1724 struct Cmds {
1672 cmd::SetBucketSize set_bucket_size1; 1725 cmd::SetBucketSize set_bucket_size1;
1673 GetProgramInfoCHROMIUM get_program_info; 1726 GetProgramInfoCHROMIUM get_program_info;
1674 cmd::GetBucketSize get_bucket_size; 1727 cmd::GetBucketStart get_bucket_start;
1675 cmd::GetBucketData get_bucket_data;
1676 cmd::SetToken set_token1; 1728 cmd::SetToken set_token1;
1677 cmd::SetBucketSize set_bucket_size2; 1729 cmd::SetBucketSize set_bucket_size2;
1678 }; 1730 };
1679 Cmds expected; 1731 Cmds expected;
1680 expected.set_bucket_size1.Init(kBucketId, 0); 1732 expected.set_bucket_size1.Init(kBucketId, 0);
1681 expected.get_program_info.Init(kProgramId, kBucketId); 1733 expected.get_program_info.Init(kProgramId, kBucketId);
1682 expected.get_bucket_size.Init(kBucketId, result1.id, result1.offset); 1734 expected.get_bucket_start.Init(
1683 expected.get_bucket_data.Init( 1735 kBucketId, result1.id, result1.offset,
1684 kBucketId, 0, sizeof(kString), mem1.id, mem1.offset); 1736 MaxTransferBufferSize(), mem1.id, mem1.offset);
1685 expected.set_token1.Init(GetNextToken()); 1737 expected.set_token1.Init(GetNextToken());
1686 expected.set_bucket_size2.Init(kBucketId, 0); 1738 expected.set_bucket_size2.Init(kBucketId, 0);
1687 gl_->GetProgramInfoCHROMIUM(kProgramId, 6, &size, &buf); 1739 gl_->GetProgramInfoCHROMIUM(kProgramId, 6, &size, &buf);
1688 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 1740 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1689 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), gl_->GetError()); 1741 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), gl_->GetError());
1690 ClearCommands(); 1742 ClearCommands();
1691 1743
1692 // try bad bufsize 1744 // try bad bufsize
1693 gl_->GetProgramInfoCHROMIUM(kProgramId, -1, &size, &buf); 1745 gl_->GetProgramInfoCHROMIUM(kProgramId, -1, &size, &buf);
1694 EXPECT_TRUE(NoCommandsWritten()); 1746 EXPECT_TRUE(NoCommandsWritten());
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 TEST_F(GLES2ImplementationTest, GetString) { 2179 TEST_F(GLES2ImplementationTest, GetString) {
2128 const uint32 kBucketId = GLES2Implementation::kResultBucketId; 2180 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
2129 const Str7 kString = {"foobar"}; 2181 const Str7 kString = {"foobar"};
2130 // GL_CHROMIUM_map_sub GL_CHROMIUM_flipy are hard coded into 2182 // GL_CHROMIUM_map_sub GL_CHROMIUM_flipy are hard coded into
2131 // GLES2Implementation. 2183 // GLES2Implementation.
2132 const char* expected_str = "foobar GL_CHROMIUM_map_sub GL_CHROMIUM_flipy"; 2184 const char* expected_str = "foobar GL_CHROMIUM_map_sub GL_CHROMIUM_flipy";
2133 const char kBad = 0x12; 2185 const char kBad = 0x12;
2134 struct Cmds { 2186 struct Cmds {
2135 cmd::SetBucketSize set_bucket_size1; 2187 cmd::SetBucketSize set_bucket_size1;
2136 GetString get_string; 2188 GetString get_string;
2137 cmd::GetBucketSize get_bucket_size; 2189 cmd::GetBucketStart get_bucket_start;
2138 cmd::GetBucketData get_bucket_data;
2139 cmd::SetToken set_token1; 2190 cmd::SetToken set_token1;
2140 cmd::SetBucketSize set_bucket_size2; 2191 cmd::SetBucketSize set_bucket_size2;
2141 }; 2192 };
2193 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize());
2142 ExpectedMemoryInfo result1 = 2194 ExpectedMemoryInfo result1 =
2143 GetExpectedResultMemory(sizeof(cmd::GetBucketSize::Result)); 2195 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result));
2144 ExpectedMemoryInfo mem1 = GetExpectedMemory(sizeof(kString));
2145 Cmds expected; 2196 Cmds expected;
2146 expected.set_bucket_size1.Init(kBucketId, 0); 2197 expected.set_bucket_size1.Init(kBucketId, 0);
2147 expected.get_string.Init(GL_EXTENSIONS, kBucketId); 2198 expected.get_string.Init(GL_EXTENSIONS, kBucketId);
2148 expected.get_bucket_size.Init(kBucketId, result1.id, result1.offset); 2199 expected.get_bucket_start.Init(
2149 expected.get_bucket_data.Init( 2200 kBucketId, result1.id, result1.offset,
2150 kBucketId, 0, sizeof(kString), mem1.id, mem1.offset); 2201 MaxTransferBufferSize(), mem1.id, mem1.offset);
2151 expected.set_token1.Init(GetNextToken()); 2202 expected.set_token1.Init(GetNextToken());
2152 expected.set_bucket_size2.Init(kBucketId, 0); 2203 expected.set_bucket_size2.Init(kBucketId, 0);
2153 char buf[sizeof(kString) + 1]; 2204 char buf[sizeof(kString) + 1];
2154 memset(buf, kBad, sizeof(buf)); 2205 memset(buf, kBad, sizeof(buf));
2155 2206
2156 EXPECT_CALL(*command_buffer(), OnFlush()) 2207 EXPECT_CALL(*command_buffer(), OnFlush())
2157 .WillOnce(SetMemory(result1.ptr, uint32(sizeof(kString)))) 2208 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))),
2158 .WillOnce(SetMemory(mem1.ptr, kString)) 2209 SetMemory(mem1.ptr, kString)))
2159 .RetiresOnSaturation(); 2210 .RetiresOnSaturation();
2160 2211
2161 const GLubyte* result = gl_->GetString(GL_EXTENSIONS); 2212 const GLubyte* result = gl_->GetString(GL_EXTENSIONS);
2162 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 2213 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2163 EXPECT_STREQ(expected_str, reinterpret_cast<const char*>(result)); 2214 EXPECT_STREQ(expected_str, reinterpret_cast<const char*>(result));
2164 } 2215 }
2165 2216
2166 TEST_F(GLES2ImplementationTest, PixelStoreiGLPackReverseRowOrderANGLE) { 2217 TEST_F(GLES2ImplementationTest, PixelStoreiGLPackReverseRowOrderANGLE) {
2167 const uint32 kBucketId = GLES2Implementation::kResultBucketId; 2218 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
2168 const Str7 kString = {"foobar"}; 2219 const Str7 kString = {"foobar"};
2169 struct Cmds { 2220 struct Cmds {
2170 cmd::SetBucketSize set_bucket_size1; 2221 cmd::SetBucketSize set_bucket_size1;
2171 GetString get_string; 2222 GetString get_string;
2172 cmd::GetBucketSize get_bucket_size; 2223 cmd::GetBucketStart get_bucket_start;
2173 cmd::GetBucketData get_bucket_data;
2174 cmd::SetToken set_token1; 2224 cmd::SetToken set_token1;
2175 cmd::SetBucketSize set_bucket_size2; 2225 cmd::SetBucketSize set_bucket_size2;
2176 PixelStorei pixel_store; 2226 PixelStorei pixel_store;
2177 }; 2227 };
2178 2228
2229 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize());
2179 ExpectedMemoryInfo result1 = 2230 ExpectedMemoryInfo result1 =
2180 GetExpectedResultMemory(sizeof(cmd::GetBucketSize::Result)); 2231 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result));
2181 ExpectedMemoryInfo mem1 = GetExpectedMemory(sizeof(kString));
2182 2232
2183 Cmds expected; 2233 Cmds expected;
2184 expected.set_bucket_size1.Init(kBucketId, 0); 2234 expected.set_bucket_size1.Init(kBucketId, 0);
2185 expected.get_string.Init(GL_EXTENSIONS, kBucketId); 2235 expected.get_string.Init(GL_EXTENSIONS, kBucketId);
2186 expected.get_bucket_size.Init(kBucketId, result1.id, result1.offset); 2236 expected.get_bucket_start.Init(
2187 expected.get_bucket_data.Init( 2237 kBucketId, result1.id, result1.offset,
2188 kBucketId, 0, sizeof(kString), mem1.id, mem1.offset); 2238 MaxTransferBufferSize(), mem1.id, mem1.offset);
2189 expected.set_token1.Init(GetNextToken()); 2239 expected.set_token1.Init(GetNextToken());
2190 expected.set_bucket_size2.Init(kBucketId, 0); 2240 expected.set_bucket_size2.Init(kBucketId, 0);
2191 expected.pixel_store.Init(GL_PACK_REVERSE_ROW_ORDER_ANGLE, 1); 2241 expected.pixel_store.Init(GL_PACK_REVERSE_ROW_ORDER_ANGLE, 1);
2192 2242
2193 EXPECT_CALL(*command_buffer(), OnFlush()) 2243 EXPECT_CALL(*command_buffer(), OnFlush())
2194 .WillOnce(SetMemory(result1.ptr, uint32(sizeof(kString)))) 2244 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))),
2195 .WillOnce(SetMemory(mem1.ptr, kString)) 2245 SetMemory(mem1.ptr, kString)))
2196 .RetiresOnSaturation(); 2246 .RetiresOnSaturation();
2197 2247
2198 gl_->PixelStorei(GL_PACK_REVERSE_ROW_ORDER_ANGLE, 1); 2248 gl_->PixelStorei(GL_PACK_REVERSE_ROW_ORDER_ANGLE, 1);
2199 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 2249 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2200 } 2250 }
2201 2251
2202 TEST_F(GLES2ImplementationTest, CreateProgram) { 2252 TEST_F(GLES2ImplementationTest, CreateProgram) {
2203 struct Cmds { 2253 struct Cmds {
2204 CreateProgram cmd; 2254 CreateProgram cmd;
2205 }; 2255 };
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
2358 EXPECT_TRUE(NoCommandsWritten()); 2408 EXPECT_TRUE(NoCommandsWritten());
2359 EXPECT_EQ(0u, available); 2409 EXPECT_EQ(0u, available);
2360 } 2410 }
2361 2411
2362 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" 2412 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h"
2363 2413
2364 } // namespace gles2 2414 } // namespace gles2
2365 } // namespace gpu 2415 } // namespace gpu
2366 2416
2367 2417
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.cc ('k') | gpu/command_buffer/common/cmd_buffer_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698