Revert "Add memory alignment parameter to gpu::Buffer"
This reverts commit 2b034ff051
.
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}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
19258eb7cc
commit
00d34c8c94
cc
paint
test
tiles
gpu
command_buffer
client
buffer_tracker_unittest.ccclient_discardable_manager_unittest.ccclient_test_helper.ccclient_test_helper.hcommand_buffer_direct_locked.cccommand_buffer_direct_locked.hmapped_memory.cctransfer_buffer.cctransfer_buffer_unittest.cc
common
service
ipc
ppapi/proxy
@ -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());
|
||||
|
@ -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);
|
||||
|
@ -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_; }
|
||||
|
@ -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(),
|
||||
|
@ -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 {
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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());
|
||||
|
@ -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))
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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_);
|
||||
|
@ -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;
|
||||
|
@ -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(_))
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user