From 00d34c8c941b51e02b93c2adb0337b562ceeb859 Mon Sep 17 00:00:00 2001 From: Austin Sullivan <asully@chromium.org> Date: Wed, 19 Apr 2023 04:40:11 +0000 Subject: [PATCH] Revert "Add memory alignment parameter to gpu::Buffer" This reverts commit 2b034ff0510317e1f2be13ec99e889c63d2bfbb6. Reason for revert: broke MSAN bots. See https://crbug.com/1434472 Original change's description: > Add memory alignment parameter to gpu::Buffer > > Bug: 1426766 > Change-Id: I0902bf42975ca0a1bb967208fa51e42f4a74392e > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4377798 > Commit-Queue: Sergey Pashaev <bioh@yandex-team.ru> > Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org> > Cr-Commit-Position: refs/heads/main@{#1131990} Bug: 1426766 Change-Id: I80d49b1f5712cd50e63f041feac79e9415349aad No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4443370 Reviewed-by: Meredith Lane <meredithl@chromium.org> Auto-Submit: Austin Sullivan <asully@chromium.org> Owners-Override: Austin Sullivan <asully@chromium.org> Commit-Queue: Meredith Lane <meredithl@chromium.org> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Cr-Commit-Position: refs/heads/main@{#1132321} --- .../image_transfer_cache_entry_unittest.cc | 21 ++++++-------- cc/paint/paint_op_buffer_unittest.cc | 8 +++--- cc/paint/paint_op_writer.h | 7 ++--- cc/test/test_options_provider.cc | 9 +++--- cc/tiles/gpu_image_decode_cache_unittest.cc | 7 ++--- .../client/buffer_tracker_unittest.cc | 3 +- .../client_discardable_manager_unittest.cc | 3 +- .../client/client_test_helper.cc | 1 - .../client/client_test_helper.h | 1 - .../client/command_buffer_direct_locked.cc | 4 +-- .../client/command_buffer_direct_locked.h | 1 - gpu/command_buffer/client/mapped_memory.cc | 4 +-- gpu/command_buffer/client/transfer_buffer.cc | 2 +- .../client/transfer_buffer_unittest.cc | 28 +++++++++---------- gpu/command_buffer/common/buffer.cc | 8 ++---- gpu/command_buffer/common/buffer.h | 8 ++---- gpu/command_buffer/common/command_buffer.h | 1 - .../service/command_buffer_direct.cc | 3 +- .../service/command_buffer_direct.h | 1 - .../service/command_buffer_service.cc | 16 ++++------- .../service/command_buffer_service.h | 8 ++---- gpu/ipc/client/command_buffer_proxy_impl.cc | 1 - gpu/ipc/client/command_buffer_proxy_impl.h | 1 - .../command_buffer_proxy_impl_unittest.cc | 5 ++-- gpu/ipc/in_process_command_buffer.cc | 3 +- gpu/ipc/in_process_command_buffer.h | 1 - ppapi/proxy/ppapi_command_buffer_proxy.cc | 1 - ppapi/proxy/ppapi_command_buffer_proxy.h | 1 - 28 files changed, 59 insertions(+), 98 deletions(-) diff --git a/cc/paint/image_transfer_cache_entry_unittest.cc b/cc/paint/image_transfer_cache_entry_unittest.cc index cc2c096cfbce4..44601c543fcf6 100644 --- a/cc/paint/image_transfer_cache_entry_unittest.cc +++ b/cc/paint/image_transfer_cache_entry_unittest.cc @@ -16,7 +16,6 @@ #include "base/notreached.h" #include "build/build_config.h" #include "cc/paint/image_transfer_cache_entry.h" -#include "cc/paint/paint_op_writer.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkColor.h" @@ -243,14 +242,14 @@ TEST_P(ImageTransferCacheEntryTest, MAYBE_Deserialize) { nullptr /* decoded color space*/), true /* needs_mips */, absl::nullopt)); uint32_t size = client_entry->SerializedSize(); - auto data = PaintOpWriter::AllocateAlignedBuffer<uint8_t>(size); + std::vector<uint8_t> data(size); ASSERT_TRUE(client_entry->Serialize( - base::make_span(static_cast<uint8_t*>(data.get()), size))); + base::make_span(static_cast<uint8_t*>(data.data()), size))); // Create service-side entry from the client-side serialize info auto entry(std::make_unique<ServiceImageTransferCacheEntry>()); ASSERT_TRUE(entry->Deserialize( - gr_context(), base::make_span(static_cast<uint8_t*>(data.get()), size))); + gr_context(), base::make_span(static_cast<uint8_t*>(data.data()), size))); ASSERT_TRUE(entry->is_yuv()); // Check color of pixels @@ -395,13 +394,12 @@ TEST(ImageTransferCacheEntryTestNoYUV, CPUImageWithMips) { ClientImageTransferCacheEntry client_entry( ClientImageTransferCacheEntry::Image(&bitmap.pixmap()), true, absl::nullopt); - const uint32_t storage_size = client_entry.SerializedSize(); - auto storage = PaintOpWriter::AllocateAlignedBuffer<uint8_t>(storage_size); - client_entry.Serialize(base::make_span(storage.get(), storage_size)); + std::vector<uint8_t> storage(client_entry.SerializedSize()); + client_entry.Serialize(base::make_span(storage.data(), storage.size())); ServiceImageTransferCacheEntry service_entry; service_entry.Deserialize(gr_context.get(), - base::make_span(storage.get(), storage_size)); + base::make_span(storage.data(), storage.size())); ASSERT_TRUE(service_entry.image()); auto pre_mip_image = service_entry.image(); EXPECT_FALSE(pre_mip_image->isTextureBacked()); @@ -424,13 +422,12 @@ TEST(ImageTransferCacheEntryTestNoYUV, CPUImageAddMipsLater) { ClientImageTransferCacheEntry client_entry( ClientImageTransferCacheEntry::Image(&bitmap.pixmap()), false, absl::nullopt); - const uint32_t storage_size = client_entry.SerializedSize(); - auto storage = PaintOpWriter::AllocateAlignedBuffer<uint8_t>(storage_size); - client_entry.Serialize(base::make_span(storage.get(), storage_size)); + std::vector<uint8_t> storage(client_entry.SerializedSize()); + client_entry.Serialize(base::make_span(storage.data(), storage.size())); ServiceImageTransferCacheEntry service_entry; service_entry.Deserialize(gr_context.get(), - base::make_span(storage.get(), storage_size)); + base::make_span(storage.data(), storage.size())); ASSERT_TRUE(service_entry.image()); auto pre_mip_image = service_entry.image(); EXPECT_FALSE(pre_mip_image->isTextureBacked()); diff --git a/cc/paint/paint_op_buffer_unittest.cc b/cc/paint/paint_op_buffer_unittest.cc index 070c3e4fa8b16..a0abe2aaebd62 100644 --- a/cc/paint/paint_op_buffer_unittest.cc +++ b/cc/paint/paint_op_buffer_unittest.cc @@ -3319,8 +3319,8 @@ TEST(PaintOpBufferTest, RecordPaintFilterDeserializationInvalidPaintOp) { SkRect::MakeWH(100, 100)); TestOptionsProvider options_provider; - auto memory = AllocateSerializedBuffer(); - PaintOpWriter writer(memory.get(), kDefaultSerializedBufferSize, + std::vector<uint8_t> memory(kDefaultSerializedBufferSize); + PaintOpWriter writer(memory.data(), memory.size(), options_provider.serialize_options(), false); writer.Write(filter.get(), SkM44()); ASSERT_GT(writer.size(), sizeof(float)); @@ -3328,14 +3328,14 @@ TEST(PaintOpBufferTest, RecordPaintFilterDeserializationInvalidPaintOp) { // Replace the first occurrence of rect_size with NaN to make the ClipRectOp // invalid. for (size_t i = 0; i < writer.size(); i += sizeof(float)) { - float* f = reinterpret_cast<float*>(memory.get() + i); + float* f = reinterpret_cast<float*>(memory.data() + i); if (*f == rect_size) { *f = std::numeric_limits<float>::quiet_NaN(); break; } } sk_sp<PaintFilter> deserialized_filter; - PaintOpReader reader(memory.get(), writer.size(), + PaintOpReader reader(memory.data(), writer.size(), options_provider.deserialize_options(), false); reader.Read(&deserialized_filter); EXPECT_FALSE(deserialized_filter); diff --git a/cc/paint/paint_op_writer.h b/cc/paint/paint_op_writer.h index dee0d60003587..ef077f3926c08 100644 --- a/cc/paint/paint_op_writer.h +++ b/cc/paint/paint_op_writer.h @@ -50,11 +50,10 @@ class CC_PAINT_EXPORT PaintOpWriter { bool enable_security_constraints = false); ~PaintOpWriter(); - template <typename T = char> - static std::unique_ptr<T, base::AlignedFreeDeleter> AllocateAlignedBuffer( + static std::unique_ptr<char, base::AlignedFreeDeleter> AllocateAlignedBuffer( size_t size) { - return std::unique_ptr<T, base::AlignedFreeDeleter>( - static_cast<T*>(base::AlignedAlloc(size, kMaxAlignment))); + return std::unique_ptr<char, base::AlignedFreeDeleter>( + static_cast<char*>(base::AlignedAlloc(size, kMaxAlignment))); } const PaintOp::SerializeOptions& options() const { return *options_; } diff --git a/cc/test/test_options_provider.cc b/cc/test/test_options_provider.cc index 5eec903b19224..3b2d89f26265b 100644 --- a/cc/test/test_options_provider.cc +++ b/cc/test/test_options_provider.cc @@ -7,7 +7,6 @@ #include <limits> #include <vector> -#include "cc/paint/paint_op_writer.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkColorSpace.h" #include "third_party/skia/include/core/SkImageInfo.h" @@ -115,13 +114,13 @@ ImageProvider::ScopedResult TestOptionsProvider::GetRasterContent( ClientImageTransferCacheEntry cache_entry( ClientImageTransferCacheEntry::Image(&bitmap.pixmap()), false /* needs_mips */, target_color_params); - const uint32_t data_size = cache_entry.SerializedSize(); - auto data = PaintOpWriter::AllocateAlignedBuffer<uint8_t>(data_size); - if (!cache_entry.Serialize(base::span<uint8_t>(data.get(), data_size))) { + std::vector<uint8_t> data; + data.resize(cache_entry.SerializedSize()); + if (!cache_entry.Serialize(base::span<uint8_t>(data.data(), data.size()))) { return ScopedResult(); } - CreateEntryDirect(entry_key, base::span<uint8_t>(data.get(), data_size)); + CreateEntryDirect(entry_key, base::span<uint8_t>(data.data(), data.size())); return ScopedResult(DecodedDrawImage( image_id, nullptr, SkSize::MakeEmpty(), draw_image.scale(), diff --git a/cc/tiles/gpu_image_decode_cache_unittest.cc b/cc/tiles/gpu_image_decode_cache_unittest.cc index fb9dd49538e1a..fde38587eee51 100644 --- a/cc/tiles/gpu_image_decode_cache_unittest.cc +++ b/cc/tiles/gpu_image_decode_cache_unittest.cc @@ -20,7 +20,6 @@ #include "cc/paint/draw_image.h" #include "cc/paint/image_transfer_cache_entry.h" #include "cc/paint/paint_image_builder.h" -#include "cc/paint/paint_op_writer.h" #include "cc/test/fake_paint_image_generator.h" #include "cc/test/skia_common.h" #include "cc/test/test_tile_task_runner.h" @@ -171,9 +170,7 @@ class FakeGPUImageDecodeTestGLES2Interface : public viz::TestGLES2Interface, void* MapTransferCacheEntry(uint32_t serialized_size) override { mapped_entry_size_ = serialized_size; - auto buffer = - PaintOpWriter::AllocateAlignedBuffer<uint8_t>(serialized_size); - mapped_entry_.swap(buffer); + mapped_entry_.reset(new uint8_t[serialized_size]); return mapped_entry_.get(); } @@ -273,7 +270,7 @@ class FakeGPUImageDecodeTestGLES2Interface : public viz::TestGLES2Interface, raw_ptr<TransferCacheTestHelper> transfer_cache_helper_; bool advertise_accelerated_decoding_ = false; size_t mapped_entry_size_ = 0; - std::unique_ptr<uint8_t, base::AlignedFreeDeleter> mapped_entry_; + std::unique_ptr<uint8_t[]> mapped_entry_; }; class MockRasterImplementation : public gpu::raster::RasterImplementationGLES { diff --git a/gpu/command_buffer/client/buffer_tracker_unittest.cc b/gpu/command_buffer/client/buffer_tracker_unittest.cc index dee24d9ca9b81..2c057605ddb3d 100644 --- a/gpu/command_buffer/client/buffer_tracker_unittest.cc +++ b/gpu/command_buffer/client/buffer_tracker_unittest.cc @@ -33,14 +33,13 @@ class MockClientCommandBufferImpl : public MockClientCommandBuffer { scoped_refptr<gpu::Buffer> CreateTransferBuffer( uint32_t size, int32_t* id, - uint32_t alignment = 0, TransferBufferAllocationOption option = TransferBufferAllocationOption::kLoseContextOnOOM) override { if (context_lost_) { *id = -1; return nullptr; } - return MockClientCommandBuffer::CreateTransferBuffer(size, id, alignment); + return MockClientCommandBuffer::CreateTransferBuffer(size, id); } void set_context_lost(bool context_lost) { diff --git a/gpu/command_buffer/client/client_discardable_manager_unittest.cc b/gpu/command_buffer/client/client_discardable_manager_unittest.cc index 4f2fa68de8302..1ab2e010355f3 100644 --- a/gpu/command_buffer/client/client_discardable_manager_unittest.cc +++ b/gpu/command_buffer/client/client_discardable_manager_unittest.cc @@ -34,12 +34,11 @@ class FakeCommandBuffer : public CommandBuffer { scoped_refptr<gpu::Buffer> CreateTransferBuffer( uint32_t size, int32_t* id, - uint32_t alignment = 0, TransferBufferAllocationOption option = TransferBufferAllocationOption::kLoseContextOnOOM) override { *id = next_id_++; active_ids_.insert(*id); - return MakeMemoryBuffer(size, alignment); + return MakeMemoryBuffer(size); } void DestroyTransferBuffer(int32_t id) override { auto found = active_ids_.find(id); diff --git a/gpu/command_buffer/client/client_test_helper.cc b/gpu/command_buffer/client/client_test_helper.cc index f21ec2dbbc821..be91ffac8298a 100644 --- a/gpu/command_buffer/client/client_test_helper.cc +++ b/gpu/command_buffer/client/client_test_helper.cc @@ -137,7 +137,6 @@ void MockClientCommandBuffer::SetGetBuffer(int transfer_buffer_id) { scoped_refptr<gpu::Buffer> MockClientCommandBuffer::CreateTransferBuffer( uint32_t size, int32_t* id, - uint32_t alignment, TransferBufferAllocationOption option) { return CreateTransferBufferHelper(size, id); } diff --git a/gpu/command_buffer/client/client_test_helper.h b/gpu/command_buffer/client/client_test_helper.h index 5399b365fc4c7..a7464d5ef1941 100644 --- a/gpu/command_buffer/client/client_test_helper.h +++ b/gpu/command_buffer/client/client_test_helper.h @@ -69,7 +69,6 @@ class MockClientCommandBuffer : public CommandBuffer, scoped_refptr<gpu::Buffer> CreateTransferBuffer( uint32_t size, int32_t* id, - uint32_t alignment = 0, TransferBufferAllocationOption option = TransferBufferAllocationOption::kLoseContextOnOOM) override; diff --git a/gpu/command_buffer/client/command_buffer_direct_locked.cc b/gpu/command_buffer/client/command_buffer_direct_locked.cc index 5cb71b212e32b..04de60d6582b7 100644 --- a/gpu/command_buffer/client/command_buffer_direct_locked.cc +++ b/gpu/command_buffer/client/command_buffer_direct_locked.cc @@ -44,14 +44,12 @@ CommandBuffer::State CommandBufferDirectLocked::WaitForGetOffsetInRange( scoped_refptr<Buffer> CommandBufferDirectLocked::CreateTransferBuffer( uint32_t size, int32_t* id, - uint32_t alignment, TransferBufferAllocationOption option) { if (fail_create_transfer_buffer_) { *id = -1; return nullptr; } else { - return CommandBufferDirect::CreateTransferBuffer(size, id, alignment, - option); + return CommandBufferDirect::CreateTransferBuffer(size, id, option); } } diff --git a/gpu/command_buffer/client/command_buffer_direct_locked.h b/gpu/command_buffer/client/command_buffer_direct_locked.h index a4c1bbf800ac5..41957977025e4 100644 --- a/gpu/command_buffer/client/command_buffer_direct_locked.h +++ b/gpu/command_buffer/client/command_buffer_direct_locked.h @@ -30,7 +30,6 @@ class CommandBufferDirectLocked : public CommandBufferDirect { scoped_refptr<Buffer> CreateTransferBuffer( uint32_t size, int32_t* id, - uint32_t alignment = 0, TransferBufferAllocationOption option = TransferBufferAllocationOption::kLoseContextOnOOM) override; diff --git a/gpu/command_buffer/client/mapped_memory.cc b/gpu/command_buffer/client/mapped_memory.cc index b4b3572016581..8acb49e71b43a 100644 --- a/gpu/command_buffer/client/mapped_memory.cc +++ b/gpu/command_buffer/client/mapped_memory.cc @@ -112,8 +112,8 @@ void* MappedMemoryManager::Alloc(unsigned int size, return nullptr; int32_t id = -1; - scoped_refptr<gpu::Buffer> shm = cmd_buf->CreateTransferBuffer( - safe_chunk_size, &id, /* alignment */ 0, option); + scoped_refptr<gpu::Buffer> shm = + cmd_buf->CreateTransferBuffer(safe_chunk_size, &id, option); if (id < 0) return nullptr; DCHECK(shm.get()); diff --git a/gpu/command_buffer/client/transfer_buffer.cc b/gpu/command_buffer/client/transfer_buffer.cc index 81a3848cbb7a7..698da1485d1d9 100644 --- a/gpu/command_buffer/client/transfer_buffer.cc +++ b/gpu/command_buffer/client/transfer_buffer.cc @@ -119,7 +119,7 @@ void TransferBuffer::AllocateRingBuffer(unsigned int size) { for (;size >= min_buffer_size_; size /= 2) { int32_t id = -1; scoped_refptr<gpu::Buffer> buffer = - helper_->command_buffer()->CreateTransferBuffer(size, &id, alignment_); + helper_->command_buffer()->CreateTransferBuffer(size, &id); if (id != -1) { last_allocated_size_ = size; DCHECK(buffer.get()); diff --git a/gpu/command_buffer/client/transfer_buffer_unittest.cc b/gpu/command_buffer/client/transfer_buffer_unittest.cc index f9b703703e318..6781aa821cfe4 100644 --- a/gpu/command_buffer/client/transfer_buffer_unittest.cc +++ b/gpu/command_buffer/client/transfer_buffer_unittest.cc @@ -230,19 +230,17 @@ class MockClientCommandBufferCanFail : public MockClientCommandBufferMockFlush { MockClientCommandBufferCanFail() = default; ~MockClientCommandBufferCanFail() override = default; - MOCK_METHOD4(CreateTransferBuffer, + MOCK_METHOD3(CreateTransferBuffer, scoped_refptr<Buffer>(uint32_t size, int32_t* id, - uint32_t alignment, TransferBufferAllocationOption option)); scoped_refptr<gpu::Buffer> RealCreateTransferBuffer( uint32_t size, int32_t* id, - uint32_t alignment, TransferBufferAllocationOption option) { - return MockClientCommandBufferMockFlush::CreateTransferBuffer( - size, id, alignment, option); + return MockClientCommandBufferMockFlush::CreateTransferBuffer(size, id, + option); } }; @@ -280,7 +278,7 @@ void TransferBufferExpandContractTest::SetUp() { command_buffer_->SetTokenForSetGetBuffer(0); EXPECT_CALL(*command_buffer(), - CreateTransferBuffer(kCommandBufferSizeBytes, _, _, _)) + CreateTransferBuffer(kCommandBufferSizeBytes, _, _)) .WillOnce( Invoke(command_buffer(), &MockClientCommandBufferCanFail::RealCreateTransferBuffer)) @@ -293,7 +291,7 @@ void TransferBufferExpandContractTest::SetUp() { transfer_buffer_id_ = command_buffer()->GetNextFreeTransferBufferId(); EXPECT_CALL(*command_buffer(), - CreateTransferBuffer(kStartTransferBufferSize, _, _, _)) + CreateTransferBuffer(kStartTransferBufferSize, _, _)) .WillOnce( Invoke(command_buffer(), &MockClientCommandBufferCanFail::RealCreateTransferBuffer)) @@ -344,7 +342,7 @@ TEST_F(TransferBufferExpandContractTest, ExpandWithSmallAllocations) { EXPECT_CALL(*command_buffer(), OrderingBarrier(_)) .Times(1) .RetiresOnSaturation(); - EXPECT_CALL(*command_buffer(), CreateTransferBuffer(size, _, _, _)) + EXPECT_CALL(*command_buffer(), CreateTransferBuffer(size, _, _)) .WillOnce( Invoke(command_buffer(), &MockClientCommandBufferCanFail::RealCreateTransferBuffer)) @@ -441,7 +439,7 @@ TEST_F(TransferBufferExpandContractTest, ExpandWithLargeAllocations) { EXPECT_CALL(*command_buffer(), OrderingBarrier(_)) .Times(1) .RetiresOnSaturation(); - EXPECT_CALL(*command_buffer(), CreateTransferBuffer(size, _, _, _)) + EXPECT_CALL(*command_buffer(), CreateTransferBuffer(size, _, _)) .WillOnce( Invoke(command_buffer(), &MockClientCommandBufferCanFail::RealCreateTransferBuffer)) @@ -491,7 +489,7 @@ TEST_F(TransferBufferExpandContractTest, ShrinkRingBuffer) { EXPECT_CALL(*command_buffer(), OrderingBarrier(_)) .Times(1) .RetiresOnSaturation(); - EXPECT_CALL(*command_buffer(), CreateTransferBuffer(size, _, _, _)) + EXPECT_CALL(*command_buffer(), CreateTransferBuffer(size, _, _)) .WillOnce( Invoke(command_buffer(), &MockClientCommandBufferCanFail::RealCreateTransferBuffer)) @@ -539,12 +537,12 @@ TEST_F(TransferBufferExpandContractTest, Contract) { // Try to allocate again, fail first request EXPECT_CALL(*command_buffer(), - CreateTransferBuffer(kStartTransferBufferSize, _, _, _)) + CreateTransferBuffer(kStartTransferBufferSize, _, _)) .WillOnce( DoAll(SetArgPointee<1>(-1), Return(scoped_refptr<gpu::Buffer>()))) .RetiresOnSaturation(); EXPECT_CALL(*command_buffer(), - CreateTransferBuffer(kMinTransferBufferSize, _, _, _)) + CreateTransferBuffer(kMinTransferBufferSize, _, _)) .WillOnce( Invoke(command_buffer(), &MockClientCommandBufferCanFail::RealCreateTransferBuffer)) @@ -572,7 +570,7 @@ TEST_F(TransferBufferExpandContractTest, Contract) { // Try to allocate again, EXPECT_CALL(*command_buffer(), - CreateTransferBuffer(kMinTransferBufferSize, _, _, _)) + CreateTransferBuffer(kMinTransferBufferSize, _, _)) .WillOnce( Invoke(command_buffer(), &MockClientCommandBufferCanFail::RealCreateTransferBuffer)) @@ -598,7 +596,7 @@ TEST_F(TransferBufferExpandContractTest, OutOfMemory) { EXPECT_FALSE(transfer_buffer_->HaveBuffer()); // Try to allocate again, fail both requests. - EXPECT_CALL(*command_buffer(), CreateTransferBuffer(_, _, _, _)) + EXPECT_CALL(*command_buffer(), CreateTransferBuffer(_, _, _)) .WillOnce( DoAll(SetArgPointee<1>(-1), Return(scoped_refptr<gpu::Buffer>()))) .WillOnce( @@ -628,7 +626,7 @@ TEST_F(TransferBufferExpandContractTest, ReallocsToDefault) { // See that it gets reallocated. EXPECT_CALL(*command_buffer(), - CreateTransferBuffer(kStartTransferBufferSize, _, _, _)) + CreateTransferBuffer(kStartTransferBufferSize, _, _)) .WillOnce( Invoke(command_buffer(), &MockClientCommandBufferCanFail::RealCreateTransferBuffer)) diff --git a/gpu/command_buffer/common/buffer.cc b/gpu/command_buffer/common/buffer.cc index a99be7081f8b5..d3d5ac84104ad 100644 --- a/gpu/command_buffer/common/buffer.cc +++ b/gpu/command_buffer/common/buffer.cc @@ -9,7 +9,6 @@ #include <ostream> #include "base/atomic_sequence_num.h" -#include "base/bits.h" #include "base/check_op.h" #include "base/format_macros.h" #include "base/no_destructor.h" @@ -35,14 +34,13 @@ base::UnguessableToken BufferBacking::GetGUID() const { return base::UnguessableToken(); } -MemoryBufferBacking::MemoryBufferBacking(uint32_t size, uint32_t alignment) - : memory_(new char[size + alignment]), size_(size), alignment_(alignment) {} +MemoryBufferBacking::MemoryBufferBacking(uint32_t size) + : memory_(new char[size]), size_(size) {} MemoryBufferBacking::~MemoryBufferBacking() = default; void* MemoryBufferBacking::GetMemory() const { - return alignment_ > 0 ? base::bits::AlignUp(memory_.get(), alignment_) - : memory_.get(); + return memory_.get(); } uint32_t MemoryBufferBacking::GetSize() const { diff --git a/gpu/command_buffer/common/buffer.h b/gpu/command_buffer/common/buffer.h index 28e47ee2ecfa8..b441738cd522f 100644 --- a/gpu/command_buffer/common/buffer.h +++ b/gpu/command_buffer/common/buffer.h @@ -29,7 +29,7 @@ class GPU_EXPORT BufferBacking { class GPU_EXPORT MemoryBufferBacking : public BufferBacking { public: - explicit MemoryBufferBacking(uint32_t size, uint32_t alignment = 0); + explicit MemoryBufferBacking(uint32_t size); MemoryBufferBacking(const MemoryBufferBacking&) = delete; MemoryBufferBacking& operator=(const MemoryBufferBacking&) = delete; @@ -41,7 +41,6 @@ class GPU_EXPORT MemoryBufferBacking : public BufferBacking { private: std::unique_ptr<char[]> memory_; uint32_t size_; - uint32_t alignment_; }; @@ -109,10 +108,9 @@ inline scoped_refptr<Buffer> MakeBufferFromSharedMemory( std::move(shared_memory_region), std::move(shared_memory_mapping))); } -inline scoped_refptr<Buffer> MakeMemoryBuffer(uint32_t size, - uint32_t alignment = 0) { +inline scoped_refptr<Buffer> MakeMemoryBuffer(uint32_t size) { return base::MakeRefCounted<Buffer>( - std::make_unique<MemoryBufferBacking>(size, alignment)); + std::make_unique<MemoryBufferBacking>(size)); } // Generates a process unique buffer ID which can be safely used with diff --git a/gpu/command_buffer/common/command_buffer.h b/gpu/command_buffer/common/command_buffer.h index 5cc7983d6538c..40acc174d43d1 100644 --- a/gpu/command_buffer/common/command_buffer.h +++ b/gpu/command_buffer/common/command_buffer.h @@ -119,7 +119,6 @@ class GPU_EXPORT CommandBuffer { virtual scoped_refptr<gpu::Buffer> CreateTransferBuffer( uint32_t size, int32_t* id, - uint32_t alignment = 0, TransferBufferAllocationOption option = TransferBufferAllocationOption::kLoseContextOnOOM) = 0; diff --git a/gpu/command_buffer/service/command_buffer_direct.cc b/gpu/command_buffer/service/command_buffer_direct.cc index 4a46a88be24eb..13ad519afd9a6 100644 --- a/gpu/command_buffer/service/command_buffer_direct.cc +++ b/gpu/command_buffer/service/command_buffer_direct.cc @@ -55,9 +55,8 @@ void CommandBufferDirect::SetGetBuffer(int32_t transfer_buffer_id) { scoped_refptr<Buffer> CommandBufferDirect::CreateTransferBuffer( uint32_t size, int32_t* id, - uint32_t alignment, TransferBufferAllocationOption option) { - return service_.CreateTransferBuffer(size, id, alignment); + return service_.CreateTransferBuffer(size, id); } void CommandBufferDirect::DestroyTransferBuffer(int32_t id) { diff --git a/gpu/command_buffer/service/command_buffer_direct.h b/gpu/command_buffer/service/command_buffer_direct.h index 6fa3e7f4a97d2..7483bd85ff75f 100644 --- a/gpu/command_buffer/service/command_buffer_direct.h +++ b/gpu/command_buffer/service/command_buffer_direct.h @@ -38,7 +38,6 @@ class GPU_EXPORT CommandBufferDirect : public CommandBuffer, scoped_refptr<Buffer> CreateTransferBuffer( uint32_t size, int32_t* id, - uint32_t alignment = 0, TransferBufferAllocationOption option = TransferBufferAllocationOption::kLoseContextOnOOM) override; void DestroyTransferBuffer(int32_t id) override; diff --git a/gpu/command_buffer/service/command_buffer_service.cc b/gpu/command_buffer/service/command_buffer_service.cc index 7368f3e68a558..be460adc918b9 100644 --- a/gpu/command_buffer/service/command_buffer_service.cc +++ b/gpu/command_buffer/service/command_buffer_service.cc @@ -309,15 +309,12 @@ void CommandBufferService::SetReleaseCount(uint64_t release_count) { UpdateState(); } -scoped_refptr<Buffer> CommandBufferService::CreateTransferBuffer( - uint32_t size, - int32_t* id, - uint32_t alignment) { +scoped_refptr<Buffer> CommandBufferService::CreateTransferBuffer(uint32_t size, + int32_t* id) { *id = GetNextBufferId(); - auto result = CreateTransferBufferWithId(size, *id, alignment); - if (!result) { + auto result = CreateTransferBufferWithId(size, *id); + if (!result) *id = -1; - } return result; } @@ -338,9 +335,8 @@ bool CommandBufferService::RegisterTransferBuffer( scoped_refptr<Buffer> CommandBufferService::CreateTransferBufferWithId( uint32_t size, - int32_t id, - uint32_t alignment) { - scoped_refptr<Buffer> buffer = MakeMemoryBuffer(size, alignment); + int32_t id) { + scoped_refptr<Buffer> buffer = MakeMemoryBuffer(size); if (!RegisterTransferBuffer(id, buffer)) { SetParseError(gpu::error::kOutOfBounds); return nullptr; diff --git a/gpu/command_buffer/service/command_buffer_service.h b/gpu/command_buffer/service/command_buffer_service.h index 4c6ca4afbcbde..557a168e3dadb 100644 --- a/gpu/command_buffer/service/command_buffer_service.h +++ b/gpu/command_buffer/service/command_buffer_service.h @@ -112,14 +112,10 @@ class GPU_EXPORT CommandBufferService : public CommandBufferServiceBase { // Creates an in-process transfer buffer and register it with a newly created // id. - scoped_refptr<Buffer> CreateTransferBuffer(uint32_t size, - int32_t* id, - uint32_t alignment = 0); + scoped_refptr<Buffer> CreateTransferBuffer(uint32_t size, int32_t* id); // Creates an in-process transfer buffer and register it with a given id. - scoped_refptr<Buffer> CreateTransferBufferWithId(uint32_t size, - int32_t id, - uint32_t alignment = 0); + scoped_refptr<Buffer> CreateTransferBufferWithId(uint32_t size, int32_t id); // Sets whether commands should be processed by this scheduler. Setting to // false unschedules. Setting to true reschedules. diff --git a/gpu/ipc/client/command_buffer_proxy_impl.cc b/gpu/ipc/client/command_buffer_proxy_impl.cc index ab04701bddddc..8469e93046292 100644 --- a/gpu/ipc/client/command_buffer_proxy_impl.cc +++ b/gpu/ipc/client/command_buffer_proxy_impl.cc @@ -342,7 +342,6 @@ void CommandBufferProxyImpl::SetGetBuffer(int32_t shm_id) { scoped_refptr<gpu::Buffer> CommandBufferProxyImpl::CreateTransferBuffer( uint32_t size, int32_t* id, - uint32_t alignment, TransferBufferAllocationOption option) { CheckLock(); base::AutoLock lock(last_state_lock_); diff --git a/gpu/ipc/client/command_buffer_proxy_impl.h b/gpu/ipc/client/command_buffer_proxy_impl.h index 18859f8fbab4c..c4bedde073bba 100644 --- a/gpu/ipc/client/command_buffer_proxy_impl.h +++ b/gpu/ipc/client/command_buffer_proxy_impl.h @@ -118,7 +118,6 @@ class GPU_EXPORT CommandBufferProxyImpl : public gpu::CommandBuffer, scoped_refptr<gpu::Buffer> CreateTransferBuffer( uint32_t size, int32_t* id, - uint32_t alignment = 0, TransferBufferAllocationOption option = TransferBufferAllocationOption::kLoseContextOnOOM) override; void DestroyTransferBuffer(int32_t id) override; diff --git a/gpu/ipc/client/command_buffer_proxy_impl_unittest.cc b/gpu/ipc/client/command_buffer_proxy_impl_unittest.cc index 16d78ff660604..8f01de683b404 100644 --- a/gpu/ipc/client/command_buffer_proxy_impl_unittest.cc +++ b/gpu/ipc/client/command_buffer_proxy_impl_unittest.cc @@ -4,7 +4,6 @@ #include "gpu/ipc/client/command_buffer_proxy_impl.h" -#include <limits> #include <utility> #include <vector> @@ -291,7 +290,7 @@ TEST_F(CommandBufferProxyImplTest, CreateTransferBufferOOM) { int32_t id = -1; scoped_refptr<gpu::Buffer> transfer_buffer_oom = proxy->CreateTransferBuffer( - std::numeric_limits<uint32_t>::max(), &id, 0, + std::numeric_limits<uint32_t>::max(), &id, TransferBufferAllocationOption::kReturnNullOnOOM); if (transfer_buffer_oom) { // In this test, there's no guarantee allocating UINT32_MAX will definitely @@ -316,7 +315,7 @@ TEST_F(CommandBufferProxyImplTest, CreateTransferBufferOOM) { .RetiresOnSaturation(); transfer_buffer_oom = proxy->CreateTransferBuffer( - std::numeric_limits<uint32_t>::max(), &id, 0, + std::numeric_limits<uint32_t>::max(), &id, TransferBufferAllocationOption::kLoseContextOnOOM); EXPECT_CALL(mock_gpu_channel_, DestroyCommandBuffer(_)) diff --git a/gpu/ipc/in_process_command_buffer.cc b/gpu/ipc/in_process_command_buffer.cc index b459188bc3666..7cc291333730a 100644 --- a/gpu/ipc/in_process_command_buffer.cc +++ b/gpu/ipc/in_process_command_buffer.cc @@ -747,9 +747,8 @@ void InProcessCommandBuffer::SetGetBufferOnGpuThread( scoped_refptr<Buffer> InProcessCommandBuffer::CreateTransferBuffer( uint32_t size, int32_t* id, - uint32_t alignment, TransferBufferAllocationOption option) { - scoped_refptr<Buffer> buffer = MakeMemoryBuffer(size, alignment); + scoped_refptr<Buffer> buffer = MakeMemoryBuffer(size); *id = GetNextBufferId(); ScheduleGpuTask( base::BindOnce(&InProcessCommandBuffer::RegisterTransferBufferOnGpuThread, diff --git a/gpu/ipc/in_process_command_buffer.h b/gpu/ipc/in_process_command_buffer.h index 47e677ceaebeb..774a2356e1c08 100644 --- a/gpu/ipc/in_process_command_buffer.h +++ b/gpu/ipc/in_process_command_buffer.h @@ -117,7 +117,6 @@ class GL_IN_PROCESS_CONTEXT_EXPORT InProcessCommandBuffer scoped_refptr<Buffer> CreateTransferBuffer( uint32_t size, int32_t* id, - uint32_t alignment = 0, TransferBufferAllocationOption option = TransferBufferAllocationOption::kLoseContextOnOOM) override; void DestroyTransferBuffer(int32_t id) override; diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.cc b/ppapi/proxy/ppapi_command_buffer_proxy.cc index d096a77de6500..e92622a7c3c4f 100644 --- a/ppapi/proxy/ppapi_command_buffer_proxy.cc +++ b/ppapi/proxy/ppapi_command_buffer_proxy.cc @@ -119,7 +119,6 @@ void PpapiCommandBufferProxy::SetGetBuffer(int32_t transfer_buffer_id) { scoped_refptr<gpu::Buffer> PpapiCommandBufferProxy::CreateTransferBuffer( uint32_t size, int32_t* id, - uint32_t alignment, gpu::TransferBufferAllocationOption option) { *id = -1; diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.h b/ppapi/proxy/ppapi_command_buffer_proxy.h index 403e97dfdcc82..0a8feb3400b4a 100644 --- a/ppapi/proxy/ppapi_command_buffer_proxy.h +++ b/ppapi/proxy/ppapi_command_buffer_proxy.h @@ -55,7 +55,6 @@ class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy : public gpu::CommandBuffer, scoped_refptr<gpu::Buffer> CreateTransferBuffer( uint32_t size, int32_t* id, - uint32_t alignment = 0, gpu::TransferBufferAllocationOption option = gpu::TransferBufferAllocationOption::kLoseContextOnOOM) override; void DestroyTransferBuffer(int32_t id) override;