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

Side by Side Diff: gpu/command_buffer/common/cmd_buffer_common.h

Issue 2275203002: Make command buffer commands and immediate data volatile (Closed)
Patch Set: std::copy->const_cast+memcpy Created 4 years, 3 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file contains the common parts of command buffer formats. 5 // This file contains the common parts of command buffer formats.
6 6
7 #ifndef GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ 7 #ifndef GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_
8 #define GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ 8 #define GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_
9 9
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 // Sets the header by a size in bytes. 74 // Sets the header by a size in bytes.
75 template <typename T> 75 template <typename T>
76 void SetCmdByTotalSize(uint32_t size_in_bytes) { 76 void SetCmdByTotalSize(uint32_t size_in_bytes) {
77 static_assert(T::kArgFlags == cmd::kAtLeastN, 77 static_assert(T::kArgFlags == cmd::kAtLeastN,
78 "T::kArgFlags should equal cmd::kAtLeastN"); 78 "T::kArgFlags should equal cmd::kAtLeastN");
79 DCHECK_GE(size_in_bytes, sizeof(T)); // NOLINT 79 DCHECK_GE(size_in_bytes, sizeof(T)); // NOLINT
80 Init(T::kCmdId, ComputeNumEntries(size_in_bytes)); 80 Init(T::kCmdId, ComputeNumEntries(size_in_bytes));
81 } 81 }
82
83 static CommandHeader FromVolatile(const volatile CommandHeader& other) {
84 // const_cast is safe because the copy constructor is trivial.
85 return const_cast<const CommandHeader&>(other);
86 }
82 }; 87 };
83 88
84 static_assert(sizeof(CommandHeader) == 4, 89 static_assert(sizeof(CommandHeader) == 4,
85 "size of CommandHeader should equal 4"); 90 "size of CommandHeader should equal 4");
86 91
87 // Union that defines possible command buffer entries. 92 // Union that defines possible command buffer entries.
88 union CommandBufferEntry { 93 union CommandBufferEntry {
89 CommandHeader value_header; 94 CommandHeader value_header;
90 uint32_t value_uint32; 95 uint32_t value_uint32;
91 int32_t value_int32; 96 int32_t value_int32;
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 "offset of GetBucketData.shared_memory_offset should be 20"); 555 "offset of GetBucketData.shared_memory_offset should be 20");
551 556
552 } // namespace cmd 557 } // namespace cmd
553 558
554 #pragma pack(pop) 559 #pragma pack(pop)
555 560
556 } // namespace gpu 561 } // namespace gpu
557 562
558 #endif // GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ 563 #endif // GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_
559 564
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/ring_buffer_test.cc ('k') | gpu/command_buffer/common/gles2_cmd_format_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698