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_shader.h"
40 int rbug_send_shader_list(struct rbug_connection
*__con
,
41 rbug_context_t context
,
46 uint8_t *__data
= NULL
;
55 __data
= (uint8_t*)MALLOC(__len
);
59 WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_LIST
));
60 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
61 WRITE(8, rbug_context_t
, context
); /* context */
69 rbug_connection_send_start(__con
, RBUG_OP_SHADER_LIST
, __len
);
70 rbug_connection_write(__con
, __data
, __len
);
71 __ret
= rbug_connection_send_finish(__con
, __serial
);
78 int rbug_send_shader_info(struct rbug_connection
*__con
,
79 rbug_context_t context
,
85 uint8_t *__data
= NULL
;
95 __data
= (uint8_t*)MALLOC(__len
);
99 WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_INFO
));
100 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
101 WRITE(8, rbug_context_t
, context
); /* context */
102 WRITE(8, rbug_shader_t
, shader
); /* shader */
107 if (__pos
!= __len
) {
110 rbug_connection_send_start(__con
, RBUG_OP_SHADER_INFO
, __len
);
111 rbug_connection_write(__con
, __data
, __len
);
112 __ret
= rbug_connection_send_finish(__con
, __serial
);
119 int rbug_send_shader_disable(struct rbug_connection
*__con
,
120 rbug_context_t context
,
121 rbug_shader_t shader
,
127 uint8_t *__data
= NULL
;
131 LEN(8); /* context */
133 LEN(1); /* disable */
138 __data
= (uint8_t*)MALLOC(__len
);
142 WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_DISABLE
));
143 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
144 WRITE(8, rbug_context_t
, context
); /* context */
145 WRITE(8, rbug_shader_t
, shader
); /* shader */
146 WRITE(1, uint8_t, disable
); /* disable */
151 if (__pos
!= __len
) {
154 rbug_connection_send_start(__con
, RBUG_OP_SHADER_DISABLE
, __len
);
155 rbug_connection_write(__con
, __data
, __len
);
156 __ret
= rbug_connection_send_finish(__con
, __serial
);
163 int rbug_send_shader_replace(struct rbug_connection
*__con
,
164 rbug_context_t context
,
165 rbug_shader_t shader
,
172 uint8_t *__data
= NULL
;
176 LEN(8); /* context */
178 LEN_ARRAY(4, tokens
); /* tokens */
183 __data
= (uint8_t*)MALLOC(__len
);
187 WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_REPLACE
));
188 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
189 WRITE(8, rbug_context_t
, context
); /* context */
190 WRITE(8, rbug_shader_t
, shader
); /* shader */
191 WRITE_ARRAY(4, uint32_t, tokens
); /* tokens */
196 if (__pos
!= __len
) {
199 rbug_connection_send_start(__con
, RBUG_OP_SHADER_REPLACE
, __len
);
200 rbug_connection_write(__con
, __data
, __len
);
201 __ret
= rbug_connection_send_finish(__con
, __serial
);
208 int rbug_send_shader_list_reply(struct rbug_connection
*__con
,
210 rbug_shader_t
*shaders
,
211 uint32_t shaders_len
,
216 uint8_t *__data
= NULL
;
221 LEN_ARRAY(8, shaders
); /* shaders */
226 __data
= (uint8_t*)MALLOC(__len
);
230 WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_LIST_REPLY
));
231 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
232 WRITE(4, uint32_t, serial
); /* serial */
233 WRITE_ARRAY(8, rbug_shader_t
, shaders
); /* shaders */
238 if (__pos
!= __len
) {
241 rbug_connection_send_start(__con
, RBUG_OP_SHADER_LIST_REPLY
, __len
);
242 rbug_connection_write(__con
, __data
, __len
);
243 __ret
= rbug_connection_send_finish(__con
, __serial
);
250 int rbug_send_shader_info_reply(struct rbug_connection
*__con
,
253 uint32_t original_len
,
255 uint32_t replaced_len
,
261 uint8_t *__data
= NULL
;
266 LEN_ARRAY(4, original
); /* original */
267 LEN_ARRAY(4, replaced
); /* replaced */
268 LEN(1); /* disabled */
273 __data
= (uint8_t*)MALLOC(__len
);
277 WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_INFO_REPLY
));
278 WRITE(4, uint32_t, ((uint32_t)(__len
/ 4)));
279 WRITE(4, uint32_t, serial
); /* serial */
280 WRITE_ARRAY(4, uint32_t, original
); /* original */
281 WRITE_ARRAY(4, uint32_t, replaced
); /* replaced */
282 WRITE(1, uint8_t, disabled
); /* disabled */
287 if (__pos
!= __len
) {
290 rbug_connection_send_start(__con
, RBUG_OP_SHADER_INFO_REPLY
, __len
);
291 rbug_connection_write(__con
, __data
, __len
);
292 __ret
= rbug_connection_send_finish(__con
, __serial
);
299 struct rbug_proto_shader_list
* rbug_demarshal_shader_list(struct rbug_proto_header
*header
)
303 uint8_t *data
= NULL
;
304 struct rbug_proto_shader_list
*ret
;
308 if (header
->opcode
!= (int32_t)RBUG_OP_SHADER_LIST
)
312 len
= header
->length
* 4;
313 data
= (uint8_t*)&header
[1];
314 ret
= MALLOC(sizeof(*ret
));
318 ret
->header
.__message
= header
;
319 ret
->header
.opcode
= header
->opcode
;
321 READ(8, rbug_context_t
, context
); /* context */
326 struct rbug_proto_shader_info
* rbug_demarshal_shader_info(struct rbug_proto_header
*header
)
330 uint8_t *data
= NULL
;
331 struct rbug_proto_shader_info
*ret
;
335 if (header
->opcode
!= (int32_t)RBUG_OP_SHADER_INFO
)
339 len
= header
->length
* 4;
340 data
= (uint8_t*)&header
[1];
341 ret
= MALLOC(sizeof(*ret
));
345 ret
->header
.__message
= header
;
346 ret
->header
.opcode
= header
->opcode
;
348 READ(8, rbug_context_t
, context
); /* context */
349 READ(8, rbug_shader_t
, shader
); /* shader */
354 struct rbug_proto_shader_disable
* rbug_demarshal_shader_disable(struct rbug_proto_header
*header
)
358 uint8_t *data
= NULL
;
359 struct rbug_proto_shader_disable
*ret
;
363 if (header
->opcode
!= (int32_t)RBUG_OP_SHADER_DISABLE
)
367 len
= header
->length
* 4;
368 data
= (uint8_t*)&header
[1];
369 ret
= MALLOC(sizeof(*ret
));
373 ret
->header
.__message
= header
;
374 ret
->header
.opcode
= header
->opcode
;
376 READ(8, rbug_context_t
, context
); /* context */
377 READ(8, rbug_shader_t
, shader
); /* shader */
378 READ(1, uint8_t, disable
); /* disable */
383 struct rbug_proto_shader_replace
* rbug_demarshal_shader_replace(struct rbug_proto_header
*header
)
387 uint8_t *data
= NULL
;
388 struct rbug_proto_shader_replace
*ret
;
392 if (header
->opcode
!= (int32_t)RBUG_OP_SHADER_REPLACE
)
396 len
= header
->length
* 4;
397 data
= (uint8_t*)&header
[1];
398 ret
= MALLOC(sizeof(*ret
));
402 ret
->header
.__message
= header
;
403 ret
->header
.opcode
= header
->opcode
;
405 READ(8, rbug_context_t
, context
); /* context */
406 READ(8, rbug_shader_t
, shader
); /* shader */
407 READ_ARRAY(4, uint32_t, tokens
); /* tokens */
412 struct rbug_proto_shader_list_reply
* rbug_demarshal_shader_list_reply(struct rbug_proto_header
*header
)
416 uint8_t *data
= NULL
;
417 struct rbug_proto_shader_list_reply
*ret
;
421 if (header
->opcode
!= (int32_t)RBUG_OP_SHADER_LIST_REPLY
)
425 len
= header
->length
* 4;
426 data
= (uint8_t*)&header
[1];
427 ret
= MALLOC(sizeof(*ret
));
431 ret
->header
.__message
= header
;
432 ret
->header
.opcode
= header
->opcode
;
434 READ(4, uint32_t, serial
); /* serial */
435 READ_ARRAY(8, rbug_shader_t
, shaders
); /* shaders */
440 struct rbug_proto_shader_info_reply
* rbug_demarshal_shader_info_reply(struct rbug_proto_header
*header
)
444 uint8_t *data
= NULL
;
445 struct rbug_proto_shader_info_reply
*ret
;
449 if (header
->opcode
!= (int32_t)RBUG_OP_SHADER_INFO_REPLY
)
453 len
= header
->length
* 4;
454 data
= (uint8_t*)&header
[1];
455 ret
= MALLOC(sizeof(*ret
));
459 ret
->header
.__message
= header
;
460 ret
->header
.opcode
= header
->opcode
;
462 READ(4, uint32_t, serial
); /* serial */
463 READ_ARRAY(4, uint32_t, original
); /* original */
464 READ_ARRAY(4, uint32_t, replaced
); /* replaced */
465 READ(1, uint8_t, disabled
); /* disabled */