diff options
Diffstat (limited to 'progs')
-rw-r--r-- | progs/demos/vao_demo.c | 2 | ||||
-rw-r--r-- | progs/glsl/multitex.c | 76 | ||||
-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 | ||||
-rw-r--r-- | progs/samples/prim.c | 7 | ||||
-rw-r--r-- | progs/tests/Makefile | 3 | ||||
-rw-r--r-- | progs/tests/getteximage.c | 217 | ||||
-rw-r--r-- | progs/trivial/.gitignore | 3 | ||||
-rw-r--r-- | progs/util/extfuncs.h | 19 |
18 files changed, 1116 insertions, 11 deletions
diff --git a/progs/demos/vao_demo.c b/progs/demos/vao_demo.c index ce416712fe..206e06fc6c 100644 --- a/progs/demos/vao_demo.c +++ b/progs/demos/vao_demo.c @@ -260,6 +260,8 @@ static void Key( unsigned char key, int x, int y ) (void) y; switch (key) { case 27: + (*delete_vertex_arrays)( 1, & cube_array_obj ); + (*delete_vertex_arrays)( 1, & oct_array_obj ); glutDestroyWindow(Win); exit(0); break; diff --git a/progs/glsl/multitex.c b/progs/glsl/multitex.c index bbf58af055..1a1c63aaf4 100644 --- a/progs/glsl/multitex.c +++ b/progs/glsl/multitex.c @@ -51,6 +51,8 @@ static GLfloat Xrot = 0.0, Yrot = .0, Zrot = 0.0; static GLfloat EyeDist = 10; static GLboolean Anim = GL_TRUE; static GLboolean UseArrays = GL_TRUE; +static GLboolean UseVBO = GL_TRUE; +static GLuint VBO = 0; static GLint VertCoord_attr = -1, TexCoord0_attr = -1, TexCoord1_attr = -1; @@ -76,28 +78,81 @@ static const GLfloat VertCoords[4][2] = { }; + +static void +SetupVertexBuffer(void) +{ + glGenBuffersARB_func(1, &VBO); + glBindBufferARB_func(GL_ARRAY_BUFFER_ARB, VBO); + + glBufferDataARB_func(GL_ARRAY_BUFFER_ARB, + sizeof(VertCoords) + + sizeof(Tex0Coords) + + sizeof(Tex1Coords), + NULL, + GL_STATIC_DRAW_ARB); + + /* non-interleaved vertex arrays */ + + glBufferSubDataARB_func(GL_ARRAY_BUFFER_ARB, + 0, /* offset */ + sizeof(VertCoords), /* size */ + VertCoords); /* data */ + + glBufferSubDataARB_func(GL_ARRAY_BUFFER_ARB, + sizeof(VertCoords), /* offset */ + sizeof(Tex0Coords), /* size */ + Tex0Coords); /* data */ + + glBufferSubDataARB_func(GL_ARRAY_BUFFER_ARB, + sizeof(VertCoords) + + sizeof(Tex0Coords), /* offset */ + sizeof(Tex1Coords), /* size */ + Tex1Coords); /* data */ + + glBindBufferARB_func(GL_ARRAY_BUFFER_ARB, 0); +} + + static void DrawPolygonArray(void) { + void *vertPtr, *tex0Ptr, *tex1Ptr; + + if (UseVBO) { + glBindBufferARB_func(GL_ARRAY_BUFFER_ARB, VBO); + vertPtr = (void *) 0; + tex0Ptr = (void *) sizeof(VertCoords); + tex1Ptr = (void *) (sizeof(VertCoords) + sizeof(Tex0Coords)); + } + else { + glBindBufferARB_func(GL_ARRAY_BUFFER_ARB, 0); + vertPtr = VertCoords; + tex0Ptr = Tex0Coords; + tex1Ptr = Tex1Coords; + } + if (VertCoord_attr >= 0) { glVertexAttribPointer_func(VertCoord_attr, 2, GL_FLOAT, GL_FALSE, - 0, VertCoords); + 0, vertPtr); glEnableVertexAttribArray_func(VertCoord_attr); } else { - glVertexPointer(2, GL_FLOAT, 0, VertCoords); + glVertexPointer(2, GL_FLOAT, 0, vertPtr); glEnable(GL_VERTEX_ARRAY); } glVertexAttribPointer_func(TexCoord0_attr, 2, GL_FLOAT, GL_FALSE, - 0, Tex0Coords); + 0, tex0Ptr); glEnableVertexAttribArray_func(TexCoord0_attr); glVertexAttribPointer_func(TexCoord1_attr, 2, GL_FLOAT, GL_FALSE, - 0, Tex1Coords); + 0, tex1Ptr); glEnableVertexAttribArray_func(TexCoord1_attr); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + + glBindBufferARB_func(GL_ARRAY_BUFFER_ARB, 0); } @@ -163,6 +218,10 @@ key(unsigned char k, int x, int y) UseArrays = !UseArrays; printf("Arrays: %d\n", UseArrays); break; + case 'v': + UseVBO = !UseVBO; + printf("Use VBO: %d\n", UseVBO); + break; case ' ': Anim = !Anim; if (Anim) @@ -314,12 +373,19 @@ InitGL(void) /*exit(1);*/ } printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER)); - + printf("Usage:\n"); + printf(" a - toggle arrays vs. immediate mode rendering\n"); + printf(" v - toggle VBO usage for array rendering\n"); + printf(" z/Z - change viewing distance\n"); + printf(" SPACE - toggle animation\n"); + printf(" Esc - exit\n"); GetExtensionFuncs(); InitTextures(); InitPrograms(); + SetupVertexBuffer(); + glEnable(GL_DEPTH_TEST); glClearColor(.6, .6, .9, 0); diff --git a/progs/rbug/.gitignore b/progs/rbug/.gitignore new file mode 100644 index 0000000000..317290bbb3 --- /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 0000000000..8df03dd4e1 --- /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 0000000000..0eb0a5de9a --- /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 0000000000..d72c326719 --- /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 0000000000..e6b12073d8 --- /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 0000000000..8f9d758d51 --- /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 0000000000..b6864e988e --- /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 0000000000..38929fa796 --- /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 0000000000..04380c3310 --- /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 0000000000..f9e06ee994 --- /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 0000000000..4a21bae359 --- /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; +} diff --git a/progs/samples/prim.c b/progs/samples/prim.c index f47c60faef..c04750725f 100644 --- a/progs/samples/prim.c +++ b/progs/samples/prim.c @@ -466,25 +466,22 @@ static void Draw(void) } else { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } -#if 01 + Viewport(0, 0); Point(); Viewport(0, 1); Lines(); Viewport(0, 2); LineStrip(); Viewport(0, 3); LineLoop(); Viewport(1, 0); Bitmap(); - Viewport(1, 1); TriangleFan(); Viewport(1, 2); Triangles(); Viewport(1, 3); TriangleStrip(); Viewport(2, 0); Rect(); -#endif Viewport(2, 1); PolygonFunc(); -#if 01 Viewport(2, 2); Quads(); Viewport(2, 3); QuadStrip(); -#endif + glFlush(); if (doubleBuffer) { diff --git a/progs/tests/Makefile b/progs/tests/Makefile index 7604b22788..5069817be3 100644 --- a/progs/tests/Makefile +++ b/progs/tests/Makefile @@ -48,7 +48,8 @@ SOURCES = \ fptest1.c \ fptexture.c \ getprocaddress.c \ - glutfx \ + getteximage.c \ + glutfx.c \ interleave.c \ invert.c \ jkrahntest.c \ diff --git a/progs/tests/getteximage.c b/progs/tests/getteximage.c new file mode 100644 index 0000000000..e4818a8fab --- /dev/null +++ b/progs/tests/getteximage.c @@ -0,0 +1,217 @@ +/** + * Test glGetTexImage() + * Brian Paul + * 9 June 2009 + */ + + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <GL/glew.h> +#include <GL/glut.h> + +static int Win; + + +static void +TestGetTexImage(void) +{ + GLuint iter; + GLubyte *data = (GLubyte *) malloc(1024 * 1024 * 4); + GLubyte *data2 = (GLubyte *) malloc(1024 * 1024 * 4); + + glEnable(GL_TEXTURE_2D); + + printf("glTexImage2D + glGetTexImage:\n"); + + for (iter = 0; iter < 8; iter++) { + GLint p = (iter % 8) + 3; + GLint w = (1 << p); + GLint h = (1 << p); + GLuint i; + GLint level = 0; + + printf(" Testing %d x %d tex image\n", w, h); + + /* fill data */ + for (i = 0; i < w * h * 4; i++) { + data[i] = i & 0xff; + data2[i] = 0; + } + + glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, w, h, 0, + GL_RGBA, GL_UNSIGNED_BYTE, data); + + glBegin(GL_POINTS); + glVertex2f(0, 0); + glEnd(); + + /* get */ + glGetTexImage(GL_TEXTURE_2D, level, GL_RGBA, GL_UNSIGNED_BYTE, data2); + + /* compare */ + for (i = 0; i < w * h * 4; i++) { + if (data2[i] != data[i]) { + printf("glTexImage + glGetTexImage failure!\n"); + printf("Expected value %d, found %d\n", data[i], data2[i]); + abort(); + } + } + } + + printf("Passed\n"); + glDisable(GL_TEXTURE_2D); + free(data); + free(data2); +} + + +static GLboolean +ColorsEqual(const GLubyte ref[4], const GLubyte act[4]) +{ + if (abs((int) ref[0] - (int) act[0]) > 1 || + abs((int) ref[1] - (int) act[1]) > 1 || + abs((int) ref[2] - (int) act[2]) > 1 || + abs((int) ref[3] - (int) act[3]) > 1) { + printf("expected %d %d %d %d\n", ref[0], ref[1], ref[2], ref[3]); + printf("found %d %d %d %d\n", act[0], act[1], act[2], act[3]); + return GL_FALSE; + } + return GL_TRUE; +} + + +static void +TestGetTexImageRTT(void) +{ + GLuint iter; + GLuint fb, tex; + GLint w = 512; + GLint h = 256; + GLint level = 0; + + glGenTextures(1, &tex); + glGenFramebuffersEXT(1, &fb); + + glBindTexture(GL_TEXTURE_2D, tex); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + + glBindFramebuffer(GL_FRAMEBUFFER_EXT, fb); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + GL_TEXTURE_2D, tex, level); + + printf("Render to texture + glGetTexImage:\n"); + printf(" Testing %d x %d tex image\n", w, h); + for (iter = 0; iter < 8; iter++) { + GLubyte color[4]; + GLubyte *data2 = (GLubyte *) malloc(w * h * 4); + GLuint i; + + /* random clear color */ + for (i = 0; i < 4; i++) { + color[i] = rand() % 256; + } + + glClearColor(color[0] / 255.0, + color[1] / 255.0, + color[2] / 255.0, + color[3] / 255.0); + + glClear(GL_COLOR_BUFFER_BIT); + + /* get */ + glGetTexImage(GL_TEXTURE_2D, level, GL_RGBA, GL_UNSIGNED_BYTE, data2); + + /* compare */ + for (i = 0; i < w * h; i += 4) { + if (!ColorsEqual(color, data2 + i * 4)) { + printf("Render to texture failure!\n"); + abort(); + } + } + + free(data2); + } + + glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); + glDeleteFramebuffersEXT(1, &fb); + glDeleteTextures(1, &tex); + + printf("Passed\n"); +} + + + + +static void +Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + TestGetTexImage(); + + if (glutExtensionSupported("GL_EXT_framebuffer_object") || + glutExtensionSupported("GL_ARB_framebuffer_object")) + TestGetTexImageRTT(); + + glutDestroyWindow(Win); + exit(0); + + glutSwapBuffers(); +} + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -15.0); +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case 27: + glutDestroyWindow(Win); + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void +Init(void) +{ +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); + glutInitWindowSize(400, 400); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); + Win = glutCreateWindow(argv[0]); + glewInit(); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/.gitignore b/progs/trivial/.gitignore index 8dcb20a68f..dce733a70a 100644 --- a/progs/trivial/.gitignore +++ b/progs/trivial/.gitignore @@ -19,6 +19,7 @@ fs-tri line line-clip line-cull +line-flat line-smooth line-stipple-wide line-userclip @@ -130,6 +131,7 @@ tristrip-flat vbo-drawarrays vbo-drawelements vbo-drawrange +vbo-noninterleaved vp-array vp-array-int vp-clip @@ -139,6 +141,7 @@ vp-tri-cb vp-tri-cb-pos vp-tri-cb-tex vp-tri-imm +vp-tri-invariant vp-tri-swap vp-tri-tex vp-unfilled diff --git a/progs/util/extfuncs.h b/progs/util/extfuncs.h index 070414e294..238794d55a 100644 --- a/progs/util/extfuncs.h +++ b/progs/util/extfuncs.h @@ -86,6 +86,15 @@ static PFNGLISVERTEXARRAYAPPLEPROC glIsVertexArrayAPPLE_func = NULL; /* GL_EXT_stencil_two_side */ static PFNGLACTIVESTENCILFACEEXTPROC glActiveStencilFaceEXT_func = NULL; +/* GL_ARB_buffer_object */ +static PFNGLGENBUFFERSARBPROC glGenBuffersARB_func = NULL; +static PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB_func = NULL; +static PFNGLBINDBUFFERARBPROC glBindBufferARB_func = NULL; +static PFNGLBUFFERDATAARBPROC glBufferDataARB_func = NULL; +static PFNGLBUFFERSUBDATAARBPROC glBufferSubDataARB_func = NULL; +static PFNGLMAPBUFFERARBPROC glMapBufferARB_func = NULL; +static PFNGLUNMAPBUFFERARBPROC glUnmapBufferARB_func = NULL; + static void GetExtensionFuncs(void) @@ -173,5 +182,15 @@ GetExtensionFuncs(void) /* GL_EXT_stencil_two_side */ glActiveStencilFaceEXT_func = (PFNGLACTIVESTENCILFACEEXTPROC) glutGetProcAddress("glActiveStencilFaceEXT"); + + /* GL_ARB_vertex_buffer_object */ + glGenBuffersARB_func = (PFNGLGENBUFFERSARBPROC) glutGetProcAddress("glGenBuffersARB"); + glDeleteBuffersARB_func = (PFNGLDELETEBUFFERSARBPROC) glutGetProcAddress("glDeleteBuffersARB"); + glBindBufferARB_func = (PFNGLBINDBUFFERARBPROC) glutGetProcAddress("glBindBufferARB"); + glBufferDataARB_func = (PFNGLBUFFERDATAARBPROC) glutGetProcAddress("glBufferDataARB"); + glBufferSubDataARB_func = (PFNGLBUFFERSUBDATAARBPROC) glutGetProcAddress("glBufferSubDataARB"); + glMapBufferARB_func = (PFNGLMAPBUFFERARBPROC) glutGetProcAddress("glMapBufferARB"); + glUnmapBufferARB_func = (PFNGLUNMAPBUFFERARBPROC) glutGetProcAddress("glUnmapBufferARB"); + } |