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_flush(struct rbug_connection
*__con
,
237 rbug_context_t context
,
243 uint8_t *__data
= NULL
;
247 LEN(8); /* context */
253 __data
= (uint8_t*)MALLOC(__len
);
257 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_FLUSH
));
258 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
259 WRITE(8, rbug_context_t
, context
); /* context */
260 WRITE(4, int32_t, flags
); /* flags */
265 if (__pos
!= __len
) {
268 rbug_connection_send_start(__con
, RBUG_OP_CONTEXT_FLUSH
, __len
);
269 rbug_connection_write(__con
, __data
, __len
);
270 __ret
= rbug_connection_send_finish(__con
, __serial
);
277 int rbug_send_context_list_reply(struct rbug_connection
*__con
,
279 rbug_context_t
*contexts
,
280 uint32_t contexts_len
,
285 uint8_t *__data
= NULL
;
290 LEN_ARRAY(8, contexts
); /* contexts */
295 __data
= (uint8_t*)MALLOC(__len
);
299 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_LIST_REPLY
));
300 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
301 WRITE(4, uint32_t, serial
); /* serial */
302 WRITE_ARRAY(8, rbug_context_t
, contexts
); /* contexts */
307 if (__pos
!= __len
) {
310 rbug_connection_send_start(__con
, RBUG_OP_CONTEXT_LIST_REPLY
, __len
);
311 rbug_connection_write(__con
, __data
, __len
);
312 __ret
= rbug_connection_send_finish(__con
, __serial
);
319 int rbug_send_context_info_reply(struct rbug_connection
*__con
,
321 rbug_shader_t vertex
,
322 rbug_shader_t fragment
,
323 rbug_texture_t
*cbufs
,
325 rbug_texture_t zsbuf
,
326 rbug_block_t blocker
,
327 rbug_block_t blocked
,
332 uint8_t *__data
= NULL
;
338 LEN(8); /* fragment */
339 LEN_ARRAY(8, cbufs
); /* cbufs */
341 LEN(4); /* blocker */
342 LEN(4); /* blocked */
347 __data
= (uint8_t*)MALLOC(__len
);
351 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_INFO_REPLY
));
352 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
353 WRITE(4, uint32_t, serial
); /* serial */
354 WRITE(8, rbug_shader_t
, vertex
); /* vertex */
355 WRITE(8, rbug_shader_t
, fragment
); /* fragment */
356 WRITE_ARRAY(8, rbug_texture_t
, cbufs
); /* cbufs */
357 WRITE(8, rbug_texture_t
, zsbuf
); /* zsbuf */
358 WRITE(4, rbug_block_t
, blocker
); /* blocker */
359 WRITE(4, rbug_block_t
, blocked
); /* blocked */
364 if (__pos
!= __len
) {
367 rbug_connection_send_start(__con
, RBUG_OP_CONTEXT_INFO_REPLY
, __len
);
368 rbug_connection_write(__con
, __data
, __len
);
369 __ret
= rbug_connection_send_finish(__con
, __serial
);
376 int rbug_send_context_draw_blocked(struct rbug_connection
*__con
,
377 rbug_context_t context
,
383 uint8_t *__data
= NULL
;
387 LEN(8); /* context */
393 __data
= (uint8_t*)MALLOC(__len
);
397 WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_BLOCKED
));
398 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
399 WRITE(8, rbug_context_t
, context
); /* context */
400 WRITE(4, rbug_block_t
, block
); /* block */
405 if (__pos
!= __len
) {
408 rbug_connection_send_start(__con
, RBUG_OP_CONTEXT_DRAW_BLOCKED
, __len
);
409 rbug_connection_write(__con
, __data
, __len
);
410 __ret
= rbug_connection_send_finish(__con
, __serial
);
417 struct rbug_proto_context_list
* rbug_demarshal_context_list(struct rbug_proto_header
*header
)
421 uint8_t *data
= NULL
;
422 struct rbug_proto_context_list
*ret
;
426 if (header
->opcode
!= (int16_t)RBUG_OP_CONTEXT_LIST
)
430 len
= header
->length
* 4;
431 data
= (uint8_t*)&header
[1];
432 ret
= MALLOC(sizeof(*ret
));
436 ret
->header
.__message
= header
;
437 ret
->header
.opcode
= header
->opcode
;
443 struct rbug_proto_context_info
* rbug_demarshal_context_info(struct rbug_proto_header
*header
)
447 uint8_t *data
= NULL
;
448 struct rbug_proto_context_info
*ret
;
452 if (header
->opcode
!= (int16_t)RBUG_OP_CONTEXT_INFO
)
456 len
= header
->length
* 4;
457 data
= (uint8_t*)&header
[1];
458 ret
= MALLOC(sizeof(*ret
));
462 ret
->header
.__message
= header
;
463 ret
->header
.opcode
= header
->opcode
;
465 READ(8, rbug_context_t
, context
); /* context */
470 struct rbug_proto_context_draw_block
* rbug_demarshal_context_draw_block(struct rbug_proto_header
*header
)
474 uint8_t *data
= NULL
;
475 struct rbug_proto_context_draw_block
*ret
;
479 if (header
->opcode
!= (int16_t)RBUG_OP_CONTEXT_DRAW_BLOCK
)
483 len
= header
->length
* 4;
484 data
= (uint8_t*)&header
[1];
485 ret
= MALLOC(sizeof(*ret
));
489 ret
->header
.__message
= header
;
490 ret
->header
.opcode
= header
->opcode
;
492 READ(8, rbug_context_t
, context
); /* context */
493 READ(4, rbug_block_t
, block
); /* block */
498 struct rbug_proto_context_draw_step
* rbug_demarshal_context_draw_step(struct rbug_proto_header
*header
)
502 uint8_t *data
= NULL
;
503 struct rbug_proto_context_draw_step
*ret
;
507 if (header
->opcode
!= (int16_t)RBUG_OP_CONTEXT_DRAW_STEP
)
511 len
= header
->length
* 4;
512 data
= (uint8_t*)&header
[1];
513 ret
= MALLOC(sizeof(*ret
));
517 ret
->header
.__message
= header
;
518 ret
->header
.opcode
= header
->opcode
;
520 READ(8, rbug_context_t
, context
); /* context */
521 READ(4, rbug_block_t
, step
); /* step */
526 struct rbug_proto_context_draw_unblock
* rbug_demarshal_context_draw_unblock(struct rbug_proto_header
*header
)
530 uint8_t *data
= NULL
;
531 struct rbug_proto_context_draw_unblock
*ret
;
535 if (header
->opcode
!= (int16_t)RBUG_OP_CONTEXT_DRAW_UNBLOCK
)
539 len
= header
->length
* 4;
540 data
= (uint8_t*)&header
[1];
541 ret
= MALLOC(sizeof(*ret
));
545 ret
->header
.__message
= header
;
546 ret
->header
.opcode
= header
->opcode
;
548 READ(8, rbug_context_t
, context
); /* context */
549 READ(4, rbug_block_t
, unblock
); /* unblock */
554 struct rbug_proto_context_flush
* rbug_demarshal_context_flush(struct rbug_proto_header
*header
)
558 uint8_t *data
= NULL
;
559 struct rbug_proto_context_flush
*ret
;
563 if (header
->opcode
!= (int16_t)RBUG_OP_CONTEXT_FLUSH
)
567 len
= header
->length
* 4;
568 data
= (uint8_t*)&header
[1];
569 ret
= MALLOC(sizeof(*ret
));
573 ret
->header
.__message
= header
;
574 ret
->header
.opcode
= header
->opcode
;
576 READ(8, rbug_context_t
, context
); /* context */
577 READ(4, int32_t, flags
); /* flags */
582 struct rbug_proto_context_list_reply
* rbug_demarshal_context_list_reply(struct rbug_proto_header
*header
)
586 uint8_t *data
= NULL
;
587 struct rbug_proto_context_list_reply
*ret
;
591 if (header
->opcode
!= (int16_t)RBUG_OP_CONTEXT_LIST_REPLY
)
595 len
= header
->length
* 4;
596 data
= (uint8_t*)&header
[1];
597 ret
= MALLOC(sizeof(*ret
));
601 ret
->header
.__message
= header
;
602 ret
->header
.opcode
= header
->opcode
;
604 READ(4, uint32_t, serial
); /* serial */
605 READ_ARRAY(8, rbug_context_t
, contexts
); /* contexts */
610 struct rbug_proto_context_info_reply
* rbug_demarshal_context_info_reply(struct rbug_proto_header
*header
)
614 uint8_t *data
= NULL
;
615 struct rbug_proto_context_info_reply
*ret
;
619 if (header
->opcode
!= (int16_t)RBUG_OP_CONTEXT_INFO_REPLY
)
623 len
= header
->length
* 4;
624 data
= (uint8_t*)&header
[1];
625 ret
= MALLOC(sizeof(*ret
));
629 ret
->header
.__message
= header
;
630 ret
->header
.opcode
= header
->opcode
;
632 READ(4, uint32_t, serial
); /* serial */
633 READ(8, rbug_shader_t
, vertex
); /* vertex */
634 READ(8, rbug_shader_t
, fragment
); /* fragment */
635 READ_ARRAY(8, rbug_texture_t
, cbufs
); /* cbufs */
636 READ(8, rbug_texture_t
, zsbuf
); /* zsbuf */
637 READ(4, rbug_block_t
, blocker
); /* blocker */
638 READ(4, rbug_block_t
, blocked
); /* blocked */
643 struct rbug_proto_context_draw_blocked
* rbug_demarshal_context_draw_blocked(struct rbug_proto_header
*header
)
647 uint8_t *data
= NULL
;
648 struct rbug_proto_context_draw_blocked
*ret
;
652 if (header
->opcode
!= (int16_t)RBUG_OP_CONTEXT_DRAW_BLOCKED
)
656 len
= header
->length
* 4;
657 data
= (uint8_t*)&header
[1];
658 ret
= MALLOC(sizeof(*ret
));
662 ret
->header
.__message
= header
;
663 ret
->header
.opcode
= header
->opcode
;
665 READ(8, rbug_context_t
, context
); /* context */
666 READ(4, rbug_block_t
, block
); /* block */