OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "base/cross/bits.h" | 36 #include "base/cross/bits.h" |
37 #include "command_buffer/common/cross/gapi_interface.h" | 37 #include "command_buffer/common/cross/gapi_interface.h" |
38 #include "command_buffer/service/cross/gapi_decoder.h" | 38 #include "command_buffer/service/cross/gapi_decoder.h" |
39 #include "command_buffer/service/cross/cmd_buffer_engine.h" | 39 #include "command_buffer/service/cross/cmd_buffer_engine.h" |
40 | 40 |
41 namespace o3d { | 41 namespace o3d { |
42 namespace command_buffer { | 42 namespace command_buffer { |
43 | 43 |
44 namespace { | 44 namespace { |
45 | 45 |
| 46 // Returns the address of the first byte after a struct. |
46 template <typename T> | 47 template <typename T> |
47 const void* AddressAfterStruct(const T& pod) { | 48 const void* AddressAfterStruct(const T& pod) { |
48 return reinterpret_cast<const uint8*>(&pod) + sizeof(pod); | 49 return reinterpret_cast<const uint8*>(&pod) + sizeof(pod); |
49 } | 50 } |
50 | 51 |
| 52 // Returns the size in bytes of the data of an Immediate command, a command with |
| 53 // its data inline in the command buffer. |
51 template <typename T> | 54 template <typename T> |
52 unsigned int ImmediateSize(uint32 arg_count, const T& pod) { | 55 unsigned int ImmediateDataSize(uint32 arg_count, const T& pod) { |
53 return (arg_count - sizeof(pod) / sizeof(uint32)) * sizeof(uint32); | 56 return static_cast<unsigned int>( |
| 57 (arg_count + 1 - ComputeNumEntries(sizeof(pod))) * |
| 58 sizeof(CommandBufferEntry)); // NOLINT |
54 } | 59 } |
55 | 60 |
56 // TODO(gman): Remove this. | 61 // A struct to hold info about each command. |
57 CommandBufferEntry* TempHack(const void* foo) { | |
58 return reinterpret_cast<CommandBufferEntry*>(const_cast<void*>(foo)); | |
59 } | |
60 | |
61 struct CommandInfo { | 62 struct CommandInfo { |
62 int arg_flags; | 63 int arg_flags; // How to handle the arguments for this command |
63 int arg_count; | 64 int arg_count; // How many arguments are expected for this command. |
64 }; | 65 }; |
65 | 66 |
| 67 // A table of CommandInfo for all the commands. |
66 const CommandInfo g_command_info[] = { | 68 const CommandInfo g_command_info[] = { |
67 #define O3D_COMMAND_BUFFER_CMD_OP(name) { \ | 69 #define O3D_COMMAND_BUFFER_CMD_OP(name) { \ |
68 cmd::name::kArgFlags, \ | 70 cmd::name::kArgFlags, \ |
69 sizeof(cmd::name) / sizeof(uint32), }, \ | 71 sizeof(cmd::name) / sizeof(CommandBufferEntry) - 1, }, /* NOLINT */ \ |
70 | 72 |
71 O3D_COMMAND_BUFFER_CMDS | 73 O3D_COMMAND_BUFFER_CMDS |
72 | 74 |
73 #undef O3D_COMMAND_BUFFER_CMD_OP | 75 #undef O3D_COMMAND_BUFFER_CMD_OP |
74 }; | 76 }; |
75 | 77 |
76 } // anonymous namespace. | 78 } // anonymous namespace. |
77 | 79 |
78 // Decode command with its arguments, and call the corresponding GAPIInterface | 80 // Decode command with its arguments, and call the corresponding GAPIInterface |
79 // method. | 81 // method. |
80 // Note: args is a pointer to the command buffer. As such, it could be changed | 82 // Note: args is a pointer to the command buffer. As such, it could be changed |
81 // by a (malicious) client at any time, so if validation has to happen, it | 83 // by a (malicious) client at any time, so if validation has to happen, it |
82 // should operate on a copy of them. | 84 // should operate on a copy of them. |
83 BufferSyncInterface::ParseError GAPIDecoder::DoCommand( | 85 BufferSyncInterface::ParseError GAPIDecoder::DoCommand( |
84 unsigned int command, | 86 unsigned int command, |
85 unsigned int arg_count, | 87 unsigned int arg_count, |
86 const void* args) { | 88 const void* cmd_data) { |
87 if (command < arraysize(g_command_info)) { | 89 if (command < arraysize(g_command_info)) { |
88 const CommandInfo& info = g_command_info[command]; | 90 const CommandInfo& info = g_command_info[command]; |
89 » unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count); | 91 unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count); |
90 if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) || | 92 if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) || |
91 (info.arg_flags == cmd::kAtLeastN && arg_count > info_arg_count)) { | 93 (info.arg_flags == cmd::kAtLeastN && arg_count > info_arg_count)) { |
92 switch (command) { | 94 switch (command) { |
93 #define O3D_COMMAND_BUFFER_CMD_OP(name) \ | 95 #define O3D_COMMAND_BUFFER_CMD_OP(name) \ |
94 case cmd::name::kCmdId: \ | 96 case cmd::name::kCmdId: \ |
95 return Handle_ ## name( \ | 97 return Handle ## name( \ |
96 arg_count, \ | 98 arg_count, \ |
97 *static_cast<const cmd::name*>(args)); \ | 99 *static_cast<const cmd::name*>(cmd_data)); \ |
98 | 100 |
99 O3D_COMMAND_BUFFER_CMDS | 101 O3D_COMMAND_BUFFER_CMDS |
100 | 102 |
101 #undef O3D_COMMAND_BUFFER_CMD_OP | 103 #undef O3D_COMMAND_BUFFER_CMD_OP |
102 } | 104 } |
103 } else { | 105 } else { |
104 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 106 return BufferSyncInterface::kParseInvalidArguments; |
105 } | 107 } |
106 } | 108 } |
107 return BufferSyncInterface::PARSE_UNKNOWN_COMMAND; | 109 return BufferSyncInterface::kParseUnknownCommand; |
108 } | |
109 | |
110 | |
111 // Decodes the SET_VERTEX_INPUT command. | |
112 BufferSyncInterface::ParseError GAPIDecoder::DecodeSetVertexInput( | |
113 unsigned int arg_count, | |
114 CommandBufferEntry *args) { | |
115 namespace cmd = set_vertex_input_cmd; | |
116 if (arg_count != 5) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
117 ResourceID vertex_struct_id = args[0].value_uint32; | |
118 unsigned int input_index = args[1].value_uint32; | |
119 ResourceID vertex_buffer_id = args[2].value_uint32; | |
120 unsigned int offset = args[3].value_uint32; | |
121 unsigned int type_stride_semantic = args[4].value_uint32; | |
122 unsigned int semantic_index = cmd::SemanticIndex::Get(type_stride_semantic); | |
123 unsigned int semantic = cmd::Semantic::Get(type_stride_semantic); | |
124 unsigned int type = cmd::Type::Get(type_stride_semantic); | |
125 unsigned int stride = cmd::Stride::Get(type_stride_semantic); | |
126 if (semantic >= vertex_struct::NUM_SEMANTICS || | |
127 type >= vertex_struct::NUM_TYPES || stride == 0) | |
128 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
129 return gapi_->SetVertexInput(vertex_struct_id, input_index, vertex_buffer_id, | |
130 offset, stride, | |
131 static_cast<vertex_struct::Type>(type), | |
132 static_cast<vertex_struct::Semantic>(semantic), | |
133 semantic_index); | |
134 } | |
135 | |
136 // Decodes the CREATE_TEXTURE_2D command. | |
137 BufferSyncInterface::ParseError GAPIDecoder::DecodeCreateTexture2D( | |
138 unsigned int arg_count, | |
139 CommandBufferEntry *args) { | |
140 if (arg_count == 3) { | |
141 namespace cmd = create_texture_2d_cmd; | |
142 unsigned int id = args[0].value_uint32; | |
143 unsigned int width_height = args[1].value_uint32; | |
144 unsigned int levels_format_flags = args[2].value_uint32; | |
145 unsigned int width = cmd::Width::Get(width_height); | |
146 unsigned int height = cmd::Height::Get(width_height); | |
147 unsigned int levels = cmd::Levels::Get(levels_format_flags); | |
148 unsigned int unused = cmd::Unused::Get(levels_format_flags); | |
149 unsigned int format = cmd::Format::Get(levels_format_flags); | |
150 unsigned int flags = cmd::Flags::Get(levels_format_flags); | |
151 unsigned int max_levels = | |
152 1 + base::bits::Log2Ceiling(std::max(width, height)); | |
153 if ((width == 0) || (height == 0) || (levels > max_levels) || | |
154 (unused != 0) || (format >= texture::NUM_FORMATS)) | |
155 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
156 if (levels == 0) levels = max_levels; | |
157 bool enable_render_surfaces = !!flags; | |
158 return gapi_->CreateTexture2D(id, width, height, levels, | |
159 static_cast<texture::Format>(format), flags, | |
160 enable_render_surfaces); | |
161 } else { | |
162 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
163 } | |
164 } | |
165 | |
166 // Decodes the CREATE_TEXTURE_3D command. | |
167 BufferSyncInterface::ParseError GAPIDecoder::DecodeCreateTexture3D( | |
168 unsigned int arg_count, | |
169 CommandBufferEntry *args) { | |
170 if (arg_count == 4) { | |
171 namespace cmd = create_texture_3d_cmd; | |
172 unsigned int id = args[0].value_uint32; | |
173 unsigned int width_height = args[1].value_uint32; | |
174 unsigned int depth_unused = args[2].value_uint32; | |
175 unsigned int levels_format_flags = args[3].value_uint32; | |
176 unsigned int width = cmd::Width::Get(width_height); | |
177 unsigned int height = cmd::Height::Get(width_height); | |
178 unsigned int depth = cmd::Depth::Get(depth_unused); | |
179 unsigned int unused1 = cmd::Unused1::Get(depth_unused); | |
180 unsigned int levels = cmd::Levels::Get(levels_format_flags); | |
181 unsigned int unused2 = cmd::Unused2::Get(levels_format_flags); | |
182 unsigned int format = cmd::Format::Get(levels_format_flags); | |
183 unsigned int flags = cmd::Flags::Get(levels_format_flags); | |
184 unsigned int max_levels = | |
185 1 + base::bits::Log2Ceiling(std::max(depth, std::max(width, height))); | |
186 if ((width == 0) || (height == 0) || (depth == 0) || | |
187 (levels > max_levels) || (unused1 != 0) || (unused2 != 0) || | |
188 (format >= texture::NUM_FORMATS)) | |
189 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
190 if (levels == 0) levels = max_levels; | |
191 bool enable_render_surfaces = !!flags; | |
192 return gapi_->CreateTexture3D(id, width, height, depth, levels, | |
193 static_cast<texture::Format>(format), flags, | |
194 enable_render_surfaces); | |
195 } else { | |
196 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
197 } | |
198 } | |
199 | |
200 // Decodes the CREATE_TEXTURE_CUBE command. | |
201 BufferSyncInterface::ParseError GAPIDecoder::DecodeCreateTextureCube( | |
202 unsigned int arg_count, | |
203 CommandBufferEntry *args) { | |
204 if (arg_count == 3) { | |
205 namespace cmd = create_texture_cube_cmd; | |
206 unsigned int id = args[0].value_uint32; | |
207 unsigned int side_unused = args[1].value_uint32; | |
208 unsigned int levels_format_flags = args[2].value_uint32; | |
209 unsigned int side = cmd::Side::Get(side_unused); | |
210 unsigned int unused1 = cmd::Unused1::Get(side_unused); | |
211 unsigned int levels = cmd::Levels::Get(levels_format_flags); | |
212 unsigned int unused2 = cmd::Unused2::Get(levels_format_flags); | |
213 unsigned int format = cmd::Format::Get(levels_format_flags); | |
214 unsigned int flags = cmd::Flags::Get(levels_format_flags); | |
215 unsigned int max_levels = 1 + base::bits::Log2Ceiling(side); | |
216 if ((side == 0) || (levels > max_levels) || (unused1 != 0) || | |
217 (unused2 != 0) || (format >= texture::NUM_FORMATS)) | |
218 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
219 if (levels == 0) levels = max_levels; | |
220 bool enable_render_surfaces = !!flags; | |
221 return gapi_->CreateTextureCube(id, side, levels, | |
222 static_cast<texture::Format>(format), | |
223 flags, enable_render_surfaces); | |
224 } else { | |
225 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
226 } | |
227 } | |
228 | |
229 // Decodes the SET_TEXTURE_DATA command. | |
230 BufferSyncInterface::ParseError GAPIDecoder::DecodeSetTextureData( | |
231 unsigned int arg_count, | |
232 CommandBufferEntry *args) { | |
233 if (arg_count == 10) { | |
234 namespace cmd = set_texture_data_cmd; | |
235 unsigned int id = args[0].value_uint32; | |
236 unsigned int x_y = args[1].value_uint32; | |
237 unsigned int width_height = args[2].value_uint32; | |
238 unsigned int z_depth = args[3].value_uint32; | |
239 unsigned int level_face = args[4].value_uint32; | |
240 unsigned int row_pitch = args[5].value_uint32; | |
241 unsigned int slice_pitch = args[6].value_uint32; | |
242 unsigned int size = args[7].value_uint32; | |
243 unsigned int shm_id = args[8].value_uint32; | |
244 unsigned int offset = args[9].value_uint32; | |
245 unsigned int x = cmd::X::Get(x_y); | |
246 unsigned int y = cmd::Y::Get(x_y); | |
247 unsigned int width = cmd::Width::Get(width_height); | |
248 unsigned int height = cmd::Height::Get(width_height); | |
249 unsigned int z = cmd::Z::Get(z_depth); | |
250 unsigned int depth = cmd::Depth::Get(z_depth); | |
251 unsigned int level = cmd::Level::Get(level_face); | |
252 unsigned int face = cmd::Face::Get(level_face); | |
253 unsigned int unused = cmd::Unused::Get(level_face); | |
254 const void *data = GetAddressAndCheckSize(shm_id, offset, size); | |
255 if (face >= 6 || unused != 0 || !data) | |
256 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
257 return gapi_->SetTextureData(id, x, y, z, width, height, depth, level, | |
258 static_cast<texture::Face>(face), row_pitch, | |
259 slice_pitch, size, data); | |
260 | |
261 } else { | |
262 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
263 } | |
264 } | |
265 | |
266 // Decodes the SET_TEXTURE_DATA_IMMEDIATE command. | |
267 BufferSyncInterface::ParseError GAPIDecoder::DecodeSetTextureDataImmediate( | |
268 unsigned int arg_count, | |
269 CommandBufferEntry *args) { | |
270 if (arg_count > 8) { | |
271 namespace cmd = set_texture_data_immediate_cmd; | |
272 unsigned int id = args[0].value_uint32; | |
273 unsigned int x_y = args[1].value_uint32; | |
274 unsigned int width_height = args[2].value_uint32; | |
275 unsigned int z_depth = args[3].value_uint32; | |
276 unsigned int level_face = args[4].value_uint32; | |
277 unsigned int row_pitch = args[5].value_uint32; | |
278 unsigned int slice_pitch = args[6].value_uint32; | |
279 unsigned int size = args[7].value_uint32; | |
280 unsigned int x = cmd::X::Get(x_y); | |
281 unsigned int y = cmd::Y::Get(x_y); | |
282 unsigned int width = cmd::Width::Get(width_height); | |
283 unsigned int height = cmd::Height::Get(width_height); | |
284 unsigned int z = cmd::Z::Get(z_depth); | |
285 unsigned int depth = cmd::Depth::Get(z_depth); | |
286 unsigned int level = cmd::Level::Get(level_face); | |
287 unsigned int face = cmd::Face::Get(level_face); | |
288 unsigned int unused = cmd::Unused::Get(level_face); | |
289 if (face >= 6 || unused != 0 || | |
290 size > (arg_count - 5) * sizeof(args[0])) | |
291 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
292 return gapi_->SetTextureData(id, x, y, z, width, height, depth, level, | |
293 static_cast<texture::Face>(face), row_pitch, | |
294 slice_pitch, size, args + 8); | |
295 } else { | |
296 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
297 } | |
298 } | |
299 | |
300 // Decodes the GET_TEXTURE_DATA command. | |
301 BufferSyncInterface::ParseError GAPIDecoder::DecodeGetTextureData( | |
302 unsigned int arg_count, | |
303 CommandBufferEntry *args) { | |
304 if (arg_count == 10) { | |
305 namespace cmd = get_texture_data_cmd; | |
306 unsigned int id = args[0].value_uint32; | |
307 unsigned int x_y = args[1].value_uint32; | |
308 unsigned int width_height = args[2].value_uint32; | |
309 unsigned int z_depth = args[3].value_uint32; | |
310 unsigned int level_face = args[4].value_uint32; | |
311 unsigned int row_pitch = args[5].value_uint32; | |
312 unsigned int slice_pitch = args[6].value_uint32; | |
313 unsigned int size = args[7].value_uint32; | |
314 unsigned int shm_id = args[8].value_uint32; | |
315 unsigned int offset = args[9].value_uint32; | |
316 unsigned int x = cmd::X::Get(x_y); | |
317 unsigned int y = cmd::Y::Get(x_y); | |
318 unsigned int width = cmd::Width::Get(width_height); | |
319 unsigned int height = cmd::Height::Get(width_height); | |
320 unsigned int z = cmd::Z::Get(z_depth); | |
321 unsigned int depth = cmd::Depth::Get(z_depth); | |
322 unsigned int level = cmd::Level::Get(level_face); | |
323 unsigned int face = cmd::Face::Get(level_face); | |
324 unsigned int unused = cmd::Unused::Get(level_face); | |
325 void *data = GetAddressAndCheckSize(shm_id, offset, size); | |
326 if (face >= 6 || unused != 0 || !data) | |
327 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
328 return gapi_->GetTextureData(id, x, y, z, width, height, depth, level, | |
329 static_cast<texture::Face>(face), row_pitch, | |
330 slice_pitch, size, data); | |
331 | |
332 } else { | |
333 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
334 } | |
335 } | |
336 | |
337 // Decodes the SET_SAMPLER_STATES command. | |
338 BufferSyncInterface::ParseError GAPIDecoder::DecodeSetSamplerStates( | |
339 unsigned int arg_count, | |
340 CommandBufferEntry *args) { | |
341 namespace cmd = set_sampler_states; | |
342 if (arg_count != 2) | |
343 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
344 ResourceID id = args[0].value_uint32; | |
345 Uint32 arg = args[1].value_uint32; | |
346 if (cmd::Unused::Get(arg) != 0) | |
347 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
348 unsigned int address_u_value = cmd::AddressingU::Get(arg); | |
349 unsigned int address_v_value = cmd::AddressingV::Get(arg); | |
350 unsigned int address_w_value = cmd::AddressingW::Get(arg); | |
351 unsigned int mag_filter_value = cmd::MagFilter::Get(arg); | |
352 unsigned int min_filter_value = cmd::MinFilter::Get(arg); | |
353 unsigned int mip_filter_value = cmd::MipFilter::Get(arg); | |
354 unsigned int max_anisotropy = cmd::MaxAnisotropy::Get(arg); | |
355 if (address_u_value >= sampler::NUM_ADDRESSING_MODE || | |
356 address_v_value >= sampler::NUM_ADDRESSING_MODE || | |
357 address_w_value >= sampler::NUM_ADDRESSING_MODE || | |
358 mag_filter_value >= sampler::NUM_FILTERING_MODE || | |
359 min_filter_value >= sampler::NUM_FILTERING_MODE || | |
360 mip_filter_value >= sampler::NUM_FILTERING_MODE || | |
361 mag_filter_value == sampler::NONE || | |
362 min_filter_value == sampler::NONE || | |
363 max_anisotropy == 0) { | |
364 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
365 } | |
366 gapi_->SetSamplerStates( | |
367 id, | |
368 static_cast<sampler::AddressingMode>(address_u_value), | |
369 static_cast<sampler::AddressingMode>(address_v_value), | |
370 static_cast<sampler::AddressingMode>(address_w_value), | |
371 static_cast<sampler::FilteringMode>(mag_filter_value), | |
372 static_cast<sampler::FilteringMode>(min_filter_value), | |
373 static_cast<sampler::FilteringMode>(mip_filter_value), | |
374 max_anisotropy); | |
375 return BufferSyncInterface::PARSE_NO_ERROR; | |
376 } | |
377 | |
378 // Decodes the SET_STENCIL_TEST command. | |
379 BufferSyncInterface::ParseError GAPIDecoder::DecodeSetStencilTest( | |
380 unsigned int arg_count, | |
381 CommandBufferEntry *args) { | |
382 namespace cmd = set_stencil_test; | |
383 if (arg_count != 2) | |
384 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
385 Uint32 arg0 = args[0].value_uint32; | |
386 Uint32 arg1 = args[1].value_uint32; | |
387 if (cmd::Unused0::Get(arg0) != 0 || | |
388 cmd::Unused1::Get(arg1) != 0 || | |
389 cmd::Unused2::Get(arg1) != 0) | |
390 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
391 unsigned int write_mask = cmd::WriteMask::Get(arg0); | |
392 unsigned int compare_mask = cmd::CompareMask::Get(arg0); | |
393 unsigned int ref = cmd::ReferenceValue::Get(arg0); | |
394 bool enable = cmd::Enable::Get(arg0) != 0; | |
395 bool separate_ccw = cmd::SeparateCCW::Get(arg0) != 0; | |
396 gapi_->SetStencilTest(enable, separate_ccw, write_mask, compare_mask, ref, | |
397 arg1); | |
398 return BufferSyncInterface::PARSE_NO_ERROR; | |
399 } | |
400 | |
401 // Decodes the SET_BLENDING command. | |
402 BufferSyncInterface::ParseError GAPIDecoder::DecodeSetBlending( | |
403 unsigned int arg_count, | |
404 CommandBufferEntry *args) { | |
405 namespace cmd = set_blending; | |
406 if (arg_count != 1) | |
407 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
408 Uint32 arg = args[0].value_uint32; | |
409 bool enable = cmd::Enable::Get(arg) != 0; | |
410 bool separate_alpha = cmd::SeparateAlpha::Get(arg) != 0; | |
411 unsigned int color_eq = cmd::ColorEq::Get(arg); | |
412 unsigned int color_src = cmd::ColorSrcFunc::Get(arg); | |
413 unsigned int color_dst = cmd::ColorDstFunc::Get(arg); | |
414 unsigned int alpha_eq = cmd::AlphaEq::Get(arg); | |
415 unsigned int alpha_src = cmd::AlphaSrcFunc::Get(arg); | |
416 unsigned int alpha_dst = cmd::AlphaDstFunc::Get(arg); | |
417 if (cmd::Unused0::Get(arg) != 0 || | |
418 cmd::Unused1::Get(arg) != 0 || | |
419 color_eq >= GAPIInterface::NUM_BLEND_EQ || | |
420 color_src >= GAPIInterface::NUM_BLEND_FUNC || | |
421 color_dst >= GAPIInterface::NUM_BLEND_FUNC || | |
422 alpha_eq >= GAPIInterface::NUM_BLEND_EQ || | |
423 alpha_src >= GAPIInterface::NUM_BLEND_FUNC || | |
424 alpha_dst >= GAPIInterface::NUM_BLEND_FUNC) | |
425 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | |
426 gapi_->SetBlending(enable, | |
427 separate_alpha, | |
428 static_cast<GAPIInterface::BlendEq>(color_eq), | |
429 static_cast<GAPIInterface::BlendFunc>(color_src), | |
430 static_cast<GAPIInterface::BlendFunc>(color_dst), | |
431 static_cast<GAPIInterface::BlendEq>(alpha_eq), | |
432 static_cast<GAPIInterface::BlendFunc>(alpha_src), | |
433 static_cast<GAPIInterface::BlendFunc>(alpha_dst)); | |
434 return BufferSyncInterface::PARSE_NO_ERROR; | |
435 } | 110 } |
436 | 111 |
437 void *GAPIDecoder::GetAddressAndCheckSize(unsigned int shm_id, | 112 void *GAPIDecoder::GetAddressAndCheckSize(unsigned int shm_id, |
438 unsigned int offset, | 113 unsigned int offset, |
439 unsigned int size) { | 114 unsigned int size) { |
440 void * shm_addr = engine_->GetSharedMemoryAddress(shm_id); | 115 void * shm_addr = engine_->GetSharedMemoryAddress(shm_id); |
441 if (!shm_addr) return NULL; | 116 if (!shm_addr) return NULL; |
442 size_t shm_size = engine_->GetSharedMemorySize(shm_id); | 117 size_t shm_size = engine_->GetSharedMemorySize(shm_id); |
443 if (offset + size > shm_size) return NULL; | 118 if (offset + size > shm_size) return NULL; |
444 return static_cast<char *>(shm_addr) + offset; | 119 return static_cast<char *>(shm_addr) + offset; |
445 } | 120 } |
446 | 121 |
447 BufferSyncInterface::ParseError GAPIDecoder::Handle_NOOP( | 122 BufferSyncInterface::ParseError GAPIDecoder::HandleNoop( |
448 uint32 arg_count, | 123 uint32 arg_count, |
449 const cmd::NOOP& args) { | 124 const cmd::Noop& args) { |
450 return BufferSyncInterface::PARSE_NO_ERROR; | 125 return BufferSyncInterface::kParseNoError; |
451 } | 126 } |
452 | 127 |
453 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_TOKEN( | 128 BufferSyncInterface::ParseError GAPIDecoder::HandleSetToken( |
454 uint32 arg_count, | 129 uint32 arg_count, |
455 const cmd::SET_TOKEN& args) { | 130 const cmd::SetToken& args) { |
456 engine_->set_token(args.token); | 131 engine_->set_token(args.token); |
457 return BufferSyncInterface::PARSE_NO_ERROR; | 132 return BufferSyncInterface::kParseNoError; |
458 } | 133 } |
459 | 134 |
460 BufferSyncInterface::ParseError GAPIDecoder::Handle_BEGIN_FRAME( | 135 BufferSyncInterface::ParseError GAPIDecoder::HandleBeginFrame( |
461 uint32 arg_count, | 136 uint32 arg_count, |
462 const cmd::BEGIN_FRAME& args) { | 137 const cmd::BeginFrame& args) { |
463 gapi_->BeginFrame(); | 138 gapi_->BeginFrame(); |
464 return BufferSyncInterface::PARSE_NO_ERROR; | 139 return BufferSyncInterface::kParseNoError; |
465 } | 140 } |
466 | 141 |
467 BufferSyncInterface::ParseError GAPIDecoder::Handle_END_FRAME( | 142 BufferSyncInterface::ParseError GAPIDecoder::HandleEndFrame( |
468 uint32 arg_count, | 143 uint32 arg_count, |
469 const cmd::END_FRAME& args) { | 144 const cmd::EndFrame& args) { |
470 gapi_->EndFrame(); | 145 gapi_->EndFrame(); |
471 return BufferSyncInterface::PARSE_NO_ERROR; | 146 return BufferSyncInterface::kParseNoError; |
472 } | 147 } |
473 | 148 |
474 BufferSyncInterface::ParseError GAPIDecoder::Handle_CLEAR( | 149 BufferSyncInterface::ParseError GAPIDecoder::HandleClear( |
475 uint32 arg_count, | 150 uint32 arg_count, |
476 const cmd::CLEAR& args) { | 151 const cmd::Clear& args) { |
477 // Pull out some values so they can't be changed by another thread after we've | 152 // Pull out some values so they can't be changed by another thread after we've |
478 // validated them. | 153 // validated them. |
479 uint32 buffers = args.buffers; | 154 uint32 buffers = args.buffers; |
480 if (buffers & ~GAPIInterface::ALL_BUFFERS) | 155 if (buffers & ~GAPIInterface::ALL_BUFFERS) |
481 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 156 return BufferSyncInterface::kParseInvalidArguments; |
482 RGBA rgba; | 157 RGBA rgba; |
483 rgba.red = args.red; | 158 rgba.red = args.red; |
484 rgba.green = args.green; | 159 rgba.green = args.green; |
485 rgba.blue = args.blue; | 160 rgba.blue = args.blue; |
486 rgba.alpha = args.alpha; | 161 rgba.alpha = args.alpha; |
487 gapi_->Clear(buffers, rgba, args.depth, args.stencil); | 162 gapi_->Clear(buffers, rgba, args.depth, args.stencil); |
488 return BufferSyncInterface::PARSE_NO_ERROR; | 163 return BufferSyncInterface::kParseNoError; |
489 } | 164 } |
490 | 165 |
491 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_VIEWPORT( | 166 BufferSyncInterface::ParseError GAPIDecoder::HandleSetViewport( |
492 uint32 arg_count, | 167 uint32 arg_count, |
493 const cmd::SET_VIEWPORT& args) { | 168 const cmd::SetViewport& args) { |
494 gapi_->SetViewport(args.left, | 169 gapi_->SetViewport(args.left, |
495 args.top, | 170 args.top, |
496 args.width, | 171 args.width, |
497 args.height, | 172 args.height, |
498 args.z_min, | 173 args.z_min, |
499 args.z_max); | 174 args.z_max); |
500 return BufferSyncInterface::PARSE_NO_ERROR; | 175 return BufferSyncInterface::kParseNoError; |
501 } | 176 } |
502 | 177 |
503 BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_VERTEX_BUFFER( | 178 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateVertexBuffer( |
504 uint32 arg_count, | 179 uint32 arg_count, |
505 const cmd::CREATE_VERTEX_BUFFER& args) { | 180 const cmd::CreateVertexBuffer& args) { |
506 return gapi_->CreateVertexBuffer(args.id, args.size, args.flags); | 181 return gapi_->CreateVertexBuffer(args.id, args.size, args.flags); |
507 } | 182 } |
508 | 183 |
509 BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_VERTEX_BUFFER( | 184 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyVertexBuffer( |
510 uint32 arg_count, | 185 uint32 arg_count, |
511 const cmd::DESTROY_VERTEX_BUFFER& args) { | 186 const cmd::DestroyVertexBuffer& args) { |
512 return gapi_->DestroyVertexBuffer(args.id); | 187 return gapi_->DestroyVertexBuffer(args.id); |
513 } | 188 } |
514 | 189 |
515 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_VERTEX_BUFFER_DATA_IMMED
IATE( | 190 BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexBufferDataImmediate( |
516 uint32 arg_count, | 191 uint32 arg_count, |
517 const cmd::SET_VERTEX_BUFFER_DATA_IMMEDIATE& args) { | 192 const cmd::SetVertexBufferDataImmediate& args) { |
518 return gapi_->SetVertexBufferData(args.id, args.offset, | 193 return gapi_->SetVertexBufferData(args.id, args.offset, |
519 ImmediateSize(arg_count, args), | 194 ImmediateDataSize(arg_count, args), |
520 AddressAfterStruct(args)); | 195 AddressAfterStruct(args)); |
521 } | 196 } |
522 | 197 |
523 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_VERTEX_BUFFER_DATA( | 198 BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexBufferData( |
524 uint32 arg_count, | 199 uint32 arg_count, |
525 const cmd::SET_VERTEX_BUFFER_DATA& args) { | 200 const cmd::SetVertexBufferData& args) { |
526 // Pull out some values so they can't be changed by another thread after we've | 201 // Pull out some values so they can't be changed by another thread after we've |
527 // validated them. | 202 // validated them. |
528 uint32 size = args.size; | 203 uint32 size = args.size; |
529 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 204 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
530 args.shared_memory.offset, | 205 args.shared_memory.offset, |
531 size); | 206 size); |
532 if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 207 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
533 return gapi_->SetVertexBufferData(args.id, args.offset, size, data); | 208 return gapi_->SetVertexBufferData(args.id, args.offset, size, data); |
534 } | 209 } |
535 | 210 |
536 BufferSyncInterface::ParseError GAPIDecoder::Handle_GET_VERTEX_BUFFER_DATA( | 211 BufferSyncInterface::ParseError GAPIDecoder::HandleGetVertexBufferData( |
537 uint32 arg_count, | 212 uint32 arg_count, |
538 const cmd::GET_VERTEX_BUFFER_DATA& args) { | 213 const cmd::GetVertexBufferData& args) { |
539 // Pull out some values so they can't be changed by another thread after we've | 214 // Pull out some values so they can't be changed by another thread after we've |
540 // validated them. | 215 // validated them. |
541 uint32 size = args.size; | 216 uint32 size = args.size; |
542 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 217 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
543 args.shared_memory.offset, | 218 args.shared_memory.offset, |
544 size); | 219 size); |
545 if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 220 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
546 return gapi_->GetVertexBufferData(args.id, args.offset, size, data); | 221 return gapi_->GetVertexBufferData(args.id, args.offset, size, data); |
547 } | 222 } |
548 | 223 |
549 BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_INDEX_BUFFER( | 224 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateIndexBuffer( |
550 uint32 arg_count, | 225 uint32 arg_count, |
551 const cmd::CREATE_INDEX_BUFFER& args) { | 226 const cmd::CreateIndexBuffer& args) { |
552 return gapi_->CreateIndexBuffer(args.id, args.size, args.flags); | 227 return gapi_->CreateIndexBuffer(args.id, args.size, args.flags); |
553 } | 228 } |
554 | 229 |
555 BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_INDEX_BUFFER( | 230 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyIndexBuffer( |
556 uint32 arg_count, | 231 uint32 arg_count, |
557 const cmd::DESTROY_INDEX_BUFFER& args) { | 232 const cmd::DestroyIndexBuffer& args) { |
558 return gapi_->DestroyIndexBuffer(args.id); | 233 return gapi_->DestroyIndexBuffer(args.id); |
559 } | 234 } |
560 | 235 |
561 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_INDEX_BUFFER_DATA_IMMEDI
ATE( | 236 BufferSyncInterface::ParseError GAPIDecoder::HandleSetIndexBufferDataImmediate( |
562 uint32 arg_count, | 237 uint32 arg_count, |
563 const cmd::SET_INDEX_BUFFER_DATA_IMMEDIATE& args) { | 238 const cmd::SetIndexBufferDataImmediate& args) { |
564 return gapi_->SetIndexBufferData(args.id, args.offset, | 239 return gapi_->SetIndexBufferData(args.id, args.offset, |
565 ImmediateSize(arg_count, args), | 240 ImmediateDataSize(arg_count, args), |
566 AddressAfterStruct(args)); | 241 AddressAfterStruct(args)); |
567 } | 242 } |
568 | 243 |
569 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_INDEX_BUFFER_DATA( | 244 BufferSyncInterface::ParseError GAPIDecoder::HandleSetIndexBufferData( |
570 uint32 arg_count, | 245 uint32 arg_count, |
571 const cmd::SET_INDEX_BUFFER_DATA& args) { | 246 const cmd::SetIndexBufferData& args) { |
572 // Pull out some values so they can't be changed by another thread after we've | 247 // Pull out some values so they can't be changed by another thread after we've |
573 // validated them. | 248 // validated them. |
574 uint32 size = args.size; | 249 uint32 size = args.size; |
575 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 250 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
576 args.shared_memory.offset, | 251 args.shared_memory.offset, |
577 size); | 252 size); |
578 if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 253 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
579 return gapi_->SetIndexBufferData(args.id, args.offset, size, data); | 254 return gapi_->SetIndexBufferData(args.id, args.offset, size, data); |
580 } | 255 } |
581 | 256 |
582 BufferSyncInterface::ParseError GAPIDecoder::Handle_GET_INDEX_BUFFER_DATA( | 257 BufferSyncInterface::ParseError GAPIDecoder::HandleGetIndexBufferData( |
583 uint32 arg_count, | 258 uint32 arg_count, |
584 const cmd::GET_INDEX_BUFFER_DATA& args) { | 259 const cmd::GetIndexBufferData& args) { |
585 // Pull out some values so they can't be changed by another thread after we've | 260 // Pull out some values so they can't be changed by another thread after we've |
586 // validated them. | 261 // validated them. |
587 uint32 size = args.size; | 262 uint32 size = args.size; |
588 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 263 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
589 args.shared_memory.offset, | 264 args.shared_memory.offset, |
590 size); | 265 size); |
591 if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 266 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
592 return gapi_->GetIndexBufferData(args.id, args.offset, size, data); | 267 return gapi_->GetIndexBufferData(args.id, args.offset, size, data); |
593 } | 268 } |
594 | 269 |
595 BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_VERTEX_STRUCT( | 270 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateVertexStruct( |
596 uint32 arg_count, | 271 uint32 arg_count, |
597 const cmd::CREATE_VERTEX_STRUCT& args) { | 272 const cmd::CreateVertexStruct& args) { |
598 return gapi_->CreateVertexStruct(args.id, args.input_count); | 273 return gapi_->CreateVertexStruct(args.id, args.input_count); |
599 } | 274 } |
600 | 275 |
601 BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_VERTEX_STRUCT( | 276 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyVertexStruct( |
602 uint32 arg_count, | 277 uint32 arg_count, |
603 const cmd::DESTROY_VERTEX_STRUCT& args) { | 278 const cmd::DestroyVertexStruct& args) { |
604 return gapi_->DestroyVertexStruct(args.id); | 279 return gapi_->DestroyVertexStruct(args.id); |
605 } | 280 } |
606 | 281 |
607 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_VERTEX_INPUT( | 282 BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexInput( |
608 uint32 arg_count, | 283 uint32 arg_count, |
609 const cmd::SET_VERTEX_INPUT& args) { | 284 const cmd::SetVertexInput& args) { |
610 // TODO(gman): fix. | 285 namespace cmd = set_vertex_input_cmd; |
611 return DecodeSetVertexInput(arg_count, TempHack(&args)); | 286 unsigned int type_stride_semantic = args.fixme4; |
612 } | 287 unsigned int semantic_index = cmd::SemanticIndex::Get(type_stride_semantic); |
613 | 288 unsigned int semantic = cmd::Semantic::Get(type_stride_semantic); |
614 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_VERTEX_STRUCT( | 289 unsigned int type = cmd::Type::Get(type_stride_semantic); |
615 uint32 arg_count, | 290 unsigned int stride = cmd::Stride::Get(type_stride_semantic); |
616 const cmd::SET_VERTEX_STRUCT& args) { | 291 if (semantic >= vertex_struct::NUM_SEMANTICS || |
| 292 type >= vertex_struct::NUM_TYPES || stride == 0) |
| 293 return BufferSyncInterface::kParseInvalidArguments; |
| 294 return gapi_->SetVertexInput( |
| 295 args.vertex_struct_id, args.input_index, args.vertex_buffer_id, |
| 296 args.offset, stride, |
| 297 static_cast<vertex_struct::Type>(type), |
| 298 static_cast<vertex_struct::Semantic>(semantic), |
| 299 semantic_index); |
| 300 } |
| 301 |
| 302 BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexStruct( |
| 303 uint32 arg_count, |
| 304 const cmd::SetVertexStruct& args) { |
617 return gapi_->SetVertexStruct(args.id); | 305 return gapi_->SetVertexStruct(args.id); |
618 } | 306 } |
619 | 307 |
620 BufferSyncInterface::ParseError GAPIDecoder::Handle_DRAW( | 308 BufferSyncInterface::ParseError GAPIDecoder::HandleDraw( |
621 uint32 arg_count, | 309 uint32 arg_count, |
622 const cmd::DRAW& args) { | 310 const cmd::Draw& args) { |
623 // Pull out some values so they can't be changed by another thread after we've | 311 // Pull out some values so they can't be changed by another thread after we've |
624 // validated them. | 312 // validated them. |
625 uint32 primitive_type = args.primitive_type; | 313 uint32 primitive_type = args.primitive_type; |
626 if (primitive_type >= GAPIInterface::MAX_PRIMITIVE_TYPE) | 314 if (primitive_type >= GAPIInterface::MAX_PRIMITIVE_TYPE) |
627 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 315 return BufferSyncInterface::kParseInvalidArguments; |
628 return gapi_->Draw( | 316 return gapi_->Draw( |
629 static_cast<GAPIInterface::PrimitiveType>(primitive_type), | 317 static_cast<GAPIInterface::PrimitiveType>(primitive_type), |
630 args.first, args.count); | 318 args.first, args.count); |
631 } | 319 } |
632 | 320 |
633 BufferSyncInterface::ParseError GAPIDecoder::Handle_DRAW_INDEXED( | 321 BufferSyncInterface::ParseError GAPIDecoder::HandleDrawIndexed( |
634 uint32 arg_count, | 322 uint32 arg_count, |
635 const cmd::DRAW_INDEXED& args) { | 323 const cmd::DrawIndexed& args) { |
636 // Pull out some values so they can't be changed by another thread after we've | 324 // Pull out some values so they can't be changed by another thread after we've |
637 // validated them. | 325 // validated them. |
638 uint32 primitive_type = args.primitive_type; | 326 uint32 primitive_type = args.primitive_type; |
639 if (primitive_type >= GAPIInterface::MAX_PRIMITIVE_TYPE) | 327 if (primitive_type >= GAPIInterface::MAX_PRIMITIVE_TYPE) |
640 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 328 return BufferSyncInterface::kParseInvalidArguments; |
641 return gapi_->DrawIndexed( | 329 return gapi_->DrawIndexed( |
642 static_cast<GAPIInterface::PrimitiveType>(primitive_type), | 330 static_cast<GAPIInterface::PrimitiveType>(primitive_type), |
643 args.index_buffer_id, | 331 args.index_buffer_id, |
644 args.first, args.count, args.min_index, args.max_index); | 332 args.first, args.count, args.min_index, args.max_index); |
645 } | 333 } |
646 | 334 |
647 BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_EFFECT( | 335 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateEffect( |
648 uint32 arg_count, | 336 uint32 arg_count, |
649 const cmd::CREATE_EFFECT& args) { | 337 const cmd::CreateEffect& args) { |
650 // Pull out some values so they can't be changed by another thread after we've | 338 // Pull out some values so they can't be changed by another thread after we've |
651 // validated them. | 339 // validated them. |
652 uint32 size = args.size; | 340 uint32 size = args.size; |
653 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 341 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
654 args.shared_memory.offset, | 342 args.shared_memory.offset, |
655 size); | 343 size); |
656 if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 344 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
657 return gapi_->CreateEffect(args.id, size, data); | 345 return gapi_->CreateEffect(args.id, size, data); |
658 } | 346 } |
659 | 347 |
660 BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_EFFECT_IMMEDIATE( | 348 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateEffectImmediate( |
661 uint32 arg_count, | 349 uint32 arg_count, |
662 const cmd::CREATE_EFFECT_IMMEDIATE& args) { | 350 const cmd::CreateEffectImmediate& args) { |
663 // Pull out some values so they can't be changed by another thread after we've | 351 // Pull out some values so they can't be changed by another thread after we've |
664 // validated them. | 352 // validated them. |
665 uint32 size = args.size; | 353 uint32 size = args.size; |
666 if (size > ImmediateSize(arg_count, args)) | 354 uint32 data_size = ImmediateDataSize(arg_count, args); |
667 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 355 if (size > data_size) |
| 356 return BufferSyncInterface::kParseInvalidArguments; |
668 return gapi_->CreateEffect(args.id, size, AddressAfterStruct(args)); | 357 return gapi_->CreateEffect(args.id, size, AddressAfterStruct(args)); |
669 } | 358 } |
670 | 359 |
671 BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_EFFECT( | 360 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyEffect( |
672 uint32 arg_count, | 361 uint32 arg_count, |
673 const cmd::DESTROY_EFFECT& args) { | 362 const cmd::DestroyEffect& args) { |
674 return gapi_->DestroyEffect(args.id); | 363 return gapi_->DestroyEffect(args.id); |
675 } | 364 } |
676 | 365 |
677 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_EFFECT( | 366 BufferSyncInterface::ParseError GAPIDecoder::HandleSetEffect( |
678 uint32 arg_count, | 367 uint32 arg_count, |
679 const cmd::SET_EFFECT& args) { | 368 const cmd::SetEffect& args) { |
680 return gapi_->SetEffect(args.id); | 369 return gapi_->SetEffect(args.id); |
681 } | 370 } |
682 | 371 |
683 BufferSyncInterface::ParseError GAPIDecoder::Handle_GET_PARAM_COUNT( | 372 BufferSyncInterface::ParseError GAPIDecoder::HandleGetParamCount( |
684 uint32 arg_count, | 373 uint32 arg_count, |
685 const cmd::GET_PARAM_COUNT& args) { | 374 const cmd::GetParamCount& args) { |
686 // Pull out some values so they can't be changed by another thread after we've | 375 // Pull out some values so they can't be changed by another thread after we've |
687 // validated them. | 376 // validated them. |
688 uint32 size = args.size; | 377 uint32 size = args.size; |
689 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 378 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
690 args.shared_memory.offset, | 379 args.shared_memory.offset, |
691 size); | 380 size); |
692 if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 381 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
693 return gapi_->GetParamCount(args.id, size, data); | 382 return gapi_->GetParamCount(args.id, size, data); |
694 } | 383 } |
695 | 384 |
696 BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_PARAM( | 385 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateParam( |
697 uint32 arg_count, | 386 uint32 arg_count, |
698 const cmd::CREATE_PARAM& args) { | 387 const cmd::CreateParam& args) { |
699 return gapi_->CreateParam(args.param_id, args.effect_id, args.index); | 388 return gapi_->CreateParam(args.param_id, args.effect_id, args.index); |
700 } | 389 } |
701 | 390 |
702 BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_PARAM_BY_NAME( | 391 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateParamByName( |
703 uint32 arg_count, | 392 uint32 arg_count, |
704 const cmd::CREATE_PARAM_BY_NAME& args) { | 393 const cmd::CreateParamByName& args) { |
705 // Pull out some values so they can't be changed by another thread after we've | 394 // Pull out some values so they can't be changed by another thread after we've |
706 // validated them. | 395 // validated them. |
707 uint32 size = args.size; | 396 uint32 size = args.size; |
708 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 397 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
709 args.shared_memory.offset, | 398 args.shared_memory.offset, |
710 size); | 399 size); |
711 if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 400 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
712 return gapi_->CreateParamByName(args.param_id, args.effect_id, size, | 401 return gapi_->CreateParamByName(args.param_id, args.effect_id, size, |
713 data); | 402 data); |
714 } | 403 } |
715 | 404 |
716 BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_PARAM_BY_NAME_IMMEDIA
TE( | 405 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateParamByNameImmediate( |
717 uint32 arg_count, | 406 uint32 arg_count, |
718 const cmd::CREATE_PARAM_BY_NAME_IMMEDIATE& args) { | 407 const cmd::CreateParamByNameImmediate& args) { |
719 // Pull out some values so they can't be changed by another thread after we've | 408 // Pull out some values so they can't be changed by another thread after we've |
720 // validated them. | 409 // validated them. |
721 uint32 size = args.size; | 410 uint32 size = args.size; |
722 if (size > ImmediateSize(arg_count, args)) | 411 uint32 data_size = ImmediateDataSize(arg_count, args); |
723 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 412 if (size > data_size) |
| 413 return BufferSyncInterface::kParseInvalidArguments; |
724 return gapi_->CreateParamByName(args.param_id, args.effect_id, size, | 414 return gapi_->CreateParamByName(args.param_id, args.effect_id, size, |
725 AddressAfterStruct(args)); | 415 AddressAfterStruct(args)); |
726 } | 416 } |
727 | 417 |
728 BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_PARAM( | 418 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyParam( |
729 uint32 arg_count, | 419 uint32 arg_count, |
730 const cmd::DESTROY_PARAM& args) { | 420 const cmd::DestroyParam& args) { |
731 return gapi_->DestroyParam(args.id); | 421 return gapi_->DestroyParam(args.id); |
732 } | 422 } |
733 | 423 |
734 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_PARAM_DATA( | 424 BufferSyncInterface::ParseError GAPIDecoder::HandleSetParamData( |
735 uint32 arg_count, | 425 uint32 arg_count, |
736 const cmd::SET_PARAM_DATA& args) { | 426 const cmd::SetParamData& args) { |
737 // Pull out some values so they can't be changed by another thread after we've | 427 // Pull out some values so they can't be changed by another thread after we've |
738 // validated them. | 428 // validated them. |
739 uint32 size = args.size; | 429 uint32 size = args.size; |
740 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 430 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
741 args.shared_memory.offset, | 431 args.shared_memory.offset, |
742 size); | 432 size); |
743 if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 433 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
744 return gapi_->SetParamData(args.id, size, data); | 434 return gapi_->SetParamData(args.id, size, data); |
745 } | 435 } |
746 | 436 |
747 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_PARAM_DATA_IMMEDIATE( | 437 BufferSyncInterface::ParseError GAPIDecoder::HandleSetParamDataImmediate( |
748 uint32 arg_count, | 438 uint32 arg_count, |
749 const cmd::SET_PARAM_DATA_IMMEDIATE& args) { | 439 const cmd::SetParamDataImmediate& args) { |
750 // Pull out some values so they can't be changed by another thread after we've | 440 // Pull out some values so they can't be changed by another thread after we've |
751 // validated them. | 441 // validated them. |
752 uint32 size = args.size; | 442 uint32 size = args.size; |
753 if (size > ImmediateSize(arg_count, args)) | 443 uint32 data_size = ImmediateDataSize(arg_count, args); |
754 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 444 if (size > data_size) |
| 445 return BufferSyncInterface::kParseInvalidArguments; |
755 return gapi_->SetParamData(args.id, size, AddressAfterStruct(args)); | 446 return gapi_->SetParamData(args.id, size, AddressAfterStruct(args)); |
756 } | 447 } |
757 | 448 |
758 BufferSyncInterface::ParseError GAPIDecoder::Handle_GET_PARAM_DESC( | 449 BufferSyncInterface::ParseError GAPIDecoder::HandleGetParamDesc( |
759 uint32 arg_count, | 450 uint32 arg_count, |
760 const cmd::GET_PARAM_DESC& args) { | 451 const cmd::GetParamDesc& args) { |
761 // Pull out some values so they can't be changed by another thread after we've | 452 // Pull out some values so they can't be changed by another thread after we've |
762 // validated them. | 453 // validated them. |
763 uint32 size = args.size; | 454 uint32 size = args.size; |
764 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 455 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
765 args.shared_memory.offset, | 456 args.shared_memory.offset, |
766 size); | 457 size); |
767 if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 458 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
768 return gapi_->GetParamDesc(args.id, size, data); | 459 return gapi_->GetParamDesc(args.id, size, data); |
769 } | 460 } |
770 | 461 |
771 BufferSyncInterface::ParseError GAPIDecoder::Handle_GET_STREAM_COUNT( | 462 BufferSyncInterface::ParseError GAPIDecoder::HandleGetStreamCount( |
772 uint32 arg_count, | 463 uint32 arg_count, |
773 const cmd::GET_STREAM_COUNT& args) { | 464 const cmd::GetStreamCount& args) { |
774 // Pull out some values so they can't be changed by another thread after we've | 465 // Pull out some values so they can't be changed by another thread after we've |
775 // validated them. | 466 // validated them. |
776 uint32 size = args.size; | 467 uint32 size = args.size; |
777 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 468 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
778 args.shared_memory.offset, | 469 args.shared_memory.offset, |
779 size); | 470 size); |
780 if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 471 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
781 return gapi_->GetStreamCount(args.id, size, data); | 472 return gapi_->GetStreamCount(args.id, size, data); |
782 } | 473 } |
783 | 474 |
784 BufferSyncInterface::ParseError GAPIDecoder::Handle_GET_STREAM_DESC( | 475 BufferSyncInterface::ParseError GAPIDecoder::HandleGetStreamDesc( |
785 uint32 arg_count, | 476 uint32 arg_count, |
786 const cmd::GET_STREAM_DESC& args) { | 477 const cmd::GetStreamDesc& args) { |
787 // Pull out some values so they can't be changed by another thread after we've | 478 // Pull out some values so they can't be changed by another thread after we've |
788 // validated them. | 479 // validated them. |
789 uint32 size = args.size; | 480 uint32 size = args.size; |
790 void *data = GetAddressAndCheckSize(args.shared_memory.id, | 481 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
791 args.shared_memory.offset, | 482 args.shared_memory.offset, |
792 size); | 483 size); |
793 if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 484 if (!data) return BufferSyncInterface::kParseInvalidArguments; |
794 return gapi_->GetStreamDesc(args.id, args.index, size, data); | 485 return gapi_->GetStreamDesc(args.id, args.index, size, data); |
795 } | 486 } |
796 | 487 |
797 BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_TEXTURE( | 488 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyTexture( |
798 uint32 arg_count, | 489 uint32 arg_count, |
799 const cmd::DESTROY_TEXTURE& args) { | 490 const cmd::DestroyTexture& args) { |
800 return gapi_->DestroyTexture(args.id); | 491 return gapi_->DestroyTexture(args.id); |
801 } | 492 } |
802 | 493 |
803 BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_TEXTURE_2D( | 494 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTexture2d( |
804 uint32 arg_count, | 495 uint32 arg_count, |
805 const cmd::CREATE_TEXTURE_2D& args) { | 496 const cmd::CreateTexture2d& args) { |
806 // TODO(gman): fix. | 497 namespace cmd = create_texture_2d_cmd; |
807 return DecodeCreateTexture2D(arg_count, TempHack(&args)); | 498 unsigned int width_height = args.fixme1; |
808 } | 499 unsigned int levels_format_flags = args.fixme2; |
809 | 500 unsigned int width = cmd::Width::Get(width_height); |
810 BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_TEXTURE_3D( | 501 unsigned int height = cmd::Height::Get(width_height); |
811 uint32 arg_count, | 502 unsigned int levels = cmd::Levels::Get(levels_format_flags); |
812 const cmd::CREATE_TEXTURE_3D& args) { | 503 unsigned int unused = cmd::Unused::Get(levels_format_flags); |
813 // TODO(gman): fix. | 504 unsigned int format = cmd::Format::Get(levels_format_flags); |
814 return DecodeCreateTexture3D(arg_count, TempHack(&args)); | 505 unsigned int flags = cmd::Flags::Get(levels_format_flags); |
815 } | 506 unsigned int max_levels = |
816 | 507 1 + base::bits::Log2Ceiling(std::max(width, height)); |
817 BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_TEXTURE_CUBE( | 508 if ((width == 0) || (height == 0) || (levels > max_levels) || |
818 uint32 arg_count, | 509 (unused != 0) || (format >= texture::NUM_FORMATS)) |
819 const cmd::CREATE_TEXTURE_CUBE& args) { | 510 return BufferSyncInterface::kParseInvalidArguments; |
820 // TODO(gman): fix. | 511 if (levels == 0) levels = max_levels; |
821 return DecodeCreateTextureCube(arg_count, TempHack(&args)); | 512 bool enable_render_surfaces = !!flags; |
822 } | 513 return gapi_->CreateTexture2D(args.texture_id, width, height, levels, |
823 | 514 static_cast<texture::Format>(format), flags, |
824 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_TEXTURE_DATA( | 515 enable_render_surfaces); |
825 uint32 arg_count, | 516 } |
826 const cmd::SET_TEXTURE_DATA& args) { | 517 |
827 // TODO(gman): fix. | 518 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTexture3d( |
828 return DecodeSetTextureData(arg_count, TempHack(&args)); | 519 uint32 arg_count, |
829 } | 520 const cmd::CreateTexture3d& args) { |
830 | 521 namespace cmd = create_texture_3d_cmd; |
831 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_TEXTURE_DATA_IMMEDIATE( | 522 unsigned int width_height = args.fixme1; |
832 uint32 arg_count, | 523 unsigned int depth_unused = args.fixme2; |
833 const cmd::SET_TEXTURE_DATA_IMMEDIATE& args) { | 524 unsigned int levels_format_flags = args.fixme3; |
834 // TODO(gman): fix. | 525 unsigned int width = cmd::Width::Get(width_height); |
835 return DecodeSetTextureDataImmediate(arg_count, TempHack(&args)); | 526 unsigned int height = cmd::Height::Get(width_height); |
836 } | 527 unsigned int depth = cmd::Depth::Get(depth_unused); |
837 | 528 unsigned int unused1 = cmd::Unused1::Get(depth_unused); |
838 BufferSyncInterface::ParseError GAPIDecoder::Handle_GET_TEXTURE_DATA( | 529 unsigned int levels = cmd::Levels::Get(levels_format_flags); |
839 uint32 arg_count, | 530 unsigned int unused2 = cmd::Unused2::Get(levels_format_flags); |
840 const cmd::GET_TEXTURE_DATA& args) { | 531 unsigned int format = cmd::Format::Get(levels_format_flags); |
841 // TODO(gman): fix. | 532 unsigned int flags = cmd::Flags::Get(levels_format_flags); |
842 return DecodeGetTextureData(arg_count, TempHack(&args)); | 533 unsigned int max_levels = |
843 } | 534 1 + base::bits::Log2Ceiling(std::max(depth, std::max(width, height))); |
844 | 535 if ((width == 0) || (height == 0) || (depth == 0) || |
845 BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_SAMPLER( | 536 (levels > max_levels) || (unused1 != 0) || (unused2 != 0) || |
846 uint32 arg_count, | 537 (format >= texture::NUM_FORMATS)) |
847 const cmd::CREATE_SAMPLER& args) { | 538 return BufferSyncInterface::kParseInvalidArguments; |
| 539 if (levels == 0) levels = max_levels; |
| 540 bool enable_render_surfaces = !!flags; |
| 541 return gapi_->CreateTexture3D(args.texture_id, width, height, depth, levels, |
| 542 static_cast<texture::Format>(format), flags, |
| 543 enable_render_surfaces); |
| 544 } |
| 545 |
| 546 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTextureCube( |
| 547 uint32 arg_count, |
| 548 const cmd::CreateTextureCube& args) { |
| 549 namespace cmd = create_texture_cube_cmd; |
| 550 unsigned int side_unused = args.edge_length; |
| 551 unsigned int levels_format_flags = args.fixme2; |
| 552 unsigned int side = cmd::Side::Get(side_unused); |
| 553 unsigned int unused1 = cmd::Unused1::Get(side_unused); |
| 554 unsigned int levels = cmd::Levels::Get(levels_format_flags); |
| 555 unsigned int unused2 = cmd::Unused2::Get(levels_format_flags); |
| 556 unsigned int format = cmd::Format::Get(levels_format_flags); |
| 557 unsigned int flags = cmd::Flags::Get(levels_format_flags); |
| 558 unsigned int max_levels = 1 + base::bits::Log2Ceiling(side); |
| 559 if ((side == 0) || (levels > max_levels) || (unused1 != 0) || |
| 560 (unused2 != 0) || (format >= texture::NUM_FORMATS)) |
| 561 return BufferSyncInterface::kParseInvalidArguments; |
| 562 if (levels == 0) levels = max_levels; |
| 563 bool enable_render_surfaces = !!flags; |
| 564 return gapi_->CreateTextureCube(args.texture_id, side, levels, |
| 565 static_cast<texture::Format>(format), |
| 566 flags, enable_render_surfaces); |
| 567 } |
| 568 |
| 569 BufferSyncInterface::ParseError GAPIDecoder::HandleSetTextureData( |
| 570 uint32 arg_count, |
| 571 const cmd::SetTextureData& args) { |
| 572 namespace cmd = set_texture_data_cmd; |
| 573 unsigned int x_y = args.fixme1; |
| 574 unsigned int width_height = args.fixme2; |
| 575 unsigned int z_depth = args.fixme3; |
| 576 unsigned int level_face = args.fixme4; |
| 577 unsigned int size = args.size; |
| 578 unsigned int x = cmd::X::Get(x_y); |
| 579 unsigned int y = cmd::Y::Get(x_y); |
| 580 unsigned int width = cmd::Width::Get(width_height); |
| 581 unsigned int height = cmd::Height::Get(width_height); |
| 582 unsigned int z = cmd::Z::Get(z_depth); |
| 583 unsigned int depth = cmd::Depth::Get(z_depth); |
| 584 unsigned int level = cmd::Level::Get(level_face); |
| 585 unsigned int face = cmd::Face::Get(level_face); |
| 586 unsigned int unused = cmd::Unused::Get(level_face); |
| 587 const void *data = GetAddressAndCheckSize(args.shared_memory.id, |
| 588 args.shared_memory.offset, size); |
| 589 if (face >= 6 || unused != 0 || !data) |
| 590 return BufferSyncInterface::kParseInvalidArguments; |
| 591 return gapi_->SetTextureData( |
| 592 args.texture_id, x, y, z, width, height, depth, level, |
| 593 static_cast<texture::Face>(face), args.row_pitch, |
| 594 args.slice_pitch, size, data); |
| 595 } |
| 596 |
| 597 BufferSyncInterface::ParseError GAPIDecoder::HandleSetTextureDataImmediate( |
| 598 uint32 arg_count, |
| 599 const cmd::SetTextureDataImmediate& args) { |
| 600 namespace cmd = set_texture_data_immediate_cmd; |
| 601 unsigned int x_y = args.fixme1; |
| 602 unsigned int width_height = args.fixme2; |
| 603 unsigned int z_depth = args.fixme3; |
| 604 unsigned int level_face = args.fixme4; |
| 605 unsigned int size = args.size; |
| 606 unsigned int x = cmd::X::Get(x_y); |
| 607 unsigned int y = cmd::Y::Get(x_y); |
| 608 unsigned int width = cmd::Width::Get(width_height); |
| 609 unsigned int height = cmd::Height::Get(width_height); |
| 610 unsigned int z = cmd::Z::Get(z_depth); |
| 611 unsigned int depth = cmd::Depth::Get(z_depth); |
| 612 unsigned int level = cmd::Level::Get(level_face); |
| 613 unsigned int face = cmd::Face::Get(level_face); |
| 614 unsigned int unused = cmd::Unused::Get(level_face); |
| 615 uint32 data_size = ImmediateDataSize(arg_count, args); |
| 616 if (face >= 6 || unused != 0 || |
| 617 size > data_size) |
| 618 return BufferSyncInterface::kParseInvalidArguments; |
| 619 return gapi_->SetTextureData( |
| 620 args.texture_id, x, y, z, width, height, depth, level, |
| 621 static_cast<texture::Face>(face), args.row_pitch, |
| 622 args.slice_pitch, size, AddressAfterStruct(args)); |
| 623 } |
| 624 |
| 625 BufferSyncInterface::ParseError GAPIDecoder::HandleGetTextureData( |
| 626 uint32 arg_count, |
| 627 const cmd::GetTextureData& args) { |
| 628 namespace cmd = get_texture_data_cmd; |
| 629 unsigned int x_y = args.fixme1; |
| 630 unsigned int width_height = args.fixme2; |
| 631 unsigned int z_depth = args.fixme3; |
| 632 unsigned int level_face = args.fixme4; |
| 633 unsigned int size = args.size; |
| 634 unsigned int x = cmd::X::Get(x_y); |
| 635 unsigned int y = cmd::Y::Get(x_y); |
| 636 unsigned int width = cmd::Width::Get(width_height); |
| 637 unsigned int height = cmd::Height::Get(width_height); |
| 638 unsigned int z = cmd::Z::Get(z_depth); |
| 639 unsigned int depth = cmd::Depth::Get(z_depth); |
| 640 unsigned int level = cmd::Level::Get(level_face); |
| 641 unsigned int face = cmd::Face::Get(level_face); |
| 642 unsigned int unused = cmd::Unused::Get(level_face); |
| 643 void *data = GetAddressAndCheckSize(args.shared_memory.id, |
| 644 args.shared_memory.offset, size); |
| 645 if (face >= 6 || unused != 0 || !data) |
| 646 return BufferSyncInterface::kParseInvalidArguments; |
| 647 return gapi_->GetTextureData( |
| 648 args.texture_id, x, y, z, width, height, depth, level, |
| 649 static_cast<texture::Face>(face), args.row_pitch, |
| 650 args.slice_pitch, size, data); |
| 651 } |
| 652 |
| 653 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateSampler( |
| 654 uint32 arg_count, |
| 655 const cmd::CreateSampler& args) { |
848 return gapi_->CreateSampler(args.id); | 656 return gapi_->CreateSampler(args.id); |
849 } | 657 } |
850 | 658 |
851 BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_SAMPLER( | 659 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroySampler( |
852 uint32 arg_count, | 660 uint32 arg_count, |
853 const cmd::DESTROY_SAMPLER& args) { | 661 const cmd::DestroySampler& args) { |
854 return gapi_->DestroySampler(args.id); | 662 return gapi_->DestroySampler(args.id); |
855 } | 663 } |
856 | 664 |
857 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_SAMPLER_STATES( | 665 BufferSyncInterface::ParseError GAPIDecoder::HandleSetSamplerStates( |
858 uint32 arg_count, | 666 uint32 arg_count, |
859 const cmd::SET_SAMPLER_STATES& args) { | 667 const cmd::SetSamplerStates& args) { |
860 // TODO(gman): fix. | 668 namespace cmd = set_sampler_states; |
861 return DecodeSetSamplerStates(arg_count, TempHack(&args)); | 669 Uint32 arg = args.fixme1; |
862 } | 670 if (cmd::Unused::Get(arg) != 0) |
863 | 671 return BufferSyncInterface::kParseInvalidArguments; |
864 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_SAMPLER_BORDER_COLOR( | 672 unsigned int address_u_value = cmd::AddressingU::Get(arg); |
865 uint32 arg_count, | 673 unsigned int address_v_value = cmd::AddressingV::Get(arg); |
866 const cmd::SET_SAMPLER_BORDER_COLOR& args) { | 674 unsigned int address_w_value = cmd::AddressingW::Get(arg); |
| 675 unsigned int mag_filter_value = cmd::MagFilter::Get(arg); |
| 676 unsigned int min_filter_value = cmd::MinFilter::Get(arg); |
| 677 unsigned int mip_filter_value = cmd::MipFilter::Get(arg); |
| 678 unsigned int max_anisotropy = cmd::MaxAnisotropy::Get(arg); |
| 679 if (address_u_value >= sampler::NUM_ADDRESSING_MODE || |
| 680 address_v_value >= sampler::NUM_ADDRESSING_MODE || |
| 681 address_w_value >= sampler::NUM_ADDRESSING_MODE || |
| 682 mag_filter_value >= sampler::NUM_FILTERING_MODE || |
| 683 min_filter_value >= sampler::NUM_FILTERING_MODE || |
| 684 mip_filter_value >= sampler::NUM_FILTERING_MODE || |
| 685 mag_filter_value == sampler::NONE || |
| 686 min_filter_value == sampler::NONE || |
| 687 max_anisotropy == 0) { |
| 688 return BufferSyncInterface::kParseInvalidArguments; |
| 689 } |
| 690 gapi_->SetSamplerStates( |
| 691 args.id, |
| 692 static_cast<sampler::AddressingMode>(address_u_value), |
| 693 static_cast<sampler::AddressingMode>(address_v_value), |
| 694 static_cast<sampler::AddressingMode>(address_w_value), |
| 695 static_cast<sampler::FilteringMode>(mag_filter_value), |
| 696 static_cast<sampler::FilteringMode>(min_filter_value), |
| 697 static_cast<sampler::FilteringMode>(mip_filter_value), |
| 698 max_anisotropy); |
| 699 return BufferSyncInterface::kParseNoError; |
| 700 } |
| 701 |
| 702 BufferSyncInterface::ParseError GAPIDecoder::HandleSetSamplerBorderColor( |
| 703 uint32 arg_count, |
| 704 const cmd::SetSamplerBorderColor& args) { |
867 RGBA rgba; | 705 RGBA rgba; |
868 rgba.red = args.red; | 706 rgba.red = args.red; |
869 rgba.green = args.green; | 707 rgba.green = args.green; |
870 rgba.blue = args.blue; | 708 rgba.blue = args.blue; |
871 rgba.alpha = args.alpha; | 709 rgba.alpha = args.alpha; |
872 return gapi_->SetSamplerBorderColor(args.id, rgba); | 710 return gapi_->SetSamplerBorderColor(args.id, rgba); |
873 } | 711 } |
874 | 712 |
875 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_SAMPLER_TEXTURE( | 713 BufferSyncInterface::ParseError GAPIDecoder::HandleSetSamplerTexture( |
876 uint32 arg_count, | 714 uint32 arg_count, |
877 const cmd::SET_SAMPLER_TEXTURE& args) { | 715 const cmd::SetSamplerTexture& args) { |
878 return gapi_->SetSamplerTexture(args.id, args.texture_id); | 716 return gapi_->SetSamplerTexture(args.id, args.texture_id); |
879 } | 717 } |
880 | 718 |
881 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_SCISSOR( | 719 BufferSyncInterface::ParseError GAPIDecoder::HandleSetScissor( |
882 uint32 arg_count, | 720 uint32 arg_count, |
883 const cmd::SET_SCISSOR& args) { | 721 const cmd::SetScissor& args) { |
884 namespace cmd = set_scissor; | 722 namespace cmd = set_scissor; |
885 Uint32 x_y_enable = args.fixme0; | 723 Uint32 x_y_enable = args.fixme0; |
886 if (cmd::Unused::Get(x_y_enable) != 0) | 724 if (cmd::Unused::Get(x_y_enable) != 0) |
887 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 725 return BufferSyncInterface::kParseInvalidArguments; |
888 unsigned int x = cmd::X::Get(x_y_enable); | 726 unsigned int x = cmd::X::Get(x_y_enable); |
889 unsigned int y = cmd::Y::Get(x_y_enable); | 727 unsigned int y = cmd::Y::Get(x_y_enable); |
890 bool enable = cmd::Enable::Get(x_y_enable) != 0; | 728 bool enable = cmd::Enable::Get(x_y_enable) != 0; |
891 Uint32 width_height = args.fixme1; | 729 Uint32 width_height = args.fixme1; |
892 unsigned int width = cmd::Width::Get(width_height); | 730 unsigned int width = cmd::Width::Get(width_height); |
893 unsigned int height = cmd::Height::Get(width_height); | 731 unsigned int height = cmd::Height::Get(width_height); |
894 gapi_->SetScissor(enable, x, y, width, height); | 732 gapi_->SetScissor(enable, x, y, width, height); |
895 return BufferSyncInterface::PARSE_NO_ERROR; | 733 return BufferSyncInterface::kParseNoError; |
896 } | 734 } |
897 | 735 |
898 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_POLYGON_OFFSET( | 736 BufferSyncInterface::ParseError GAPIDecoder::HandleSetPolygonOffset( |
899 uint32 arg_count, | 737 uint32 arg_count, |
900 const cmd::SET_POLYGON_OFFSET& args) { | 738 const cmd::SetPolygonOffset& args) { |
901 gapi_->SetPolygonOffset(args.slope_factor, args.units); | 739 gapi_->SetPolygonOffset(args.slope_factor, args.units); |
902 return BufferSyncInterface::PARSE_NO_ERROR; | 740 return BufferSyncInterface::kParseNoError; |
903 } | 741 } |
904 | 742 |
905 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_POINT_LINE_RASTER( | 743 BufferSyncInterface::ParseError GAPIDecoder::HandleSetPointLineRaster( |
906 uint32 arg_count, | 744 uint32 arg_count, |
907 const cmd::SET_POINT_LINE_RASTER& args) { | 745 const cmd::SetPointLineRaster& args) { |
908 namespace cmd = set_point_line_raster; | 746 namespace cmd = set_point_line_raster; |
909 Uint32 enables = args.fixme0; | 747 Uint32 enables = args.fixme0; |
910 if (cmd::Unused::Get(enables) != 0) | 748 if (cmd::Unused::Get(enables) != 0) |
911 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 749 return BufferSyncInterface::kParseInvalidArguments; |
912 bool line_smooth = !!cmd::LineSmoothEnable::Get(enables); | 750 bool line_smooth = !!cmd::LineSmoothEnable::Get(enables); |
913 bool point_sprite = !!cmd::PointSpriteEnable::Get(enables); | 751 bool point_sprite = !!cmd::PointSpriteEnable::Get(enables); |
914 gapi_->SetPointLineRaster(line_smooth, point_sprite, args.point_size); | 752 gapi_->SetPointLineRaster(line_smooth, point_sprite, args.point_size); |
915 return BufferSyncInterface::PARSE_NO_ERROR; | 753 return BufferSyncInterface::kParseNoError; |
916 } | 754 } |
917 | 755 |
918 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_POLYGON_RASTER( | 756 BufferSyncInterface::ParseError GAPIDecoder::HandleSetPolygonRaster( |
919 uint32 arg_count, | 757 uint32 arg_count, |
920 const cmd::SET_POLYGON_RASTER& args) { | 758 const cmd::SetPolygonRaster& args) { |
921 namespace cmd = set_polygon_raster; | 759 namespace cmd = set_polygon_raster; |
922 Uint32 fill_cull = args.fixme0; | 760 Uint32 fill_cull = args.fixme0; |
923 unsigned int fill_value = cmd::FillMode::Get(fill_cull); | 761 unsigned int fill_value = cmd::FillMode::Get(fill_cull); |
924 unsigned int cull_value = cmd::CullMode::Get(fill_cull); | 762 unsigned int cull_value = cmd::CullMode::Get(fill_cull); |
925 if (cmd::Unused::Get(fill_cull) != 0 || | 763 if (cmd::Unused::Get(fill_cull) != 0 || |
926 fill_value >= GAPIInterface::NUM_POLYGON_MODE || | 764 fill_value >= GAPIInterface::NUM_POLYGON_MODE || |
927 cull_value >= GAPIInterface::NUM_FACE_CULL_MODE) | 765 cull_value >= GAPIInterface::NUM_FACE_CULL_MODE) |
928 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 766 return BufferSyncInterface::kParseInvalidArguments; |
929 gapi_->SetPolygonRaster( | 767 gapi_->SetPolygonRaster( |
930 static_cast<GAPIInterface::PolygonMode>(fill_value), | 768 static_cast<GAPIInterface::PolygonMode>(fill_value), |
931 static_cast<GAPIInterface::FaceCullMode>(cull_value)); | 769 static_cast<GAPIInterface::FaceCullMode>(cull_value)); |
932 return BufferSyncInterface::PARSE_NO_ERROR; | 770 return BufferSyncInterface::kParseNoError; |
933 } | 771 } |
934 | 772 |
935 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_ALPHA_TEST( | 773 BufferSyncInterface::ParseError GAPIDecoder::HandleSetAlphaTest( |
936 uint32 arg_count, | 774 uint32 arg_count, |
937 const cmd::SET_ALPHA_TEST& args) { | 775 const cmd::SetAlphaTest& args) { |
938 namespace cmd = set_alpha_test; | 776 namespace cmd = set_alpha_test; |
939 Uint32 func_enable = args.fixme0; | 777 Uint32 func_enable = args.fixme0; |
940 if (cmd::Unused::Get(func_enable) != 0) | 778 if (cmd::Unused::Get(func_enable) != 0) |
941 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 779 return BufferSyncInterface::kParseInvalidArguments; |
942 // Check that the bitmask get cannot generate values outside of the | 780 // Check that the bitmask get cannot generate values outside of the |
943 // allowed range. | 781 // allowed range. |
944 COMPILE_ASSERT(cmd::Func::kMask < GAPIInterface::NUM_COMPARISON, | 782 COMPILE_ASSERT(cmd::Func::kMask < GAPIInterface::NUM_COMPARISON, |
945 set_alpha_test_Func_may_produce_invalid_values); | 783 set_alpha_test_Func_may_produce_invalid_values); |
946 GAPIInterface::Comparison comp = | 784 GAPIInterface::Comparison comp = |
947 static_cast<GAPIInterface::Comparison>(cmd::Func::Get(func_enable)); | 785 static_cast<GAPIInterface::Comparison>(cmd::Func::Get(func_enable)); |
948 bool enable = cmd::Enable::Get(func_enable) != 0; | 786 bool enable = cmd::Enable::Get(func_enable) != 0; |
949 gapi_->SetAlphaTest(enable, args.value, comp); | 787 gapi_->SetAlphaTest(enable, args.value, comp); |
950 return BufferSyncInterface::PARSE_NO_ERROR; | 788 return BufferSyncInterface::kParseNoError; |
951 } | 789 } |
952 | 790 |
953 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_DEPTH_TEST( | 791 BufferSyncInterface::ParseError GAPIDecoder::HandleSetDepthTest( |
954 uint32 arg_count, | 792 uint32 arg_count, |
955 const cmd::SET_DEPTH_TEST& args) { | 793 const cmd::SetDepthTest& args) { |
956 namespace cmd = set_depth_test; | 794 namespace cmd = set_depth_test; |
957 Uint32 func_enable = args.fixme0; | 795 Uint32 func_enable = args.fixme0; |
958 if (cmd::Unused::Get(func_enable) != 0) | 796 if (cmd::Unused::Get(func_enable) != 0) |
959 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 797 return BufferSyncInterface::kParseInvalidArguments; |
960 // Check that the bitmask get cannot generate values outside of the | 798 // Check that the bitmask get cannot generate values outside of the |
961 // allowed range. | 799 // allowed range. |
962 COMPILE_ASSERT(cmd::Func::kMask < GAPIInterface::NUM_COMPARISON, | 800 COMPILE_ASSERT(cmd::Func::kMask < GAPIInterface::NUM_COMPARISON, |
963 set_alpha_test_Func_may_produce_invalid_values); | 801 set_alpha_test_Func_may_produce_invalid_values); |
964 GAPIInterface::Comparison comp = | 802 GAPIInterface::Comparison comp = |
965 static_cast<GAPIInterface::Comparison>(cmd::Func::Get(func_enable)); | 803 static_cast<GAPIInterface::Comparison>(cmd::Func::Get(func_enable)); |
966 bool write_enable = cmd::WriteEnable::Get(func_enable) != 0; | 804 bool write_enable = cmd::WriteEnable::Get(func_enable) != 0; |
967 bool enable = cmd::Enable::Get(func_enable) != 0; | 805 bool enable = cmd::Enable::Get(func_enable) != 0; |
968 gapi_->SetDepthTest(enable, write_enable, comp); | 806 gapi_->SetDepthTest(enable, write_enable, comp); |
969 return BufferSyncInterface::PARSE_NO_ERROR; | 807 return BufferSyncInterface::kParseNoError; |
970 } | 808 } |
971 | 809 |
972 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_STENCIL_TEST( | 810 BufferSyncInterface::ParseError GAPIDecoder::HandleSetStencilTest( |
973 uint32 arg_count, | 811 uint32 arg_count, |
974 const cmd::SET_STENCIL_TEST& args) { | 812 const cmd::SetStencilTest& args) { |
975 // TODO(gman): fix. | 813 namespace cmd = set_stencil_test; |
976 return DecodeSetStencilTest(arg_count, TempHack(&args)); | 814 Uint32 arg0 = args.fixme0; |
| 815 Uint32 arg1 = args.fixme1; |
| 816 if (cmd::Unused0::Get(arg0) != 0 || |
| 817 cmd::Unused1::Get(arg1) != 0 || |
| 818 cmd::Unused2::Get(arg1) != 0) |
| 819 return BufferSyncInterface::kParseInvalidArguments; |
| 820 unsigned int write_mask = cmd::WriteMask::Get(arg0); |
| 821 unsigned int compare_mask = cmd::CompareMask::Get(arg0); |
| 822 unsigned int ref = cmd::ReferenceValue::Get(arg0); |
| 823 bool enable = cmd::Enable::Get(arg0) != 0; |
| 824 bool separate_ccw = cmd::SeparateCCW::Get(arg0) != 0; |
| 825 gapi_->SetStencilTest(enable, separate_ccw, write_mask, compare_mask, ref, |
| 826 arg1); |
| 827 return BufferSyncInterface::kParseNoError; |
977 } | 828 } |
978 | 829 |
979 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_COLOR_WRITE( | 830 BufferSyncInterface::ParseError GAPIDecoder::HandleSetColorWrite( |
980 uint32 arg_count, | 831 uint32 arg_count, |
981 const cmd::SET_COLOR_WRITE& args) { | 832 const cmd::SetColorWrite& args) { |
982 namespace cmd = set_color_write; | 833 namespace cmd = set_color_write; |
983 Uint32 enables = args.flags; | 834 Uint32 enables = args.flags; |
984 if (cmd::Unused::Get(enables) != 0) | 835 if (cmd::Unused::Get(enables) != 0) |
985 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 836 return BufferSyncInterface::kParseInvalidArguments; |
986 bool red = cmd::RedMask::Get(enables) != 0; | 837 bool red = cmd::RedMask::Get(enables) != 0; |
987 bool green = cmd::GreenMask::Get(enables) != 0; | 838 bool green = cmd::GreenMask::Get(enables) != 0; |
988 bool blue = cmd::BlueMask::Get(enables) != 0; | 839 bool blue = cmd::BlueMask::Get(enables) != 0; |
989 bool alpha = cmd::AlphaMask::Get(enables) != 0; | 840 bool alpha = cmd::AlphaMask::Get(enables) != 0; |
990 bool dither = cmd::DitherEnable::Get(enables) != 0; | 841 bool dither = cmd::DitherEnable::Get(enables) != 0; |
991 gapi_->SetColorWrite(red, green, blue, alpha, dither); | 842 gapi_->SetColorWrite(red, green, blue, alpha, dither); |
992 return BufferSyncInterface::PARSE_NO_ERROR; | 843 return BufferSyncInterface::kParseNoError; |
993 } | 844 } |
994 | 845 |
995 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_BLENDING( | 846 BufferSyncInterface::ParseError GAPIDecoder::HandleSetBlending( |
996 uint32 arg_count, | 847 uint32 arg_count, |
997 const cmd::SET_BLENDING& args) { | 848 const cmd::SetBlending& args) { |
998 return DecodeSetBlending(arg_count, TempHack(&args)); | 849 namespace cmd = set_blending; |
| 850 Uint32 arg = args.fixme0; |
| 851 bool enable = cmd::Enable::Get(arg) != 0; |
| 852 bool separate_alpha = cmd::SeparateAlpha::Get(arg) != 0; |
| 853 unsigned int color_eq = cmd::ColorEq::Get(arg); |
| 854 unsigned int color_src = cmd::ColorSrcFunc::Get(arg); |
| 855 unsigned int color_dst = cmd::ColorDstFunc::Get(arg); |
| 856 unsigned int alpha_eq = cmd::AlphaEq::Get(arg); |
| 857 unsigned int alpha_src = cmd::AlphaSrcFunc::Get(arg); |
| 858 unsigned int alpha_dst = cmd::AlphaDstFunc::Get(arg); |
| 859 if (cmd::Unused0::Get(arg) != 0 || |
| 860 cmd::Unused1::Get(arg) != 0 || |
| 861 color_eq >= GAPIInterface::NUM_BLEND_EQ || |
| 862 color_src >= GAPIInterface::NUM_BLEND_FUNC || |
| 863 color_dst >= GAPIInterface::NUM_BLEND_FUNC || |
| 864 alpha_eq >= GAPIInterface::NUM_BLEND_EQ || |
| 865 alpha_src >= GAPIInterface::NUM_BLEND_FUNC || |
| 866 alpha_dst >= GAPIInterface::NUM_BLEND_FUNC) |
| 867 return BufferSyncInterface::kParseInvalidArguments; |
| 868 gapi_->SetBlending(enable, |
| 869 separate_alpha, |
| 870 static_cast<GAPIInterface::BlendEq>(color_eq), |
| 871 static_cast<GAPIInterface::BlendFunc>(color_src), |
| 872 static_cast<GAPIInterface::BlendFunc>(color_dst), |
| 873 static_cast<GAPIInterface::BlendEq>(alpha_eq), |
| 874 static_cast<GAPIInterface::BlendFunc>(alpha_src), |
| 875 static_cast<GAPIInterface::BlendFunc>(alpha_dst)); |
| 876 return BufferSyncInterface::kParseNoError; |
999 } | 877 } |
1000 | 878 |
1001 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_BLENDING_COLOR( | 879 BufferSyncInterface::ParseError GAPIDecoder::HandleSetBlendingColor( |
1002 uint32 arg_count, | 880 uint32 arg_count, |
1003 const cmd::SET_BLENDING_COLOR& args) { | 881 const cmd::SetBlendingColor& args) { |
1004 RGBA rgba; | 882 RGBA rgba; |
1005 rgba.red = args.red; | 883 rgba.red = args.red; |
1006 rgba.green = args.green; | 884 rgba.green = args.green; |
1007 rgba.blue = args.blue; | 885 rgba.blue = args.blue; |
1008 rgba.alpha = args.alpha; | 886 rgba.alpha = args.alpha; |
1009 gapi_->SetBlendingColor(rgba); | 887 gapi_->SetBlendingColor(rgba); |
1010 return BufferSyncInterface::PARSE_NO_ERROR; | 888 return BufferSyncInterface::kParseNoError; |
1011 } | 889 } |
1012 | 890 |
1013 BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_RENDER_SURFACE( | 891 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateRenderSurface( |
1014 uint32 arg_count, | 892 uint32 arg_count, |
1015 const cmd::CREATE_RENDER_SURFACE& args) { | 893 const cmd::CreateRenderSurface& args) { |
1016 namespace cmd = create_render_surface_cmd; | 894 namespace cmd = create_render_surface_cmd; |
1017 unsigned int width_height = args.fixme1; | 895 unsigned int width_height = args.fixme1; |
1018 unsigned int width = cmd::Width::Get(width_height); | 896 unsigned int width = cmd::Width::Get(width_height); |
1019 unsigned int height = cmd::Height::Get(width_height); | 897 unsigned int height = cmd::Height::Get(width_height); |
1020 unsigned int levels_side = args.fixme2; | 898 unsigned int levels_side = args.fixme2; |
1021 unsigned int mip_level = cmd::Levels::Get(levels_side); | 899 unsigned int mip_level = cmd::Levels::Get(levels_side); |
1022 unsigned int side = cmd::Side::Get(levels_side); | 900 unsigned int side = cmd::Side::Get(levels_side); |
1023 return gapi_->CreateRenderSurface(args.id, width, height, mip_level, | 901 return gapi_->CreateRenderSurface(args.id, width, height, mip_level, |
1024 side, args.texture_id); | 902 side, args.texture_id); |
1025 } | 903 } |
1026 | 904 |
1027 BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_RENDER_SURFACE( | 905 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyRenderSurface( |
1028 uint32 arg_count, | 906 uint32 arg_count, |
1029 const cmd::DESTROY_RENDER_SURFACE& args) { | 907 const cmd::DestroyRenderSurface& args) { |
1030 return gapi_->DestroyRenderSurface(args.id); | 908 return gapi_->DestroyRenderSurface(args.id); |
1031 } | 909 } |
1032 | 910 |
1033 BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_DEPTH_SURFACE( | 911 BufferSyncInterface::ParseError GAPIDecoder::HandleCreateDepthSurface( |
1034 uint32 arg_count, | 912 uint32 arg_count, |
1035 const cmd::CREATE_DEPTH_SURFACE& args) { | 913 const cmd::CreateDepthSurface& args) { |
1036 namespace cmd = create_render_surface_cmd; | 914 namespace cmd = create_depth_surface_cmd; |
1037 unsigned int width_height = args.fixme1; | 915 unsigned int width_height = args.fixme1; |
1038 unsigned int width = cmd::Width::Get(width_height); | 916 unsigned int width = cmd::Width::Get(width_height); |
1039 unsigned int height = cmd::Height::Get(width_height); | 917 unsigned int height = cmd::Height::Get(width_height); |
1040 return gapi_->CreateDepthSurface(args.id, width, height); | 918 return gapi_->CreateDepthSurface(args.id, width, height); |
1041 } | 919 } |
1042 | 920 |
1043 BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_DEPTH_SURFACE( | 921 BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyDepthSurface( |
1044 uint32 arg_count, | 922 uint32 arg_count, |
1045 const cmd::DESTROY_DEPTH_SURFACE& args) { | 923 const cmd::DestroyDepthSurface& args) { |
1046 return gapi_->DestroyDepthSurface(args.id); | 924 return gapi_->DestroyDepthSurface(args.id); |
1047 } | 925 } |
1048 | 926 |
1049 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_RENDER_SURFACE( | 927 BufferSyncInterface::ParseError GAPIDecoder::HandleSetRenderSurface( |
1050 uint32 arg_count, | 928 uint32 arg_count, |
1051 const cmd::SET_RENDER_SURFACE& args) { | 929 const cmd::SetRenderSurface& args) { |
1052 return gapi_->SetRenderSurface(args.render_surface_id, args.depth_surface_id); | 930 return gapi_->SetRenderSurface(args.render_surface_id, args.depth_surface_id); |
1053 } | 931 } |
1054 | 932 |
1055 BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_BACK_SURFACES( | 933 BufferSyncInterface::ParseError GAPIDecoder::HandleSetBackSurfaces( |
1056 uint32 arg_count, | 934 uint32 arg_count, |
1057 const cmd::SET_BACK_SURFACES& args) { | 935 const cmd::SetBackSurfaces& args) { |
1058 gapi_->SetBackSurfaces(); | 936 gapi_->SetBackSurfaces(); |
1059 return BufferSyncInterface::PARSE_NO_ERROR; | 937 return BufferSyncInterface::kParseNoError; |
1060 } | 938 } |
1061 | 939 |
1062 } // namespace command_buffer | 940 } // namespace command_buffer |
1063 } // namespace o3d | 941 } // namespace o3d |
OLD | NEW |