Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
| 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| (...skipping 2497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2508 .RetiresOnSaturation(); | 2508 .RetiresOnSaturation(); |
| 2509 DiscardFramebufferEXTImmediate& cmd = | 2509 DiscardFramebufferEXTImmediate& cmd = |
| 2510 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); | 2510 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); |
| 2511 cmd.Init(target, count, attachments); | 2511 cmd.Init(target, count, attachments); |
| 2512 | 2512 |
| 2513 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(attachments))); | 2513 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(attachments))); |
| 2514 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2514 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2515 EXPECT_FALSE(framebuffer->IsCleared()); | 2515 EXPECT_FALSE(framebuffer->IsCleared()); |
| 2516 } | 2516 } |
| 2517 | 2517 |
| 2518 TEST_P(GLES2DecoderManualInitTest, ClearBackbufferBitsOnDiscardFramebufferEXT) { | |
| 2519 InitState init; | |
| 2520 init.extensions = "GL_EXT_discard_framebuffer"; | |
| 2521 init.gl_version = "opengl es 2.0"; | |
| 2522 InitDecoder(init); | |
| 2523 | |
| 2524 // EXPECT_EQ can't be used to compare function pointers | |
|
Sami
2015/11/04 11:55:52
nit: append a full stop.
RaviKasibhatla
2015/11/04 14:59:40
Done.
| |
| 2525 EXPECT_TRUE( | |
| 2526 gfx::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT") == | |
| 2527 gfx::g_driver_gl.fn.glDiscardFramebufferEXTFn); | |
| 2528 | |
| 2529 const GLenum target = GL_FRAMEBUFFER; | |
| 2530 const GLsizei count = 1; | |
| 2531 GLenum attachments[] = {GL_COLOR_EXT}; | |
| 2532 | |
| 2533 EXPECT_CALL(*gl_, DiscardFramebufferEXT(target, count, _)) | |
| 2534 .Times(1) | |
| 2535 .RetiresOnSaturation(); | |
| 2536 DiscardFramebufferEXTImmediate& cmd = | |
| 2537 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); | |
| 2538 cmd.Init(target, count, attachments); | |
| 2539 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(attachments))); | |
| 2540 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 2541 | |
| 2542 uint32 clear_bits = GetBackbufferClearBits(); | |
| 2543 EXPECT_EQ(GL_COLOR_BUFFER_BIT, clear_bits); | |
| 2544 ClearBackbufferClearBits(); | |
| 2545 | |
| 2546 attachments[0] = GL_DEPTH_EXT; | |
| 2547 EXPECT_CALL(*gl_, DiscardFramebufferEXT(target, count, _)) | |
| 2548 .Times(1) | |
| 2549 .RetiresOnSaturation(); | |
| 2550 cmd.Init(target, count, attachments); | |
| 2551 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(attachments))); | |
| 2552 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 2553 | |
| 2554 clear_bits = GetBackbufferClearBits(); | |
| 2555 EXPECT_EQ(GL_DEPTH_BUFFER_BIT, clear_bits); | |
| 2556 ClearBackbufferClearBits(); | |
| 2557 | |
| 2558 attachments[0] = GL_STENCIL_EXT; | |
| 2559 EXPECT_CALL(*gl_, DiscardFramebufferEXT(target, count, _)) | |
| 2560 .Times(1) | |
| 2561 .RetiresOnSaturation(); | |
| 2562 cmd.Init(target, count, attachments); | |
| 2563 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(attachments))); | |
| 2564 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 2565 | |
| 2566 clear_bits = GetBackbufferClearBits(); | |
| 2567 EXPECT_EQ(GL_STENCIL_BUFFER_BIT, clear_bits); | |
| 2568 ClearBackbufferClearBits(); | |
| 2569 | |
| 2570 const GLsizei count0 = 3; | |
| 2571 const GLenum attachments0[] = {GL_COLOR_EXT, GL_DEPTH_EXT, GL_STENCIL_EXT}; | |
| 2572 EXPECT_CALL(*gl_, DiscardFramebufferEXT(target, count0, _)) | |
| 2573 .Times(1) | |
| 2574 .RetiresOnSaturation(); | |
| 2575 cmd.Init(target, count0, attachments0); | |
| 2576 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(attachments0))); | |
| 2577 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 2578 | |
| 2579 clear_bits = GetBackbufferClearBits(); | |
| 2580 EXPECT_EQ(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, | |
| 2581 clear_bits); | |
| 2582 ClearBackbufferClearBits(); | |
| 2583 } | |
| 2584 | |
| 2518 TEST_P(GLES2DecoderTest, DiscardFramebufferEXTUnsupported) { | 2585 TEST_P(GLES2DecoderTest, DiscardFramebufferEXTUnsupported) { |
| 2519 const GLenum target = GL_FRAMEBUFFER; | 2586 const GLenum target = GL_FRAMEBUFFER; |
| 2520 const GLsizei count = 1; | 2587 const GLsizei count = 1; |
| 2521 const GLenum attachments[] = {GL_COLOR_EXT}; | 2588 const GLenum attachments[] = {GL_COLOR_EXT}; |
| 2522 DiscardFramebufferEXTImmediate& cmd = | 2589 DiscardFramebufferEXTImmediate& cmd = |
| 2523 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); | 2590 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); |
| 2524 cmd.Init(target, count, attachments); | 2591 cmd.Init(target, count, attachments); |
| 2525 | 2592 |
| 2526 // Should not result into a call into GL. | 2593 // Should not result into a call into GL. |
| 2527 EXPECT_EQ(error::kUnknownCommand, | 2594 EXPECT_EQ(error::kUnknownCommand, |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2736 EXPECT_EQ(1, result->GetNumResults()); | 2803 EXPECT_EQ(1, result->GetNumResults()); |
| 2737 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2804 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2738 } | 2805 } |
| 2739 | 2806 |
| 2740 // TODO(gman): PixelStorei | 2807 // TODO(gman): PixelStorei |
| 2741 | 2808 |
| 2742 // TODO(gman): SwapBuffers | 2809 // TODO(gman): SwapBuffers |
| 2743 | 2810 |
| 2744 } // namespace gles2 | 2811 } // namespace gles2 |
| 2745 } // namespace gpu | 2812 } // namespace gpu |
| OLD | NEW |