Chromium Code Reviews| 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 the Command Buffer Helper. | 5 // Tests for the Command Buffer Helper. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/transfer_buffer.h" | 7 #include "gpu/command_buffer/client/transfer_buffer.h" |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "gpu/command_buffer/client/client_test_helper.h" | 10 #include "gpu/command_buffer/client/client_test_helper.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 kTransferBufferSize + 1, &size_allocated); | 178 kTransferBufferSize + 1, &size_allocated); |
| 179 ASSERT_TRUE(ptr != NULL); | 179 ASSERT_TRUE(ptr != NULL); |
| 180 EXPECT_EQ(kTransferBufferSize - kStartingOffset, size_allocated); | 180 EXPECT_EQ(kTransferBufferSize - kStartingOffset, size_allocated); |
| 181 transfer_buffer_->FreePendingToken(ptr, 1); | 181 transfer_buffer_->FreePendingToken(ptr, 1); |
| 182 } | 182 } |
| 183 | 183 |
| 184 TEST_F(TransferBufferTest, MemoryAlignmentAfterZeroAllocation) { | 184 TEST_F(TransferBufferTest, MemoryAlignmentAfterZeroAllocation) { |
| 185 Initialize(32u); | 185 Initialize(32u); |
| 186 void* ptr = transfer_buffer_->Alloc(0); | 186 void* ptr = transfer_buffer_->Alloc(0); |
| 187 EXPECT_EQ((reinterpret_cast<uintptr_t>(ptr) & (kAlignment - 1)), 0u); | 187 EXPECT_EQ((reinterpret_cast<uintptr_t>(ptr) & (kAlignment - 1)), 0u); |
| 188 transfer_buffer_->FreePendingToken(ptr, -1); | 188 transfer_buffer_->FreePendingToken(ptr, static_cast<unsigned int>(-1)); |
|
no sievers
2014/07/08 00:51:13
nit: can you do '-1u' instead of the cast?
Peter Kasting
2014/07/08 01:03:51
Nope. That produces this warning instead:
warnin
| |
| 189 // Check that the pointer is aligned on the following allocation. | 189 // Check that the pointer is aligned on the following allocation. |
| 190 ptr = transfer_buffer_->Alloc(4); | 190 ptr = transfer_buffer_->Alloc(4); |
| 191 EXPECT_EQ((reinterpret_cast<uintptr_t>(ptr) & (kAlignment - 1)), 0u); | 191 EXPECT_EQ((reinterpret_cast<uintptr_t>(ptr) & (kAlignment - 1)), 0u); |
| 192 transfer_buffer_->FreePendingToken(ptr, 1); | 192 transfer_buffer_->FreePendingToken(ptr, 1); |
| 193 } | 193 } |
| 194 | 194 |
| 195 TEST_F(TransferBufferTest, Flush) { | 195 TEST_F(TransferBufferTest, Flush) { |
| 196 Initialize(16u); | 196 Initialize(16u); |
| 197 unsigned int size_allocated = 0; | 197 unsigned int size_allocated = 0; |
| 198 for (int i = 0; i < 8; ++i) { | 198 for (int i = 0; i < 8; ++i) { |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 476 | 476 |
| 477 // Check it's the default size. | 477 // Check it's the default size. |
| 478 EXPECT_EQ( | 478 EXPECT_EQ( |
| 479 kStartTransferBufferSize - kStartingOffset, | 479 kStartTransferBufferSize - kStartingOffset, |
| 480 transfer_buffer_->GetCurrentMaxAllocationWithoutRealloc()); | 480 transfer_buffer_->GetCurrentMaxAllocationWithoutRealloc()); |
| 481 } | 481 } |
| 482 | 482 |
| 483 } // namespace gpu | 483 } // namespace gpu |
| 484 | 484 |
| 485 | 485 |
| OLD | NEW |