14a49301eSmrg/* 24a49301eSmrg * Copyright 2009 VMware, Inc. 34a49301eSmrg * All Rights Reserved. 44a49301eSmrg * 54a49301eSmrg * Permission is hereby granted, free of charge, to any person obtaining a 64a49301eSmrg * copy of this software and associated documentation files (the "Software"), 74a49301eSmrg * to deal in the Software without restriction, including without limitation 84a49301eSmrg * on the rights to use, copy, modify, merge, publish, distribute, sub 94a49301eSmrg * license, and/or sell copies of the Software, and to permit persons to whom 104a49301eSmrg * the Software is furnished to do so, subject to the following conditions: 114a49301eSmrg * 124a49301eSmrg * The above copyright notice and this permission notice (including the next 134a49301eSmrg * paragraph) shall be included in all copies or substantial portions of the 144a49301eSmrg * Software. 154a49301eSmrg * 164a49301eSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 174a49301eSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 184a49301eSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 194a49301eSmrg * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 204a49301eSmrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 214a49301eSmrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 224a49301eSmrg * USE OR OTHER DEALINGS IN THE SOFTWARE. 234a49301eSmrg */ 244a49301eSmrg 254a49301eSmrg/* 264a49301eSmrg * This file holds the function implementation for one of the rbug extensions. 274a49301eSmrg * Prototypes and declerations of functions and structs is in the same folder 284a49301eSmrg * in the header file matching this file's name. 294a49301eSmrg * 304a49301eSmrg * The functions starting rbug_send_* encodes a call to the write format and 314a49301eSmrg * sends that to the supplied connection, while functions starting with 324a49301eSmrg * rbug_demarshal_* demarshal data in the wire protocol. 334a49301eSmrg * 344a49301eSmrg * Functions ending with _reply are replies to requests. 354a49301eSmrg */ 364a49301eSmrg 377ec681f3Smrg#include "c99_alloca.h" 387ec681f3Smrg 394a49301eSmrg#include "rbug_internal.h" 40af69d88dSmrg#include "rbug_texture.h" 414a49301eSmrg 424a49301eSmrgint rbug_send_texture_list(struct rbug_connection *__con, 434a49301eSmrg uint32_t *__serial) 444a49301eSmrg{ 454a49301eSmrg uint32_t __len = 0; 464a49301eSmrg uint32_t __pos = 0; 474a49301eSmrg uint8_t *__data = NULL; 484a49301eSmrg int __ret = 0; 494a49301eSmrg 504a49301eSmrg LEN(8); /* header */ 514a49301eSmrg 524a49301eSmrg /* align */ 534a49301eSmrg PAD(__len, 8); 544a49301eSmrg 554a49301eSmrg __data = (uint8_t*)MALLOC(__len); 564a49301eSmrg if (!__data) 574a49301eSmrg return -ENOMEM; 584a49301eSmrg 594a49301eSmrg WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_LIST)); 604a49301eSmrg WRITE(4, uint32_t, ((uint32_t)(__len / 4))); 614a49301eSmrg 624a49301eSmrg /* final pad */ 634a49301eSmrg PAD(__pos, 8); 644a49301eSmrg 654a49301eSmrg if (__pos != __len) { 664a49301eSmrg __ret = -EINVAL; 674a49301eSmrg } else { 684a49301eSmrg rbug_connection_send_start(__con, RBUG_OP_TEXTURE_LIST, __len); 694a49301eSmrg rbug_connection_write(__con, __data, __len); 704a49301eSmrg __ret = rbug_connection_send_finish(__con, __serial); 714a49301eSmrg } 724a49301eSmrg 734a49301eSmrg FREE(__data); 744a49301eSmrg return __ret; 754a49301eSmrg} 764a49301eSmrg 774a49301eSmrgint rbug_send_texture_info(struct rbug_connection *__con, 784a49301eSmrg rbug_texture_t texture, 794a49301eSmrg uint32_t *__serial) 804a49301eSmrg{ 814a49301eSmrg uint32_t __len = 0; 824a49301eSmrg uint32_t __pos = 0; 834a49301eSmrg uint8_t *__data = NULL; 844a49301eSmrg int __ret = 0; 854a49301eSmrg 864a49301eSmrg LEN(8); /* header */ 874a49301eSmrg LEN(8); /* texture */ 884a49301eSmrg 894a49301eSmrg /* align */ 904a49301eSmrg PAD(__len, 8); 914a49301eSmrg 924a49301eSmrg __data = (uint8_t*)MALLOC(__len); 934a49301eSmrg if (!__data) 944a49301eSmrg return -ENOMEM; 954a49301eSmrg 964a49301eSmrg WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_INFO)); 974a49301eSmrg WRITE(4, uint32_t, ((uint32_t)(__len / 4))); 984a49301eSmrg WRITE(8, rbug_texture_t, texture); /* texture */ 994a49301eSmrg 1004a49301eSmrg /* final pad */ 1014a49301eSmrg PAD(__pos, 8); 1024a49301eSmrg 1034a49301eSmrg if (__pos != __len) { 1044a49301eSmrg __ret = -EINVAL; 1054a49301eSmrg } else { 1064a49301eSmrg rbug_connection_send_start(__con, RBUG_OP_TEXTURE_INFO, __len); 1074a49301eSmrg rbug_connection_write(__con, __data, __len); 1084a49301eSmrg __ret = rbug_connection_send_finish(__con, __serial); 1094a49301eSmrg } 1104a49301eSmrg 1114a49301eSmrg FREE(__data); 1124a49301eSmrg return __ret; 1134a49301eSmrg} 1144a49301eSmrg 1154a49301eSmrgint rbug_send_texture_write(struct rbug_connection *__con, 1164a49301eSmrg rbug_texture_t texture, 1174a49301eSmrg uint32_t face, 1184a49301eSmrg uint32_t level, 1194a49301eSmrg uint32_t zslice, 1204a49301eSmrg uint32_t x, 1214a49301eSmrg uint32_t y, 1224a49301eSmrg uint32_t w, 1234a49301eSmrg uint32_t h, 1244a49301eSmrg uint8_t *data, 1254a49301eSmrg uint32_t data_len, 1264a49301eSmrg uint32_t stride, 1274a49301eSmrg uint32_t *__serial) 1284a49301eSmrg{ 1294a49301eSmrg uint32_t __len = 0; 1304a49301eSmrg uint32_t __pos = 0; 1314a49301eSmrg uint8_t *__data = NULL; 1324a49301eSmrg int __ret = 0; 1334a49301eSmrg 1344a49301eSmrg LEN(8); /* header */ 1354a49301eSmrg LEN(8); /* texture */ 1364a49301eSmrg LEN(4); /* face */ 1374a49301eSmrg LEN(4); /* level */ 1384a49301eSmrg LEN(4); /* zslice */ 1394a49301eSmrg LEN(4); /* x */ 1404a49301eSmrg LEN(4); /* y */ 1414a49301eSmrg LEN(4); /* w */ 1424a49301eSmrg LEN(4); /* h */ 1434a49301eSmrg LEN_ARRAY(1, data); /* data */ 1444a49301eSmrg LEN(4); /* stride */ 1454a49301eSmrg 1464a49301eSmrg /* align */ 1474a49301eSmrg PAD(__len, 8); 1484a49301eSmrg 1494a49301eSmrg __data = (uint8_t*)MALLOC(__len); 1504a49301eSmrg if (!__data) 1514a49301eSmrg return -ENOMEM; 1524a49301eSmrg 1534a49301eSmrg WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_WRITE)); 1544a49301eSmrg WRITE(4, uint32_t, ((uint32_t)(__len / 4))); 1554a49301eSmrg WRITE(8, rbug_texture_t, texture); /* texture */ 1564a49301eSmrg WRITE(4, uint32_t, face); /* face */ 1574a49301eSmrg WRITE(4, uint32_t, level); /* level */ 1584a49301eSmrg WRITE(4, uint32_t, zslice); /* zslice */ 1594a49301eSmrg WRITE(4, uint32_t, x); /* x */ 1604a49301eSmrg WRITE(4, uint32_t, y); /* y */ 1614a49301eSmrg WRITE(4, uint32_t, w); /* w */ 1624a49301eSmrg WRITE(4, uint32_t, h); /* h */ 1634a49301eSmrg WRITE_ARRAY(1, uint8_t, data); /* data */ 1644a49301eSmrg WRITE(4, uint32_t, stride); /* stride */ 1654a49301eSmrg 1664a49301eSmrg /* final pad */ 1674a49301eSmrg PAD(__pos, 8); 1684a49301eSmrg 1694a49301eSmrg if (__pos != __len) { 1704a49301eSmrg __ret = -EINVAL; 1714a49301eSmrg } else { 1724a49301eSmrg rbug_connection_send_start(__con, RBUG_OP_TEXTURE_WRITE, __len); 1734a49301eSmrg rbug_connection_write(__con, __data, __len); 1744a49301eSmrg __ret = rbug_connection_send_finish(__con, __serial); 1754a49301eSmrg } 1764a49301eSmrg 1774a49301eSmrg FREE(__data); 1784a49301eSmrg return __ret; 1794a49301eSmrg} 1804a49301eSmrg 1814a49301eSmrgint rbug_send_texture_read(struct rbug_connection *__con, 1824a49301eSmrg rbug_texture_t texture, 1834a49301eSmrg uint32_t face, 1844a49301eSmrg uint32_t level, 1854a49301eSmrg uint32_t zslice, 1864a49301eSmrg uint32_t x, 1874a49301eSmrg uint32_t y, 1884a49301eSmrg uint32_t w, 1894a49301eSmrg uint32_t h, 1904a49301eSmrg uint32_t *__serial) 1914a49301eSmrg{ 1924a49301eSmrg uint32_t __len = 0; 1934a49301eSmrg uint32_t __pos = 0; 1944a49301eSmrg uint8_t *__data = NULL; 1954a49301eSmrg int __ret = 0; 1964a49301eSmrg 1974a49301eSmrg LEN(8); /* header */ 1984a49301eSmrg LEN(8); /* texture */ 1994a49301eSmrg LEN(4); /* face */ 2004a49301eSmrg LEN(4); /* level */ 2014a49301eSmrg LEN(4); /* zslice */ 2024a49301eSmrg LEN(4); /* x */ 2034a49301eSmrg LEN(4); /* y */ 2044a49301eSmrg LEN(4); /* w */ 2054a49301eSmrg LEN(4); /* h */ 2064a49301eSmrg 2074a49301eSmrg /* align */ 2084a49301eSmrg PAD(__len, 8); 2094a49301eSmrg 2104a49301eSmrg __data = (uint8_t*)MALLOC(__len); 2114a49301eSmrg if (!__data) 2124a49301eSmrg return -ENOMEM; 2134a49301eSmrg 2144a49301eSmrg WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_READ)); 2154a49301eSmrg WRITE(4, uint32_t, ((uint32_t)(__len / 4))); 2164a49301eSmrg WRITE(8, rbug_texture_t, texture); /* texture */ 2174a49301eSmrg WRITE(4, uint32_t, face); /* face */ 2184a49301eSmrg WRITE(4, uint32_t, level); /* level */ 2194a49301eSmrg WRITE(4, uint32_t, zslice); /* zslice */ 2204a49301eSmrg WRITE(4, uint32_t, x); /* x */ 2214a49301eSmrg WRITE(4, uint32_t, y); /* y */ 2224a49301eSmrg WRITE(4, uint32_t, w); /* w */ 2234a49301eSmrg WRITE(4, uint32_t, h); /* h */ 2244a49301eSmrg 2254a49301eSmrg /* final pad */ 2264a49301eSmrg PAD(__pos, 8); 2274a49301eSmrg 2284a49301eSmrg if (__pos != __len) { 2294a49301eSmrg __ret = -EINVAL; 2304a49301eSmrg } else { 2314a49301eSmrg rbug_connection_send_start(__con, RBUG_OP_TEXTURE_READ, __len); 2324a49301eSmrg rbug_connection_write(__con, __data, __len); 2334a49301eSmrg __ret = rbug_connection_send_finish(__con, __serial); 2344a49301eSmrg } 2354a49301eSmrg 2364a49301eSmrg FREE(__data); 2374a49301eSmrg return __ret; 2384a49301eSmrg} 2394a49301eSmrg 2404a49301eSmrgint rbug_send_texture_list_reply(struct rbug_connection *__con, 2414a49301eSmrg uint32_t serial, 2424a49301eSmrg rbug_texture_t *textures, 2434a49301eSmrg uint32_t textures_len, 2444a49301eSmrg uint32_t *__serial) 2454a49301eSmrg{ 2464a49301eSmrg uint32_t __len = 0; 2474a49301eSmrg uint32_t __pos = 0; 2484a49301eSmrg uint8_t *__data = NULL; 2494a49301eSmrg int __ret = 0; 2504a49301eSmrg 2514a49301eSmrg LEN(8); /* header */ 2524a49301eSmrg LEN(4); /* serial */ 2534a49301eSmrg LEN_ARRAY(8, textures); /* textures */ 2544a49301eSmrg 2554a49301eSmrg /* align */ 2564a49301eSmrg PAD(__len, 8); 2574a49301eSmrg 2584a49301eSmrg __data = (uint8_t*)MALLOC(__len); 2594a49301eSmrg if (!__data) 2604a49301eSmrg return -ENOMEM; 2614a49301eSmrg 2624a49301eSmrg WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_LIST_REPLY)); 2634a49301eSmrg WRITE(4, uint32_t, ((uint32_t)(__len / 4))); 2644a49301eSmrg WRITE(4, uint32_t, serial); /* serial */ 2654a49301eSmrg WRITE_ARRAY(8, rbug_texture_t, textures); /* textures */ 2664a49301eSmrg 2674a49301eSmrg /* final pad */ 2684a49301eSmrg PAD(__pos, 8); 2694a49301eSmrg 2704a49301eSmrg if (__pos != __len) { 2714a49301eSmrg __ret = -EINVAL; 2724a49301eSmrg } else { 2734a49301eSmrg rbug_connection_send_start(__con, RBUG_OP_TEXTURE_LIST_REPLY, __len); 2744a49301eSmrg rbug_connection_write(__con, __data, __len); 2754a49301eSmrg __ret = rbug_connection_send_finish(__con, __serial); 2764a49301eSmrg } 2774a49301eSmrg 2784a49301eSmrg FREE(__data); 2794a49301eSmrg return __ret; 2804a49301eSmrg} 2814a49301eSmrg 2824a49301eSmrgint rbug_send_texture_info_reply(struct rbug_connection *__con, 2834a49301eSmrg uint32_t serial, 2844a49301eSmrg uint32_t target, 2854a49301eSmrg uint32_t format, 2864a49301eSmrg uint32_t *width, 2874a49301eSmrg uint32_t width_len, 2887ec681f3Smrg uint16_t *h16, 2894a49301eSmrg uint32_t height_len, 2907ec681f3Smrg uint16_t *d16, 2914a49301eSmrg uint32_t depth_len, 2924a49301eSmrg uint32_t blockw, 2934a49301eSmrg uint32_t blockh, 2944a49301eSmrg uint32_t blocksize, 2954a49301eSmrg uint32_t last_level, 2964a49301eSmrg uint32_t nr_samples, 2974a49301eSmrg uint32_t tex_usage, 2984a49301eSmrg uint32_t *__serial) 2994a49301eSmrg{ 3004a49301eSmrg uint32_t __len = 0; 3014a49301eSmrg uint32_t __pos = 0; 3024a49301eSmrg uint8_t *__data = NULL; 3034a49301eSmrg int __ret = 0; 3047ec681f3Smrg uint32_t *height = alloca(sizeof(uint32_t) * height_len); 3057ec681f3Smrg uint32_t *depth = alloca(sizeof(uint32_t) * height_len); 3064a49301eSmrg 3074a49301eSmrg LEN(8); /* header */ 3084a49301eSmrg LEN(4); /* serial */ 3094a49301eSmrg LEN(4); /* target */ 3104a49301eSmrg LEN(4); /* format */ 3114a49301eSmrg LEN_ARRAY(4, width); /* width */ 3124a49301eSmrg LEN_ARRAY(4, height); /* height */ 3134a49301eSmrg LEN_ARRAY(4, depth); /* depth */ 3144a49301eSmrg LEN(4); /* blockw */ 3154a49301eSmrg LEN(4); /* blockh */ 3164a49301eSmrg LEN(4); /* blocksize */ 3174a49301eSmrg LEN(4); /* last_level */ 3184a49301eSmrg LEN(4); /* nr_samples */ 3194a49301eSmrg LEN(4); /* tex_usage */ 3204a49301eSmrg 3214a49301eSmrg /* align */ 3224a49301eSmrg PAD(__len, 8); 3234a49301eSmrg 3244a49301eSmrg __data = (uint8_t*)MALLOC(__len); 3254a49301eSmrg if (!__data) 3264a49301eSmrg return -ENOMEM; 3274a49301eSmrg 3287ec681f3Smrg for (int i = 0; i < height_len; i++) 3297ec681f3Smrg height[i] = h16[i]; 3307ec681f3Smrg for (int i = 0; i < depth_len; i++) 3317ec681f3Smrg depth[i] = d16[i]; 3327ec681f3Smrg 3334a49301eSmrg WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_INFO_REPLY)); 3344a49301eSmrg WRITE(4, uint32_t, ((uint32_t)(__len / 4))); 3354a49301eSmrg WRITE(4, uint32_t, serial); /* serial */ 3364a49301eSmrg WRITE(4, uint32_t, target); /* target */ 3374a49301eSmrg WRITE(4, uint32_t, format); /* format */ 3384a49301eSmrg WRITE_ARRAY(4, uint32_t, width); /* width */ 3394a49301eSmrg WRITE_ARRAY(4, uint32_t, height); /* height */ 3404a49301eSmrg WRITE_ARRAY(4, uint32_t, depth); /* depth */ 3414a49301eSmrg WRITE(4, uint32_t, blockw); /* blockw */ 3424a49301eSmrg WRITE(4, uint32_t, blockh); /* blockh */ 3434a49301eSmrg WRITE(4, uint32_t, blocksize); /* blocksize */ 3444a49301eSmrg WRITE(4, uint32_t, last_level); /* last_level */ 3454a49301eSmrg WRITE(4, uint32_t, nr_samples); /* nr_samples */ 3464a49301eSmrg WRITE(4, uint32_t, tex_usage); /* tex_usage */ 3474a49301eSmrg 3484a49301eSmrg /* final pad */ 3494a49301eSmrg PAD(__pos, 8); 3504a49301eSmrg 3514a49301eSmrg if (__pos != __len) { 3524a49301eSmrg __ret = -EINVAL; 3534a49301eSmrg } else { 3544a49301eSmrg rbug_connection_send_start(__con, RBUG_OP_TEXTURE_INFO_REPLY, __len); 3554a49301eSmrg rbug_connection_write(__con, __data, __len); 3564a49301eSmrg __ret = rbug_connection_send_finish(__con, __serial); 3574a49301eSmrg } 3584a49301eSmrg 3594a49301eSmrg FREE(__data); 3604a49301eSmrg return __ret; 3614a49301eSmrg} 3624a49301eSmrg 3634a49301eSmrgint rbug_send_texture_read_reply(struct rbug_connection *__con, 3644a49301eSmrg uint32_t serial, 3654a49301eSmrg uint32_t format, 3664a49301eSmrg uint32_t blockw, 3674a49301eSmrg uint32_t blockh, 3684a49301eSmrg uint32_t blocksize, 3694a49301eSmrg uint8_t *data, 3704a49301eSmrg uint32_t data_len, 3714a49301eSmrg uint32_t stride, 3724a49301eSmrg uint32_t *__serial) 3734a49301eSmrg{ 3744a49301eSmrg uint32_t __len = 0; 3754a49301eSmrg uint32_t __pos = 0; 3764a49301eSmrg uint8_t *__data = NULL; 3774a49301eSmrg int __ret = 0; 3784a49301eSmrg 3794a49301eSmrg LEN(8); /* header */ 3804a49301eSmrg LEN(4); /* serial */ 3814a49301eSmrg LEN(4); /* format */ 3824a49301eSmrg LEN(4); /* blockw */ 3834a49301eSmrg LEN(4); /* blockh */ 3844a49301eSmrg LEN(4); /* blocksize */ 3854a49301eSmrg LEN_ARRAY(1, data); /* data */ 3864a49301eSmrg LEN(4); /* stride */ 3874a49301eSmrg 3884a49301eSmrg /* align */ 3894a49301eSmrg PAD(__len, 8); 3904a49301eSmrg 3914a49301eSmrg __data = (uint8_t*)MALLOC(__len); 3924a49301eSmrg if (!__data) 3934a49301eSmrg return -ENOMEM; 3944a49301eSmrg 3954a49301eSmrg WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_READ_REPLY)); 3964a49301eSmrg WRITE(4, uint32_t, ((uint32_t)(__len / 4))); 3974a49301eSmrg WRITE(4, uint32_t, serial); /* serial */ 3984a49301eSmrg WRITE(4, uint32_t, format); /* format */ 3994a49301eSmrg WRITE(4, uint32_t, blockw); /* blockw */ 4004a49301eSmrg WRITE(4, uint32_t, blockh); /* blockh */ 4014a49301eSmrg WRITE(4, uint32_t, blocksize); /* blocksize */ 4024a49301eSmrg WRITE_ARRAY(1, uint8_t, data); /* data */ 4034a49301eSmrg WRITE(4, uint32_t, stride); /* stride */ 4044a49301eSmrg 4054a49301eSmrg /* final pad */ 4064a49301eSmrg PAD(__pos, 8); 4074a49301eSmrg 4084a49301eSmrg if (__pos != __len) { 4094a49301eSmrg __ret = -EINVAL; 4104a49301eSmrg } else { 4114a49301eSmrg rbug_connection_send_start(__con, RBUG_OP_TEXTURE_READ_REPLY, __len); 4124a49301eSmrg rbug_connection_write(__con, __data, __len); 4134a49301eSmrg __ret = rbug_connection_send_finish(__con, __serial); 4144a49301eSmrg } 4154a49301eSmrg 4164a49301eSmrg FREE(__data); 4174a49301eSmrg return __ret; 4184a49301eSmrg} 4194a49301eSmrg 4204a49301eSmrgstruct rbug_proto_texture_list * rbug_demarshal_texture_list(struct rbug_proto_header *header) 4214a49301eSmrg{ 4224a49301eSmrg struct rbug_proto_texture_list *ret; 4234a49301eSmrg 4244a49301eSmrg if (!header) 4254a49301eSmrg return NULL; 4263464ebd5Sriastradh if (header->opcode != (int32_t)RBUG_OP_TEXTURE_LIST) 4274a49301eSmrg return NULL; 4284a49301eSmrg 4294a49301eSmrg ret = MALLOC(sizeof(*ret)); 4304a49301eSmrg if (!ret) 4314a49301eSmrg return NULL; 4324a49301eSmrg 4334a49301eSmrg ret->header.__message = header; 4344a49301eSmrg ret->header.opcode = header->opcode; 4354a49301eSmrg 4364a49301eSmrg return ret; 4374a49301eSmrg} 4384a49301eSmrg 4394a49301eSmrgstruct rbug_proto_texture_info * rbug_demarshal_texture_info(struct rbug_proto_header *header) 4404a49301eSmrg{ 4414a49301eSmrg uint32_t len = 0; 4424a49301eSmrg uint32_t pos = 0; 4434a49301eSmrg uint8_t *data = NULL; 4444a49301eSmrg struct rbug_proto_texture_info *ret; 4454a49301eSmrg 4464a49301eSmrg if (!header) 4474a49301eSmrg return NULL; 4483464ebd5Sriastradh if (header->opcode != (int32_t)RBUG_OP_TEXTURE_INFO) 4494a49301eSmrg return NULL; 4504a49301eSmrg 4514a49301eSmrg pos = 0; 4524a49301eSmrg len = header->length * 4; 4534a49301eSmrg data = (uint8_t*)&header[1]; 4544a49301eSmrg ret = MALLOC(sizeof(*ret)); 4554a49301eSmrg if (!ret) 4564a49301eSmrg return NULL; 4574a49301eSmrg 4584a49301eSmrg ret->header.__message = header; 4594a49301eSmrg ret->header.opcode = header->opcode; 4604a49301eSmrg 4614a49301eSmrg READ(8, rbug_texture_t, texture); /* texture */ 4624a49301eSmrg 4634a49301eSmrg return ret; 4644a49301eSmrg} 4654a49301eSmrg 4664a49301eSmrgstruct rbug_proto_texture_write * rbug_demarshal_texture_write(struct rbug_proto_header *header) 4674a49301eSmrg{ 4684a49301eSmrg uint32_t len = 0; 4694a49301eSmrg uint32_t pos = 0; 4704a49301eSmrg uint8_t *data = NULL; 4714a49301eSmrg struct rbug_proto_texture_write *ret; 4724a49301eSmrg 4734a49301eSmrg if (!header) 4744a49301eSmrg return NULL; 4753464ebd5Sriastradh if (header->opcode != (int32_t)RBUG_OP_TEXTURE_WRITE) 4764a49301eSmrg return NULL; 4774a49301eSmrg 4784a49301eSmrg pos = 0; 4794a49301eSmrg len = header->length * 4; 4804a49301eSmrg data = (uint8_t*)&header[1]; 4814a49301eSmrg ret = MALLOC(sizeof(*ret)); 4824a49301eSmrg if (!ret) 4834a49301eSmrg return NULL; 4844a49301eSmrg 4854a49301eSmrg ret->header.__message = header; 4864a49301eSmrg ret->header.opcode = header->opcode; 4874a49301eSmrg 4884a49301eSmrg READ(8, rbug_texture_t, texture); /* texture */ 4894a49301eSmrg READ(4, uint32_t, face); /* face */ 4904a49301eSmrg READ(4, uint32_t, level); /* level */ 4914a49301eSmrg READ(4, uint32_t, zslice); /* zslice */ 4924a49301eSmrg READ(4, uint32_t, x); /* x */ 4934a49301eSmrg READ(4, uint32_t, y); /* y */ 4944a49301eSmrg READ(4, uint32_t, w); /* w */ 4954a49301eSmrg READ(4, uint32_t, h); /* h */ 4964a49301eSmrg READ_ARRAY(1, uint8_t, data); /* data */ 4974a49301eSmrg READ(4, uint32_t, stride); /* stride */ 4984a49301eSmrg 4994a49301eSmrg return ret; 5004a49301eSmrg} 5014a49301eSmrg 5024a49301eSmrgstruct rbug_proto_texture_read * rbug_demarshal_texture_read(struct rbug_proto_header *header) 5034a49301eSmrg{ 5044a49301eSmrg uint32_t len = 0; 5054a49301eSmrg uint32_t pos = 0; 5064a49301eSmrg uint8_t *data = NULL; 5074a49301eSmrg struct rbug_proto_texture_read *ret; 5084a49301eSmrg 5094a49301eSmrg if (!header) 5104a49301eSmrg return NULL; 5113464ebd5Sriastradh if (header->opcode != (int32_t)RBUG_OP_TEXTURE_READ) 5124a49301eSmrg return NULL; 5134a49301eSmrg 5144a49301eSmrg pos = 0; 5154a49301eSmrg len = header->length * 4; 5164a49301eSmrg data = (uint8_t*)&header[1]; 5174a49301eSmrg ret = MALLOC(sizeof(*ret)); 5184a49301eSmrg if (!ret) 5194a49301eSmrg return NULL; 5204a49301eSmrg 5214a49301eSmrg ret->header.__message = header; 5224a49301eSmrg ret->header.opcode = header->opcode; 5234a49301eSmrg 5244a49301eSmrg READ(8, rbug_texture_t, texture); /* texture */ 5254a49301eSmrg READ(4, uint32_t, face); /* face */ 5264a49301eSmrg READ(4, uint32_t, level); /* level */ 5274a49301eSmrg READ(4, uint32_t, zslice); /* zslice */ 5284a49301eSmrg READ(4, uint32_t, x); /* x */ 5294a49301eSmrg READ(4, uint32_t, y); /* y */ 5304a49301eSmrg READ(4, uint32_t, w); /* w */ 5314a49301eSmrg READ(4, uint32_t, h); /* h */ 5324a49301eSmrg 5334a49301eSmrg return ret; 5344a49301eSmrg} 5354a49301eSmrg 5364a49301eSmrgstruct rbug_proto_texture_list_reply * rbug_demarshal_texture_list_reply(struct rbug_proto_header *header) 5374a49301eSmrg{ 5384a49301eSmrg uint32_t len = 0; 5394a49301eSmrg uint32_t pos = 0; 5404a49301eSmrg uint8_t *data = NULL; 5414a49301eSmrg struct rbug_proto_texture_list_reply *ret; 5424a49301eSmrg 5434a49301eSmrg if (!header) 5444a49301eSmrg return NULL; 5453464ebd5Sriastradh if (header->opcode != (int32_t)RBUG_OP_TEXTURE_LIST_REPLY) 5464a49301eSmrg return NULL; 5474a49301eSmrg 5484a49301eSmrg pos = 0; 5494a49301eSmrg len = header->length * 4; 5504a49301eSmrg data = (uint8_t*)&header[1]; 5514a49301eSmrg ret = MALLOC(sizeof(*ret)); 5524a49301eSmrg if (!ret) 5534a49301eSmrg return NULL; 5544a49301eSmrg 5554a49301eSmrg ret->header.__message = header; 5564a49301eSmrg ret->header.opcode = header->opcode; 5574a49301eSmrg 5584a49301eSmrg READ(4, uint32_t, serial); /* serial */ 5594a49301eSmrg READ_ARRAY(8, rbug_texture_t, textures); /* textures */ 5604a49301eSmrg 5614a49301eSmrg return ret; 5624a49301eSmrg} 5634a49301eSmrg 5644a49301eSmrgstruct rbug_proto_texture_info_reply * rbug_demarshal_texture_info_reply(struct rbug_proto_header *header) 5654a49301eSmrg{ 5664a49301eSmrg uint32_t len = 0; 5674a49301eSmrg uint32_t pos = 0; 5684a49301eSmrg uint8_t *data = NULL; 5694a49301eSmrg struct rbug_proto_texture_info_reply *ret; 5704a49301eSmrg 5714a49301eSmrg if (!header) 5724a49301eSmrg return NULL; 5733464ebd5Sriastradh if (header->opcode != (int32_t)RBUG_OP_TEXTURE_INFO_REPLY) 5744a49301eSmrg return NULL; 5754a49301eSmrg 5764a49301eSmrg pos = 0; 5774a49301eSmrg len = header->length * 4; 5784a49301eSmrg data = (uint8_t*)&header[1]; 5794a49301eSmrg ret = MALLOC(sizeof(*ret)); 5804a49301eSmrg if (!ret) 5814a49301eSmrg return NULL; 5824a49301eSmrg 5834a49301eSmrg ret->header.__message = header; 5844a49301eSmrg ret->header.opcode = header->opcode; 5854a49301eSmrg 5864a49301eSmrg READ(4, uint32_t, serial); /* serial */ 5874a49301eSmrg READ(4, uint32_t, target); /* target */ 5884a49301eSmrg READ(4, uint32_t, format); /* format */ 5894a49301eSmrg READ_ARRAY(4, uint32_t, width); /* width */ 5904a49301eSmrg READ_ARRAY(4, uint32_t, height); /* height */ 5914a49301eSmrg READ_ARRAY(4, uint32_t, depth); /* depth */ 5924a49301eSmrg READ(4, uint32_t, blockw); /* blockw */ 5934a49301eSmrg READ(4, uint32_t, blockh); /* blockh */ 5944a49301eSmrg READ(4, uint32_t, blocksize); /* blocksize */ 5954a49301eSmrg READ(4, uint32_t, last_level); /* last_level */ 5964a49301eSmrg READ(4, uint32_t, nr_samples); /* nr_samples */ 5974a49301eSmrg READ(4, uint32_t, tex_usage); /* tex_usage */ 5984a49301eSmrg 5994a49301eSmrg return ret; 6004a49301eSmrg} 6014a49301eSmrg 6024a49301eSmrgstruct rbug_proto_texture_read_reply * rbug_demarshal_texture_read_reply(struct rbug_proto_header *header) 6034a49301eSmrg{ 6044a49301eSmrg uint32_t len = 0; 6054a49301eSmrg uint32_t pos = 0; 6064a49301eSmrg uint8_t *data = NULL; 6074a49301eSmrg struct rbug_proto_texture_read_reply *ret; 6084a49301eSmrg 6094a49301eSmrg if (!header) 6104a49301eSmrg return NULL; 6113464ebd5Sriastradh if (header->opcode != (int32_t)RBUG_OP_TEXTURE_READ_REPLY) 6124a49301eSmrg return NULL; 6134a49301eSmrg 6144a49301eSmrg pos = 0; 6154a49301eSmrg len = header->length * 4; 6164a49301eSmrg data = (uint8_t*)&header[1]; 6174a49301eSmrg ret = MALLOC(sizeof(*ret)); 6184a49301eSmrg if (!ret) 6194a49301eSmrg return NULL; 6204a49301eSmrg 6214a49301eSmrg ret->header.__message = header; 6224a49301eSmrg ret->header.opcode = header->opcode; 6234a49301eSmrg 6244a49301eSmrg READ(4, uint32_t, serial); /* serial */ 6254a49301eSmrg READ(4, uint32_t, format); /* format */ 6264a49301eSmrg READ(4, uint32_t, blockw); /* blockw */ 6274a49301eSmrg READ(4, uint32_t, blockh); /* blockh */ 6284a49301eSmrg READ(4, uint32_t, blocksize); /* blocksize */ 6294a49301eSmrg READ_ARRAY(1, uint8_t, data); /* data */ 6304a49301eSmrg READ(4, uint32_t, stride); /* stride */ 6314a49301eSmrg 6324a49301eSmrg return ret; 6334a49301eSmrg} 634