summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/common
diff options
context:
space:
mode:
Diffstat (limited to 'gpu/command_buffer/common')
-rw-r--r--gpu/command_buffer/common/cmd_buffer_common.h29
-rw-r--r--gpu/command_buffer/common/constants.h15
2 files changed, 41 insertions, 3 deletions
diff --git a/gpu/command_buffer/common/cmd_buffer_common.h b/gpu/command_buffer/common/cmd_buffer_common.h
index e8bcd43..80d1e28 100644
--- a/gpu/command_buffer/common/cmd_buffer_common.h
+++ b/gpu/command_buffer/common/cmd_buffer_common.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -157,6 +157,7 @@ namespace cmd {
OP(SetBucketDataImmediate) /* 9 */ \
OP(GetBucketSize) /* 10 */ \
OP(GetBucketData) /* 11 */ \
+ OP(YieldScheduler) /* 12 */ \
// Common commands.
enum CommandId {
@@ -641,6 +642,32 @@ COMPILE_ASSERT(offsetof(GetBucketData, shared_memory_id) == 16,
COMPILE_ASSERT(offsetof(GetBucketData, shared_memory_offset) == 20,
Offsetof_GetBucketData_shared_memory_offset_not_20);
+// A Yield command. Hints the scheduler that this is a good point to update the
+// state and schedule other command buffers.
+struct YieldScheduler {
+ typedef YieldScheduler ValueType;
+ static const CommandId kCmdId = kYieldScheduler;
+ static const cmd::ArgFlags kArgFlags = cmd::kFixed;
+
+ void SetHeader() {
+ header.SetCmd<ValueType>();
+ }
+
+ void Init() {
+ SetHeader();
+ }
+ static void* Set(void* cmd) {
+ static_cast<ValueType*>(cmd)->Init();
+ return NextCmdAddress<ValueType>(cmd);
+ }
+
+ CommandHeader header;
+};
+
+COMPILE_ASSERT(sizeof(YieldScheduler) == 4, Sizeof_YieldScheduler_is_not_4);
+COMPILE_ASSERT(offsetof(YieldScheduler, header) == 0,
+ Offsetof_YieldScheduler_header_not_0);
+
} // namespace cmd
#pragma pack(pop)
diff --git a/gpu/command_buffer/common/constants.h b/gpu/command_buffer/common/constants.h
index ca1d5a8..3b06cad 100644
--- a/gpu/command_buffer/common/constants.h
+++ b/gpu/command_buffer/common/constants.h
@@ -26,12 +26,23 @@ namespace error {
// This is not an error. It is returned by WaitLatch when it is blocked.
// When blocked, the context will not reschedule itself until another
// context executes a SetLatch command.
- kWaiting
+ kWaiting,
+
+ // This is not an error either. It just hints the scheduler that it can exit
+ // its loop, update state, and schedule other command buffers.
+ kYield
};
// Return true if the given error code is an actual error.
inline bool IsError(Error error) {
- return (error != kNoError && error != kWaiting);
+ switch (error) {
+ case kNoError:
+ case kWaiting:
+ case kYield:
+ return false;
+ default:
+ return true;
+ }
}
}