diff options
Diffstat (limited to 'progs/rbug')
-rw-r--r-- | progs/rbug/.gitignore | 9 | ||||
-rw-r--r-- | progs/rbug/Makefile | 46 | ||||
-rw-r--r-- | progs/rbug/README | 39 | ||||
-rw-r--r-- | progs/rbug/ctx_info.c | 80 | ||||
-rw-r--r-- | progs/rbug/shdr_disable.c | 82 | ||||
-rw-r--r-- | progs/rbug/shdr_dump.c | 115 | ||||
-rw-r--r-- | progs/rbug/shdr_info.c | 98 | ||||
-rw-r--r-- | progs/rbug/simple_client.c | 64 | ||||
-rw-r--r-- | progs/rbug/simple_server.c | 62 | ||||
-rw-r--r-- | progs/rbug/tex_dump.c | 127 | ||||
-rw-r--r-- | progs/rbug/tex_info.c | 78 |
11 files changed, 800 insertions, 0 deletions
diff --git a/progs/rbug/.gitignore b/progs/rbug/.gitignore new file mode 100644 index 0000000..317290b --- /dev/null +++ b/progs/rbug/.gitignore @@ -0,0 +1,9 @@ +simple_client +simple_server +shdr_info +shdr_dump +shdr_disable +ctx_info +tex_dump +tex_info +*.bmp diff --git a/progs/rbug/Makefile b/progs/rbug/Makefile new file mode 100644 index 0000000..8df03dd --- /dev/null +++ b/progs/rbug/Makefile @@ -0,0 +1,46 @@ +# progs/rbug/Makefile + +TOP = ../.. +include $(TOP)/configs/current + +INCLUDES = \ + -I. \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/auxiliary \ + -I$(TOP)/src/gallium/drivers \ + $(PROG_INCLUDES) + +LINKS = \ + $(GALLIUM_AUXILIARIES) \ + $(PROG_LINKS) + +SOURCES = \ + simple_client.c \ + simple_server.c \ + shdr_info.c \ + shdr_dump.c \ + shdr_disable.c \ + ctx_info.c \ + tex_info.c \ + tex_dump.c + + +OBJECTS = $(SOURCES:.c=.o) + +PROGS = $(OBJECTS:.o=) + +##### TARGETS ##### + +default: $(OBJECTS) $(PROGS) + +clean: + -rm -f $(PROGS) + -rm -f *.o + +##### RULES ##### + +$(OBJECTS): %.o: %.c + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $(PROG_DEFINES) $< -o $@ + +$(PROGS): %: %.o + $(CC) $(LDFLAGS) $< $(LINKS) -o $@ diff --git a/progs/rbug/README b/progs/rbug/README new file mode 100644 index 0000000..0eb0a5d --- /dev/null +++ b/progs/rbug/README @@ -0,0 +1,39 @@ + REMOTE DEBUGGING CLI APPLICATIONS + + += About = + +This directory contains a Gallium3D remote debugging cli applications. + + += Build Instructions = + +To build, build a normal gallium build and from this directory do the following. + + make + += Usage = + +Make sure that you driver has trace integration, see +src/gallium/driver/trace/README for more information about that. Then from on +the computer that you want to debug do: + + export GALLIUM_RBUG=true + + <launch app> + +From the debugging computer launch apps form this directory. Currently ip +addresses are hardcoded and you need to edit the application, but that will +change in the future. + += Testing = + +The two apps simple_client and simple_server. Are unit testing of the +connection and (de)marsheler. Just run the server first and then the client: + + ./simple_server & + ./simple_client + + +-- +Jakob Bornecrantz <jakob@vmware.com> diff --git a/progs/rbug/ctx_info.c b/progs/rbug/ctx_info.c new file mode 100644 index 0000000..d72c326 --- /dev/null +++ b/progs/rbug/ctx_info.c @@ -0,0 +1,80 @@ +/* + * Copyright 2009 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "pipe/p_compiler.h" +#include "pipe/p_format.h" +#include "util/u_memory.h" +#include "util/u_debug.h" +#include "util/u_network.h" + +#include "rbug/rbug.h" + +static void talk() +{ + int c = u_socket_connect("localhost", 13370); + struct rbug_connection *con = rbug_from_socket(c); + struct rbug_header *header; + struct rbug_proto_context_list_reply *list; + struct rbug_proto_context_info_reply *info; + int i; + + assert(c >= 0); + assert(con); + debug_printf("Connection get!\n"); + + debug_printf("Sending get contexts\n"); + rbug_send_context_list(con, NULL); + + debug_printf("Waiting for contexts\n"); + header = rbug_get_message(con, NULL); + assert(header->opcode == RBUG_OP_CONTEXT_LIST_REPLY); + list = (struct rbug_proto_context_list_reply *)header; + + debug_printf("Got contexts:\n"); + for (i = 0; i < list->contexts_len; i++) { +#if 0 + rbug_send_contexts_info(con, list->contexts[i], NULL); + + header = rbug_get_message(con, NULL); + assert(header->opcode == RBUG_OP_CONTEXT_INFO_REPLY); + info = (struct rbug_proto_context_info_reply *)header; +#else + (void)info; + header = NULL; +#endif + + debug_printf("%llu\n", + (unsigned long long)list->contexts[i]); + rbug_free_header(header); + } + + rbug_free_header(&list->header); + rbug_disconnect(con); +} + +int main(int argc, char** argv) +{ + talk(); + return 0; +} diff --git a/progs/rbug/shdr_disable.c b/progs/rbug/shdr_disable.c new file mode 100644 index 0000000..e6b1207 --- /dev/null +++ b/progs/rbug/shdr_disable.c @@ -0,0 +1,82 @@ +/* + * Copyright 2009 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "pipe/p_compiler.h" +#include "pipe/p_format.h" +#include "util/u_memory.h" +#include "util/u_debug.h" +#include "util/u_network.h" + +#include "rbug/rbug.h" + +static void talk(rbug_context_t ctx, rbug_shader_t shdr) +{ + int c = u_socket_connect("localhost", 13370); + struct rbug_connection *con = rbug_from_socket(c); + struct rbug_header *header; + + assert(c >= 0); + assert(con); + debug_printf("Connection get!\n"); + + rbug_send_shader_disable(con, ctx, shdr, true, NULL); + + rbug_send_ping(con, NULL); + + debug_printf("Sent waiting for reply\n"); + header = rbug_get_message(con, NULL); + + if (header->opcode != RBUG_OP_PING_REPLY) + debug_printf("Error\n"); + else + debug_printf("Ok!\n"); + + rbug_free_header(header); + rbug_disconnect(con); +} + +static void print_usage() +{ + printf("Usage shdr_disable <context> <shader>\n"); + exit(-1); +} + +int main(int argc, char** argv) +{ + long ctx; + long shdr; + + if (argc < 3) + print_usage(); + + ctx = atol(argv[1]); + shdr = atol(argv[2]); + + if (ctx <= 0 && ctx <= 0) + print_usage(); + + talk((uint64_t)ctx, (uint64_t)shdr); + + return 0; +} diff --git a/progs/rbug/shdr_dump.c b/progs/rbug/shdr_dump.c new file mode 100644 index 0000000..8f9d758 --- /dev/null +++ b/progs/rbug/shdr_dump.c @@ -0,0 +1,115 @@ +/* + * Copyright 2009 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "pipe/p_compiler.h" +#include "pipe/p_format.h" +#include "util/u_memory.h" +#include "util/u_debug.h" +#include "util/u_network.h" + +#include "rbug/rbug.h" + +#include "tgsi/tgsi_dump.h" + +static void shader_info(struct rbug_connection *con, rbug_context_t ctx) +{ + struct rbug_header *header; + struct rbug_proto_shader_list_reply *list; + struct rbug_proto_shader_info_reply *info; + int i; + + debug_printf("Sending get shaders to %llu\n", (unsigned long long)ctx); + rbug_send_shader_list(con, ctx, NULL); + + debug_printf("Waiting for shaders from %llu\n", (unsigned long long)ctx); + header = rbug_get_message(con, NULL); + assert(header->opcode == RBUG_OP_SHADER_LIST_REPLY); + list = (struct rbug_proto_shader_list_reply *)header; + + debug_printf("Got shaders:\n"); + for (i = 0; i < list->shaders_len; i++) { + rbug_send_shader_info(con, ctx, list->shaders[i], NULL); + + header = rbug_get_message(con, NULL); + assert(header->opcode == RBUG_OP_SHADER_INFO_REPLY); + info = (struct rbug_proto_shader_info_reply *)header; + + debug_printf("#####################################################\n"); + debug_printf("ctx: %llu shdr: %llu disabled %u\n", + (unsigned long long)ctx, + (unsigned long long)list->shaders[i], + info->disabled); + + /* just to be sure */ + assert(sizeof(struct tgsi_token) == 4); + + debug_printf("-----------------------------------------------------\n"); + tgsi_dump((struct tgsi_token *)info->original, 0); + + if (info->replaced_len > 0) { + debug_printf("-----------------------------------------------------\n"); + tgsi_dump((struct tgsi_token *)info->replaced, 0); + } + + rbug_free_header(header); + } + + debug_printf("#####################################################\n"); + rbug_free_header(&list->header); +} + +static void talk() +{ + int c = u_socket_connect("localhost", 13370); + struct rbug_connection *con = rbug_from_socket(c); + struct rbug_header *header; + struct rbug_proto_context_list_reply *list; + int i; + + assert(c >= 0); + assert(con); + debug_printf("Connection get!\n"); + + debug_printf("Sending get contexts\n"); + rbug_send_context_list(con, NULL); + + debug_printf("Waiting for contexts\n"); + header = rbug_get_message(con, NULL); + assert(header->opcode == RBUG_OP_CONTEXT_LIST_REPLY); + list = (struct rbug_proto_context_list_reply *)header; + + debug_printf("Got contexts:\n"); + for (i = 0; i < list->contexts_len; i++) { + shader_info(con, list->contexts[i]); + } + + rbug_free_header(&list->header); + rbug_disconnect(con); +} + +int main(int argc, char** argv) +{ + talk(); + return 0; +} diff --git a/progs/rbug/shdr_info.c b/progs/rbug/shdr_info.c new file mode 100644 index 0000000..b6864e9 --- /dev/null +++ b/progs/rbug/shdr_info.c @@ -0,0 +1,98 @@ +/* + * Copyright 2009 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "pipe/p_compiler.h" +#include "pipe/p_format.h" +#include "util/u_memory.h" +#include "util/u_debug.h" +#include "util/u_network.h" + +#include "rbug/rbug.h" + +static void shader_info(struct rbug_connection *con, rbug_context_t ctx) +{ + struct rbug_header *header; + struct rbug_proto_shader_list_reply *list; + struct rbug_proto_shader_info_reply *info; + int i; + + rbug_send_shader_list(con, ctx, NULL); + + header = rbug_get_message(con, NULL); + assert(header->opcode == RBUG_OP_SHADER_LIST_REPLY); + list = (struct rbug_proto_shader_list_reply *)header; + + debug_printf(" context | shader | disabled |\n"); + for (i = 0; i < list->shaders_len; i++) { + rbug_send_shader_info(con, ctx, list->shaders[i], NULL); + + header = rbug_get_message(con, NULL); + assert(header->opcode == RBUG_OP_SHADER_INFO_REPLY); + info = (struct rbug_proto_shader_info_reply *)header; + + debug_printf("% 15llu |% 15llu |% 15u |\n", + (unsigned long long)ctx, + (unsigned long long)list->shaders[i], + (unsigned)info->disabled); + + rbug_free_header(header); + } + + rbug_free_header(&list->header); +} + +static void talk() +{ + int c = u_socket_connect("localhost", 13370); + struct rbug_connection *con = rbug_from_socket(c); + struct rbug_header *header; + struct rbug_proto_context_list_reply *list; + int i; + + assert(c >= 0); + assert(con); + debug_printf("Connection get!\n"); + + debug_printf("Sending get contexts\n"); + rbug_send_context_list(con, NULL); + + debug_printf("Waiting for contexts\n"); + header = rbug_get_message(con, NULL); + assert(header->opcode == RBUG_OP_CONTEXT_LIST_REPLY); + list = (struct rbug_proto_context_list_reply *)header; + + debug_printf("Got contexts:\n"); + for (i = 0; i < list->contexts_len; i++) { + shader_info(con, list->contexts[i]); + } + + rbug_free_header(&list->header); + rbug_disconnect(con); +} + +int main(int argc, char** argv) +{ + talk(); + return 0; +} diff --git a/progs/rbug/simple_client.c b/progs/rbug/simple_client.c new file mode 100644 index 0000000..38929fa --- /dev/null +++ b/progs/rbug/simple_client.c @@ -0,0 +1,64 @@ +/* + * Copyright 2009 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "pipe/p_compiler.h" +#include "util/u_memory.h" +#include "util/u_debug.h" +#include "util/u_network.h" + +#include "rbug/rbug.h" + +static void talk() +{ + int c = u_socket_connect("localhost", 13370); + struct rbug_connection *con = rbug_from_socket(c); + struct rbug_header *header; + struct rbug_proto_texture_list_reply *list; + int i; + + assert(c >= 0); + assert(con); + debug_printf("Connection get!\n"); + + debug_printf("Sending get textures\n"); + rbug_send_texture_list(con, NULL); + + debug_printf("Waiting for textures\n"); + header = rbug_get_message(con, NULL); + assert(header->opcode == RBUG_OP_TEXTURE_LIST_REPLY); + list = (struct rbug_proto_texture_list_reply *)header; + + debug_printf("Got textures:\n"); + for (i = 0; i < list->textures_len; i++) + debug_printf("\ttex %llu\n", (unsigned long long)list->textures[i]); + + rbug_free_header(header); + rbug_disconnect(con); +} + +int main(int argc, char** argv) +{ + talk(); + return 0; +} diff --git a/progs/rbug/simple_server.c b/progs/rbug/simple_server.c new file mode 100644 index 0000000..04380c3 --- /dev/null +++ b/progs/rbug/simple_server.c @@ -0,0 +1,62 @@ +/* + * Copyright 2009 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "pipe/p_compiler.h" +#include "util/u_memory.h" +#include "util/u_debug.h" +#include "util/u_network.h" + +#include "rbug/rbug.h" + +static void wait() +{ + int s = u_socket_listen_on_port(13370); + int c = u_socket_accept(s); + struct rbug_connection *con = rbug_from_socket(c); + struct rbug_header *header; + rbug_texture_t texs[2]; + uint32_t serial; + texs[0] = 1337; + texs[1] = 7331; + + assert(s >= 0); + assert(c >= 0); + assert(con); + debug_printf("Connection get!\n"); + + debug_printf("Waiting for get textures\n"); + header = rbug_get_message(con, &serial); + assert(header); + assert(header->opcode == RBUG_OP_TEXTURE_LIST); + rbug_free_header(header); + + rbug_send_texture_list_reply(con, serial, texs, 2, NULL); + rbug_disconnect(con); +} + +int main(int argc, char** argv) +{ + wait(); + return 0; +} diff --git a/progs/rbug/tex_dump.c b/progs/rbug/tex_dump.c new file mode 100644 index 0000000..f9e06ee --- /dev/null +++ b/progs/rbug/tex_dump.c @@ -0,0 +1,127 @@ +/* + * Copyright 2009 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "pipe/p_compiler.h" +#include "pipe/p_format.h" +#include "pipe/p_state.h" +#include "util/u_memory.h" +#include "util/u_debug.h" +#include "util/u_network.h" +#include "util/u_tile.h" +#include "rbug/rbug.h" + +static void dump(rbug_texture_t tex, + struct rbug_proto_texture_info_reply *info, + struct rbug_proto_texture_read_reply *read, + int mip) +{ + enum pipe_format format = info->format; + uint8_t *data = read->data; + unsigned width = info->width[mip]; + unsigned height = info->height[mip]; + unsigned dst_stride = width * 4 * 4; + unsigned src_stride = read->stride; + float *rgba = MALLOC(dst_stride * height); + int i; + char filename[512]; + + util_snprintf(filename, 512, "%llu_%s_%u.bmp", + (unsigned long long)tex, pf_name(info->format), mip); + + if (pf_is_compressed(info->format)) { + debug_printf("skipping: %s\n", filename); + return; + } + + debug_printf("saving: %s\n", filename); + + for (i = 0; i < height; i++) { + pipe_tile_raw_to_rgba(format, data + src_stride * i, + width, 1, + &rgba[width*4*i], dst_stride); + } + + debug_dump_float_rgba_bmp(filename, width, height, rgba, width); + + FREE(rgba); +} + +static void talk() +{ + int c = u_socket_connect("localhost", 13370); + struct rbug_connection *con = rbug_from_socket(c); + struct rbug_header *header; + struct rbug_header *header2; + struct rbug_proto_texture_list_reply *list; + struct rbug_proto_texture_info_reply *info; + struct rbug_proto_texture_read_reply *read; + int i, j; + + assert(c >= 0); + assert(con); + debug_printf("Connection get!\n"); + + debug_printf("Sending get textures\n"); + rbug_send_texture_list(con, NULL); + + debug_printf("Waiting for textures\n"); + header = rbug_get_message(con, NULL); + assert(header->opcode == RBUG_OP_TEXTURE_LIST_REPLY); + list = (struct rbug_proto_texture_list_reply *)header; + + debug_printf("Got textures:\n"); + for (i = 0; i < list->textures_len; i++) { + rbug_send_texture_info(con, list->textures[i], NULL); + + header = rbug_get_message(con, NULL); + assert(header->opcode == RBUG_OP_TEXTURE_INFO_REPLY); + info = (struct rbug_proto_texture_info_reply *)header; + + for (j = 0; j <= info->last_level; j++) { + rbug_send_texture_read(con, list->textures[i], + 0, j, 0, + 0, 0, info->width[j], info->height[j], + NULL); + + header2 = rbug_get_message(con, NULL); + assert(header2->opcode == RBUG_OP_TEXTURE_READ_REPLY); + read = (struct rbug_proto_texture_read_reply *)header2; + + dump(list->textures[i], info, read, j); + + rbug_free_header(header2); + } + + rbug_free_header(header); + + } + rbug_free_header(&list->header); + rbug_disconnect(con); +} + +int main(int argc, char** argv) +{ + talk(); + return 0; +} diff --git a/progs/rbug/tex_info.c b/progs/rbug/tex_info.c new file mode 100644 index 0000000..4a21bae --- /dev/null +++ b/progs/rbug/tex_info.c @@ -0,0 +1,78 @@ +/* + * Copyright 2009 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "pipe/p_compiler.h" +#include "pipe/p_format.h" +#include "util/u_memory.h" +#include "util/u_debug.h" +#include "util/u_network.h" + +#include "rbug/rbug.h" + +static void talk() +{ + int c = u_socket_connect("localhost", 13370); + struct rbug_connection *con = rbug_from_socket(c); + struct rbug_header *header; + struct rbug_proto_texture_list_reply *list; + struct rbug_proto_texture_info_reply *info; + int i; + + assert(c >= 0); + assert(con); + debug_printf("Connection get!\n"); + + debug_printf("Sending get textures\n"); + rbug_send_texture_list(con, NULL); + + debug_printf("Waiting for textures\n"); + header = rbug_get_message(con, NULL); + assert(header->opcode == RBUG_OP_TEXTURE_LIST_REPLY); + list = (struct rbug_proto_texture_list_reply *)header; + + debug_printf("Got textures:\n"); + for (i = 0; i < list->textures_len; i++) { + rbug_send_texture_info(con, list->textures[i], NULL); + + header = rbug_get_message(con, NULL); + assert(header->opcode == RBUG_OP_TEXTURE_INFO_REPLY); + info = (struct rbug_proto_texture_info_reply *)header; + + debug_printf("%llu %s %u x %u x %u, block(%ux%u %u), last_level: %u, nr_samples: %u, usage: %u\n", + (unsigned long long)list->textures[i], pf_name(info->format), + info->width[0], info->height[0], info->depth[0], + info->blockw, info->blockh, info->blocksize, + info->last_level, info->nr_samples, info->tex_usage); + rbug_free_header(header); + } + + rbug_free_header(&list->header); + rbug_disconnect(con); +} + +int main(int argc, char** argv) +{ + talk(); + return 0; +} |