Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Unified Diff: gpu/command_buffer/client/cmd_buffer_helper.h

Issue 2550583002: gpu: Thread-safe command buffer state lookup. (Closed)
Patch Set: jbauman's review Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/client/client_test_helper.cc ('k') | gpu/command_buffer/client/cmd_buffer_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/client/cmd_buffer_helper.h
diff --git a/gpu/command_buffer/client/cmd_buffer_helper.h b/gpu/command_buffer/client/cmd_buffer_helper.h
index 0c0edddfd7bab70bcf9d026f5db2f93f99593a23..3ea507f897547e1c42a587f1c3c604e669cab47f 100644
--- a/gpu/command_buffer/client/cmd_buffer_helper.h
+++ b/gpu/command_buffer/client/cmd_buffer_helper.h
@@ -102,11 +102,7 @@ class GPU_EXPORT CommandBufferHelper
// Returns true if the token has passed.
// Parameters:
// the value of the token to check whether it has passed
- bool HasTokenPassed(int32_t token) const {
- if (token > token_)
- return true; // we wrapped
- return last_token_read() >= token;
- }
+ bool HasTokenPassed(int32_t token);
// Waits until the token of a particular value has passed through the command
// stream (i.e. commands inserted before that token have been executed).
@@ -179,12 +175,6 @@ class GPU_EXPORT CommandBufferHelper
return data;
}
- int32_t last_token_read() const { return command_buffer_->GetLastToken(); }
-
- int32_t get_offset() const {
- return command_buffer_->GetLastState().get_offset;
- }
-
// Common Commands
void Noop(uint32_t skip_count) {
cmd::Noop* cmd = GetImmediateCmdSpace<cmd::Noop>(
@@ -215,10 +205,7 @@ class GPU_EXPORT CommandBufferHelper
uint32_t shared_memory_offset) {
cmd::SetBucketData* cmd = GetCmdSpace<cmd::SetBucketData>();
if (cmd) {
- cmd->Init(bucket_id,
- offset,
- size,
- shared_memory_id,
+ cmd->Init(bucket_id, offset, size, shared_memory_id,
shared_memory_offset);
}
}
@@ -243,12 +230,8 @@ class GPU_EXPORT CommandBufferHelper
uint32_t data_memory_offset) {
cmd::GetBucketStart* cmd = GetCmdSpace<cmd::GetBucketStart>();
if (cmd) {
- cmd->Init(bucket_id,
- result_memory_id,
- result_memory_offset,
- data_memory_size,
- data_memory_id,
- data_memory_offset);
+ cmd->Init(bucket_id, result_memory_id, result_memory_offset,
+ data_memory_size, data_memory_id, data_memory_offset);
}
}
@@ -259,17 +242,12 @@ class GPU_EXPORT CommandBufferHelper
uint32_t shared_memory_offset) {
cmd::GetBucketData* cmd = GetCmdSpace<cmd::GetBucketData>();
if (cmd) {
- cmd->Init(bucket_id,
- offset,
- size,
- shared_memory_id,
+ cmd->Init(bucket_id, offset, size, shared_memory_id,
shared_memory_offset);
}
}
- CommandBuffer* command_buffer() const {
- return command_buffer_;
- }
+ CommandBuffer* command_buffer() const { return command_buffer_; }
scoped_refptr<Buffer> get_ring_buffer() const { return ring_buffer_; }
@@ -277,13 +255,9 @@ class GPU_EXPORT CommandBufferHelper
void FreeRingBuffer();
- bool HaveRingBuffer() const {
- return ring_buffer_id_ != -1;
- }
+ bool HaveRingBuffer() const { return ring_buffer_id_ != -1; }
- bool usable () const {
- return usable_;
- }
+ bool usable() const { return usable_; }
void ClearUsable() {
usable_ = false;
@@ -296,11 +270,6 @@ class GPU_EXPORT CommandBufferHelper
base::trace_event::ProcessMemoryDump* pmd) override;
private:
- // Returns the number of available entries (they may not be contiguous).
- int32_t AvailableEntries() {
- return (get_offset() - put_ - 1 + total_entry_count_) % total_entry_count_;
- }
-
void CalcImmediateEntries(int waiting_count);
bool AllocateRingBuffer();
void FreeResources();
@@ -316,6 +285,10 @@ class GPU_EXPORT CommandBufferHelper
int32_t GetTotalFreeEntriesNoWaiting() const;
+ // Updates |cached_get_offset_|, |cached_last_token_read_| and |context_lost_|
+ // from given command buffer state.
+ void UpdateCachedState(const CommandBuffer::State& state);
+
CommandBuffer* command_buffer_;
int32_t ring_buffer_id_;
int32_t ring_buffer_size_;
@@ -326,7 +299,8 @@ class GPU_EXPORT CommandBufferHelper
int32_t token_;
int32_t put_;
int32_t last_put_sent_;
- int32_t last_barrier_put_sent_;
+ int32_t cached_last_token_read_;
+ int32_t cached_get_offset_;
#if defined(CMD_HELPER_PERIODIC_FLUSH_CHECK)
int commands_issued_;
« no previous file with comments | « gpu/command_buffer/client/client_test_helper.cc ('k') | gpu/command_buffer/client/cmd_buffer_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698