2 * Copyright 2009 VMware, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * This file holds the function implementation for one of the rbug extensions.
27 * Prototypes and declerations of functions and structs is in the same folder
28 * in the header file matching this file's name.
30 * The functions starting rbug_send_* encodes a call to the write format and
31 * sends that to the supplied connection, while functions starting with
32 * rbug_demarshal_* demarshal data in the wire protocol.
34 * Functions ending with _reply are replies to requests.
37 #include "rbug_internal.h"
38 #include "rbug/rbug_context.h"
40 int rbug_send_context_list(struct rbug_connection
*__con
,
45 uint8_t *__data
= NULL
;
53 __data
= (uint8_t*)MALLOC(__len
);
57 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_LIST
));
58 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
66 rbug_connection_send_start(__con
, RBUG_OP_CONTEXT_LIST
, __len
);
67 rbug_connection_write(__con
, __data
, __len
);
68 __ret
= rbug_connection_send_finish(__con
, __serial
);
75 int rbug_send_context_info(struct rbug_connection
*__con
,
76 rbug_context_t context
,
81 uint8_t *__data
= NULL
;
90 __data
= (uint8_t*)MALLOC(__len
);
94 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_INFO
));
95 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
96 WRITE(8, rbug_context_t
, context
); /* context */
101 if (__pos
!= __len
) {
104 rbug_connection_send_start(__con
, RBUG_OP_CONTEXT_INFO
, __len
);
105 rbug_connection_write(__con
, __data
, __len
);
106 __ret
= rbug_connection_send_finish(__con
, __serial
);
113 int rbug_send_context_draw_block(struct rbug_connection
*__con
,
114 rbug_context_t context
,
120 uint8_t *__data
= NULL
;
124 LEN(8); /* context */
130 __data
= (uint8_t*)MALLOC(__len
);
134 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_BLOCK
));
135 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
136 WRITE(8, rbug_context_t
, context
); /* context */
137 WRITE(4, rbug_block_t
, block
); /* block */
142 if (__pos
!= __len
) {
145 rbug_connection_send_start(__con
, RBUG_OP_CONTEXT_DRAW_BLOCK
, __len
);
146 rbug_connection_write(__con
, __data
, __len
);
147 __ret
= rbug_connection_send_finish(__con
, __serial
);
154 int rbug_send_context_draw_step(struct rbug_connection
*__con
,
155 rbug_context_t context
,
161 uint8_t *__data
= NULL
;
165 LEN(8); /* context */
171 __data
= (uint8_t*)MALLOC(__len
);
175 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_STEP
));
176 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
177 WRITE(8, rbug_context_t
, context
); /* context */
178 WRITE(4, rbug_block_t
, step
); /* step */
183 if (__pos
!= __len
) {
186 rbug_connection_send_start(__con
, RBUG_OP_CONTEXT_DRAW_STEP
, __len
);
187 rbug_connection_write(__con
, __data
, __len
);
188 __ret
= rbug_connection_send_finish(__con
, __serial
);
195 int rbug_send_context_draw_unblock(struct rbug_connection
*__con
,
196 rbug_context_t context
,
197 rbug_block_t unblock
,
202 uint8_t *__data
= NULL
;
206 LEN(8); /* context */
207 LEN(4); /* unblock */
212 __data
= (uint8_t*)MALLOC(__len
);
216 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_UNBLOCK
));
217 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
218 WRITE(8, rbug_context_t
, context
); /* context */
219 WRITE(4, rbug_block_t
, unblock
); /* unblock */
224 if (__pos
!= __len
) {
227 rbug_connection_send_start(__con
, RBUG_OP_CONTEXT_DRAW_UNBLOCK
, __len
);
228 rbug_connection_write(__con
, __data
, __len
);
229 __ret
= rbug_connection_send_finish(__con
, __serial
);
236 int rbug_send_context_draw_rule(struct rbug_connection
*__con
,
237 rbug_context_t context
,
238 rbug_shader_t vertex
,
239 rbug_shader_t fragment
,
240 rbug_texture_t texture
,
241 rbug_texture_t surface
,
247 uint8_t *__data
= NULL
;
251 LEN(8); /* context */
253 LEN(8); /* fragment */
254 LEN(8); /* texture */
255 LEN(8); /* surface */
261 __data
= (uint8_t*)MALLOC(__len
);
265 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_RULE
));
266 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
267 WRITE(8, rbug_context_t
, context
); /* context */
268 WRITE(8, rbug_shader_t
, vertex
); /* vertex */
269 WRITE(8, rbug_shader_t
, fragment
); /* fragment */
270 WRITE(8, rbug_texture_t
, texture
); /* texture */
271 WRITE(8, rbug_texture_t
, surface
); /* surface */
272 WRITE(4, rbug_block_t
, block
); /* block */
277 if (__pos
!= __len
) {
280 rbug_connection_send_start(__con
, RBUG_OP_CONTEXT_DRAW_RULE
, __len
);
281 rbug_connection_write(__con
, __data
, __len
);
282 __ret
= rbug_connection_send_finish(__con
, __serial
);
289 int rbug_send_context_flush(struct rbug_connection
*__con
,
290 rbug_context_t context
,
295 uint8_t *__data
= NULL
;
299 LEN(8); /* context */
304 __data
= (uint8_t*)MALLOC(__len
);
308 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_FLUSH
));
309 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
310 WRITE(8, rbug_context_t
, context
); /* context */
315 if (__pos
!= __len
) {
318 rbug_connection_send_start(__con
, RBUG_OP_CONTEXT_FLUSH
, __len
);
319 rbug_connection_write(__con
, __data
, __len
);
320 __ret
= rbug_connection_send_finish(__con
, __serial
);
327 int rbug_send_context_list_reply(struct rbug_connection
*__con
,
329 rbug_context_t
*contexts
,
330 uint32_t contexts_len
,
335 uint8_t *__data
= NULL
;
340 LEN_ARRAY(8, contexts
); /* contexts */
345 __data
= (uint8_t*)MALLOC(__len
);
349 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_LIST_REPLY
));
350 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
351 WRITE(4, uint32_t, serial
); /* serial */
352 WRITE_ARRAY(8, rbug_context_t
, contexts
); /* contexts */
357 if (__pos
!= __len
) {
360 rbug_connection_send_start(__con
, RBUG_OP_CONTEXT_LIST_REPLY
, __len
);
361 rbug_connection_write(__con
, __data
, __len
);
362 __ret
= rbug_connection_send_finish(__con
, __serial
);
369 int rbug_send_context_info_reply(struct rbug_connection
*__con
,
371 rbug_shader_t vertex
,
372 rbug_shader_t fragment
,
373 rbug_texture_t
*texs
,
375 rbug_texture_t
*cbufs
,
377 rbug_texture_t zsbuf
,
378 rbug_block_t blocker
,
379 rbug_block_t blocked
,
384 uint8_t *__data
= NULL
;
390 LEN(8); /* fragment */
391 LEN_ARRAY(8, texs
); /* texs */
392 LEN_ARRAY(8, cbufs
); /* cbufs */
394 LEN(4); /* blocker */
395 LEN(4); /* blocked */
400 __data
= (uint8_t*)MALLOC(__len
);
404 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_INFO_REPLY
));
405 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
406 WRITE(4, uint32_t, serial
); /* serial */
407 WRITE(8, rbug_shader_t
, vertex
); /* vertex */
408 WRITE(8, rbug_shader_t
, fragment
); /* fragment */
409 WRITE_ARRAY(8, rbug_texture_t
, texs
); /* texs */
410 WRITE_ARRAY(8, rbug_texture_t
, cbufs
); /* cbufs */
411 WRITE(8, rbug_texture_t
, zsbuf
); /* zsbuf */
412 WRITE(4, rbug_block_t
, blocker
); /* blocker */
413 WRITE(4, rbug_block_t
, blocked
); /* blocked */
418 if (__pos
!= __len
) {
421 rbug_connection_send_start(__con
, RBUG_OP_CONTEXT_INFO_REPLY
, __len
);
422 rbug_connection_write(__con
, __data
, __len
);
423 __ret
= rbug_connection_send_finish(__con
, __serial
);
430 int rbug_send_context_draw_blocked(struct rbug_connection
*__con
,
431 rbug_context_t context
,
437 uint8_t *__data
= NULL
;
441 LEN(8); /* context */
447 __data
= (uint8_t*)MALLOC(__len
);
451 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_BLOCKED
));
452 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
453 WRITE(8, rbug_context_t
, context
); /* context */
454 WRITE(4, rbug_block_t
, block
); /* block */
459 if (__pos
!= __len
) {
462 rbug_connection_send_start(__con
, RBUG_OP_CONTEXT_DRAW_BLOCKED
, __len
);
463 rbug_connection_write(__con
, __data
, __len
);
464 __ret
= rbug_connection_send_finish(__con
, __serial
);
471 struct rbug_proto_context_list
* rbug_demarshal_context_list(struct rbug_proto_header
*header
)
473 struct rbug_proto_context_list
*ret
;
477 if (header
->opcode
!= (int32_t)RBUG_OP_CONTEXT_LIST
)
480 ret
= MALLOC(sizeof(*ret
));
484 ret
->header
.__message
= header
;
485 ret
->header
.opcode
= header
->opcode
;
490 struct rbug_proto_context_info
* rbug_demarshal_context_info(struct rbug_proto_header
*header
)
494 uint8_t *data
= NULL
;
495 struct rbug_proto_context_info
*ret
;
499 if (header
->opcode
!= (int32_t)RBUG_OP_CONTEXT_INFO
)
503 len
= header
->length
* 4;
504 data
= (uint8_t*)&header
[1];
505 ret
= MALLOC(sizeof(*ret
));
509 ret
->header
.__message
= header
;
510 ret
->header
.opcode
= header
->opcode
;
512 READ(8, rbug_context_t
, context
); /* context */
517 struct rbug_proto_context_draw_block
* rbug_demarshal_context_draw_block(struct rbug_proto_header
*header
)
521 uint8_t *data
= NULL
;
522 struct rbug_proto_context_draw_block
*ret
;
526 if (header
->opcode
!= (int32_t)RBUG_OP_CONTEXT_DRAW_BLOCK
)
530 len
= header
->length
* 4;
531 data
= (uint8_t*)&header
[1];
532 ret
= MALLOC(sizeof(*ret
));
536 ret
->header
.__message
= header
;
537 ret
->header
.opcode
= header
->opcode
;
539 READ(8, rbug_context_t
, context
); /* context */
540 READ(4, rbug_block_t
, block
); /* block */
545 struct rbug_proto_context_draw_step
* rbug_demarshal_context_draw_step(struct rbug_proto_header
*header
)
549 uint8_t *data
= NULL
;
550 struct rbug_proto_context_draw_step
*ret
;
554 if (header
->opcode
!= (int32_t)RBUG_OP_CONTEXT_DRAW_STEP
)
558 len
= header
->length
* 4;
559 data
= (uint8_t*)&header
[1];
560 ret
= MALLOC(sizeof(*ret
));
564 ret
->header
.__message
= header
;
565 ret
->header
.opcode
= header
->opcode
;
567 READ(8, rbug_context_t
, context
); /* context */
568 READ(4, rbug_block_t
, step
); /* step */
573 struct rbug_proto_context_draw_unblock
* rbug_demarshal_context_draw_unblock(struct rbug_proto_header
*header
)
577 uint8_t *data
= NULL
;
578 struct rbug_proto_context_draw_unblock
*ret
;
582 if (header
->opcode
!= (int32_t)RBUG_OP_CONTEXT_DRAW_UNBLOCK
)
586 len
= header
->length
* 4;
587 data
= (uint8_t*)&header
[1];
588 ret
= MALLOC(sizeof(*ret
));
592 ret
->header
.__message
= header
;
593 ret
->header
.opcode
= header
->opcode
;
595 READ(8, rbug_context_t
, context
); /* context */
596 READ(4, rbug_block_t
, unblock
); /* unblock */
601 struct rbug_proto_context_draw_rule
* rbug_demarshal_context_draw_rule(struct rbug_proto_header
*header
)
605 uint8_t *data
= NULL
;
606 struct rbug_proto_context_draw_rule
*ret
;
610 if (header
->opcode
!= (int32_t)RBUG_OP_CONTEXT_DRAW_RULE
)
614 len
= header
->length
* 4;
615 data
= (uint8_t*)&header
[1];
616 ret
= MALLOC(sizeof(*ret
));
620 ret
->header
.__message
= header
;
621 ret
->header
.opcode
= header
->opcode
;
623 READ(8, rbug_context_t
, context
); /* context */
624 READ(8, rbug_shader_t
, vertex
); /* vertex */
625 READ(8, rbug_shader_t
, fragment
); /* fragment */
626 READ(8, rbug_texture_t
, texture
); /* texture */
627 READ(8, rbug_texture_t
, surface
); /* surface */
628 READ(4, rbug_block_t
, block
); /* block */
633 struct rbug_proto_context_flush
* rbug_demarshal_context_flush(struct rbug_proto_header
*header
)
637 uint8_t *data
= NULL
;
638 struct rbug_proto_context_flush
*ret
;
642 if (header
->opcode
!= (int32_t)RBUG_OP_CONTEXT_FLUSH
)
646 len
= header
->length
* 4;
647 data
= (uint8_t*)&header
[1];
648 ret
= MALLOC(sizeof(*ret
));
652 ret
->header
.__message
= header
;
653 ret
->header
.opcode
= header
->opcode
;
655 READ(8, rbug_context_t
, context
); /* context */
660 struct rbug_proto_context_list_reply
* rbug_demarshal_context_list_reply(struct rbug_proto_header
*header
)
664 uint8_t *data
= NULL
;
665 struct rbug_proto_context_list_reply
*ret
;
669 if (header
->opcode
!= (int32_t)RBUG_OP_CONTEXT_LIST_REPLY
)
673 len
= header
->length
* 4;
674 data
= (uint8_t*)&header
[1];
675 ret
= MALLOC(sizeof(*ret
));
679 ret
->header
.__message
= header
;
680 ret
->header
.opcode
= header
->opcode
;
682 READ(4, uint32_t, serial
); /* serial */
683 READ_ARRAY(8, rbug_context_t
, contexts
); /* contexts */
688 struct rbug_proto_context_info_reply
* rbug_demarshal_context_info_reply(struct rbug_proto_header
*header
)
692 uint8_t *data
= NULL
;
693 struct rbug_proto_context_info_reply
*ret
;
697 if (header
->opcode
!= (int32_t)RBUG_OP_CONTEXT_INFO_REPLY
)
701 len
= header
->length
* 4;
702 data
= (uint8_t*)&header
[1];
703 ret
= MALLOC(sizeof(*ret
));
707 ret
->header
.__message
= header
;
708 ret
->header
.opcode
= header
->opcode
;
710 READ(4, uint32_t, serial
); /* serial */
711 READ(8, rbug_shader_t
, vertex
); /* vertex */
712 READ(8, rbug_shader_t
, fragment
); /* fragment */
713 READ_ARRAY(8, rbug_texture_t
, texs
); /* texs */
714 READ_ARRAY(8, rbug_texture_t
, cbufs
); /* cbufs */
715 READ(8, rbug_texture_t
, zsbuf
); /* zsbuf */
716 READ(4, rbug_block_t
, blocker
); /* blocker */
717 READ(4, rbug_block_t
, blocked
); /* blocked */
722 struct rbug_proto_context_draw_blocked
* rbug_demarshal_context_draw_blocked(struct rbug_proto_header
*header
)
726 uint8_t *data
= NULL
;
727 struct rbug_proto_context_draw_blocked
*ret
;
731 if (header
->opcode
!= (int32_t)RBUG_OP_CONTEXT_DRAW_BLOCKED
)
735 len
= header
->length
* 4;
736 data
= (uint8_t*)&header
[1];
737 ret
= MALLOC(sizeof(*ret
));
741 ret
->header
.__message
= header
;
742 ret
->header
.opcode
= header
->opcode
;
744 READ(8, rbug_context_t
, context
); /* context */
745 READ(4, rbug_block_t
, block
); /* block */