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

Side by Side Diff: command_buffer/client/cross/cmd_buffer_helper.h

Issue 212018: Change command buffer client code to use structures.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 // Waits until all the commands have been executed. 84 // Waits until all the commands have been executed.
85 void Finish(); 85 void Finish();
86 86
87 // Waits until a given number of available entries are available. 87 // Waits until a given number of available entries are available.
88 // Parameters: 88 // Parameters:
89 // count: number of entries needed. This value must be at most 89 // count: number of entries needed. This value must be at most
90 // the size of the buffer minus one. 90 // the size of the buffer minus one.
91 void WaitForAvailableEntries(unsigned int count); 91 void WaitForAvailableEntries(unsigned int count);
92 92
93 // Adds a command data to the command buffer. This may wait until sufficient
94 // space is available.
95 // Parameters:
96 // entries: The command entries to add.
97 // count: The number of entries.
98 void AddCommandData(CommandBufferEntry* entries, unsigned int count) {
99 WaitForAvailableEntries(count);
100 for (; count > 0; --count) {
101 entries_[put_++] = *entries++;
102 }
103 DCHECK_LE(put_, entry_count_);
104 if (put_ == entry_count_) put_ = 0;
105 }
106
107 // A typed version of AddCommandData.
108 template <typename T>
109 void AddTypedCmdData(T& cmd) {
110 AddCommandData(reinterpret_cast<CommandBufferEntry*>(&cmd),
111 ComputeNumEntries(sizeof(cmd)));
112 }
113
93 // Adds a command to the command buffer. This may wait until sufficient space 114 // Adds a command to the command buffer. This may wait until sufficient space
94 // is available. 115 // is available.
95 // Parameters: 116 // Parameters:
96 // command: the command index. 117 // command: the command index.
97 // arg_count: the number of arguments for the command. 118 // arg_count: the number of arguments for the command.
98 // args: the arguments for the command (these are copied before the 119 // args: the arguments for the command (these are copied before the
99 // function returns). 120 // function returns).
100 void AddCommand(unsigned int command, 121 void AddCommand(unsigned int command,
101 unsigned int arg_count, 122 unsigned int arg_count,
102 CommandBufferEntry *args) { 123 CommandBufferEntry *args) {
(...skipping 20 matching lines...) Expand all
123 // Waits until the token of a particular value has passed through the command 144 // Waits until the token of a particular value has passed through the command
124 // stream (i.e. commands inserted before that token have been executed). 145 // stream (i.e. commands inserted before that token have been executed).
125 // NOTE: This will call Flush if it needs to block. 146 // NOTE: This will call Flush if it needs to block.
126 // Parameters: 147 // Parameters:
127 // the value of the token to wait for. 148 // the value of the token to wait for.
128 void WaitForToken(unsigned int token); 149 void WaitForToken(unsigned int token);
129 150
130 // Returns the buffer interface used to send synchronous commands. 151 // Returns the buffer interface used to send synchronous commands.
131 BufferSyncInterface *interface() { return interface_; } 152 BufferSyncInterface *interface() { return interface_; }
132 153
154 // Waits for a certain amount of space to be available. Returns address
155 // of space.
156 CommandBufferEntry* GetSpace(uint32 entries);
157
158 // Typed version of GetSpace. Gets enough room for the given type and returns
159 // a reference to it.
160 template <typename T>
161 T& GetCmdSpace() {
162 COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed);
163 uint32 space_needed = ComputeNumEntries(sizeof(T));
164 void* data = GetSpace(space_needed);
165 return *reinterpret_cast<T*>(data);
166 }
167
168 // Typed version of GetSpace for immediate commands.
169 template <typename T>
170 T& GetImmediateCmdSpace(size_t space) {
171 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN);
172 uint32 space_needed = ComputeNumEntries(sizeof(T) + space);
173 void* data = GetSpace(space_needed);
174 return *reinterpret_cast<T*>(data);
175 }
176
177 // ------------------ Individual commands ----------------------
178
179 void Noop(uint32 skip_count) {
180 cmd::Noop& cmd = GetImmediateCmdSpace<cmd::Noop>(
181 skip_count * sizeof(CommandBufferEntry));
182 cmd.Init(skip_count);
183 }
184
185
186 void SetToken(uint32 token) {
187 cmd::SetToken& cmd = GetCmdSpace<cmd::SetToken>();
188 cmd.Init(token);
189 }
190
191
192 void BeginFrame() {
193 cmd::BeginFrame& cmd = GetCmdSpace<cmd::BeginFrame>();
194 cmd.Init();
195 }
196
197
198 void EndFrame() {
199 cmd::EndFrame& cmd = GetCmdSpace<cmd::EndFrame>();
200 cmd.Init();
201 }
202
203 void Clear(
204 uint32 buffers,
205 float red, float green, float blue, float alpha,
206 float depth, uint32 stencil) {
207 cmd::Clear& cmd = GetCmdSpace<cmd::Clear>();
208 cmd.Init(buffers, red, green, blue, alpha, depth, stencil);
209 }
210
211 void SetViewport(
212 uint32 left,
213 uint32 top,
214 uint32 width,
215 uint32 height,
216 float z_min,
217 float z_max) {
218 cmd::SetViewport& cmd = GetCmdSpace<cmd::SetViewport>();
219 cmd.Init(left, top, width, height, z_min, z_max);
220 }
221
222 void CreateVertexBuffer(uint32 id, uint32 size, uint32 flags) {
223 cmd::CreateVertexBuffer& cmd = GetCmdSpace<cmd::CreateVertexBuffer>();
224 cmd.Init(id, size, flags);
225 }
226
227 void DestroyVertexBuffer(uint32 id) {
228 cmd::DestroyVertexBuffer& cmd = GetCmdSpace<cmd::DestroyVertexBuffer>();
229 cmd.Init(id);
230 }
231
232 void SetVertexBufferDataImmediate(
233 uint32 id, uint32 offset,
234 const void* data, uint32 size) {
235 cmd::SetVertexBufferDataImmediate& cmd =
236 GetImmediateCmdSpace<cmd::SetVertexBufferDataImmediate>(size);
237 cmd.Init(id, offset, data, size);
238 }
239
240 void SetVertexBufferData(
241 uint32 id, uint32 offset, uint32 size,
242 uint32 shared_memory_id, uint32 shared_memory_offset) {
243 cmd::SetVertexBufferData& cmd =
244 GetCmdSpace<cmd::SetVertexBufferData>();
245 cmd.Init(id, offset, size,
246 shared_memory_id, shared_memory_offset);
247 }
248
249 void GetVertexBufferData(
250 uint32 id, uint32 offset, uint32 size,
251 uint32 shared_memory_id, uint32 shared_memory_offset) {
252 cmd::GetVertexBufferData& cmd =
253 GetCmdSpace<cmd::GetVertexBufferData>();
254 cmd.Init(id, offset, size,
255 shared_memory_id, shared_memory_offset);
256 }
257
258 void CreateIndexBuffer(uint32 id, uint32 size, uint32 flags) {
259 cmd::CreateIndexBuffer& cmd =
260 GetCmdSpace<cmd::CreateIndexBuffer>();
261 cmd.Init(id, size, flags);
262 }
263
264 void DestroyIndexBuffer(uint32 id) {
265 cmd::DestroyIndexBuffer& cmd = GetCmdSpace<cmd::DestroyIndexBuffer>();
266 cmd.Init(id);
267 }
268
269 void SetIndexBufferDataImmediate(
270 uint32 id, uint32 offset, const void* data, uint32 size) {
271 cmd::SetIndexBufferDataImmediate& cmd =
272 GetImmediateCmdSpace<cmd::SetIndexBufferDataImmediate>(size);
273 cmd.Init(id, offset, data, size);
274 }
275
276 void SetIndexBufferData(
277 uint32 id, uint32 offset, uint32 size,
278 uint32 shared_memory_id, uint32 shared_memory_offset) {
279 cmd::SetIndexBufferData& cmd = GetCmdSpace<cmd::SetIndexBufferData>();
280 cmd.Init(id, offset, size, shared_memory_id, shared_memory_offset);
281 }
282
283 void GetIndexBufferData(
284 uint32 id, uint32 offset, uint32 size,
285 uint32 shared_memory_id, uint32 shared_memory_offset) {
286 cmd::GetIndexBufferData& cmd = GetCmdSpace<cmd::GetIndexBufferData>();
287 cmd.Init(id, offset, size, shared_memory_id, shared_memory_offset);
288 }
289
290 void CreateVertexStruct(uint32 id, uint32 input_count) {
291 cmd::CreateVertexStruct& cmd = GetCmdSpace<cmd::CreateVertexStruct>();
292 cmd.Init(id, input_count);
293 }
294
295 void DestroyVertexStruct(uint32 id) {
296 cmd::DestroyVertexStruct& cmd = GetCmdSpace<cmd::DestroyVertexStruct>();
297 cmd.Init(id);
298 }
299
300 void SetVertexInput(
301 uint32 vertex_struct_id,
302 uint32 input_index,
303 uint32 vertex_buffer_id,
304 uint32 offset,
305 uint8 semantic,
306 uint32 semantic_index,
307 uint8 type,
308 uint32 stride) {
309 cmd::SetVertexInput& cmd = GetCmdSpace<cmd::SetVertexInput>();
310 cmd.Init(
311 vertex_struct_id,
312 input_index,
313 vertex_buffer_id,
314 offset,
315 semantic,
316 semantic_index,
317 type,
318 stride);
319 }
320
321 void SetVertexStruct(uint32 id) {
322 cmd::SetVertexStruct& cmd = GetCmdSpace<cmd::SetVertexStruct>();
323 cmd.Init(id);
324 }
325
326 void Draw(uint32 primitive_type, uint32 first, uint32 count) {
327 cmd::Draw& cmd = GetCmdSpace<cmd::Draw>();
328 cmd.Init(primitive_type, first, count);
329 }
330
331 void DrawIndexed(
332 uint32 primitive_type,
333 uint32 index_buffer_id,
334 uint32 first,
335 uint32 count,
336 uint32 min_index,
337 uint32 max_index) {
338 cmd::DrawIndexed& cmd = GetCmdSpace<cmd::DrawIndexed>();
339 cmd.Init(
340 primitive_type,
341 index_buffer_id,
342 first,
343 count,
344 min_index,
345 max_index);
346 }
347
348 void CreateEffect(
349 uint32 id, uint32 size,
350 uint32 shared_memory_id, uint32 shared_memory_offset) {
351 cmd::CreateEffect& cmd = GetCmdSpace<cmd::CreateEffect>();
352 cmd.Init(id, size, shared_memory_id, shared_memory_offset);
353 }
354
355 void CreateEffectImmediate(uint32 id, uint32 size, const void* data) {
356 cmd::CreateEffectImmediate& cmd =
357 GetImmediateCmdSpace<cmd::CreateEffectImmediate>(size);
358 cmd.Init(id, size, data);
359 }
360
361 void DestroyEffect(uint32 id) {
362 cmd::DestroyEffect& cmd = GetCmdSpace<cmd::DestroyEffect>();
363 cmd.Init(id);
364 }
365
366 void SetEffect(uint32 id) {
367 cmd::SetEffect& cmd = GetCmdSpace<cmd::SetEffect>();
368 cmd.Init(id);
369 }
370
371 void GetParamCount(
372 uint32 id, uint32 size,
373 uint32 shared_memory_id, uint32 shared_memory_offset) {
374 cmd::GetParamCount& cmd = GetCmdSpace<cmd::GetParamCount>();
375 cmd.Init(id, size, shared_memory_id, shared_memory_offset);
376 }
377
378 void CreateParam(uint32 param_id, uint32 effect_id, uint32 index) {
379 cmd::CreateParam& cmd = GetCmdSpace<cmd::CreateParam>();
380 cmd.Init(param_id, effect_id, index);
381 }
382
383 void CreateParamByName(
384 uint32 param_id, uint32 effect_id, uint32 size,
385 uint32 shared_memory_id, uint32 shared_memory_offset) {
386 cmd::CreateParamByName& cmd = GetCmdSpace<cmd::CreateParamByName>();
387 cmd.Init(param_id, effect_id, size, shared_memory_id, shared_memory_offset);
388 }
389
390 void CreateParamByNameImmediate(
391 uint32 param_id, uint32 effect_id, uint32 size, const void* data) {
392 cmd::CreateParamByNameImmediate& cmd =
393 GetImmediateCmdSpace<cmd::CreateParamByNameImmediate>(size);
394 cmd.Init(param_id, effect_id, size, data);
395 }
396
397 void DestroyParam(uint32 id) {
398 cmd::DestroyParam& cmd = GetCmdSpace<cmd::DestroyParam>();
399 cmd.Init(id);
400 }
401
402 void SetParamData(
403 uint32 id, uint32 size,
404 uint32 shared_memory_id, uint32 shared_memory_offset) {
405 cmd::SetParamData& cmd = GetCmdSpace<cmd::SetParamData>();
406 cmd.Init(id, size, shared_memory_id, shared_memory_offset);
407 }
408
409 void SetParamDataImmediate(uint32 id, uint32 size, const void* data) {
410 cmd::SetParamDataImmediate& cmd =
411 GetImmediateCmdSpace<cmd::SetParamDataImmediate>(size);
412 cmd.Init(id, size, data);
413 }
414
415 void GetParamDesc(
416 uint32 id, uint32 size,
417 uint32 shared_memory_id, uint32 shared_memory_offset) {
418 cmd::GetParamDesc& cmd = GetCmdSpace<cmd::GetParamDesc>();
419 cmd.Init(id, size, shared_memory_id, shared_memory_offset);
420 }
421
422 void GetStreamCount(
423 uint32 id, uint32 size,
424 uint32 shared_memory_id, uint32 shared_memory_offset) {
425 cmd::GetStreamCount& cmd = GetCmdSpace<cmd::GetStreamCount>();
426 cmd.Init(id, size, shared_memory_id, shared_memory_offset);
427 }
428
429 void GetStreamDesc(
430 uint32 id, uint32 index, uint32 size,
431 uint32 shared_memory_id, uint32 shared_memory_offset) {
432 cmd::GetStreamDesc& cmd = GetCmdSpace<cmd::GetStreamDesc>();
433 cmd.Init(id, index, size, shared_memory_id, shared_memory_offset);
434 }
435
436 void DestroyTexture(uint32 id) {
437 cmd::DestroyTexture& cmd = GetCmdSpace<cmd::DestroyTexture>();
438 cmd.Init(id);
439 }
440
441 void CreateTexture2d(
442 uint32 texture_id,
443 uint32 width, uint32 height,
444 uint32 levels, uint32 format,
445 uint32 enable_render_surfaces) {
446 cmd::CreateTexture2d& cmd = GetCmdSpace<cmd::CreateTexture2d>();
447 cmd.Init(texture_id,
448 width, height, levels, format,
449 enable_render_surfaces);
450 }
451
452 void CreateTexture3d(
453 uint32 texture_id,
454 uint32 width, uint32 height, uint32 depth,
455 uint32 levels, uint32 format,
456 uint32 enable_render_surfaces) {
457 cmd::CreateTexture3d& cmd = GetCmdSpace<cmd::CreateTexture3d>();
458 cmd.Init(texture_id,
459 width, height, depth,
460 levels, format,
461 enable_render_surfaces);
462 }
463
464 void CreateTextureCube(
465 uint32 texture_id,
466 uint32 edge_length, uint32 levels, uint32 format,
467 uint32 enable_render_surfaces) {
468 cmd::CreateTextureCube& cmd = GetCmdSpace<cmd::CreateTextureCube>();
469 cmd.Init(texture_id,
470 edge_length, levels, format,
471 enable_render_surfaces);
472 }
473
474 void SetTextureData(
475 uint32 texture_id,
476 uint32 x,
477 uint32 y,
478 uint32 z,
479 uint32 width,
480 uint32 height,
481 uint32 depth,
482 uint32 level,
483 uint32 face,
484 uint32 row_pitch,
485 uint32 slice_pitch,
486 uint32 size,
487 uint32 shared_memory_id,
488 uint32 shared_memory_offset) {
489 cmd::SetTextureData& cmd = GetCmdSpace<cmd::SetTextureData>();
490 cmd.Init(
491 texture_id,
492 x,
493 y,
494 z,
495 width,
496 height,
497 depth,
498 level,
499 face,
500 row_pitch,
501 slice_pitch,
502 size,
503 shared_memory_id,
504 shared_memory_offset);
505 }
506
507 void SetTextureDataImmediate(
508 uint32 texture_id,
509 uint32 x,
510 uint32 y,
511 uint32 z,
512 uint32 width,
513 uint32 height,
514 uint32 depth,
515 uint32 level,
516 uint32 face,
517 uint32 row_pitch,
518 uint32 slice_pitch,
519 uint32 size,
520 const void* data) {
521 cmd::SetTextureDataImmediate& cmd =
522 GetImmediateCmdSpace<cmd::SetTextureDataImmediate>(size);
523 cmd.Init(
524 texture_id,
525 x,
526 y,
527 z,
528 width,
529 height,
530 depth,
531 level,
532 face,
533 row_pitch,
534 slice_pitch,
535 size,
536 data);
537 }
538
539 void GetTextureData(
540 uint32 texture_id,
541 uint32 x,
542 uint32 y,
543 uint32 z,
544 uint32 width,
545 uint32 height,
546 uint32 depth,
547 uint32 level,
548 uint32 face,
549 uint32 row_pitch,
550 uint32 slice_pitch,
551 uint32 size,
552 uint32 shared_memory_id,
553 uint32 shared_memory_offset) {
554 cmd::GetTextureData& cmd = GetCmdSpace<cmd::GetTextureData>();
555 cmd.Init(
556 texture_id,
557 x,
558 y,
559 z,
560 width,
561 height,
562 depth,
563 level,
564 face,
565 row_pitch,
566 slice_pitch,
567 size,
568 shared_memory_id,
569 shared_memory_offset);
570 }
571
572 void CreateSampler(uint32 id) {
573 cmd::CreateSampler& cmd = GetCmdSpace<cmd::CreateSampler>();
574 cmd.Init(id);
575 }
576
577 void DestroySampler(uint32 id) {
578 cmd::DestroySampler& cmd = GetCmdSpace<cmd::DestroySampler>();
579 cmd.Init(id);
580 }
581
582 void SetSamplerStates(uint32 id,
583 uint32 address_u_value,
584 uint32 address_v_value,
585 uint32 address_w_value,
586 uint32 mag_filter_value,
587 uint32 min_filter_value,
588 uint32 mip_filter_value,
589 uint32 max_anisotropy) {
590 cmd::SetSamplerStates& cmd = GetCmdSpace<cmd::SetSamplerStates>();
591 cmd.Init(
592 id,
593 address_u_value,
594 address_v_value,
595 address_w_value,
596 mag_filter_value,
597 min_filter_value,
598 mip_filter_value,
599 max_anisotropy);
600 }
601
602 void SetSamplerBorderColor(
603 uint32 id,
604 float red, float green, float blue, float alpha) {
605 cmd::SetSamplerBorderColor& cmd =
606 GetCmdSpace<cmd::SetSamplerBorderColor>();
607 cmd.Init(id, red, green, blue, alpha);
608 }
609
610 void SetSamplerTexture(uint32 id, uint32 texture_id) {
611 cmd::SetSamplerTexture& cmd = GetCmdSpace<cmd::SetSamplerTexture>();
612 cmd.Init(id, texture_id);
613 }
614
615 void SetScissor(
616 uint32 x,
617 uint32 y,
618 uint32 width,
619 uint32 height,
620 bool enable) {
621 cmd::SetScissor& cmd = GetCmdSpace<cmd::SetScissor>();
622 cmd.Init(
623 x,
624 y,
625 width,
626 height,
627 enable);
628 }
629
630 void SetPolygonOffset(float slope_factor, float units) {
631 cmd::SetPolygonOffset& cmd = GetCmdSpace<cmd::SetPolygonOffset>();
632 cmd.Init(slope_factor, units);
633 }
634
635 void SetPointLineRaster(
636 bool line_smooth_enable, bool point_sprite_enable, float point_size) {
637 cmd::SetPointLineRaster& cmd = GetCmdSpace<cmd::SetPointLineRaster>();
638 cmd.Init(line_smooth_enable, point_sprite_enable, point_size);
639 }
640
641 void SetPolygonRaster(uint32 fill_mode, uint32 cull_mode) {
642 cmd::SetPolygonRaster& cmd = GetCmdSpace<cmd::SetPolygonRaster>();
643 cmd.Init(fill_mode, cull_mode);
644 }
645
646 void SetAlphaTest(uint32 func, bool enable, float value) {
647 cmd::SetAlphaTest& cmd = GetCmdSpace<cmd::SetAlphaTest>();
648 cmd.Init(func, enable, value);
649 }
650
651 void SetDepthTest(uint32 func, bool write_enable, bool enable) {
652 cmd::SetDepthTest& cmd = GetCmdSpace<cmd::SetDepthTest>();
653 cmd.Init(func, write_enable, enable);
654 }
655
656 void SetStencilTest(
657 uint8 write_mask,
658 uint8 compare_mask,
659 uint8 reference_value,
660 bool separate_ccw,
661 bool enable,
662 uint8 cw_func,
663 uint8 cw_pass_op,
664 uint8 cw_fail_op,
665 uint8 cw_z_fail_op,
666 uint8 ccw_func,
667 uint8 ccw_pass_op,
668 uint8 ccw_fail_op,
669 uint8 ccw_z_fail_op) {
670 cmd::SetStencilTest& cmd = GetCmdSpace<cmd::SetStencilTest>();
671 cmd.Init(
672 write_mask,
673 compare_mask,
674 reference_value,
675 separate_ccw,
676 enable,
677 cw_func,
678 cw_pass_op,
679 cw_fail_op,
680 cw_z_fail_op,
681 ccw_func,
682 ccw_pass_op,
683 ccw_fail_op,
684 ccw_z_fail_op);
685 }
686
687 void SetColorWrite(uint8 mask, bool dither_enable) {
688 cmd::SetColorWrite& cmd = GetCmdSpace<cmd::SetColorWrite>();
689 cmd.Init(mask, dither_enable);
690 }
691
692 void SetBlending(
693 uint8 color_src_func,
694 uint8 color_dst_func,
695 uint8 color_eq,
696 uint8 alpha_src_func,
697 uint8 alpha_dst_func,
698 uint8 alpha_eq,
699 bool separate_alpha,
700 bool enable) {
701 cmd::SetBlending& cmd = GetCmdSpace<cmd::SetBlending>();
702 cmd.Init(
703 color_src_func,
704 color_dst_func,
705 color_eq,
706 alpha_src_func,
707 alpha_dst_func,
708 alpha_eq,
709 separate_alpha,
710 enable);
711 }
712
713 void SetBlendingColor(float red, float green, float blue, float alpha) {
714 cmd::SetBlendingColor& cmd = GetCmdSpace<cmd::SetBlendingColor>();
715 cmd.Init(red, green, blue, alpha);
716 }
717
718 void CreateRenderSurface(
719 uint32 id, uint32 texture_id,
720 uint32 width, uint32 height,
721 uint32 level, uint32 side) {
722 cmd::CreateRenderSurface& cmd = GetCmdSpace<cmd::CreateRenderSurface>();
723 cmd.Init(id, texture_id, width, height, level, side);
724 }
725
726 void DestroyRenderSurface(uint32 id) {
727 cmd::DestroyRenderSurface& cmd =
728 GetCmdSpace<cmd::DestroyRenderSurface>();
729 cmd.Init(id);
730 }
731
732 void CreateDepthSurface(uint32 id, uint32 width, uint32 height) {
733 cmd::CreateDepthSurface& cmd = GetCmdSpace<cmd::CreateDepthSurface>();
734 cmd.Init(id, width, height);
735 }
736
737 void DestroyDepthSurface(uint32 id) {
738 cmd::DestroyDepthSurface& cmd = GetCmdSpace<cmd::DestroyDepthSurface>();
739 cmd.Init(id);
740 }
741
742 void SetRenderSurface(uint32 render_surface_id, uint32 depth_surface_id) {
743 cmd::SetRenderSurface& cmd = GetCmdSpace<cmd::SetRenderSurface>();
744 cmd.Init(render_surface_id, depth_surface_id);
745 }
746
747 void SetBackSurfaces() {
748 cmd::SetBackSurfaces& cmd = GetCmdSpace<cmd::SetBackSurfaces>();
749 cmd.Init();
750 }
751
133 private: 752 private:
134 // Waits until get changes, updating the value of get_. 753 // Waits until get changes, updating the value of get_.
135 void WaitForGetChange(); 754 void WaitForGetChange();
136 755
137 // Returns the number of available entries (they may not be contiguous). 756 // Returns the number of available entries (they may not be contiguous).
138 unsigned int AvailableEntries() { 757 unsigned int AvailableEntries() {
139 return (get_ - put_ - 1 + entry_count_) % entry_count_; 758 return static_cast<unsigned int>(
759 (get_ - put_ - 1 + entry_count_) % entry_count_);
140 } 760 }
141 761
142 BufferSyncInterface *interface_; 762 BufferSyncInterface *interface_;
143 CommandBufferEntry *entries_; 763 CommandBufferEntry *entries_;
144 unsigned int entry_count_; 764 unsigned int entry_count_;
145 unsigned int token_; 765 unsigned int token_;
146 unsigned int last_token_read_; 766 unsigned int last_token_read_;
147 RPCShmHandle shm_handle_; 767 RPCShmHandle shm_handle_;
148 unsigned int shm_id_; 768 unsigned int shm_id_;
149 CommandBufferOffset get_; 769 CommandBufferOffset get_;
150 CommandBufferOffset put_; 770 CommandBufferOffset put_;
151 771
152 friend class CommandBufferHelperTest; 772 friend class CommandBufferHelperTest;
153 }; 773 };
154 774
155 } // namespace command_buffer 775 } // namespace command_buffer
156 } // namespace o3d 776 } // namespace o3d
157 777
158 #endif // O3D_COMMAND_BUFFER_CLIENT_CROSS_CMD_BUFFER_HELPER_H_ 778 #endif // O3D_COMMAND_BUFFER_CLIENT_CROSS_CMD_BUFFER_HELPER_H_
OLDNEW
« no previous file with comments | « command_buffer/client/cross/buffer_sync_proxy_test.cc ('k') | command_buffer/client/cross/cmd_buffer_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698