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

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

Issue 434063: Merged in recent changes to command buffer code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years 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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 // This is here because service side code must include the system's version of 10 // This is here because service side code must include the system's version of
(...skipping 11 matching lines...) Expand all
22 #include "gpu/command_buffer/common/types.h" 22 #include "gpu/command_buffer/common/types.h"
23 #include "gpu/command_buffer/common/bitfield_helpers.h" 23 #include "gpu/command_buffer/common/bitfield_helpers.h"
24 #include "gpu/command_buffer/common/cmd_buffer_common.h" 24 #include "gpu/command_buffer/common/cmd_buffer_common.h"
25 #include "gpu/command_buffer/common/gles2_cmd_ids.h" 25 #include "gpu/command_buffer/common/gles2_cmd_ids.h"
26 26
27 namespace command_buffer { 27 namespace command_buffer {
28 namespace gles2 { 28 namespace gles2 {
29 29
30 #include "gpu/command_buffer/common/gles2_cmd_format_autogen.h" 30 #include "gpu/command_buffer/common/gles2_cmd_format_autogen.h"
31 31
32 // These are hand written commands.
33 // TODO(gman): Attempt to make these auto-generated.
34
35 struct GetAttribLocation {
36 typedef GetAttribLocation ValueType;
37 static const CommandId kCmdId = kGetAttribLocation;
38 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
39
40 static uint32 ComputeSize() {
41 return static_cast<uint32>(sizeof(ValueType)); // NOLINT
42 }
43
44 void SetHeader() {
45 header.SetCmd<ValueType>();
46 }
47
48 void Init(
49 GLuint _program, uint32 _name_shm_id, uint32 _name_shm_offset,
50 uint32 _location_shm_id, uint32 _location_shm_offset,
51 uint32 _data_size) {
52 SetHeader();
53 program = _program;
54 name_shm_id = _name_shm_id;
55 name_shm_offset = _name_shm_offset;
56 location_shm_id = _location_shm_id;
57 location_shm_offset = _location_shm_offset;
58 data_size = _data_size;
59 }
60
61 void* Set(
62 void* cmd, GLuint _program, uint32 _name_shm_id, uint32 _name_shm_offset,
63 uint32 _location_shm_id, uint32 _location_shm_offset,
64 uint32 _data_size) {
65 static_cast<ValueType*>(
66 cmd)->Init(
67 _program, _name_shm_id, _name_shm_offset, _location_shm_id,
68 _location_shm_offset, _data_size);
69 return NextCmdAddress<ValueType>(cmd);
70 }
71
72 command_buffer::CommandHeader header;
73 uint32 program;
74 uint32 name_shm_id;
75 uint32 name_shm_offset;
76 uint32 location_shm_id;
77 uint32 location_shm_offset;
78 uint32 data_size;
79 };
80
81 COMPILE_ASSERT(sizeof(GetAttribLocation) == 28,
82 Sizeof_GetAttribLocation_is_not_28);
83 COMPILE_ASSERT(offsetof(GetAttribLocation, header) == 0,
84 OffsetOf_GetAttribLocation_header_not_0);
85 COMPILE_ASSERT(offsetof(GetAttribLocation, program) == 4,
86 OffsetOf_GetAttribLocation_program_not_4);
87 COMPILE_ASSERT(offsetof(GetAttribLocation, name_shm_id) == 8,
88 OffsetOf_GetAttribLocation_name_shm_id_not_8);
89 COMPILE_ASSERT(offsetof(GetAttribLocation, name_shm_offset) == 12,
90 OffsetOf_GetAttribLocation_name_shm_offset_not_12);
91 COMPILE_ASSERT(offsetof(GetAttribLocation, location_shm_id) == 16,
92 OffsetOf_GetAttribLocation_location_shm_id_not_16);
93 COMPILE_ASSERT(offsetof(GetAttribLocation, location_shm_offset) == 20,
94 OffsetOf_GetAttribLocation_location_shm_offset_not_20);
95 COMPILE_ASSERT(offsetof(GetAttribLocation, data_size) == 24,
96 OffsetOf_GetAttribLocation_data_size_not_24);
97
98 struct GetAttribLocationImmediate {
99 typedef GetAttribLocationImmediate ValueType;
100 static const CommandId kCmdId = kGetAttribLocationImmediate;
101 static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN;
102
103 static uint32 ComputeDataSize(const char* s) {
104 return strlen(s);
105 }
106
107 static uint32 ComputeSize(const char* s) {
108 return static_cast<uint32>(sizeof(ValueType) + ComputeDataSize(s));
109 }
110
111 void SetHeader(const char* s) {
112 header.SetCmdByTotalSize<ValueType>(ComputeSize(s));
113 }
114
115 void Init(
116 GLuint _program, const char* _name,
117 uint32 _location_shm_id, uint32 _location_shm_offset) {
118 SetHeader(_name);
119 program = _program;
120 location_shm_id = _location_shm_id;
121 location_shm_offset = _location_shm_offset;
122 data_size = ComputeDataSize(_name);
123 memcpy(ImmediateDataAddress(this), _name, data_size);
124 }
125
126 void* Set(
127 void* cmd, GLuint _program, const char* _name,
128 uint32 _location_shm_id, uint32 _location_shm_offset) {
129 uint32 total_size = ComputeSize(_name);
130 static_cast<ValueType*>(
131 cmd)->Init(_program, _name, _location_shm_id, _location_shm_offset);
132 return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size);
133 }
134
135 command_buffer::CommandHeader header;
136 uint32 program;
137 uint32 location_shm_id;
138 uint32 location_shm_offset;
139 uint32 data_size;
140 };
141
142 COMPILE_ASSERT(sizeof(GetAttribLocationImmediate) == 20,
143 Sizeof_GetAttribLocationImmediate_is_not_20);
144 COMPILE_ASSERT(offsetof(GetAttribLocationImmediate, header) == 0,
145 OffsetOf_GetAttribLocationImmediate_header_not_0);
146 COMPILE_ASSERT(offsetof(GetAttribLocationImmediate, program) == 4,
147 OffsetOf_GetAttribLocationImmediate_program_not_4);
148 COMPILE_ASSERT(offsetof(GetAttribLocationImmediate, location_shm_id) == 8,
149 OffsetOf_GetAttribLocationImmediate_location_shm_id_not_8);
150 COMPILE_ASSERT(offsetof(GetAttribLocationImmediate, location_shm_offset) == 12,
151 OffsetOf_GetAttribLocationImmediate_location_shm_offset_not_12);
152 COMPILE_ASSERT(offsetof(GetAttribLocationImmediate, data_size) == 16,
153 OffsetOf_GetAttribLocationImmediate_data_size_not_16);
154
155 struct GetUniformLocation {
156 typedef GetUniformLocation ValueType;
157 static const CommandId kCmdId = kGetUniformLocation;
158 static const cmd::ArgFlags kArgFlags = cmd::kFixed;
159
160 static uint32 ComputeSize() {
161 return static_cast<uint32>(sizeof(ValueType)); // NOLINT
162 }
163
164 void SetHeader() {
165 header.SetCmd<ValueType>();
166 }
167
168 void Init(
169 GLuint _program, uint32 _name_shm_id, uint32 _name_shm_offset,
170 uint32 _location_shm_id, uint32 _location_shm_offset,
171 uint32 _data_size) {
172 SetHeader();
173 program = _program;
174 name_shm_id = _name_shm_id;
175 name_shm_offset = _name_shm_offset;
176 location_shm_id = _location_shm_id;
177 location_shm_offset = _location_shm_offset;
178 data_size = _data_size;
179 }
180
181 void* Set(
182 void* cmd, GLuint _program, uint32 _name_shm_id, uint32 _name_shm_offset,
183 uint32 _location_shm_id, uint32 _location_shm_offset,
184 uint32 _data_size) {
185 static_cast<ValueType*>(
186 cmd)->Init(
187 _program, _name_shm_id, _name_shm_offset, _location_shm_id,
188 _location_shm_offset, _data_size);
189 return NextCmdAddress<ValueType>(cmd);
190 }
191
192 command_buffer::CommandHeader header;
193 uint32 program;
194 uint32 name_shm_id;
195 uint32 name_shm_offset;
196 uint32 location_shm_id;
197 uint32 location_shm_offset;
198 uint32 data_size;
199 };
200
201 COMPILE_ASSERT(sizeof(GetUniformLocation) == 28,
202 Sizeof_GetUniformLocation_is_not_28);
203 COMPILE_ASSERT(offsetof(GetUniformLocation, header) == 0,
204 OffsetOf_GetUniformLocation_header_not_0);
205 COMPILE_ASSERT(offsetof(GetUniformLocation, program) == 4,
206 OffsetOf_GetUniformLocation_program_not_4);
207 COMPILE_ASSERT(offsetof(GetUniformLocation, name_shm_id) == 8,
208 OffsetOf_GetUniformLocation_name_shm_id_not_8);
209 COMPILE_ASSERT(offsetof(GetUniformLocation, name_shm_offset) == 12,
210 OffsetOf_GetUniformLocation_name_shm_offset_not_12);
211 COMPILE_ASSERT(offsetof(GetUniformLocation, location_shm_id) == 16,
212 OffsetOf_GetUniformLocation_location_shm_id_not_16);
213 COMPILE_ASSERT(offsetof(GetUniformLocation, location_shm_offset) == 20,
214 OffsetOf_GetUniformLocation_location_shm_offset_not_20);
215 COMPILE_ASSERT(offsetof(GetUniformLocation, data_size) == 24,
216 OffsetOf_GetUniformLocation_data_size_not_24);
217
218 struct GetUniformLocationImmediate {
219 typedef GetUniformLocationImmediate ValueType;
220 static const CommandId kCmdId = kGetUniformLocationImmediate;
221 static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN;
222
223 static uint32 ComputeDataSize(const char* s) {
224 return strlen(s);
225 }
226
227 static uint32 ComputeSize(const char* s) {
228 return static_cast<uint32>(sizeof(ValueType) + ComputeDataSize(s));
229 }
230
231 void SetHeader(const char* s) {
232 header.SetCmdByTotalSize<ValueType>(ComputeSize(s));
233 }
234
235 void Init(
236 GLuint _program, const char* _name,
237 uint32 _location_shm_id, uint32 _location_shm_offset) {
238 SetHeader(_name);
239 program = _program;
240 location_shm_id = _location_shm_id;
241 location_shm_offset = _location_shm_offset;
242 data_size = ComputeDataSize(_name);
243 memcpy(ImmediateDataAddress(this), _name, data_size);
244 }
245
246 void* Set(
247 void* cmd, GLuint _program, const char* _name,
248 uint32 _location_shm_id, uint32 _location_shm_offset) {
249 uint32 total_size = ComputeSize(_name);
250 static_cast<ValueType*>(
251 cmd)->Init(_program, _name, _location_shm_id, _location_shm_offset);
252 return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size);
253 }
254
255 command_buffer::CommandHeader header;
256 uint32 program;
257 uint32 location_shm_id;
258 uint32 location_shm_offset;
259 uint32 data_size;
260 };
261
262 COMPILE_ASSERT(sizeof(GetUniformLocationImmediate) == 20,
263 Sizeof_GetUniformLocationImmediate_is_not_20);
264 COMPILE_ASSERT(offsetof(GetUniformLocationImmediate, header) == 0,
265 OffsetOf_GetUniformLocationImmediate_header_not_0);
266 COMPILE_ASSERT(offsetof(GetUniformLocationImmediate, program) == 4,
267 OffsetOf_GetUniformLocationImmediate_program_not_4);
268 COMPILE_ASSERT(offsetof(GetUniformLocationImmediate, location_shm_id) == 8,
269 OffsetOf_GetUniformLocationImmediate_location_shm_id_not_8);
270 COMPILE_ASSERT(
271 offsetof(GetUniformLocationImmediate, location_shm_offset) == 12,
272 OffsetOf_GetUniformLocationImmediate_location_shm_offset_not_12);
273 COMPILE_ASSERT(offsetof(GetUniformLocationImmediate, data_size) == 16,
274 OffsetOf_GetUniformLocationImmediate_data_size_not_16);
275
276
32 } // namespace gles2 277 } // namespace gles2
33 } // namespace command_buffer 278 } // namespace command_buffer
34 279
35 #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H 280 #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H
36 281
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation_autogen.h ('k') | gpu/command_buffer/common/gles2_cmd_format.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698