Commit 792420d5 authored by piman's avatar piman Committed by Commit bot

command buffers: correctly handle Flush(num_entries)

CommandBufferService should not accept put == num_entries, the client must
wraparound to 0 (CommandBufferHelper does).
CommandParser wraps to 0 and never sets get_ == num_entries, so
CommandParser::IsEmpty would never become true.

A test should have caught that but unfortunately it confused buffer size and
number of entries. This fixes it.

BUG=None
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2304813002
Cr-Commit-Position: refs/heads/master@{#417211}
parent 702552c9
...@@ -87,7 +87,7 @@ void CommandBufferService::WaitForGetOffsetInRange(int32_t start, int32_t end) { ...@@ -87,7 +87,7 @@ void CommandBufferService::WaitForGetOffsetInRange(int32_t start, int32_t end) {
} }
void CommandBufferService::Flush(int32_t put_offset) { void CommandBufferService::Flush(int32_t put_offset) {
if (put_offset < 0 || put_offset > num_entries_) { if (put_offset < 0 || put_offset >= num_entries_) {
error_ = gpu::error::kOutOfBounds; error_ = gpu::error::kOutOfBounds;
return; return;
} }
......
...@@ -45,7 +45,8 @@ class CommandBufferServiceTest : public testing::Test { ...@@ -45,7 +45,8 @@ class CommandBufferServiceTest : public testing::Test {
int32_t GetError() { return command_buffer_->GetLastState().error; } int32_t GetError() { return command_buffer_->GetLastState().error; }
bool Initialize(size_t size) { bool Initialize(size_t entries) {
size_t size = entries * sizeof(CommandBufferEntry);
int32_t id; int32_t id;
command_buffer_->CreateTransferBuffer(size, &id); command_buffer_->CreateTransferBuffer(size, &id);
EXPECT_GT(id, 0); EXPECT_GT(id, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment