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

Side by Side Diff: gpu/command_buffer/common/sync_token.cc

Issue 1394543003: Added SyncToken command buffer trait to help with IPC messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "gpu/command_buffer/common/sync_token.h"
6
7 #include <string.h>
8
9 #include "base/logging.h"
10 #include "base/rand_util.h"
11
12 namespace gpu {
13
14 namespace {
15
16 struct SyncTokenInternal {
17 CommandBufferNamespace namespace_id;
18 uint64_t command_buffer_id;
19 uint64_t release_count;
20
21 bool operator<(const SyncTokenInternal& other) const {
22 // TODO(dyen): Once all our compilers support c++11, we can replace this
23 // long list of comparisons with std::tie().
24 return (namespace_id < other.namespace_id) ||
25 ((namespace_id == other.namespace_id) &&
26 ((command_buffer_id < other.command_buffer_id) ||
27 ((command_buffer_id == other.command_buffer_id) &&
28 (release_count < other.release_count))));
29 }
30 };
31
32 static_assert(sizeof(SyncTokenInternal) <= GL_SYNC_TOKEN_SIZE_CHROMIUM,
33 "SyncTokenInternal must not exceed GL_SYNC_TOKEN_SIZE_CHROMIUM");
34 static_assert(sizeof(SyncToken) == GL_SYNC_TOKEN_SIZE_CHROMIUM,
35 "No additional members other than data are allowed in SyncToken");
36
37 } // namespace
38
39 SyncToken::SyncToken() {
40 memset(data, 0, sizeof(data));
41 }
42
43 SyncToken::SyncToken(CommandBufferNamespace namespace_id,
44 uint64_t command_buffer_id,
45 uint64_t release_count) {
46 memset(data, 0, sizeof(data));
47 SetData(namespace_id, command_buffer_id, release_count);
48 }
49
50 CommandBufferNamespace SyncToken::GetNamespaceId() const {
51 return reinterpret_cast<const SyncTokenInternal*>(data)->namespace_id;
52 }
53
54 uint64_t SyncToken::GetCommandBufferId() const {
55 return reinterpret_cast<const SyncTokenInternal*>(data)->command_buffer_id;
56 }
57
58 uint64_t SyncToken::GetReleaseCount() const {
59 return reinterpret_cast<const SyncTokenInternal*>(data)->release_count;
60 }
61
62 void SyncToken::SetData(CommandBufferNamespace namespace_id,
63 uint64_t command_buffer_id,
64 uint64_t release_count) {
65 SyncTokenInternal* sync_token_internal =
66 reinterpret_cast<SyncTokenInternal*>(data);
piman 2015/10/10 00:40:55 I think because SyncToken::data is not guaranteed
67 sync_token_internal->namespace_id = namespace_id;
68 sync_token_internal->command_buffer_id = command_buffer_id;
69 sync_token_internal->release_count = release_count;
70 }
71
72 bool SyncToken::operator<(const SyncToken& other) const {
73 const SyncTokenInternal* sync_token_internal =
74 reinterpret_cast<const SyncTokenInternal*>(data);
75 const SyncTokenInternal* other_sync_token_internal =
76 reinterpret_cast<const SyncTokenInternal*>(other.data);
77
78 return *sync_token_internal < *other_sync_token_internal;
79 }
80
81 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/sync_token.h ('k') | gpu/command_buffer/service/in_process_command_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698