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 <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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 356 |
357 transfer_buffer_.reset(new MockTransferBuffer( | 357 transfer_buffer_.reset(new MockTransferBuffer( |
358 command_buffer(), | 358 command_buffer(), |
359 kTransferBufferSize, | 359 kTransferBufferSize, |
360 GLES2Implementation::kStartingOffset, | 360 GLES2Implementation::kStartingOffset, |
361 GLES2Implementation::kAlignment)); | 361 GLES2Implementation::kAlignment)); |
362 | 362 |
363 helper_.reset(new GLES2CmdHelper(command_buffer())); | 363 helper_.reset(new GLES2CmdHelper(command_buffer())); |
364 helper_->Initialize(kCommandBufferSizeBytes); | 364 helper_->Initialize(kCommandBufferSizeBytes); |
365 | 365 |
366 GLES2Implementation::GLCachedState state; | 366 GLES2Implementation::GLStaticState state; |
367 GLES2Implementation::GLCachedState::IntState& int_state = state.int_state; | 367 GLES2Implementation::GLStaticState::IntState& int_state = state.int_state; |
368 int_state.max_combined_texture_image_units = kMaxCombinedTextureImageUnits; | 368 int_state.max_combined_texture_image_units = kMaxCombinedTextureImageUnits; |
369 int_state.max_cube_map_texture_size = kMaxCubeMapTextureSize; | 369 int_state.max_cube_map_texture_size = kMaxCubeMapTextureSize; |
370 int_state.max_fragment_uniform_vectors = kMaxFragmentUniformVectors; | 370 int_state.max_fragment_uniform_vectors = kMaxFragmentUniformVectors; |
371 int_state.max_renderbuffer_size = kMaxRenderbufferSize; | 371 int_state.max_renderbuffer_size = kMaxRenderbufferSize; |
372 int_state.max_texture_image_units = kMaxTextureImageUnits; | 372 int_state.max_texture_image_units = kMaxTextureImageUnits; |
373 int_state.max_texture_size = kMaxTextureSize; | 373 int_state.max_texture_size = kMaxTextureSize; |
374 int_state.max_varying_vectors = kMaxVaryingVectors; | 374 int_state.max_varying_vectors = kMaxVaryingVectors; |
375 int_state.max_vertex_attribs = kMaxVertexAttribs; | 375 int_state.max_vertex_attribs = kMaxVertexAttribs; |
376 int_state.max_vertex_texture_image_units = kMaxVertexTextureImageUnits; | 376 int_state.max_vertex_texture_image_units = kMaxVertexTextureImageUnits; |
377 int_state.max_vertex_uniform_vectors = kMaxVertexUniformVectors; | 377 int_state.max_vertex_uniform_vectors = kMaxVertexUniformVectors; |
(...skipping 2170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2548 }; | 2548 }; |
2549 struct Cmds { | 2549 struct Cmds { |
2550 Enable enable_cmd; | 2550 Enable enable_cmd; |
2551 }; | 2551 }; |
2552 Cmds expected; | 2552 Cmds expected; |
2553 | 2553 |
2554 for (size_t ii = 0; ii < arraysize(kStates); ++ii) { | 2554 for (size_t ii = 0; ii < arraysize(kStates); ++ii) { |
2555 GLenum state = kStates[ii]; | 2555 GLenum state = kStates[ii]; |
2556 expected.enable_cmd.Init(state); | 2556 expected.enable_cmd.Init(state); |
2557 GLboolean result = gl_->IsEnabled(state); | 2557 GLboolean result = gl_->IsEnabled(state); |
2558 EXPECT_FALSE(result); | 2558 EXPECT_EQ(static_cast<GLboolean>(ii == 0), result); |
2559 EXPECT_TRUE(NoCommandsWritten()); | 2559 EXPECT_TRUE(NoCommandsWritten()); |
2560 const void* commands = GetPut(); | 2560 const void* commands = GetPut(); |
2561 gl_->Enable(state); | 2561 if (!result) { |
2562 EXPECT_EQ(0, memcmp(&expected, commands, sizeof(expected))); | 2562 gl_->Enable(state); |
| 2563 EXPECT_EQ(0, memcmp(&expected, commands, sizeof(expected))); |
| 2564 } |
2563 ClearCommands(); | 2565 ClearCommands(); |
2564 result = gl_->IsEnabled(state); | 2566 result = gl_->IsEnabled(state); |
2565 EXPECT_TRUE(result); | 2567 EXPECT_TRUE(result); |
2566 EXPECT_TRUE(NoCommandsWritten()); | 2568 EXPECT_TRUE(NoCommandsWritten()); |
2567 } | 2569 } |
2568 } | 2570 } |
2569 | 2571 |
2570 TEST_F(GLES2ImplementationTest, BeginEndQueryEXT) { | 2572 TEST_F(GLES2ImplementationTest, BeginEndQueryEXT) { |
2571 // Test GetQueryivEXT returns 0 if no current query. | 2573 // Test GetQueryivEXT returns 0 if no current query. |
2572 GLint param = -1; | 2574 GLint param = -1; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2761 kAttribIndex1, kNumComponents1, GL_FLOAT, GL_FALSE, kClientStride, | 2763 kAttribIndex1, kNumComponents1, GL_FLOAT, GL_FALSE, kClientStride, |
2762 reinterpret_cast<const void*>(4)); | 2764 reinterpret_cast<const void*>(4)); |
2763 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); | 2765 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); |
2764 | 2766 |
2765 gl_->VertexAttribPointer( | 2767 gl_->VertexAttribPointer( |
2766 kAttribIndex1, kNumComponents1, GL_FLOAT, GL_FALSE, kClientStride, NULL); | 2768 kAttribIndex1, kNumComponents1, GL_FLOAT, GL_FALSE, kClientStride, NULL); |
2767 EXPECT_EQ(GL_NO_ERROR, CheckError()); | 2769 EXPECT_EQ(GL_NO_ERROR, CheckError()); |
2768 } | 2770 } |
2769 #endif | 2771 #endif |
2770 | 2772 |
| 2773 TEST_F(GLES2ImplementationTest, Disable) { |
| 2774 struct Cmds { |
| 2775 Disable cmd; |
| 2776 }; |
| 2777 Cmds expected; |
| 2778 expected.cmd.Init(GL_DITHER); // Note: DITHER defaults to enabled. |
| 2779 |
| 2780 gl_->Disable(GL_DITHER); |
| 2781 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2782 // Check it's cached and not called again. |
| 2783 ClearCommands(); |
| 2784 gl_->Disable(GL_DITHER); |
| 2785 EXPECT_TRUE(NoCommandsWritten()); |
| 2786 } |
| 2787 |
| 2788 TEST_F(GLES2ImplementationTest, Enable) { |
| 2789 struct Cmds { |
| 2790 Enable cmd; |
| 2791 }; |
| 2792 Cmds expected; |
| 2793 expected.cmd.Init(GL_BLEND); // Note: BLEND defaults to disabled. |
| 2794 |
| 2795 gl_->Enable(GL_BLEND); |
| 2796 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2797 // Check it's cached and not called again. |
| 2798 ClearCommands(); |
| 2799 gl_->Enable(GL_BLEND); |
| 2800 EXPECT_TRUE(NoCommandsWritten()); |
| 2801 } |
| 2802 |
| 2803 |
2771 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 2804 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" |
2772 | 2805 |
2773 } // namespace gles2 | 2806 } // namespace gles2 |
2774 } // namespace gpu | 2807 } // namespace gpu |
2775 | 2808 |
OLD | NEW |