| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 wait_stream.BeginProcessing(); | 374 wait_stream.BeginProcessing(); |
| 375 ASSERT_EQ(3u, wait_stream.order_data->current_order_num()); | 375 ASSERT_EQ(3u, wait_stream.order_data->current_order_num()); |
| 376 int test_num = 10; | 376 int test_num = 10; |
| 377 const bool valid_wait = wait_stream.client->Wait( | 377 const bool valid_wait = wait_stream.client->Wait( |
| 378 release_stream.client->client_state().get(), 1, | 378 release_stream.client->client_state().get(), 1, |
| 379 base::Bind(&SyncPointManagerTest::SetIntegerFunction, &test_num, 123)); | 379 base::Bind(&SyncPointManagerTest::SetIntegerFunction, &test_num, 123)); |
| 380 EXPECT_TRUE(valid_wait); | 380 EXPECT_TRUE(valid_wait); |
| 381 EXPECT_EQ(10, test_num); | 381 EXPECT_EQ(10, test_num); |
| 382 | 382 |
| 383 // Even though release stream order [1] did not have a release, it | 383 // Even though release stream order [1] did not have a release, it |
| 384 // should still release the fence when finish processing since the wait | 384 // should have changed test_num although the fence sync is still not released. |
| 385 // stream had expected on to exist there. | |
| 386 release_stream.BeginProcessing(); | 385 release_stream.BeginProcessing(); |
| 387 ASSERT_EQ(1u, release_stream.order_data->current_order_num()); | 386 ASSERT_EQ(1u, release_stream.order_data->current_order_num()); |
| 388 release_stream.EndProcessing(); | 387 release_stream.EndProcessing(); |
| 389 EXPECT_TRUE(release_stream.client->client_state()->IsFenceSyncReleased(1)); | 388 EXPECT_FALSE(release_stream.client->client_state()->IsFenceSyncReleased(1)); |
| 390 EXPECT_EQ(123, test_num); | 389 EXPECT_EQ(123, test_num); |
| 390 |
| 391 // Ensure that the wait callback does not get triggered again when it is |
| 392 // actually released. |
| 393 test_num = 1; |
| 394 release_stream.AllocateOrderNum(sync_point_manager_.get()); |
| 395 release_stream.BeginProcessing(); |
| 396 release_stream.client->ReleaseFenceSync(1); |
| 397 release_stream.EndProcessing(); |
| 398 EXPECT_EQ(1, test_num); |
| 391 } | 399 } |
| 392 | 400 |
| 393 TEST_F(SyncPointManagerTest, NonExistentOrderNumRelease) { | 401 TEST_F(SyncPointManagerTest, NonExistentOrderNumRelease) { |
| 394 const CommandBufferNamespace kNamespaceId = | 402 const CommandBufferNamespace kNamespaceId = |
| 395 gpu::CommandBufferNamespace::GPU_IO; | 403 gpu::CommandBufferNamespace::GPU_IO; |
| 396 const CommandBufferId kBufferId1 = CommandBufferId::FromUnsafeValue(0x123); | 404 const CommandBufferId kBufferId1 = CommandBufferId::FromUnsafeValue(0x123); |
| 397 const CommandBufferId kBufferId2 = CommandBufferId::FromUnsafeValue(0x234); | 405 const CommandBufferId kBufferId2 = CommandBufferId::FromUnsafeValue(0x234); |
| 398 | 406 |
| 399 SyncPointStream release_stream(sync_point_manager_.get(), kNamespaceId, | 407 SyncPointStream release_stream(sync_point_manager_.get(), kNamespaceId, |
| 400 kBufferId1); | 408 kBufferId1); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 426 EXPECT_EQ(10, test_num); | 434 EXPECT_EQ(10, test_num); |
| 427 | 435 |
| 428 // Release stream should know it should release fence sync by order [3], | 436 // Release stream should know it should release fence sync by order [3], |
| 429 // so going through order [1] should not release it yet. | 437 // so going through order [1] should not release it yet. |
| 430 release_stream.BeginProcessing(); | 438 release_stream.BeginProcessing(); |
| 431 ASSERT_EQ(1u, release_stream.order_data->current_order_num()); | 439 ASSERT_EQ(1u, release_stream.order_data->current_order_num()); |
| 432 release_stream.EndProcessing(); | 440 release_stream.EndProcessing(); |
| 433 EXPECT_FALSE(release_stream.client->client_state()->IsFenceSyncReleased(1)); | 441 EXPECT_FALSE(release_stream.client->client_state()->IsFenceSyncReleased(1)); |
| 434 EXPECT_EQ(10, test_num); | 442 EXPECT_EQ(10, test_num); |
| 435 | 443 |
| 436 // Beginning order [4] should immediately trigger the release. | 444 // Beginning order [4] should immediately trigger the wait although the fence |
| 445 // sync is still not released yet. |
| 437 release_stream.BeginProcessing(); | 446 release_stream.BeginProcessing(); |
| 438 ASSERT_EQ(4u, release_stream.order_data->current_order_num()); | 447 ASSERT_EQ(4u, release_stream.order_data->current_order_num()); |
| 439 EXPECT_TRUE(release_stream.client->client_state()->IsFenceSyncReleased(1)); | 448 EXPECT_FALSE(release_stream.client->client_state()->IsFenceSyncReleased(1)); |
| 440 EXPECT_EQ(123, test_num); | 449 EXPECT_EQ(123, test_num); |
| 450 |
| 451 // Ensure that the wait callback does not get triggered again when it is |
| 452 // actually released. |
| 453 test_num = 1; |
| 454 release_stream.client->ReleaseFenceSync(1); |
| 455 EXPECT_EQ(1, test_num); |
| 441 } | 456 } |
| 442 | 457 |
| 443 TEST_F(SyncPointManagerTest, OnWaitCallbackTest) { | 458 TEST_F(SyncPointManagerTest, OnWaitCallbackTest) { |
| 444 const CommandBufferNamespace kNamespaceId = | 459 const CommandBufferNamespace kNamespaceId = |
| 445 gpu::CommandBufferNamespace::GPU_IO; | 460 gpu::CommandBufferNamespace::GPU_IO; |
| 446 const CommandBufferId kBufferId1 = CommandBufferId::FromUnsafeValue(0x123); | 461 const CommandBufferId kBufferId1 = CommandBufferId::FromUnsafeValue(0x123); |
| 447 const CommandBufferId kBufferId2 = CommandBufferId::FromUnsafeValue(0x234); | 462 const CommandBufferId kBufferId2 = CommandBufferId::FromUnsafeValue(0x234); |
| 448 | 463 |
| 449 SyncPointStream release_stream(sync_point_manager_.get(), kNamespaceId, | 464 SyncPointStream release_stream(sync_point_manager_.get(), kNamespaceId, |
| 450 kBufferId1); | 465 kBufferId1); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 EXPECT_TRUE(valid_wait); | 500 EXPECT_TRUE(valid_wait); |
| 486 EXPECT_EQ(10, test_num); | 501 EXPECT_EQ(10, test_num); |
| 487 EXPECT_EQ(kNamespaceId, namespace_id); | 502 EXPECT_EQ(kNamespaceId, namespace_id); |
| 488 EXPECT_EQ(kBufferId2, client_id); | 503 EXPECT_EQ(kBufferId2, client_id); |
| 489 | 504 |
| 490 release_stream.client->ReleaseFenceSync(2); | 505 release_stream.client->ReleaseFenceSync(2); |
| 491 EXPECT_EQ(123, test_num); | 506 EXPECT_EQ(123, test_num); |
| 492 } | 507 } |
| 493 | 508 |
| 494 } // namespace gpu | 509 } // namespace gpu |
| OLD | NEW |