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

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

Issue 162023002: Reduce internal Flush() in GL resource glGen/Delete APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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
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 <GLES2/gl2extchromium.h> 10 #include <GLES2/gl2extchromium.h>
(...skipping 2426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2437 GetExpectedResultMemory(sizeof(cmds::GetIntegerv::Result)); 2437 GetExpectedResultMemory(sizeof(cmds::GetIntegerv::Result));
2438 EXPECT_CALL(*command_buffer(), OnFlush()) 2438 EXPECT_CALL(*command_buffer(), OnFlush())
2439 .WillOnce(SetMemory(result1.ptr, 2439 .WillOnce(SetMemory(result1.ptr,
2440 SizedResultHelper<GLuint>(pv.expected))) 2440 SizedResultHelper<GLuint>(pv.expected)))
2441 .RetiresOnSaturation(); 2441 .RetiresOnSaturation();
2442 gl_->GetIntegerv(pv.pname, &v); 2442 gl_->GetIntegerv(pv.pname, &v);
2443 EXPECT_EQ(pv.expected, v); 2443 EXPECT_EQ(pv.expected, v);
2444 } 2444 }
2445 } 2445 }
2446 2446
2447 // glGen* Ids must not be reused until glDelete* commands have been
2448 // flushed by glFlush.
2449 TEST_F(GLES2ImplementationStrictSharedTest, FlushGenerationGenTextures) {
2450 GLuint id1, id2, id3;
2451
2452 // Generate valid id.
2453 gl_->GenTextures(1, &id1);
2454 EXPECT_NE(id1, 0u);
2455
2456 // Delete id1 and generate id2. id1 should not be reused.
2457 gl_->DeleteTextures(1, &id1);
2458 gl_->GenTextures(1, &id2);
2459 EXPECT_NE(id2, 0u);
2460 EXPECT_NE(id2, id1);
2461
2462 // Expect id1 reuse after Flush.
2463 gl_->Flush();
2464 gl_->GenTextures(1, &id3);
2465 EXPECT_EQ(id3, id1);
2466 }
2467
2468 // glGen* Ids must not be reused until glDelete* commands have been
2469 // flushed by glFlush.
2470 TEST_F(GLES2ImplementationStrictSharedTest, FlushGenerationGenBuffers) {
2471 GLuint id1, id2, id3;
2472
2473 // Generate valid id.
2474 gl_->GenBuffers(1, &id1);
2475 EXPECT_NE(id1, 0u);
2476
2477 // Delete id1 and generate id2. id1 should not be reused.
2478 gl_->DeleteBuffers(1, &id1);
2479 gl_->GenBuffers(1, &id2);
2480 EXPECT_NE(id2, 0u);
2481 EXPECT_NE(id2, id1);
2482
2483 // Expect id1 reuse after Flush.
2484 gl_->Flush();
2485 gl_->GenBuffers(1, &id3);
2486 EXPECT_EQ(id3, id1);
2487 }
2488
2489 // glGen* Ids must not be reused until glDelete* commands have been
2490 // flushed by glFlush.
2491 TEST_F(GLES2ImplementationStrictSharedTest, FlushGenerationGenFramebuffers) {
2492 GLuint id1, id2, id3;
2493
2494 // Generate valid id.
2495 gl_->GenFramebuffers(1, &id1);
2496 EXPECT_NE(id1, 0u);
2497
2498 // Delete id1 and generate id2. id1 should not be reused.
2499 gl_->DeleteFramebuffers(1, &id1);
2500 gl_->GenFramebuffers(1, &id2);
2501 EXPECT_NE(id2, 0u);
2502 EXPECT_NE(id2, id1);
2503
2504 // Expect id1 reuse after Flush.
2505 gl_->Flush();
2506 gl_->GenFramebuffers(1, &id3);
2507 EXPECT_EQ(id3, id1);
2508 }
2509
2510 // glGen* Ids must not be reused until glDelete* commands have been
2511 // flushed by glFlush.
2512 TEST_F(GLES2ImplementationStrictSharedTest, FlushGenerationGenRenderbuffers) {
2513 GLuint id1, id2, id3;
2514
2515 // Generate valid id.
2516 gl_->GenRenderbuffers(1, &id1);
2517 EXPECT_NE(id1, 0u);
2518
2519 // Delete id1 and generate id2. id1 should not be reused.
2520 gl_->DeleteRenderbuffers(1, &id1);
2521 gl_->GenRenderbuffers(1, &id2);
2522 EXPECT_NE(id2, 0u);
2523 EXPECT_NE(id2, id1);
2524
2525 // Expect id1 reuse after Flush.
2526 gl_->Flush();
2527 gl_->GenRenderbuffers(1, &id3);
2528 EXPECT_EQ(id3, id1);
2529 }
piman 2014/02/12 23:52:34 It would be good to add tests for multiple context
vmiura 2014/02/14 00:11:11 Added. Please let me know if you think other case
2530
2447 TEST_F(GLES2ImplementationTest, GetString) { 2531 TEST_F(GLES2ImplementationTest, GetString) {
2448 const uint32 kBucketId = GLES2Implementation::kResultBucketId; 2532 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
2449 const Str7 kString = {"foobar"}; 2533 const Str7 kString = {"foobar"};
2450 // GL_CHROMIUM_map_sub GL_CHROMIUM_flipy are hard coded into 2534 // GL_CHROMIUM_map_sub GL_CHROMIUM_flipy are hard coded into
2451 // GLES2Implementation. 2535 // GLES2Implementation.
2452 const char* expected_str = 2536 const char* expected_str =
2453 "foobar " 2537 "foobar "
2454 "GL_CHROMIUM_flipy " 2538 "GL_CHROMIUM_flipy "
2455 "GL_EXT_unpack_subimage"; 2539 "GL_EXT_unpack_subimage";
2456 const char kBad = 0x12; 2540 const char kBad = 0x12;
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
2843 ClearCommands(); 2927 ClearCommands();
2844 gl_->Enable(GL_BLEND); 2928 gl_->Enable(GL_BLEND);
2845 EXPECT_TRUE(NoCommandsWritten()); 2929 EXPECT_TRUE(NoCommandsWritten());
2846 } 2930 }
2847 2931
2848 2932
2849 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" 2933 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h"
2850 2934
2851 } // namespace gles2 2935 } // namespace gles2
2852 } // namespace gpu 2936 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698