| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include "base/atomicops.h" | 7 #include "base/atomicops.h" |
| 8 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 8 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
| 9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 10 #include "gpu/command_buffer/common/gl_mock.h" | 10 #include "gpu/command_buffer/common/gl_mock.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 GLint in_read_x, GLint in_read_y, | 49 GLint in_read_x, GLint in_read_y, |
| 50 GLsizei in_read_width, GLsizei in_read_height, | 50 GLsizei in_read_width, GLsizei in_read_height, |
| 51 bool init); | 51 bool init); |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 class GLES2DecoderWithShaderTest : public GLES2DecoderWithShaderTestBase { | 54 class GLES2DecoderWithShaderTest : public GLES2DecoderWithShaderTestBase { |
| 55 public: | 55 public: |
| 56 GLES2DecoderWithShaderTest() | 56 GLES2DecoderWithShaderTest() |
| 57 : GLES2DecoderWithShaderTestBase() { | 57 : GLES2DecoderWithShaderTestBase() { |
| 58 } | 58 } |
| 59 | |
| 60 | |
| 61 void AddExpectationsForSimulatedAttrib0WithError( | |
| 62 GLsizei num_vertices, GLuint buffer_id, GLenum error) { | |
| 63 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { | |
| 64 return; | |
| 65 } | |
| 66 | |
| 67 EXPECT_CALL(*gl_, GetError()) | |
| 68 .WillOnce(Return(GL_NO_ERROR)) | |
| 69 .WillOnce(Return(error)) | |
| 70 .RetiresOnSaturation(); | |
| 71 EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, kServiceAttrib0BufferId)) | |
| 72 .Times(1) | |
| 73 .RetiresOnSaturation(); | |
| 74 EXPECT_CALL(*gl_, BufferData(GL_ARRAY_BUFFER, | |
| 75 num_vertices * sizeof(GLfloat) * 4, | |
| 76 _, GL_DYNAMIC_DRAW)) | |
| 77 .Times(1) | |
| 78 .RetiresOnSaturation(); | |
| 79 if (error == GL_NO_ERROR) { | |
| 80 EXPECT_CALL(*gl_, BufferSubData( | |
| 81 GL_ARRAY_BUFFER, 0, num_vertices * sizeof(GLfloat) * 4, _)) | |
| 82 .Times(1) | |
| 83 .RetiresOnSaturation(); | |
| 84 EXPECT_CALL(*gl_, VertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL)) | |
| 85 .Times(1) | |
| 86 .RetiresOnSaturation(); | |
| 87 EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, 0)) | |
| 88 .Times(1) | |
| 89 .RetiresOnSaturation(); | |
| 90 EXPECT_CALL(*gl_, VertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL)) | |
| 91 .Times(1) | |
| 92 .RetiresOnSaturation(); | |
| 93 EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, buffer_id)) | |
| 94 .Times(1) | |
| 95 .RetiresOnSaturation(); | |
| 96 } | |
| 97 } | |
| 98 | |
| 99 void AddExpectationsForSimulatedAttrib0( | |
| 100 GLsizei num_vertices, GLuint buffer_id) { | |
| 101 AddExpectationsForSimulatedAttrib0WithError( | |
| 102 num_vertices, buffer_id, GL_NO_ERROR); | |
| 103 } | |
| 104 }; | 59 }; |
| 105 | 60 |
| 106 class GLES2DecoderRGBBackbufferTest : public GLES2DecoderWithShaderTest { | 61 class GLES2DecoderRGBBackbufferTest : public GLES2DecoderWithShaderTest { |
| 107 public: | 62 public: |
| 108 GLES2DecoderRGBBackbufferTest() { } | 63 GLES2DecoderRGBBackbufferTest() { } |
| 109 | 64 |
| 110 virtual void SetUp() { | 65 virtual void SetUp() { |
| 111 InitDecoder( | 66 InitDecoder( |
| 112 "", // extensions | 67 "", // extensions |
| 113 false, // has alpha | 68 false, // has alpha |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 cmd.Init(GL_TRIANGLES, 0, kFakeLargeCount); | 138 cmd.Init(GL_TRIANGLES, 0, kFakeLargeCount); |
| 184 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 139 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 185 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 140 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
| 186 } | 141 } |
| 187 | 142 |
| 188 TEST_F(GLES2DecoderWithShaderTest, DrawArraysBadTextureUsesBlack) { | 143 TEST_F(GLES2DecoderWithShaderTest, DrawArraysBadTextureUsesBlack) { |
| 189 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 144 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 190 // This is an NPOT texture. As the default filtering requires mips | 145 // This is an NPOT texture. As the default filtering requires mips |
| 191 // this should trigger replacing with black textures before rendering. | 146 // this should trigger replacing with black textures before rendering. |
| 192 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 147 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 193 0, 0); | 148 kSharedMemoryId, kSharedMemoryOffset); |
| 194 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | 149 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
| 195 { | 150 { |
| 196 InSequence sequence; | 151 InSequence sequence; |
| 197 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) | 152 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) |
| 198 .Times(1) | 153 .Times(1) |
| 199 .RetiresOnSaturation(); | 154 .RetiresOnSaturation(); |
| 200 EXPECT_CALL(*gl_, BindTexture( | 155 EXPECT_CALL(*gl_, BindTexture( |
| 201 GL_TEXTURE_2D, TestHelper::kServiceBlackTexture2dId)) | 156 GL_TEXTURE_2D, TestHelper::kServiceBlackTexture2dId)) |
| 202 .Times(1) | 157 .Times(1) |
| 203 .RetiresOnSaturation(); | 158 .RetiresOnSaturation(); |
| (...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 .WillOnce(Return(GL_NO_ERROR)) | 1400 .WillOnce(Return(GL_NO_ERROR)) |
| 1446 .RetiresOnSaturation(); | 1401 .RetiresOnSaturation(); |
| 1447 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( | 1402 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( |
| 1448 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, | 1403 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, |
| 1449 kServiceRenderbufferId)) | 1404 kServiceRenderbufferId)) |
| 1450 .Times(1) | 1405 .Times(1) |
| 1451 .RetiresOnSaturation(); | 1406 .RetiresOnSaturation(); |
| 1452 EXPECT_CALL(*gl_, GetError()) | 1407 EXPECT_CALL(*gl_, GetError()) |
| 1453 .WillOnce(Return(GL_NO_ERROR)) | 1408 .WillOnce(Return(GL_NO_ERROR)) |
| 1454 .RetiresOnSaturation(); | 1409 .RetiresOnSaturation(); |
| 1455 SetupExpectationsForFramebufferAttachment( | |
| 1456 GL_COLOR_BUFFER_BIT, // clear bits | |
| 1457 0, 0, 0, 0, // color | |
| 1458 0, // stencil | |
| 1459 1.0f, // depth | |
| 1460 false); // scissor test | |
| 1461 EXPECT_CALL(*gl_, GetError()) | 1410 EXPECT_CALL(*gl_, GetError()) |
| 1462 .WillOnce(Return(GL_NO_ERROR)) | 1411 .WillOnce(Return(GL_NO_ERROR)) |
| 1463 .WillOnce(Return(GL_NO_ERROR)) | 1412 .WillOnce(Return(GL_NO_ERROR)) |
| 1464 .RetiresOnSaturation(); | 1413 .RetiresOnSaturation(); |
| 1465 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT( | 1414 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT( |
| 1466 GL_FRAMEBUFFER, | 1415 GL_FRAMEBUFFER, |
| 1467 GL_COLOR_ATTACHMENT0, | 1416 GL_COLOR_ATTACHMENT0, |
| 1468 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, _)) | 1417 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, _)) |
| 1469 .WillOnce(SetArgumentPointee<3>(kServiceRenderbufferId)) | 1418 .WillOnce(SetArgumentPointee<3>(kServiceRenderbufferId)) |
| 1470 .RetiresOnSaturation(); | 1419 .RetiresOnSaturation(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1501 .WillOnce(Return(GL_NO_ERROR)) | 1450 .WillOnce(Return(GL_NO_ERROR)) |
| 1502 .RetiresOnSaturation(); | 1451 .RetiresOnSaturation(); |
| 1503 EXPECT_CALL(*gl_, FramebufferTexture2DEXT( | 1452 EXPECT_CALL(*gl_, FramebufferTexture2DEXT( |
| 1504 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | 1453 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 1505 kServiceTextureId, 0)) | 1454 kServiceTextureId, 0)) |
| 1506 .Times(1) | 1455 .Times(1) |
| 1507 .RetiresOnSaturation(); | 1456 .RetiresOnSaturation(); |
| 1508 EXPECT_CALL(*gl_, GetError()) | 1457 EXPECT_CALL(*gl_, GetError()) |
| 1509 .WillOnce(Return(GL_NO_ERROR)) | 1458 .WillOnce(Return(GL_NO_ERROR)) |
| 1510 .RetiresOnSaturation(); | 1459 .RetiresOnSaturation(); |
| 1511 SetupExpectationsForFramebufferAttachment( | |
| 1512 0, // clear bits | |
| 1513 0, 0, 0, 0, // color | |
| 1514 0, // stencil | |
| 1515 1.0f, // depth | |
| 1516 false); // scissor test | |
| 1517 EXPECT_CALL(*gl_, GetError()) | 1460 EXPECT_CALL(*gl_, GetError()) |
| 1518 .WillOnce(Return(GL_NO_ERROR)) | 1461 .WillOnce(Return(GL_NO_ERROR)) |
| 1519 .WillOnce(Return(GL_NO_ERROR)) | 1462 .WillOnce(Return(GL_NO_ERROR)) |
| 1520 .RetiresOnSaturation(); | 1463 .RetiresOnSaturation(); |
| 1521 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT( | 1464 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT( |
| 1522 GL_FRAMEBUFFER, | 1465 GL_FRAMEBUFFER, |
| 1523 GL_COLOR_ATTACHMENT0, | 1466 GL_COLOR_ATTACHMENT0, |
| 1524 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, _)) | 1467 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, _)) |
| 1525 .WillOnce(SetArgumentPointee<3>(kServiceTextureId)) | 1468 .WillOnce(SetArgumentPointee<3>(kServiceTextureId)) |
| 1526 .RetiresOnSaturation(); | 1469 .RetiresOnSaturation(); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1664 29, 28, 23, 22, 21, 22, 21, 29, 28, 23, 22, 21, 22, 21, 28, | 1607 29, 28, 23, 22, 21, 22, 21, 29, 28, 23, 22, 21, 22, 21, 28, |
| 1665 31, 34, 39, 37, 32, 37, 32, 31, 34, 39, 37, 32, 37, 32, 34, | 1608 31, 34, 39, 37, 32, 37, 32, 31, 34, 39, 37, 32, 37, 32, 34, |
| 1666 }; | 1609 }; |
| 1667 | 1610 |
| 1668 ClearSharedMemory(); | 1611 ClearSharedMemory(); |
| 1669 | 1612 |
| 1670 // We need to setup an FBO so we can know the max size that ReadPixels will | 1613 // We need to setup an FBO so we can know the max size that ReadPixels will |
| 1671 // access | 1614 // access |
| 1672 if (init) { | 1615 if (init) { |
| 1673 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 1616 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 1674 DoTexImage2D(GL_TEXTURE_2D, 0, kFormat, kWidth, kHeight, 0, | 1617 DoTexImage2D( |
| 1675 kFormat, GL_UNSIGNED_BYTE, 0, 0); | 1618 GL_TEXTURE_2D, 0, kFormat, kWidth, kHeight, 0, |
| 1676 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | 1619 kFormat, GL_UNSIGNED_BYTE, kSharedMemoryId, |
| 1677 kServiceFramebufferId); | 1620 kSharedMemoryOffset); |
| 1678 EXPECT_CALL(*gl_, GetError()) | 1621 DoBindFramebuffer( |
| 1679 .WillOnce(Return(GL_NO_ERROR)) | 1622 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 1680 .RetiresOnSaturation(); | 1623 DoFramebufferTexture2D( |
| 1681 EXPECT_CALL(*gl_, FramebufferTexture2DEXT( | |
| 1682 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | 1624 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 1683 kServiceTextureId, 0)) | 1625 client_texture_id_, kServiceTextureId, 0, GL_NO_ERROR); |
| 1684 .Times(1) | |
| 1685 .RetiresOnSaturation(); | |
| 1686 EXPECT_CALL(*gl_, GetError()) | |
| 1687 .WillOnce(Return(GL_NO_ERROR)) | |
| 1688 .RetiresOnSaturation(); | |
| 1689 SetupExpectationsForFramebufferAttachment( | |
| 1690 0, // clear bits | |
| 1691 0, 0, 0, 0, // color | |
| 1692 0, // stencil | |
| 1693 1.0f, // depth | |
| 1694 false); // scissor test | |
| 1695 FramebufferTexture2D fbtex_cmd; | |
| 1696 fbtex_cmd.Init( | |
| 1697 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, client_texture_id_, | |
| 1698 0); | |
| 1699 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); | |
| 1700 } | 1626 } |
| 1701 | 1627 |
| 1702 ReadPixelsEmulator emu( | 1628 ReadPixelsEmulator emu( |
| 1703 kWidth, kHeight, kBytesPerPixel, kSrcPixels, kSrcPixels, kPackAlignment); | 1629 kWidth, kHeight, kBytesPerPixel, kSrcPixels, kSrcPixels, kPackAlignment); |
| 1704 typedef ReadPixels::Result Result; | 1630 typedef ReadPixels::Result Result; |
| 1705 Result* result = GetSharedMemoryAs<Result*>(); | 1631 Result* result = GetSharedMemoryAs<Result*>(); |
| 1706 uint32 result_shm_id = kSharedMemoryId; | 1632 uint32 result_shm_id = kSharedMemoryId; |
| 1707 uint32 result_shm_offset = kSharedMemoryOffset; | 1633 uint32 result_shm_offset = kSharedMemoryOffset; |
| 1708 uint32 pixels_shm_id = kSharedMemoryId; | 1634 uint32 pixels_shm_id = kSharedMemoryId; |
| 1709 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); | 1635 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2549 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kInvalidSharedMemoryOffset); | 2475 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kInvalidSharedMemoryOffset); |
| 2550 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 2476 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 2551 } | 2477 } |
| 2552 | 2478 |
| 2553 TEST_F(GLES2DecoderTest, TexSubImage2DValidArgs) { | 2479 TEST_F(GLES2DecoderTest, TexSubImage2DValidArgs) { |
| 2554 const int kWidth = 16; | 2480 const int kWidth = 16; |
| 2555 const int kHeight = 8; | 2481 const int kHeight = 8; |
| 2556 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 2482 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 2557 DoTexImage2D( | 2483 DoTexImage2D( |
| 2558 GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 2484 GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 2559 0, 0); | 2485 kSharedMemoryId, kSharedMemoryOffset); |
| 2560 EXPECT_CALL(*gl_, TexSubImage2D( | 2486 EXPECT_CALL(*gl_, TexSubImage2D( |
| 2561 GL_TEXTURE_2D, 1, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, | 2487 GL_TEXTURE_2D, 1, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, |
| 2562 shared_memory_address_)) | 2488 shared_memory_address_)) |
| 2563 .Times(1) | 2489 .Times(1) |
| 2564 .RetiresOnSaturation(); | 2490 .RetiresOnSaturation(); |
| 2565 TexSubImage2D cmd; | 2491 TexSubImage2D cmd; |
| 2566 cmd.Init( | 2492 cmd.Init( |
| 2567 GL_TEXTURE_2D, 1, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, | 2493 GL_TEXTURE_2D, 1, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, |
| 2568 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); | 2494 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); |
| 2569 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 2495 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2630 kSharedMemoryId, kInvalidSharedMemoryOffset, GL_FALSE); | 2556 kSharedMemoryId, kInvalidSharedMemoryOffset, GL_FALSE); |
| 2631 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 2557 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 2632 } | 2558 } |
| 2633 | 2559 |
| 2634 TEST_F(GLES2DecoderTest, CopyTexSubImage2DValidArgs) { | 2560 TEST_F(GLES2DecoderTest, CopyTexSubImage2DValidArgs) { |
| 2635 const int kWidth = 16; | 2561 const int kWidth = 16; |
| 2636 const int kHeight = 8; | 2562 const int kHeight = 8; |
| 2637 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 2563 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 2638 DoTexImage2D( | 2564 DoTexImage2D( |
| 2639 GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 2565 GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 2640 0, 0); | 2566 kSharedMemoryId, kSharedMemoryOffset); |
| 2641 EXPECT_CALL(*gl_, CopyTexSubImage2D( | 2567 EXPECT_CALL(*gl_, CopyTexSubImage2D( |
| 2642 GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight)) | 2568 GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight)) |
| 2643 .Times(1) | 2569 .Times(1) |
| 2644 .RetiresOnSaturation(); | 2570 .RetiresOnSaturation(); |
| 2645 CopyTexSubImage2D cmd; | 2571 CopyTexSubImage2D cmd; |
| 2646 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight); | 2572 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight); |
| 2647 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 2573 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2648 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2574 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2649 } | 2575 } |
| 2650 | 2576 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2691 color_cmd.Init(0.1f, 0.2f, 0.3f, 0.4f); | 2617 color_cmd.Init(0.1f, 0.2f, 0.3f, 0.4f); |
| 2692 color_mask_cmd.Init(0, 1, 0, 1); | 2618 color_mask_cmd.Init(0, 1, 0, 1); |
| 2693 enable_cmd.Init(GL_SCISSOR_TEST); | 2619 enable_cmd.Init(GL_SCISSOR_TEST); |
| 2694 cmd.Init( | 2620 cmd.Init( |
| 2695 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, | 2621 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, |
| 2696 client_renderbuffer_id_); | 2622 client_renderbuffer_id_); |
| 2697 InSequence sequence; | 2623 InSequence sequence; |
| 2698 EXPECT_CALL(*gl_, ClearColor(0.1f, 0.2f, 0.3f, 0.4f)) | 2624 EXPECT_CALL(*gl_, ClearColor(0.1f, 0.2f, 0.3f, 0.4f)) |
| 2699 .Times(1) | 2625 .Times(1) |
| 2700 .RetiresOnSaturation(); | 2626 .RetiresOnSaturation(); |
| 2701 // EXPECT_CALL(*gl_, ColorMask(0, 1, 0, 1)) | |
| 2702 // .Times(0) | |
| 2703 // .RetiresOnSaturation(); | |
| 2704 EXPECT_CALL(*gl_, Enable(GL_SCISSOR_TEST)) | 2627 EXPECT_CALL(*gl_, Enable(GL_SCISSOR_TEST)) |
| 2705 .Times(1) | 2628 .Times(1) |
| 2706 .RetiresOnSaturation(); | 2629 .RetiresOnSaturation(); |
| 2707 EXPECT_CALL(*gl_, GetError()) | 2630 EXPECT_CALL(*gl_, GetError()) |
| 2708 .WillOnce(Return(GL_NO_ERROR)) | 2631 .WillOnce(Return(GL_NO_ERROR)) |
| 2709 .RetiresOnSaturation(); | 2632 .RetiresOnSaturation(); |
| 2710 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( | 2633 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( |
| 2711 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, | 2634 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, |
| 2712 kServiceRenderbufferId)) | 2635 kServiceRenderbufferId)) |
| 2713 .Times(1) | 2636 .Times(1) |
| 2714 .RetiresOnSaturation(); | 2637 .RetiresOnSaturation(); |
| 2715 EXPECT_CALL(*gl_, GetError()) | 2638 EXPECT_CALL(*gl_, GetError()) |
| 2716 .WillOnce(Return(GL_NO_ERROR)) | 2639 .WillOnce(Return(GL_NO_ERROR)) |
| 2717 .RetiresOnSaturation(); | 2640 .RetiresOnSaturation(); |
| 2718 SetupExpectationsForFramebufferAttachment( | |
| 2719 GL_COLOR_BUFFER_BIT, // clear bits | |
| 2720 0.1f, 0.2f, 0.3f, 0.4f, // color | |
| 2721 0, // stencil | |
| 2722 1.0f, // depth | |
| 2723 true); // scissor test | |
| 2724 EXPECT_EQ(error::kNoError, ExecuteCmd(color_cmd)); | 2641 EXPECT_EQ(error::kNoError, ExecuteCmd(color_cmd)); |
| 2725 EXPECT_EQ(error::kNoError, ExecuteCmd(color_mask_cmd)); | 2642 EXPECT_EQ(error::kNoError, ExecuteCmd(color_mask_cmd)); |
| 2726 EXPECT_EQ(error::kNoError, ExecuteCmd(enable_cmd)); | 2643 EXPECT_EQ(error::kNoError, ExecuteCmd(enable_cmd)); |
| 2727 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 2644 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2728 } | 2645 } |
| 2729 | 2646 |
| 2730 TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearDepth) { | 2647 TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearDepth) { |
| 2731 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | 2648 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, |
| 2732 kServiceFramebufferId); | 2649 kServiceFramebufferId); |
| 2733 ClearDepthf depth_cmd; | 2650 ClearDepthf depth_cmd; |
| 2734 DepthMask depth_mask_cmd; | 2651 DepthMask depth_mask_cmd; |
| 2735 FramebufferRenderbuffer cmd; | 2652 FramebufferRenderbuffer cmd; |
| 2736 depth_cmd.Init(0.5f); | 2653 depth_cmd.Init(0.5f); |
| 2737 depth_mask_cmd.Init(false); | 2654 depth_mask_cmd.Init(false); |
| 2738 cmd.Init( | 2655 cmd.Init( |
| 2739 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, | 2656 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, |
| 2740 client_renderbuffer_id_); | 2657 client_renderbuffer_id_); |
| 2741 InSequence sequence; | 2658 InSequence sequence; |
| 2742 EXPECT_CALL(*gl_, ClearDepth(0.5f)) | 2659 EXPECT_CALL(*gl_, ClearDepth(0.5f)) |
| 2743 .Times(1) | 2660 .Times(1) |
| 2744 .RetiresOnSaturation(); | 2661 .RetiresOnSaturation(); |
| 2745 // EXPECT_CALL(*gl_, DepthMask(0)) | |
| 2746 // .Times(1) | |
| 2747 // .RetiresOnSaturation(); | |
| 2748 EXPECT_CALL(*gl_, GetError()) | 2662 EXPECT_CALL(*gl_, GetError()) |
| 2749 .WillOnce(Return(GL_NO_ERROR)) | 2663 .WillOnce(Return(GL_NO_ERROR)) |
| 2750 .RetiresOnSaturation(); | 2664 .RetiresOnSaturation(); |
| 2751 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( | 2665 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( |
| 2752 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, | 2666 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, |
| 2753 kServiceRenderbufferId)) | 2667 kServiceRenderbufferId)) |
| 2754 .Times(1) | 2668 .Times(1) |
| 2755 .RetiresOnSaturation(); | 2669 .RetiresOnSaturation(); |
| 2756 EXPECT_CALL(*gl_, GetError()) | 2670 EXPECT_CALL(*gl_, GetError()) |
| 2757 .WillOnce(Return(GL_NO_ERROR)) | 2671 .WillOnce(Return(GL_NO_ERROR)) |
| 2758 .RetiresOnSaturation(); | 2672 .RetiresOnSaturation(); |
| 2759 SetupExpectationsForFramebufferAttachment( | |
| 2760 GL_DEPTH_BUFFER_BIT, // clear bits | |
| 2761 0, 0, 0, 0, // color | |
| 2762 0, // stencil | |
| 2763 0.5f, // depth | |
| 2764 false); // scissor test | |
| 2765 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_cmd)); | 2673 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_cmd)); |
| 2766 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_mask_cmd)); | 2674 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_mask_cmd)); |
| 2767 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 2675 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2768 } | 2676 } |
| 2769 | 2677 |
| 2770 TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearStencil) { | 2678 TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearStencil) { |
| 2771 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | 2679 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, |
| 2772 kServiceFramebufferId); | 2680 kServiceFramebufferId); |
| 2773 ClearStencil stencil_cmd; | 2681 ClearStencil stencil_cmd; |
| 2774 StencilMaskSeparate stencil_mask_separate_cmd; | 2682 StencilMaskSeparate stencil_mask_separate_cmd; |
| 2775 FramebufferRenderbuffer cmd; | 2683 FramebufferRenderbuffer cmd; |
| 2776 stencil_cmd.Init(123); | 2684 stencil_cmd.Init(123); |
| 2777 stencil_mask_separate_cmd.Init(GL_BACK, 0x1234u); | 2685 stencil_mask_separate_cmd.Init(GL_BACK, 0x1234u); |
| 2778 cmd.Init( | 2686 cmd.Init( |
| 2779 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, | 2687 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, |
| 2780 client_renderbuffer_id_); | 2688 client_renderbuffer_id_); |
| 2781 InSequence sequence; | 2689 InSequence sequence; |
| 2782 EXPECT_CALL(*gl_, ClearStencil(123)) | 2690 EXPECT_CALL(*gl_, ClearStencil(123)) |
| 2783 .Times(1) | 2691 .Times(1) |
| 2784 .RetiresOnSaturation(); | 2692 .RetiresOnSaturation(); |
| 2785 // EXPECT_CALL(*gl_, StencilMaskSeparate(GL_BACK, 0x1234u)) | |
| 2786 // .Times(1) | |
| 2787 // .RetiresOnSaturation(); | |
| 2788 EXPECT_CALL(*gl_, GetError()) | 2693 EXPECT_CALL(*gl_, GetError()) |
| 2789 .WillOnce(Return(GL_NO_ERROR)) | 2694 .WillOnce(Return(GL_NO_ERROR)) |
| 2790 .RetiresOnSaturation(); | 2695 .RetiresOnSaturation(); |
| 2791 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( | 2696 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( |
| 2792 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, | 2697 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, |
| 2793 kServiceRenderbufferId)) | 2698 kServiceRenderbufferId)) |
| 2794 .Times(1) | 2699 .Times(1) |
| 2795 .RetiresOnSaturation(); | 2700 .RetiresOnSaturation(); |
| 2796 EXPECT_CALL(*gl_, GetError()) | 2701 EXPECT_CALL(*gl_, GetError()) |
| 2797 .WillOnce(Return(GL_NO_ERROR)) | 2702 .WillOnce(Return(GL_NO_ERROR)) |
| 2798 .RetiresOnSaturation(); | 2703 .RetiresOnSaturation(); |
| 2799 SetupExpectationsForFramebufferAttachment( | |
| 2800 GL_STENCIL_BUFFER_BIT, // clear bits | |
| 2801 0, 0, 0, 0, // color | |
| 2802 123, // stencil | |
| 2803 1.0f, // depth | |
| 2804 false); // scissor test | |
| 2805 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_cmd)); | 2704 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_cmd)); |
| 2806 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_mask_separate_cmd)); | 2705 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_mask_separate_cmd)); |
| 2807 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 2706 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2808 } | 2707 } |
| 2809 | 2708 |
| 2810 TEST_F(GLES2DecoderTest, IsBuffer) { | 2709 TEST_F(GLES2DecoderTest, IsBuffer) { |
| 2811 EXPECT_FALSE(DoIsBuffer(client_buffer_id_)); | 2710 EXPECT_FALSE(DoIsBuffer(client_buffer_id_)); |
| 2812 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); | 2711 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); |
| 2813 EXPECT_TRUE(DoIsBuffer(client_buffer_id_)); | 2712 EXPECT_TRUE(DoIsBuffer(client_buffer_id_)); |
| 2814 DoDeleteBuffer(client_buffer_id_, kServiceBufferId); | 2713 DoDeleteBuffer(client_buffer_id_, kServiceBufferId); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2872 .Times(1) | 2771 .Times(1) |
| 2873 .RetiresOnSaturation(); | 2772 .RetiresOnSaturation(); |
| 2874 EXPECT_CALL(*gl_, ClearStencil(123)) | 2773 EXPECT_CALL(*gl_, ClearStencil(123)) |
| 2875 .Times(1) | 2774 .Times(1) |
| 2876 .RetiresOnSaturation(); | 2775 .RetiresOnSaturation(); |
| 2877 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( | 2776 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( |
| 2878 GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, | 2777 GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, |
| 2879 kServiceRenderbufferId)) | 2778 kServiceRenderbufferId)) |
| 2880 .Times(1) | 2779 .Times(1) |
| 2881 .RetiresOnSaturation(); | 2780 .RetiresOnSaturation(); |
| 2882 SetupExpectationsForFramebufferAttachment( | |
| 2883 GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, // clear bits | |
| 2884 0, 0, 0, 0, // color | |
| 2885 123, // stencil | |
| 2886 0.5f, // depth | |
| 2887 false); // scissor test | |
| 2888 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_cmd)); | 2781 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_cmd)); |
| 2889 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_cmd)); | 2782 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_cmd)); |
| 2890 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 2783 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 2891 } | 2784 } |
| 2892 #endif | 2785 #endif |
| 2893 | 2786 |
| 2894 TEST_F(GLES2DecoderWithShaderTest, VertexAttribPointer) { | 2787 TEST_F(GLES2DecoderWithShaderTest, VertexAttribPointer) { |
| 2895 SetupVertexBuffer(); | 2788 SetupVertexBuffer(); |
| 2896 static const GLenum types[] = { | 2789 static const GLenum types[] = { |
| 2897 GL_BYTE, | 2790 GL_BYTE, |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3217 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 3110 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 3218 | 3111 |
| 3219 // Check that no extra calls are made on the next draw. | 3112 // Check that no extra calls are made on the next draw. |
| 3220 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | 3113 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
| 3221 .Times(1) | 3114 .Times(1) |
| 3222 .RetiresOnSaturation(); | 3115 .RetiresOnSaturation(); |
| 3223 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); | 3116 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); |
| 3224 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 3117 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 3225 | 3118 |
| 3226 // Setup Frame buffer. | 3119 // Setup Frame buffer. |
| 3227 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | 3120 // needs to be 1x1 or else it's not renderable. |
| 3228 kServiceFramebufferId); | 3121 const GLsizei kWidth = 1; |
| 3229 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT(_, _, _, _)) | 3122 const GLsizei kHeight = 1; |
| 3230 .Times(0); | 3123 const GLenum kFormat = GL_RGB; |
| 3231 FramebufferRenderbuffer fbrb_cmd; | 3124 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 3232 fbrb_cmd.Init( | 3125 // Pass some data so the texture will be marked as cleared. |
| 3233 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, | 3126 DoTexImage2D( |
| 3234 client_renderbuffer_id_); | 3127 GL_TEXTURE_2D, 0, kFormat, kWidth, kHeight, 0, |
| 3235 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 3128 kFormat, GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset); |
| 3129 DoBindFramebuffer( |
| 3130 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 3131 DoFramebufferTexture2D( |
| 3132 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 3133 client_texture_id_, kServiceTextureId, 0, GL_NO_ERROR); |
| 3236 | 3134 |
| 3237 // This time state needs to be set. | 3135 // This time state needs to be set. |
| 3238 SetupExpectationsForApplyingDirtyState( | 3136 SetupExpectationsForApplyingDirtyState( |
| 3239 false, // Framebuffer is RGB | 3137 false, // Framebuffer is RGB |
| 3240 false, // Framebuffer has depth | 3138 false, // Framebuffer has depth |
| 3241 false, // Framebuffer has stencil | 3139 false, // Framebuffer has stencil |
| 3242 0x1110, // color bits | 3140 0x1110, // color bits |
| 3243 false, // depth mask | 3141 false, // depth mask |
| 3244 false, // depth enabled | 3142 false, // depth enabled |
| 3245 0, // front stencil mask | 3143 0, // front stencil mask |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3812 .Times(1) | 3710 .Times(1) |
| 3813 .RetiresOnSaturation(); | 3711 .RetiresOnSaturation(); |
| 3814 RenderbufferStorage cmd; | 3712 RenderbufferStorage cmd; |
| 3815 cmd.Init(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 100, 50); | 3713 cmd.Init(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 100, 50); |
| 3816 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 3714 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 3817 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( | 3715 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( |
| 3818 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, | 3716 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, |
| 3819 kServiceRenderbufferId)) | 3717 kServiceRenderbufferId)) |
| 3820 .Times(1) | 3718 .Times(1) |
| 3821 .RetiresOnSaturation(); | 3719 .RetiresOnSaturation(); |
| 3822 SetupExpectationsForFramebufferAttachment( | |
| 3823 GL_DEPTH_BUFFER_BIT, // clear bits | |
| 3824 0, 0, 0, 0, // color | |
| 3825 0, // stencil | |
| 3826 1.0f, // depth | |
| 3827 false); // scissor test | |
| 3828 FramebufferRenderbuffer fbrb_cmd; | 3720 FramebufferRenderbuffer fbrb_cmd; |
| 3829 fbrb_cmd.Init( | 3721 fbrb_cmd.Init( |
| 3830 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, | 3722 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, |
| 3831 client_renderbuffer_id_); | 3723 client_renderbuffer_id_); |
| 3832 EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd)); | 3724 EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd)); |
| 3833 | 3725 |
| 3834 typedef GetIntegerv::Result Result; | 3726 typedef GetIntegerv::Result Result; |
| 3835 Result* result = static_cast<Result*>(shared_memory_address_); | 3727 Result* result = static_cast<Result*>(shared_memory_address_); |
| 3836 result->size = 0; | 3728 result->size = 0; |
| 3837 GetIntegerv cmd2; | 3729 GetIntegerv cmd2; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3889 .Times(1) | 3781 .Times(1) |
| 3890 .RetiresOnSaturation(); | 3782 .RetiresOnSaturation(); |
| 3891 RenderbufferStorage cmd; | 3783 RenderbufferStorage cmd; |
| 3892 cmd.Init(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 100, 50); | 3784 cmd.Init(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 100, 50); |
| 3893 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 3785 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 3894 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( | 3786 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( |
| 3895 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, | 3787 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, |
| 3896 kServiceRenderbufferId)) | 3788 kServiceRenderbufferId)) |
| 3897 .Times(1) | 3789 .Times(1) |
| 3898 .RetiresOnSaturation(); | 3790 .RetiresOnSaturation(); |
| 3899 SetupExpectationsForFramebufferAttachment( | |
| 3900 GL_STENCIL_BUFFER_BIT, // clear bits | |
| 3901 0, 0, 0, 0, // color | |
| 3902 0, // stencil | |
| 3903 1.0f, // depth | |
| 3904 false); // scissor test | |
| 3905 FramebufferRenderbuffer fbrb_cmd; | 3791 FramebufferRenderbuffer fbrb_cmd; |
| 3906 fbrb_cmd.Init( | 3792 fbrb_cmd.Init( |
| 3907 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, | 3793 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, |
| 3908 client_renderbuffer_id_); | 3794 client_renderbuffer_id_); |
| 3909 EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd)); | 3795 EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd)); |
| 3910 | 3796 |
| 3911 typedef GetIntegerv::Result Result; | 3797 typedef GetIntegerv::Result Result; |
| 3912 Result* result = static_cast<Result*>(shared_memory_address_); | 3798 Result* result = static_cast<Result*>(shared_memory_address_); |
| 3913 result->size = 0; | 3799 result->size = 0; |
| 3914 GetIntegerv cmd2; | 3800 GetIntegerv cmd2; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4065 EXPECT_EQ(kSentinel, results[num_results]); // End of results | 3951 EXPECT_EQ(kSentinel, results[num_results]); // End of results |
| 4066 } | 3952 } |
| 4067 | 3953 |
| 4068 TEST_F(GLES2DecoderTest, TexImage2DRedefinitionSucceeds) { | 3954 TEST_F(GLES2DecoderTest, TexImage2DRedefinitionSucceeds) { |
| 4069 const int kWidth = 16; | 3955 const int kWidth = 16; |
| 4070 const int kHeight = 8; | 3956 const int kHeight = 8; |
| 4071 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 3957 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 4072 EXPECT_CALL(*gl_, GetError()) | 3958 EXPECT_CALL(*gl_, GetError()) |
| 4073 .WillRepeatedly(Return(GL_NO_ERROR)); | 3959 .WillRepeatedly(Return(GL_NO_ERROR)); |
| 4074 for (int ii = 0; ii < 2; ++ii) { | 3960 for (int ii = 0; ii < 2; ++ii) { |
| 3961 TexImage2D cmd; |
| 4075 if (ii == 0) { | 3962 if (ii == 0) { |
| 4076 EXPECT_CALL(*gl_, TexImage2D( | 3963 EXPECT_CALL(*gl_, TexImage2D( |
| 4077 GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, | 3964 GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, |
| 4078 GL_UNSIGNED_BYTE, _)) | 3965 GL_UNSIGNED_BYTE, _)) |
| 4079 .Times(1) | 3966 .Times(1) |
| 4080 .RetiresOnSaturation(); | 3967 .RetiresOnSaturation(); |
| 3968 cmd.Init( |
| 3969 GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, |
| 3970 GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset); |
| 3971 } else { |
| 3972 cmd.Init( |
| 3973 GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, |
| 3974 GL_UNSIGNED_BYTE, 0, 0); |
| 4081 } | 3975 } |
| 4082 TexImage2D cmd; | |
| 4083 cmd.Init( | |
| 4084 GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, | |
| 4085 GL_UNSIGNED_BYTE, 0, 0); | |
| 4086 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 3976 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4087 EXPECT_CALL(*gl_, TexSubImage2D( | 3977 EXPECT_CALL(*gl_, TexSubImage2D( |
| 4088 GL_TEXTURE_2D, 0, 0, 0, kWidth, kHeight - 1, GL_RGBA, GL_UNSIGNED_BYTE, | 3978 GL_TEXTURE_2D, 0, 0, 0, kWidth, kHeight - 1, GL_RGBA, GL_UNSIGNED_BYTE, |
| 4089 shared_memory_address_)) | 3979 shared_memory_address_)) |
| 4090 .Times(1) | 3980 .Times(1) |
| 4091 .RetiresOnSaturation(); | 3981 .RetiresOnSaturation(); |
| 4092 // Consider this TexSubImage2D command part of the previous TexImage2D | 3982 // Consider this TexSubImage2D command part of the previous TexImage2D |
| 4093 // (last GL_TRUE argument). It will be skipped if there are bugs in the | 3983 // (last GL_TRUE argument). It will be skipped if there are bugs in the |
| 4094 // redefinition case. | 3984 // redefinition case. |
| 4095 TexSubImage2D cmd2; | 3985 TexSubImage2D cmd2; |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4992 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 4882 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 4993 } | 4883 } |
| 4994 | 4884 |
| 4995 TEST_F(GLES2DecoderTest, RequestExtensionCHROMIUMBadBucket) { | 4885 TEST_F(GLES2DecoderTest, RequestExtensionCHROMIUMBadBucket) { |
| 4996 const uint32 kBadBucketId = 123; | 4886 const uint32 kBadBucketId = 123; |
| 4997 RequestExtensionCHROMIUM cmd; | 4887 RequestExtensionCHROMIUM cmd; |
| 4998 cmd.Init(kBadBucketId); | 4888 cmd.Init(kBadBucketId); |
| 4999 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 4889 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 5000 } | 4890 } |
| 5001 | 4891 |
| 4892 TEST_F(GLES2DecoderTest, TexSubImage2DClearsAfterTexImage2DNULL) { |
| 4893 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 4894 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 4895 0, 0); |
| 4896 SetupClearTextureExpections( |
| 4897 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, |
| 4898 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); |
| 4899 EXPECT_CALL(*gl_, TexSubImage2D( |
| 4900 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, |
| 4901 shared_memory_address_)) |
| 4902 .Times(1) |
| 4903 .RetiresOnSaturation(); |
| 4904 TexSubImage2D cmd; |
| 4905 cmd.Init( |
| 4906 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, |
| 4907 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); |
| 4908 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4909 // Test if we call it again it does not clear. |
| 4910 EXPECT_CALL(*gl_, TexSubImage2D( |
| 4911 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, |
| 4912 shared_memory_address_)) |
| 4913 .Times(1) |
| 4914 .RetiresOnSaturation(); |
| 4915 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4916 } |
| 4917 |
| 4918 TEST_F(GLES2DecoderTest, |
| 4919 TexSubImage2DDoesNotClearAfterTexImage2DWithDataThenNULL) { |
| 4920 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 4921 // Put in data (so it should be marked as cleared) |
| 4922 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 4923 kSharedMemoryId, kSharedMemoryOffset); |
| 4924 // Put in no data. |
| 4925 TexImage2D tex_cmd; |
| 4926 tex_cmd.Init( |
| 4927 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 4928 // There is no expectation. Same size, no data = no-op. |
| 4929 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_cmd)); |
| 4930 EXPECT_CALL(*gl_, TexSubImage2D( |
| 4931 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, |
| 4932 shared_memory_address_)) |
| 4933 .Times(1) |
| 4934 .RetiresOnSaturation(); |
| 4935 TexSubImage2D cmd; |
| 4936 cmd.Init( |
| 4937 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, |
| 4938 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); |
| 4939 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4940 } |
| 4941 |
| 4942 TEST_F(GLES2DecoderWithShaderTest, DrawArraysClearsAfterTexImage2DNULL) { |
| 4943 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 4944 // Create an uncleared texture with 2 levels. |
| 4945 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 4946 0, 0); |
| 4947 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 4948 0, 0); |
| 4949 // Expect 2 levels will be cleared. |
| 4950 SetupClearTextureExpections( |
| 4951 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, |
| 4952 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); |
| 4953 SetupClearTextureExpections( |
| 4954 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, |
| 4955 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1); |
| 4956 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
| 4957 SetupExpectationsForApplyingDefaultDirtyState(); |
| 4958 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
| 4959 .Times(1) |
| 4960 .RetiresOnSaturation(); |
| 4961 DrawArrays cmd; |
| 4962 cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
| 4963 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4964 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4965 } |
| 4966 |
| 4967 TEST_F(GLES2DecoderWithShaderTest, DrawElementsClearsAfterTexImage2DNULL) { |
| 4968 SetupIndexBuffer(); |
| 4969 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 4970 // Create an uncleared texture with 2 levels. |
| 4971 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 4972 0, 0); |
| 4973 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 4974 0, 0); |
| 4975 // Expect 2 levels will be cleared. |
| 4976 SetupClearTextureExpections( |
| 4977 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, |
| 4978 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); |
| 4979 SetupClearTextureExpections( |
| 4980 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, |
| 4981 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1); |
| 4982 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0); |
| 4983 SetupExpectationsForApplyingDefaultDirtyState(); |
| 4984 EXPECT_CALL(*gl_, DrawElements(GL_TRIANGLES, kValidIndexRangeCount, |
| 4985 GL_UNSIGNED_SHORT, |
| 4986 BufferOffset(kValidIndexRangeStart * 2))) |
| 4987 .Times(1) |
| 4988 .RetiresOnSaturation(); |
| 4989 DrawElements cmd; |
| 4990 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, |
| 4991 kValidIndexRangeStart * 2); |
| 4992 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4993 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4994 } |
| 4995 |
| 4996 TEST_F(GLES2DecoderWithShaderTest, DrawClearsAfterTexImage2DNULLInFBO) { |
| 4997 const GLuint kFBOClientTextureId = 4100; |
| 4998 const GLuint kFBOServiceTextureId = 4101; |
| 4999 |
| 5000 // Register a texture id. |
| 5001 EXPECT_CALL(*gl_, GenTextures(_, _)) |
| 5002 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) |
| 5003 .RetiresOnSaturation(); |
| 5004 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); |
| 5005 |
| 5006 // Setup "render to" texture. |
| 5007 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); |
| 5008 DoTexImage2D( |
| 5009 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 5010 DoBindFramebuffer( |
| 5011 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 5012 DoFramebufferTexture2D( |
| 5013 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 5014 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); |
| 5015 |
| 5016 // Setup "render from" texture. |
| 5017 SetupTexture(); |
| 5018 |
| 5019 SetupExpectationsForFramebufferClearing( |
| 5020 GL_FRAMEBUFFER, // target |
| 5021 GL_COLOR_BUFFER_BIT, // clear bits |
| 5022 0, 0, 0, 0, // color |
| 5023 0, // stencil |
| 5024 1.0f, // depth |
| 5025 false); // scissor test |
| 5026 |
| 5027 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
| 5028 SetupExpectationsForApplyingDirtyState( |
| 5029 false, // Framebuffer is RGB |
| 5030 false, // Framebuffer has depth |
| 5031 false, // Framebuffer has stencil |
| 5032 0x1111, // color bits |
| 5033 false, // depth mask |
| 5034 false, // depth enabled |
| 5035 0, // front stencil mask |
| 5036 0, // back stencil mask |
| 5037 false); // stencil enabled |
| 5038 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
| 5039 .Times(1) |
| 5040 .RetiresOnSaturation(); |
| 5041 DrawArrays cmd; |
| 5042 cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
| 5043 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5044 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5045 } |
| 5046 |
| 5047 TEST_F(GLES2DecoderWithShaderTest, DrawWitFBOThatCantClearDoesNotDraw) { |
| 5048 const GLuint kFBOClientTextureId = 4100; |
| 5049 const GLuint kFBOServiceTextureId = 4101; |
| 5050 |
| 5051 // Register a texture id. |
| 5052 EXPECT_CALL(*gl_, GenTextures(_, _)) |
| 5053 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) |
| 5054 .RetiresOnSaturation(); |
| 5055 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); |
| 5056 |
| 5057 // Setup "render to" texture. |
| 5058 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); |
| 5059 DoTexImage2D( |
| 5060 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 5061 DoBindFramebuffer( |
| 5062 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 5063 DoFramebufferTexture2D( |
| 5064 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 5065 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); |
| 5066 |
| 5067 // Setup "render from" texture. |
| 5068 SetupTexture(); |
| 5069 |
| 5070 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
| 5071 .WillOnce(Return(GL_FRAMEBUFFER_UNSUPPORTED)) |
| 5072 .RetiresOnSaturation(); |
| 5073 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) |
| 5074 .Times(0) |
| 5075 .RetiresOnSaturation(); |
| 5076 DrawArrays cmd; |
| 5077 cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
| 5078 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5079 EXPECT_EQ(GL_INVALID_FRAMEBUFFER_OPERATION, GetGLError()); |
| 5080 } |
| 5081 |
| 5082 TEST_F(GLES2DecoderTest, CopyTexImage2DMarksTextureAsCleared) { |
| 5083 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 5084 |
| 5085 TextureManager* manager = group().texture_manager(); |
| 5086 TextureManager::TextureInfo* info = |
| 5087 manager->GetTextureInfo(client_texture_id_); |
| 5088 |
| 5089 EXPECT_CALL(*gl_, GetError()) |
| 5090 .WillOnce(Return(GL_NO_ERROR)) |
| 5091 .RetiresOnSaturation(); |
| 5092 EXPECT_CALL(*gl_, CopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1, 0)) |
| 5093 .Times(1) |
| 5094 .RetiresOnSaturation(); |
| 5095 EXPECT_CALL(*gl_, GetError()) |
| 5096 .WillOnce(Return(GL_NO_ERROR)) |
| 5097 .RetiresOnSaturation(); |
| 5098 CopyTexImage2D cmd; |
| 5099 cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1, 0); |
| 5100 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5101 |
| 5102 EXPECT_TRUE(info->SafeToRenderFrom()); |
| 5103 } |
| 5104 |
| 5105 TEST_F(GLES2DecoderTest, CopyTexSubImage2DClearsUnclearedTexture) { |
| 5106 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 5107 DoTexImage2D( |
| 5108 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 5109 |
| 5110 SetupClearTextureExpections( |
| 5111 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, |
| 5112 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); |
| 5113 EXPECT_CALL(*gl_, CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1)) |
| 5114 .Times(1) |
| 5115 .RetiresOnSaturation(); |
| 5116 CopyTexSubImage2D cmd; |
| 5117 cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1); |
| 5118 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5119 } |
| 5120 |
| 5121 TEST_F(GLES2DecoderManualInitTest, CompressedImage2DMarksTextureAsCleared) { |
| 5122 InitDecoder( |
| 5123 "GL_EXT_texture_compression_s3tc", // extensions |
| 5124 false, // has alpha |
| 5125 false, // has depth |
| 5126 false, // has stencil |
| 5127 false, // request alpha |
| 5128 false, // request depth |
| 5129 false, // request stencil |
| 5130 true); // bind generates resource |
| 5131 |
| 5132 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 5133 EXPECT_CALL(*gl_, GetError()) |
| 5134 .WillOnce(Return(GL_NO_ERROR)) |
| 5135 .RetiresOnSaturation(); |
| 5136 EXPECT_CALL(*gl_, CompressedTexImage2D( |
| 5137 GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0, 16, _)) |
| 5138 .Times(1) |
| 5139 .RetiresOnSaturation(); |
| 5140 EXPECT_CALL(*gl_, GetError()) |
| 5141 .WillOnce(Return(GL_NO_ERROR)) |
| 5142 .RetiresOnSaturation(); |
| 5143 CompressedTexImage2D cmd; |
| 5144 cmd.Init(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0, |
| 5145 16, kSharedMemoryId, kSharedMemoryOffset); |
| 5146 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5147 TextureManager* manager = group().texture_manager(); |
| 5148 TextureManager::TextureInfo* info = |
| 5149 manager->GetTextureInfo(client_texture_id_); |
| 5150 EXPECT_TRUE(info->SafeToRenderFrom()); |
| 5151 } |
| 5152 |
| 5153 TEST_F(GLES2DecoderWithShaderTest, UnClearedAttachmentsGetClearedOnClear) { |
| 5154 const GLuint kFBOClientTextureId = 4100; |
| 5155 const GLuint kFBOServiceTextureId = 4101; |
| 5156 |
| 5157 // Register a texture id. |
| 5158 EXPECT_CALL(*gl_, GenTextures(_, _)) |
| 5159 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) |
| 5160 .RetiresOnSaturation(); |
| 5161 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); |
| 5162 |
| 5163 // Setup "render to" texture. |
| 5164 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); |
| 5165 DoTexImage2D( |
| 5166 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 5167 DoBindFramebuffer( |
| 5168 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 5169 DoFramebufferTexture2D( |
| 5170 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 5171 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); |
| 5172 |
| 5173 // Setup "render from" texture. |
| 5174 SetupTexture(); |
| 5175 |
| 5176 SetupExpectationsForFramebufferClearing( |
| 5177 GL_FRAMEBUFFER, // target |
| 5178 GL_COLOR_BUFFER_BIT, // clear bits |
| 5179 0, 0, 0, 0, // color |
| 5180 0, // stencil |
| 5181 1.0f, // depth |
| 5182 false); // scissor test |
| 5183 SetupExpectationsForApplyingDirtyState( |
| 5184 false, // Framebuffer is RGB |
| 5185 false, // Framebuffer has depth |
| 5186 false, // Framebuffer has stencil |
| 5187 0x1111, // color bits |
| 5188 false, // depth mask |
| 5189 false, // depth enabled |
| 5190 0, // front stencil mask |
| 5191 0, // back stencil mask |
| 5192 false); // stencil enabled |
| 5193 EXPECT_CALL(*gl_, Clear(GL_COLOR_BUFFER_BIT)) |
| 5194 .Times(1) |
| 5195 .RetiresOnSaturation(); |
| 5196 |
| 5197 Clear cmd; |
| 5198 cmd.Init(GL_COLOR_BUFFER_BIT); |
| 5199 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5200 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5201 } |
| 5202 |
| 5203 TEST_F(GLES2DecoderWithShaderTest, UnClearedAttachmentsGetClearedOnReadPixels) { |
| 5204 const GLuint kFBOClientTextureId = 4100; |
| 5205 const GLuint kFBOServiceTextureId = 4101; |
| 5206 |
| 5207 // Register a texture id. |
| 5208 EXPECT_CALL(*gl_, GenTextures(_, _)) |
| 5209 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) |
| 5210 .RetiresOnSaturation(); |
| 5211 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); |
| 5212 |
| 5213 // Setup "render to" texture. |
| 5214 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); |
| 5215 DoTexImage2D( |
| 5216 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 5217 DoBindFramebuffer( |
| 5218 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 5219 DoFramebufferTexture2D( |
| 5220 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 5221 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); |
| 5222 |
| 5223 // Setup "render from" texture. |
| 5224 SetupTexture(); |
| 5225 |
| 5226 SetupExpectationsForFramebufferClearing( |
| 5227 GL_FRAMEBUFFER, // target |
| 5228 GL_COLOR_BUFFER_BIT, // clear bits |
| 5229 0, 0, 0, 0, // color |
| 5230 0, // stencil |
| 5231 1.0f, // depth |
| 5232 false); // scissor test |
| 5233 |
| 5234 EXPECT_CALL(*gl_, GetError()) |
| 5235 .WillOnce(Return(GL_NO_ERROR)) |
| 5236 .WillOnce(Return(GL_NO_ERROR)) |
| 5237 .RetiresOnSaturation(); |
| 5238 EXPECT_CALL(*gl_, ReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, _)) |
| 5239 .Times(1) |
| 5240 .RetiresOnSaturation(); |
| 5241 typedef ReadPixels::Result Result; |
| 5242 Result* result = GetSharedMemoryAs<Result*>(); |
| 5243 uint32 result_shm_id = kSharedMemoryId; |
| 5244 uint32 result_shm_offset = kSharedMemoryOffset; |
| 5245 uint32 pixels_shm_id = kSharedMemoryId; |
| 5246 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); |
| 5247 ReadPixels cmd; |
| 5248 cmd.Init(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, |
| 5249 pixels_shm_id, pixels_shm_offset, |
| 5250 result_shm_id, result_shm_offset); |
| 5251 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5252 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5253 } |
| 5254 |
| 5255 TEST_F(GLES2DecoderWithShaderTest, DrawClearsAfterRenderbufferStorageInFBO) { |
| 5256 SetupTexture(); |
| 5257 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, |
| 5258 kServiceRenderbufferId); |
| 5259 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, |
| 5260 kServiceFramebufferId); |
| 5261 DoRenderbufferStorage( |
| 5262 GL_RENDERBUFFER, GL_RGBA4, GL_RGBA, 100, 50, GL_NO_ERROR); |
| 5263 DoFramebufferRenderbuffer( |
| 5264 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, |
| 5265 client_renderbuffer_id_, kServiceRenderbufferId, GL_NO_ERROR); |
| 5266 |
| 5267 SetupExpectationsForFramebufferClearing( |
| 5268 GL_FRAMEBUFFER, // target |
| 5269 GL_COLOR_BUFFER_BIT, // clear bits |
| 5270 0, 0, 0, 0, // color |
| 5271 0, // stencil |
| 5272 1.0f, // depth |
| 5273 false); // scissor test |
| 5274 |
| 5275 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
| 5276 SetupExpectationsForApplyingDirtyState( |
| 5277 false, // Framebuffer is RGB |
| 5278 false, // Framebuffer has depth |
| 5279 false, // Framebuffer has stencil |
| 5280 0x1111, // color bits |
| 5281 false, // depth mask |
| 5282 false, // depth enabled |
| 5283 0, // front stencil mask |
| 5284 0, // back stencil mask |
| 5285 false); // stencil enabled |
| 5286 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
| 5287 .Times(1) |
| 5288 .RetiresOnSaturation(); |
| 5289 DrawArrays cmd; |
| 5290 cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
| 5291 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5292 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5293 } |
| 5294 |
| 5295 TEST_F(GLES2DecoderTest, DrawArraysClearsAfterTexImage2DNULLCubemap) { |
| 5296 static const GLenum faces[] = { |
| 5297 GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
| 5298 GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
| 5299 GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
| 5300 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, |
| 5301 GL_TEXTURE_CUBE_MAP_POSITIVE_Z, |
| 5302 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, |
| 5303 }; |
| 5304 SetupCubemapProgram(); |
| 5305 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId); |
| 5306 // Fill out all the faces for 2 levels, leave 2 uncleared. |
| 5307 for (int ii = 0; ii < 6; ++ii) { |
| 5308 GLenum face = faces[ii]; |
| 5309 int32 shm_id = |
| 5310 (face == GL_TEXTURE_CUBE_MAP_NEGATIVE_Y) ? 0 : kSharedMemoryId; |
| 5311 uint32 shm_offset = |
| 5312 (face == GL_TEXTURE_CUBE_MAP_NEGATIVE_Y) ? 0 : kSharedMemoryOffset; |
| 5313 DoTexImage2D(face, 0, GL_RGBA, 2, 2, 0, GL_RGBA, |
| 5314 GL_UNSIGNED_BYTE, shm_id, shm_offset); |
| 5315 DoTexImage2D(face, 1, GL_RGBA, 1, 1, 0, GL_RGBA, |
| 5316 GL_UNSIGNED_BYTE, shm_id, shm_offset); |
| 5317 } |
| 5318 // Expect 2 levels will be cleared. |
| 5319 SetupClearTextureExpections( |
| 5320 kServiceTextureId, kServiceTextureId, GL_TEXTURE_CUBE_MAP, |
| 5321 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); |
| 5322 SetupClearTextureExpections( |
| 5323 kServiceTextureId, kServiceTextureId, GL_TEXTURE_CUBE_MAP, |
| 5324 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1); |
| 5325 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
| 5326 SetupExpectationsForApplyingDefaultDirtyState(); |
| 5327 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
| 5328 .Times(1) |
| 5329 .RetiresOnSaturation(); |
| 5330 DrawArrays cmd; |
| 5331 cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
| 5332 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5333 } |
| 5334 |
| 5335 TEST_F(GLES2DecoderWithShaderTest, |
| 5336 DrawClearsAfterRenderbuffersWithMultipleAttachments) { |
| 5337 const GLuint kFBOClientTextureId = 4100; |
| 5338 const GLuint kFBOServiceTextureId = 4101; |
| 5339 |
| 5340 // Register a texture id. |
| 5341 EXPECT_CALL(*gl_, GenTextures(_, _)) |
| 5342 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) |
| 5343 .RetiresOnSaturation(); |
| 5344 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); |
| 5345 |
| 5346 // Setup "render to" texture. |
| 5347 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); |
| 5348 DoTexImage2D( |
| 5349 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| 5350 DoBindFramebuffer( |
| 5351 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 5352 DoFramebufferTexture2D( |
| 5353 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 5354 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); |
| 5355 |
| 5356 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, |
| 5357 kServiceRenderbufferId); |
| 5358 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, |
| 5359 kServiceFramebufferId); |
| 5360 DoRenderbufferStorage( |
| 5361 GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, |
| 5362 1, 1, GL_NO_ERROR); |
| 5363 DoFramebufferRenderbuffer( |
| 5364 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, |
| 5365 client_renderbuffer_id_, kServiceRenderbufferId, GL_NO_ERROR); |
| 5366 |
| 5367 SetupTexture(); |
| 5368 SetupExpectationsForFramebufferClearing( |
| 5369 GL_FRAMEBUFFER, // target |
| 5370 GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, // clear bits |
| 5371 0, 0, 0, 0, // color |
| 5372 0, // stencil |
| 5373 1.0f, // depth |
| 5374 false); // scissor test |
| 5375 |
| 5376 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
| 5377 SetupExpectationsForApplyingDirtyState( |
| 5378 false, // Framebuffer is RGB |
| 5379 true, // Framebuffer has depth |
| 5380 false, // Framebuffer has stencil |
| 5381 0x1111, // color bits |
| 5382 true, // depth mask |
| 5383 false, // depth enabled |
| 5384 0, // front stencil mask |
| 5385 0, // back stencil mask |
| 5386 false); // stencil enabled |
| 5387 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
| 5388 .Times(1) |
| 5389 .RetiresOnSaturation(); |
| 5390 DrawArrays cmd; |
| 5391 cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
| 5392 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5393 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5394 } |
| 5395 |
| 5396 |
| 5397 |
| 5002 // TODO(gman): Complete this test. | 5398 // TODO(gman): Complete this test. |
| 5003 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { | 5399 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { |
| 5004 // } | 5400 // } |
| 5005 | 5401 |
| 5006 // TODO(gman): BufferData | 5402 // TODO(gman): BufferData |
| 5007 | 5403 |
| 5008 // TODO(gman): BufferDataImmediate | 5404 // TODO(gman): BufferDataImmediate |
| 5009 | 5405 |
| 5010 // TODO(gman): BufferSubData | 5406 // TODO(gman): BufferSubData |
| 5011 | 5407 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 5028 // TODO(gman): TexImage2DImmediate | 5424 // TODO(gman): TexImage2DImmediate |
| 5029 | 5425 |
| 5030 // TODO(gman): TexSubImage2DImmediate | 5426 // TODO(gman): TexSubImage2DImmediate |
| 5031 | 5427 |
| 5032 // TODO(gman): UseProgram | 5428 // TODO(gman): UseProgram |
| 5033 | 5429 |
| 5034 // TODO(gman): SwapBuffers | 5430 // TODO(gman): SwapBuffers |
| 5035 | 5431 |
| 5036 } // namespace gles2 | 5432 } // namespace gles2 |
| 5037 } // namespace gpu | 5433 } // namespace gpu |
| OLD | NEW |