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

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

Issue 268063002: Remove command_buffer/common/types.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 7 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 | Annotate | Revision Log
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 defines the GLES2 command buffer commands. 5 // This file defines the GLES2 command buffer commands.
6 6
7 #ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_ 7 #ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_
8 #define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_ 8 #define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_
9 9
10 10
11 #include <KHR/khrplatform.h> 11 #include <KHR/khrplatform.h>
12 12
13 #include <stdint.h>
13 #include <string.h> 14 #include <string.h>
14 15
15 #include "base/atomicops.h" 16 #include "base/atomicops.h"
17 #include "base/macros.h"
16 #include "gpu/command_buffer/common/bitfield_helpers.h" 18 #include "gpu/command_buffer/common/bitfield_helpers.h"
17 #include "gpu/command_buffer/common/cmd_buffer_common.h" 19 #include "gpu/command_buffer/common/cmd_buffer_common.h"
18 #include "gpu/command_buffer/common/gles2_cmd_ids.h" 20 #include "gpu/command_buffer/common/gles2_cmd_ids.h"
19 #include "gpu/command_buffer/common/types.h"
20 21
21 // GL types are forward declared to avoid including the GL headers. The problem 22 // GL types are forward declared to avoid including the GL headers. The problem
22 // is determining which GL headers to include from code that is common to the 23 // is determining which GL headers to include from code that is common to the
23 // client and service sides (GLES2 or one of several GL implementations). 24 // client and service sides (GLES2 or one of several GL implementations).
24 typedef unsigned int GLenum; 25 typedef unsigned int GLenum;
25 typedef unsigned int GLbitfield; 26 typedef unsigned int GLbitfield;
26 typedef unsigned int GLuint; 27 typedef unsigned int GLuint;
27 typedef int GLint; 28 typedef int GLint;
28 typedef int GLsizei; 29 typedef int GLsizei;
29 typedef unsigned char GLboolean; 30 typedef unsigned char GLboolean;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 struct SizedResult { 77 struct SizedResult {
77 typedef T Type; 78 typedef T Type;
78 79
79 T* GetData() { 80 T* GetData() {
80 return static_cast<T*>(static_cast<void*>(&data)); 81 return static_cast<T*>(static_cast<void*>(&data));
81 } 82 }
82 83
83 // Returns the total size in bytes of the SizedResult for a given number of 84 // Returns the total size in bytes of the SizedResult for a given number of
84 // results including the size field. 85 // results including the size field.
85 static size_t ComputeSize(size_t num_results) { 86 static size_t ComputeSize(size_t num_results) {
86 return sizeof(T) * num_results + sizeof(uint32); // NOLINT 87 return sizeof(T) * num_results + sizeof(uint32_t); // NOLINT
87 } 88 }
88 89
89 // Returns the total size in bytes of the SizedResult for a given size of 90 // Returns the total size in bytes of the SizedResult for a given size of
90 // results. 91 // results.
91 static size_t ComputeSizeFromBytes(size_t size_of_result_in_bytes) { 92 static size_t ComputeSizeFromBytes(size_t size_of_result_in_bytes) {
92 return size_of_result_in_bytes + sizeof(uint32); // NOLINT 93 return size_of_result_in_bytes + sizeof(uint32_t); // NOLINT
93 } 94 }
94 95
95 // Returns the maximum number of results for a given buffer size. 96 // Returns the maximum number of results for a given buffer size.
96 static uint32 ComputeMaxResults(size_t size_of_buffer) { 97 static uint32_t ComputeMaxResults(size_t size_of_buffer) {
97 return (size_of_buffer >= sizeof(uint32)) ? 98 return (size_of_buffer >= sizeof(uint32_t)) ?
98 ((size_of_buffer - sizeof(uint32)) / sizeof(T)) : 0; // NOLINT 99 ((size_of_buffer - sizeof(uint32_t)) / sizeof(T)) : 0; // NOLINT
99 } 100 }
100 101
101 // Set the size for a given number of results. 102 // Set the size for a given number of results.
102 void SetNumResults(size_t num_results) { 103 void SetNumResults(size_t num_results) {
103 size = sizeof(T) * num_results; // NOLINT 104 size = sizeof(T) * num_results; // NOLINT
104 } 105 }
105 106
106 // Get the number of elements in the result 107 // Get the number of elements in the result
107 int32 GetNumResults() const { 108 int32_t GetNumResults() const {
108 return size / sizeof(T); // NOLINT 109 return size / sizeof(T); // NOLINT
109 } 110 }
110 111
111 // Copy the result. 112 // Copy the result.
112 void CopyResult(void* dst) const { 113 void CopyResult(void* dst) const {
113 memcpy(dst, &data, size); 114 memcpy(dst, &data, size);
114 } 115 }
115 116
116 uint32 size; // in bytes. 117 uint32_t size; // in bytes.
117 int32 data; // this is just here to get an offset. 118 int32_t data; // this is just here to get an offset.
118 }; 119 };
119 120
120 COMPILE_ASSERT(sizeof(SizedResult<int8>) == 8, SizedResult_size_not_8); 121 COMPILE_ASSERT(sizeof(SizedResult<int8_t>) == 8, SizedResult_size_not_8);
121 COMPILE_ASSERT(offsetof(SizedResult<int8>, size) == 0, 122 COMPILE_ASSERT(offsetof(SizedResult<int8_t>, size) == 0,
122 OffsetOf_SizedResult_size_not_0); 123 OffsetOf_SizedResult_size_not_0);
123 COMPILE_ASSERT(offsetof(SizedResult<int8>, data) == 4, 124 COMPILE_ASSERT(offsetof(SizedResult<int8_t>, data) == 4,
124 OffsetOf_SizedResult_data_not_4); 125 OffsetOf_SizedResult_data_not_4);
125 126
126 // The data for one attrib or uniform from GetProgramInfoCHROMIUM. 127 // The data for one attrib or uniform from GetProgramInfoCHROMIUM.
127 struct ProgramInput { 128 struct ProgramInput {
128 uint32 type; // The type (GL_VEC3, GL_MAT3, GL_SAMPLER_2D, etc. 129 uint32_t type; // The type (GL_VEC3, GL_MAT3, GL_SAMPLER_2D, etc.
129 int32 size; // The size (how big the array is for uniforms) 130 int32_t size; // The size (how big the array is for uniforms)
130 uint32 location_offset; // offset from ProgramInfoHeader to 'size' locations 131 uint32_t location_offset; // offset from ProgramInfoHeader to 'size'
131 // for uniforms, 1 for attribs. 132 // locations for uniforms, 1 for attribs.
132 uint32 name_offset; // offset from ProgrmaInfoHeader to start of name. 133 uint32_t name_offset; // offset from ProgrmaInfoHeader to start of name.
133 uint32 name_length; // length of the name. 134 uint32_t name_length; // length of the name.
134 }; 135 };
135 136
136 // The format of the bucket filled out by GetProgramInfoCHROMIUM 137 // The format of the bucket filled out by GetProgramInfoCHROMIUM
137 struct ProgramInfoHeader { 138 struct ProgramInfoHeader {
138 uint32 link_status; 139 uint32_t link_status;
139 uint32 num_attribs; 140 uint32_t num_attribs;
140 uint32 num_uniforms; 141 uint32_t num_uniforms;
141 // ProgramInput inputs[num_attribs + num_uniforms]; 142 // ProgramInput inputs[num_attribs + num_uniforms];
142 }; 143 };
143 144
144 // The format of QuerySync used by EXT_occlusion_query_boolean 145 // The format of QuerySync used by EXT_occlusion_query_boolean
145 struct QuerySync { 146 struct QuerySync {
146 void Reset() { 147 void Reset() {
147 process_count = 0; 148 process_count = 0;
148 result = 0; 149 result = 0;
149 } 150 }
150 151
151 base::subtle::Atomic32 process_count; 152 base::subtle::Atomic32 process_count;
152 uint64 result; 153 uint64_t result;
153 }; 154 };
154 155
155 struct AsyncUploadSync { 156 struct AsyncUploadSync {
156 void Reset() { 157 void Reset() {
157 base::subtle::Release_Store(&async_upload_token, 0); 158 base::subtle::Release_Store(&async_upload_token, 0);
158 } 159 }
159 160
160 void SetAsyncUploadToken(uint32 token) { 161 void SetAsyncUploadToken(uint32_t token) {
161 DCHECK_NE(token, 0u); 162 DCHECK_NE(token, 0u);
162 base::subtle::Release_Store(&async_upload_token, token); 163 base::subtle::Release_Store(&async_upload_token, token);
163 } 164 }
164 165
165 bool HasAsyncUploadTokenPassed(uint32 token) { 166 bool HasAsyncUploadTokenPassed(uint32_t token) {
166 DCHECK_NE(token, 0u); 167 DCHECK_NE(token, 0u);
167 uint32_t current_token = base::subtle::Acquire_Load(&async_upload_token); 168 uint32_t current_token = base::subtle::Acquire_Load(&async_upload_token);
168 return (current_token - token < 0x80000000); 169 return (current_token - token < 0x80000000);
169 } 170 }
170 171
171 base::subtle::Atomic32 async_upload_token; 172 base::subtle::Atomic32 async_upload_token;
172 }; 173 };
173 174
174 COMPILE_ASSERT(sizeof(ProgramInput) == 20, ProgramInput_size_not_20); 175 COMPILE_ASSERT(sizeof(ProgramInput) == 20, ProgramInput_size_not_20);
175 COMPILE_ASSERT(offsetof(ProgramInput, type) == 0, 176 COMPILE_ASSERT(offsetof(ProgramInput, type) == 0,
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 CommandHeader header; 460 CommandHeader header;
460 }; 461 };
461 462
462 #pragma pack(pop) 463 #pragma pack(pop)
463 464
464 } // namespace cmd 465 } // namespace cmd
465 } // namespace gles2 466 } // namespace gles2
466 } // namespace gpu 467 } // namespace gpu
467 468
468 #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_ 469 #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698