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

Side by Side Diff: gpu/command_buffer/common/gles2_cmd_utils.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 is here so other GLES2 related files can have a common set of 5 // This file is here so other GLES2 related files can have a common set of
6 // includes where appropriate. 6 // includes where appropriate.
7 7
8 #ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_ 8 #ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_
9 #define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_ 9 #define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 inline bool SafeAddInt32(int32_t a, int32_t b, int32_t* dst) { 50 inline bool SafeAddInt32(int32_t a, int32_t b, int32_t* dst) {
51 DCHECK(dst); 51 DCHECK(dst);
52 base::CheckedNumeric<int32_t> checked = a; 52 base::CheckedNumeric<int32_t> checked = a;
53 checked += b; 53 checked += b;
54 *dst = checked.ValueOrDefault(0); 54 *dst = checked.ValueOrDefault(0);
55 return checked.IsValid(); 55 return checked.IsValid();
56 } 56 }
57 57
58 // Returns the address of the first byte after a struct. 58 // Returns the address of the first byte after a struct.
59 template <typename T> 59 template <typename T>
60 const void* AddressAfterStruct(const T& pod) { 60 const volatile void* AddressAfterStruct(const volatile T& pod) {
61 return reinterpret_cast<const uint8_t*>(&pod) + sizeof(pod); 61 return reinterpret_cast<const volatile uint8_t*>(&pod) + sizeof(pod);
62 } 62 }
63 63
64 // Returns the address of the frst byte after the struct or NULL if size > 64 // Returns the address of the frst byte after the struct or NULL if size >
65 // immediate_data_size. 65 // immediate_data_size.
66 template <typename RETURN_TYPE, typename COMMAND_TYPE> 66 template <typename RETURN_TYPE, typename COMMAND_TYPE>
67 RETURN_TYPE GetImmediateDataAs(const COMMAND_TYPE& pod, 67 RETURN_TYPE GetImmediateDataAs(const volatile COMMAND_TYPE& pod,
68 uint32_t size, 68 uint32_t size,
69 uint32_t immediate_data_size) { 69 uint32_t immediate_data_size) {
70 return (size <= immediate_data_size) 70 return (size <= immediate_data_size)
71 ? static_cast<RETURN_TYPE>( 71 ? static_cast<RETURN_TYPE>(
72 const_cast<void*>(AddressAfterStruct(pod))) 72 const_cast<volatile void*>(AddressAfterStruct(pod)))
73 : NULL; 73 : NULL;
74 } 74 }
75 75
76 struct GLES2_UTILS_EXPORT PixelStoreParams { 76 struct GLES2_UTILS_EXPORT PixelStoreParams {
77 PixelStoreParams() 77 PixelStoreParams()
78 : alignment(4), 78 : alignment(4),
79 row_length(0), 79 row_length(0),
80 image_height(0), 80 image_height(0),
81 skip_pixels(0), 81 skip_pixels(0),
82 skip_rows(0), 82 skip_rows(0),
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 bool should_use_native_gmb_for_backbuffer; 327 bool should_use_native_gmb_for_backbuffer;
328 328
329 ContextType context_type; 329 ContextType context_type;
330 }; 330 };
331 331
332 } // namespace gles2 332 } // namespace gles2
333 } // namespace gpu 333 } // namespace gpu
334 334
335 #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_ 335 #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_
336 336
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_format_autogen.h ('k') | gpu/command_buffer/common/mailbox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698