summaryrefslogtreecommitdiff
path: root/progs
diff options
context:
space:
mode:
Diffstat (limited to 'progs')
-rw-r--r--progs/demos/cubemap.c17
-rw-r--r--progs/demos/vao_demo.c2
-rw-r--r--progs/glsl/multitex.c76
-rw-r--r--progs/rbug/.gitignore12
-rw-r--r--progs/rbug/Makefile48
-rw-r--r--progs/rbug/README39
-rw-r--r--progs/rbug/bin_to_bmp.c110
-rw-r--r--progs/rbug/ctx_info.c80
-rw-r--r--progs/rbug/ctx_rule.c86
-rw-r--r--progs/rbug/shdr_disable.c82
-rw-r--r--progs/rbug/shdr_dump.c115
-rw-r--r--progs/rbug/shdr_info.c98
-rw-r--r--progs/rbug/simple_client.c64
-rw-r--r--progs/rbug/simple_server.c62
-rw-r--r--progs/rbug/tex_dump.c127
-rw-r--r--progs/rbug/tex_info.c78
-rw-r--r--progs/samples/prim.c7
-rw-r--r--progs/tests/.gitignore4
-rw-r--r--progs/tests/Makefile7
-rw-r--r--progs/tests/SConscript2
-rw-r--r--progs/tests/arbgpuprog.c230
-rw-r--r--progs/tests/bufferobj.c120
-rw-r--r--progs/tests/getteximage.c217
-rw-r--r--progs/tests/mipmap_comp_tests.c313
-rw-r--r--progs/tests/persp_hint.c149
-rw-r--r--progs/tests/prim.c559
-rw-r--r--progs/tests/tkmap.c71
-rw-r--r--progs/trivial/.gitignore3
-rw-r--r--progs/util/extfuncs.h1
29 files changed, 2738 insertions, 41 deletions
diff --git a/progs/demos/cubemap.c b/progs/demos/cubemap.c
index 26db42aed5..1f9f290575 100644
--- a/progs/demos/cubemap.c
+++ b/progs/demos/cubemap.c
@@ -52,6 +52,7 @@ static GLboolean NoClear = GL_FALSE;
static GLint FrameParity = 0;
static GLenum FilterIndex = 0;
static GLint ClampIndex = 0;
+static GLboolean supportFBO = GL_FALSE;
static struct {
@@ -403,6 +404,10 @@ static void init_checkers( void )
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ if (!supportFBO)
+ glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
+
+
/* make colored checkerboard cube faces */
for (f = 0; f < 6; f++) {
for (i = 0; i < CUBE_TEX_SIZE; i++) {
@@ -426,7 +431,8 @@ static void init_checkers( void )
GL_BGRA, GL_UNSIGNED_BYTE, image);
}
- glGenerateMipmapEXT(GL_TEXTURE_CUBE_MAP_ARB);
+ if (supportFBO)
+ glGenerateMipmapEXT(GL_TEXTURE_CUBE_MAP_ARB);
}
@@ -503,10 +509,13 @@ static void init( GLboolean useImageFiles )
exit(0);
}
- /* Needed for glGenerateMipmapEXT
+ /* Needed for glGenerateMipmapEXT / auto mipmapping
*/
- if (!strstr(exten, "GL_EXT_framebuffer_object")) {
- printf("Sorry, this demo requires GL_EXT_framebuffer_object\n");
+ if (strstr(exten, "GL_EXT_framebuffer_object")) {
+ supportFBO = GL_TRUE;
+ }
+ else if (!strstr(exten, "GL_SGIS_generate_mipmap")) {
+ printf("Sorry, this demo requires GL_EXT_framebuffer_object or GL_SGIS_generate_mipmap\n");
exit(0);
}
}
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 724f15e1a3..cbf173304c 100644
--- a/progs/glsl/multitex.c
+++ b/progs/glsl/multitex.c
@@ -52,6 +52,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;
@@ -77,28 +79,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);
}
@@ -164,6 +219,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)
@@ -315,12 +374,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..174fe42aa7
--- /dev/null
+++ b/progs/rbug/.gitignore
@@ -0,0 +1,12 @@
+bin_to_bmp
+simple_client
+simple_server
+shdr_info
+shdr_dump
+shdr_disable
+ctx_info
+ctx_rule
+tex_dump
+tex_info
+*.bmp
+*.bin
diff --git a/progs/rbug/Makefile b/progs/rbug/Makefile
new file mode 100644
index 0000000000..fb4e91d1af
--- /dev/null
+++ b/progs/rbug/Makefile
@@ -0,0 +1,48 @@
+# 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 = \
+ bin_to_bmp.c \
+ simple_client.c \
+ simple_server.c \
+ shdr_info.c \
+ shdr_dump.c \
+ shdr_disable.c \
+ ctx_info.c \
+ ctx_rule.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/bin_to_bmp.c b/progs/rbug/bin_to_bmp.c
new file mode 100644
index 0000000000..cdae3486ce
--- /dev/null
+++ b/progs/rbug/bin_to_bmp.c
@@ -0,0 +1,110 @@
+/*
+ * 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"
+
+static uint8_t* read(const char *filename, unsigned size);
+static void dump(unsigned src_width, unsigned src_height,
+ unsigned src_stride, enum pipe_format src_format,
+ uint8_t *data, unsigned src_size);
+
+int main(int argc, char** argv)
+{
+ /* change these */
+ unsigned width = 64;
+ unsigned height = 64;
+ unsigned stride = width * 4;
+ unsigned size = stride * height;
+ const char *filename = "mybin.bin";
+ enum pipe_format format = PIPE_FORMAT_A8R8G8B8_UNORM;
+
+ dump(width, height, stride, format, read(filename, size), size);
+
+ return 0;
+}
+
+static void dump(unsigned width, unsigned height,
+ unsigned src_stride, enum pipe_format src_format,
+ uint8_t *data, unsigned src_size)
+{
+ struct pipe_format_block src_block;
+
+ enum pipe_format dst_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+ struct pipe_format_block dst_block;
+ unsigned dst_stride;
+ unsigned dst_size;
+ float *rgba;
+ int i;
+ char filename[512];
+
+ {
+ pf_get_block(src_format, &src_block);
+ assert(src_stride >= pf_get_stride(&src_block, width));
+ assert(src_size >= pf_get_2d_size(&src_block, src_stride, width));
+ }
+ {
+ pf_get_block(dst_format, &dst_block);
+ dst_stride = pf_get_stride(&dst_block, width);
+ dst_size = pf_get_2d_size(&dst_block, dst_stride, width);
+ rgba = MALLOC(dst_size);
+ }
+
+ util_snprintf(filename, 512, "%s.bmp", pf_name(src_format));
+
+ if (pf_is_compressed(src_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(src_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 uint8_t* read(const char *filename, unsigned size)
+{
+ uint8_t *data;
+ FILE *file = fopen(filename, "rb");
+
+ data = MALLOC(size);
+
+ fread(data, 1, size, file);
+ fclose(file);
+
+ return data;
+}
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/ctx_rule.c b/progs/rbug/ctx_rule.c
new file mode 100644
index 0000000000..e38b7b4e9b
--- /dev/null
+++ b/progs/rbug/ctx_rule.c
@@ -0,0 +1,86 @@
+/*
+ * 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;
+ struct rbug_header *header;
+
+ if (c < 0)
+ c = u_socket_connect("localhost", 13370);
+
+ con = rbug_from_socket(c);
+ assert(c >= 0);
+ assert(con);
+ debug_printf("Connection get!\n");
+
+ rbug_send_context_draw_rule(con, ctx, 0, shdr, 0, 0, RBUG_BLOCK_AFTER, 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 ctx_rule <context> <fragment>\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_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/.gitignore b/progs/tests/.gitignore
index d6a8538767..917c4f3e8d 100644
--- a/progs/tests/.gitignore
+++ b/progs/tests/.gitignore
@@ -5,6 +5,7 @@ arbfpspec
arbfptest1
arbfptexture
arbfptrig
+arbgpuprog
arbnpot
arbnpot-mipmap
arbvptest1
@@ -38,6 +39,7 @@ fptest1
fptexture
getprocaddress
getproclist.h
+getteximage
glutfx
interleave
invert
@@ -49,11 +51,13 @@ mapvbo
minmag
mipgen
mipmap_comp
+mipmap_comp_tests
mipmap_limits
mipmap_view
multipal
no_s3tc
packedpixels
+persp_hint
pbo
prog_parameter
quads
diff --git a/progs/tests/Makefile b/progs/tests/Makefile
index 7604b22788..f380ed4f54 100644
--- a/progs/tests/Makefile
+++ b/progs/tests/Makefile
@@ -17,6 +17,7 @@ SOURCES = \
arbfptest1.c \
arbfptexture.c \
arbfptrig.c \
+ arbgpuprog.c \
arbnpot.c \
arbnpot-mipmap.c \
arbvptest1.c \
@@ -48,7 +49,8 @@ SOURCES = \
fptest1.c \
fptexture.c \
getprocaddress.c \
- glutfx \
+ getteximage.c \
+ glutfx.c \
interleave.c \
invert.c \
jkrahntest.c \
@@ -59,12 +61,15 @@ SOURCES = \
minmag.c \
mipgen.c \
mipmap_comp.c \
+ mipmap_comp_tests.c \
mipmap_limits.c \
mipmap_view.c \
multipal.c \
no_s3tc.c \
packedpixels.c \
pbo.c \
+ persp_hint.c \
+ prim.c \
prog_parameter.c \
quads.c \
random.c \
diff --git a/progs/tests/SConscript b/progs/tests/SConscript
index 9d89ff6a0d..4c75246c30 100644
--- a/progs/tests/SConscript
+++ b/progs/tests/SConscript
@@ -82,6 +82,7 @@ progs = [
'minmag',
'mipgen',
'mipmap_comp',
+ 'mipmap_comp_tests',
'mipmap_limits',
'mipmap_view',
'multipal',
@@ -90,6 +91,7 @@ progs = [
'no_s3tc',
'packedpixels',
'pbo',
+ 'persp_hint',
'prog_parameter',
'quads',
'random',
diff --git a/progs/tests/arbgpuprog.c b/progs/tests/arbgpuprog.c
new file mode 100644
index 0000000000..23aa899d96
--- /dev/null
+++ b/progs/tests/arbgpuprog.c
@@ -0,0 +1,230 @@
+/**
+ * Just compile ARB vert/frag program from named file(s).
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+static GLuint FragProg;
+static GLuint VertProg;
+static GLint Win;
+
+static PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glProgramLocalParameter4fvARB_func;
+static PFNGLPROGRAMLOCALPARAMETER4DARBPROC glProgramLocalParameter4dARB_func;
+static PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC glGetProgramLocalParameterdvARB_func;
+static PFNGLGENPROGRAMSARBPROC glGenProgramsARB_func;
+static PFNGLPROGRAMSTRINGARBPROC glProgramStringARB_func;
+static PFNGLBINDPROGRAMARBPROC glBindProgramARB_func;
+static PFNGLISPROGRAMARBPROC glIsProgramARB_func;
+static PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB_func;
+
+
+static void Redisplay( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+ glutSwapBuffers();
+ exit(0);
+}
+
+
+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:
+ glDeleteProgramsARB_func(1, &VertProg);
+ glDeleteProgramsARB_func(1, &FragProg);
+ glutDestroyWindow(Win);
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+/* A helper for finding errors in program strings */
+static int FindLine( const char *program, int position )
+{
+ int i, line = 1;
+ for (i = 0; i < position; i++) {
+ if (program[i] == '\n')
+ line++;
+ }
+ return line;
+}
+
+
+static void Init( const char *vertProgFile,
+ const char *fragProgFile )
+{
+ GLint errorPos;
+ char buf[10*1000];
+
+ if (!glutExtensionSupported("GL_ARB_vertex_program")) {
+ printf("Sorry, this demo requires GL_ARB_vertex_program\n");
+ exit(1);
+ }
+ if (!glutExtensionSupported("GL_ARB_fragment_program")) {
+ printf("Sorry, this demo requires GL_ARB_fragment_program\n");
+ exit(1);
+ }
+
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+
+ /*
+ * Get extension function pointers.
+ */
+ glProgramLocalParameter4fvARB_func = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) glutGetProcAddress("glProgramLocalParameter4fvARB");
+ assert(glProgramLocalParameter4fvARB_func);
+
+ glProgramLocalParameter4dARB_func = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC) glutGetProcAddress("glProgramLocalParameter4dARB");
+ assert(glProgramLocalParameter4dARB_func);
+
+ glGetProgramLocalParameterdvARB_func = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) glutGetProcAddress("glGetProgramLocalParameterdvARB");
+ assert(glGetProgramLocalParameterdvARB_func);
+
+ glGenProgramsARB_func = (PFNGLGENPROGRAMSARBPROC) glutGetProcAddress("glGenProgramsARB");
+ assert(glGenProgramsARB_func);
+
+ glProgramStringARB_func = (PFNGLPROGRAMSTRINGARBPROC) glutGetProcAddress("glProgramStringARB");
+ assert(glProgramStringARB_func);
+
+ glBindProgramARB_func = (PFNGLBINDPROGRAMARBPROC) glutGetProcAddress("glBindProgramARB");
+ assert(glBindProgramARB_func);
+
+ glIsProgramARB_func = (PFNGLISPROGRAMARBPROC) glutGetProcAddress("glIsProgramARB");
+ assert(glIsProgramARB_func);
+
+ glDeleteProgramsARB_func = (PFNGLDELETEPROGRAMSARBPROC) glutGetProcAddress("glDeleteProgramsARB");
+ assert(glDeleteProgramsARB_func);
+
+ /*
+ * Vertex program
+ */
+ if (vertProgFile) {
+ FILE *f;
+ int len;
+
+ glGenProgramsARB_func(1, &VertProg);
+ assert(VertProg > 0);
+ glBindProgramARB_func(GL_VERTEX_PROGRAM_ARB, VertProg);
+
+ f = fopen(vertProgFile, "r");
+ if (!f) {
+ printf("Unable to open %s\n", fragProgFile);
+ exit(1);
+ }
+
+ len = fread(buf, 1, 10*1000,f);
+ glProgramStringARB_func(GL_VERTEX_PROGRAM_ARB,
+ GL_PROGRAM_FORMAT_ASCII_ARB,
+ len,
+ (const GLubyte *) buf);
+
+ glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
+ if (glGetError() != GL_NO_ERROR || errorPos != -1) {
+ int l = FindLine(buf, errorPos);
+ printf("Vertex Program Error (pos=%d line=%d): %s\n", errorPos, l,
+ (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+ exit(0);
+ }
+ else {
+ glEnable(GL_VERTEX_PROGRAM_ARB);
+ printf("Vertex Program OK\n");
+ }
+ }
+
+ /*
+ * Fragment program
+ */
+ if (fragProgFile) {
+ FILE *f;
+ int len;
+
+ glGenProgramsARB_func(1, &FragProg);
+ assert(FragProg > 0);
+ glBindProgramARB_func(GL_FRAGMENT_PROGRAM_ARB, FragProg);
+
+ f = fopen(fragProgFile, "r");
+ if (!f) {
+ printf("Unable to open %s\n", fragProgFile);
+ exit(1);
+ }
+
+ len = fread(buf, 1, 10*1000,f);
+ glProgramStringARB_func(GL_FRAGMENT_PROGRAM_ARB,
+ GL_PROGRAM_FORMAT_ASCII_ARB,
+ len,
+ (const GLubyte *) buf);
+
+ glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
+ if (glGetError() != GL_NO_ERROR || errorPos != -1) {
+ int l = FindLine(buf, errorPos);
+ printf("Fragment Program Error (pos=%d line=%d): %s\n", errorPos, l,
+ (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+ exit(0);
+ }
+ else {
+ glEnable(GL_FRAGMENT_PROGRAM_ARB);
+ printf("Fragment Program OK\n");
+ }
+ }
+}
+
+
+int main( int argc, char *argv[] )
+{
+ const char *vertProgFile = NULL, *fragProgFile = NULL;
+ int i;
+
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 200, 200 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ Win = glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Redisplay );
+
+ if (argc == 1) {
+ printf("arbgpuprog:\n");
+ printf(" Compile GL_ARB_vertex/fragment_programs, report any errors.\n");
+ printf("Usage:\n");
+ printf(" arbgpuprog [--vp vertprogfile] [--fp fragprogfile]\n");
+ exit(1);
+ }
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "--vp") == 0) {
+ vertProgFile = argv[i+1];
+ i++;
+ }
+ else if (strcmp(argv[i], "--fp") == 0) {
+ fragProgFile = argv[i+1];
+ i++;
+ }
+ }
+
+ Init(vertProgFile, fragProgFile);
+
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/tests/bufferobj.c b/progs/tests/bufferobj.c
index 1d97b060ef..220bd1f506 100644
--- a/progs/tests/bufferobj.c
+++ b/progs/tests/bufferobj.c
@@ -1,5 +1,6 @@
/*
* Test GL_ARB_vertex_buffer_object
+ * Also test GL_ARB_vertex_array_object if supported
*
* Brian Paul
* 16 Sep 2003
@@ -9,6 +10,7 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <math.h>
#include <GL/glew.h>
#include <GL/glut.h>
@@ -17,6 +19,7 @@
struct object
{
+ GLuint ArrayObjectID; /** GL_ARB_vertex_array_object */
GLuint VertexBufferID;
GLuint ColorBufferID;
GLuint ElementsBufferID;
@@ -35,6 +38,7 @@ static GLuint Win;
static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
static GLboolean Anim = GL_TRUE;
+static GLboolean Have_ARB_vertex_array_object = GL_FALSE;
static void CheckError(int line)
@@ -48,34 +52,54 @@ static void CheckError(int line)
static void DrawObject( const struct object *obj )
{
- glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->VertexBufferID);
- glVertexPointer(3, GL_FLOAT, obj->VertexStride, (void *) obj->VertexOffset);
- glEnable(GL_VERTEX_ARRAY);
+ if (Have_ARB_vertex_array_object && obj->ArrayObjectID) {
+ glBindVertexArray(obj->ArrayObjectID);
+
+ if (obj->NumElements > 0) {
+ /* indexed arrays */
+ glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, obj->ElementsBufferID);
+ glDrawElements(GL_LINE_LOOP, obj->NumElements, GL_UNSIGNED_INT, NULL);
+ }
+ else {
+ /* non-indexed arrays */
+ glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
+ glDrawArrays(GL_LINE_LOOP, 0, obj->NumVerts);
+ }
+
+ glBindVertexArray(0);
+ }
+ else {
+ /* no vertex array objects, must set vertex/color pointers per draw */
- /* test push/pop attrib */
- /* XXX this leads to a segfault with NVIDIA's 53.36 driver */
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->VertexBufferID);
+ glVertexPointer(3, GL_FLOAT, obj->VertexStride, (void *) obj->VertexOffset);
+ glEnable(GL_VERTEX_ARRAY);
+
+ /* test push/pop attrib */
+ /* XXX this leads to a segfault with NVIDIA's 53.36 driver */
#if 0
- if (1)
- {
- glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
- /*glVertexPointer(3, GL_FLOAT, 0, (void *) (obj->VertexOffset + 10000));*/
- glBindBufferARB(GL_ARRAY_BUFFER_ARB, 999999);
- glPopClientAttrib();
- }
+ if (1)
+ {
+ glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
+ /*glVertexPointer(3, GL_FLOAT, 0, (void *) (obj->VertexOffset + 10000));*/
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, 999999);
+ glPopClientAttrib();
+ }
#endif
- glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->ColorBufferID);
- glColorPointer(3, GL_FLOAT, obj->ColorStride, (void *) obj->ColorOffset);
- glEnable(GL_COLOR_ARRAY);
-
- if (obj->NumElements > 0) {
- /* indexed arrays */
- glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, obj->ElementsBufferID);
- glDrawElements(GL_LINE_LOOP, obj->NumElements, GL_UNSIGNED_INT, NULL);
- }
- else {
- /* non-indexed arrays */
- glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
- glDrawArrays(GL_LINE_LOOP, 0, obj->NumVerts);
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->ColorBufferID);
+ glColorPointer(3, GL_FLOAT, obj->ColorStride, (void *) obj->ColorOffset);
+ glEnable(GL_COLOR_ARRAY);
+
+ if (obj->NumElements > 0) {
+ /* indexed arrays */
+ glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, obj->ElementsBufferID);
+ glDrawElements(GL_LINE_LOOP, obj->NumElements, GL_UNSIGNED_INT, NULL);
+ }
+ else {
+ /* non-indexed arrays */
+ glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
+ glDrawArrays(GL_LINE_LOOP, 0, obj->NumVerts);
+ }
}
}
@@ -187,6 +211,28 @@ static void SpecialKey( int key, int x, int y )
}
+/**
+ * If GL_ARB_vertex_array_object is supported, create an array object
+ * and set all the per-array state.
+ */
+static void
+CreateVertexArrayObject(struct object *obj)
+{
+ glGenVertexArrays(1, &obj->ArrayObjectID);
+ glBindVertexArray(obj->ArrayObjectID);
+
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->VertexBufferID);
+ glVertexPointer(3, GL_FLOAT, obj->VertexStride, (void *) obj->VertexOffset);
+ glEnable(GL_VERTEX_ARRAY);
+
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->ColorBufferID);
+ glColorPointer(3, GL_FLOAT, obj->ColorStride, (void *) obj->ColorOffset);
+ glEnable(GL_COLOR_ARRAY);
+
+ glBindVertexArray(0);
+}
+
+
/*
* Non-interleaved position/color data.
*/
@@ -262,6 +308,10 @@ static void MakeObject1(struct object *obj)
glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAPPED_ARB, &i);
assert(!i);
+
+ if (Have_ARB_vertex_array_object) {
+ CreateVertexArrayObject(obj);
+ }
}
@@ -297,6 +347,10 @@ static void MakeObject2(struct object *obj)
obj->NumElements = 0;
glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
+
+ if (Have_ARB_vertex_array_object) {
+ CreateVertexArrayObject(obj);
+ }
}
@@ -347,6 +401,10 @@ static void MakeObject3(struct object *obj)
i[3] = 3;
glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB);
obj->NumElements = 4;
+
+ if (Have_ARB_vertex_array_object) {
+ CreateVertexArrayObject(obj);
+ }
}
@@ -387,6 +445,10 @@ static void MakeObject4(struct object *obj)
/* Setup a buffer of indices to test the ELEMENTS path */
obj->ElementsBufferID = 0;
obj->NumElements = 0;
+
+ if (Have_ARB_vertex_array_object) {
+ CreateVertexArrayObject(obj);
+ }
}
@@ -399,6 +461,13 @@ static void Init( void )
}
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ Have_ARB_vertex_array_object =
+ glutExtensionSupported("GL_ARB_vertex_array_object");
+
+ printf("Using GL_ARB_vertex_array_object: %s\n",
+ (Have_ARB_vertex_array_object ? "yes" : "no"));
+
+
/* Test buffer object deletion */
if (1) {
static GLubyte data[1000];
@@ -413,6 +482,7 @@ static void Init( void )
assert(!glIsBufferARB(id));
}
+ memset(Objects, 0, sizeof(Objects));
MakeObject1(Objects + 0);
MakeObject2(Objects + 1);
MakeObject3(Objects + 2);
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/tests/mipmap_comp_tests.c b/progs/tests/mipmap_comp_tests.c
new file mode 100644
index 0000000000..8f20625378
--- /dev/null
+++ b/progs/tests/mipmap_comp_tests.c
@@ -0,0 +1,313 @@
+/* Copyright (c) Mark J. Kilgard, 1994. */
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+
+/* mipmap_comp
+ * Test compressed texture mipmaps
+ *
+ * Based on mipmap_limits
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <GL/glew.h>
+#include <GL/glut.h>
+
+#include "readtex.h"
+
+#define SIZE 16 /* not larger then 16 */
+
+static GLint BaseLevel = 0, MaxLevel ;
+static GLfloat MinLod, MaxLod;
+static GLfloat LodBias;
+static GLboolean NearestFilter;
+static GLuint texImage;
+static GLuint View;
+
+struct view {
+ GLfloat minLod;
+ GLfloat maxLod;
+ const char *string;
+};
+
+static struct view views[] =
+{
+ { 0, 0, "Green" },
+ { 0, 1, "Green, Red" },
+ { 0, 2, "Green, Red, Blue" },
+ { 0, 3, "Green, Red, Blue, Black" },
+ { 0, 4, "Green, Red, Blue, Black, White" },
+ { 1, 4, "Red, Blue, Black, White" },
+ { 2, 4, "Blue, Black, White" },
+ { 3, 4, "Black, White" },
+ { 4, 4, "White" },
+ { 1, 3, "Red, Blue, Black" },
+ { 1, 2, "Red, Blue" },
+ { 2, 3, "Blue, Black" },
+ { 0, 0, NULL },
+};
+
+static void
+initValues(void)
+{
+ View = 9;
+ BaseLevel = 0;
+ MaxLevel = 9;
+ MinLod = views[View].minLod;
+ MaxLod = views[View].maxLod;
+ LodBias = 5.0;
+ NearestFilter = GL_TRUE;
+}
+
+
+static void
+changeView(void)
+{
+ if (views[++View].string == NULL)
+ View = 0;
+
+ MinLod = views[View].minLod;
+ MaxLod = views[View].maxLod;
+}
+
+
+static void
+makeImage(int level, int width, int height)
+{
+ GLubyte img[SIZE*SIZE*3];
+ GLubyte color[5][3] = {
+ { 0, 255, 0 },
+ { 255, 0, 0 },
+ { 0, 0, 255 },
+ { 0, 0, 0 },
+ { 255, 255, 255 },
+ };
+ int i, j;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++) {
+ int k = (i * width + j) * 3;
+ img[k + 0] = color[level][0];
+ img[k + 1] = color[level][1];
+ img[k + 2] = color[level][2];
+ }
+ }
+
+ glTexImage2D(GL_TEXTURE_2D, level, 3, width, height, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, img);
+}
+
+
+static void
+makeImages(void)
+{
+ int i, sz;
+
+ for (i = 0, sz = SIZE; sz >= 1; i++, sz /= 2) {
+ makeImage(i, sz, sz);
+ printf("Level %d size: %d x %d\n", i, sz, sz);
+ }
+}
+
+
+static void
+myInit(void)
+{
+
+ initValues();
+
+ glEnable(GL_DEPTH_TEST);
+ glDepthFunc(GL_LESS);
+ glShadeModel(GL_FLAT);
+
+ glTranslatef(0.0, 0.0, -3.6);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glGenTextures(1, &texImage);
+ glBindTexture(GL_TEXTURE_2D, texImage);
+ makeImages();
+
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
+ glEnable(GL_TEXTURE_2D);
+}
+
+
+static void
+display(void)
+{
+ GLfloat tcm = 1.0;
+ glBindTexture(GL_TEXTURE_2D, texImage);
+
+ printf("BASE_LEVEL=%d MAX_LEVEL=%d MIN_LOD=%.2g MAX_LOD=%.2g Bias=%.2g Filter=%s\n",
+ BaseLevel, MaxLevel, MinLod, MaxLod, LodBias,
+ NearestFilter ? "NEAREST" : "LINEAR");
+ printf("You should see: %s\n", views[View].string );
+ fflush(stdout);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, BaseLevel);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, MaxLevel);
+
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, MinLod);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, MaxLod);
+
+ if (NearestFilter) {
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST_MIPMAP_NEAREST);
+ }
+ else {
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR_MIPMAP_LINEAR);
+ }
+
+ glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, LodBias);
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0);
+ glTexCoord2f(0.0, tcm); glVertex3f(-2.0, 1.0, 0.0);
+ glTexCoord2f(tcm * 3000.0, tcm); glVertex3f(3000.0, 1.0, -6000.0);
+ glTexCoord2f(tcm * 3000.0, 0.0); glVertex3f(3000.0, -1.0, -6000.0);
+ glEnd();
+ glFlush();
+}
+
+
+static void
+myReshape(int w, int h)
+{
+ glViewport(0, 0, w, h);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30000.0);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+}
+
+
+static void
+key(unsigned char k, int x, int y)
+{
+ (void) x;
+ (void) y;
+ switch (k) {
+#if 0
+ case 'b':
+ BaseLevel--;
+ if (BaseLevel < 0)
+ BaseLevel = 0;
+ break;
+ case 'B':
+ BaseLevel++;
+ if (BaseLevel > 10)
+ BaseLevel = 10;
+ break;
+ case 'm':
+ MaxLevel--;
+ if (MaxLevel < 0)
+ MaxLevel = 0;
+ break;
+ case 'M':
+ MaxLevel++;
+ if (MaxLevel > 10)
+ MaxLevel = 10;
+ break;
+ case 'l':
+ LodBias -= 0.25;
+ break;
+ case 'L':
+ LodBias += 0.25;
+ break;
+ case 'n':
+ MinLod -= 0.25;
+ break;
+ case 'N':
+ MinLod += 0.25;
+ break;
+ case 'x':
+ MaxLod -= 0.25;
+ break;
+ case 'X':
+ MaxLod += 0.25;
+ break;
+ case 'f':
+ NearestFilter = !NearestFilter;
+ break;
+#endif
+ case ' ':
+ initValues();
+ break;
+ case 27: /* Escape */
+ exit(0);
+ break;
+ default:
+ changeView();
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+usage(void)
+{
+ printf("usage:\n");
+ printf(" Any Change view\n");
+ printf(" SPACE reset values\n");
+}
+
+
+int
+main(int argc, char** argv)
+{
+ glutInit(&argc, argv);
+ glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
+ glutInitWindowSize (600, 600);
+ glutCreateWindow (argv[0]);
+ glewInit();
+ myInit();
+ glutReshapeFunc (myReshape);
+ glutDisplayFunc(display);
+ glutKeyboardFunc(key);
+ usage();
+ glutMainLoop();
+ return 0; /* ANSI C requires main to return int. */
+}
diff --git a/progs/tests/persp_hint.c b/progs/tests/persp_hint.c
new file mode 100644
index 0000000000..27140d1f56
--- /dev/null
+++ b/progs/tests/persp_hint.c
@@ -0,0 +1,149 @@
+/*
+ * Test the GL_PERSPECTIVE_CORRECTION_HINT setting and its effect on
+ * color interpolation.
+ *
+ * Press 'i' to toggle between GL_NICEST/GL_FASTEST/GL_DONT_CARE.
+ *
+ * Depending on the driver, the hint may make a difference, or not.
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <GL/glut.h>
+
+
+static GLenum PerspHint = GL_DONT_CARE;
+
+
+static void
+init(void)
+{
+ GLubyte image[256][256][4];
+ GLuint i, j;
+ for (i = 0; i < 256; i++) {
+ for (j = 0; j < 256; j++) {
+ image[i][j][0] = j;
+ image[i][j][1] = j;
+ image[i][j][2] = j;
+ image[i][j][3] = 255;
+ }
+ }
+ glTexImage2D(GL_TEXTURE_2D, 0, 4, 256, 256, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, image);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
+
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+}
+
+
+static void
+display(void)
+{
+ switch (PerspHint) {
+ case GL_NICEST:
+ printf("hint = GL_NICEST\n");
+ break;
+ case GL_FASTEST:
+ printf("hint = GL_FASTEST\n");
+ break;
+ case GL_DONT_CARE:
+ printf("hint = GL_DONT_CARE\n");
+ break;
+ default:
+ ;
+ }
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+#if 1
+ glBegin(GL_QUADS);
+ /* exercise perspective interpolation */
+ glColor3f(0.0, 0.0, 0.0); glVertex3f(-1.0, -1.0, -1.0);
+ glColor3f(0.0, 0.0, 0.0); glVertex3f(-1.0, 1.0, -1.0);
+ glColor3f(0.0, 1.0, 0.0); glVertex3f( 7.0, 1.0, -7.0);
+ glColor3f(0.0, 1.0, 0.0); glVertex3f( 7.0, -1.0, -7.0);
+
+ /* stripe of linear interpolation */
+ glColor3f(0.0, 0.0, 0.0); glVertex3f(-1.0, -0.1, -1.001);
+ glColor3f(0.0, 0.0, 0.0); glVertex3f(-1.0, 0.1, -1.001);
+ glColor3f(0.0, 1.0, 0.0); glVertex3f( 1.0, 0.1, -1.001);
+ glColor3f(0.0, 1.0, 0.0); glVertex3f( 1.0, -0.1, -1.001);
+ glEnd();
+#else
+ glEnable(GL_TEXTURE_2D);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, 0.0, -1.0);
+ glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0);
+ glTexCoord2f(1.0, 1.0); glVertex3f( 5.0, 1.0, -7.0);
+ glTexCoord2f(1.0, 0.0); glVertex3f( 5.0, 0.0, -7.0);
+
+ glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, -1.001);
+ glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 0.0, -1.001);
+ glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 0.0, -1.001);
+ glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, -1.001);
+ glEnd();
+#endif
+
+ glFlush();
+}
+
+
+static void
+reshape(int w, int h)
+{
+ glViewport(0, 0, w, h);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluPerspective(90.0, (GLfloat) w / h, 1.0, 300.0);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+}
+
+
+static void
+key(unsigned char k, int x, int y)
+{
+ switch (k) {
+ case 27: /* Escape */
+ exit(0);
+ break;
+ case 'i':
+ if (PerspHint == GL_FASTEST)
+ PerspHint = GL_NICEST;
+ else if (PerspHint == GL_NICEST)
+ PerspHint = GL_DONT_CARE;
+ else
+ PerspHint = GL_FASTEST;
+ glHint(GL_PERSPECTIVE_CORRECTION_HINT, PerspHint);
+ break;
+ default:
+ return;
+ }
+ glutPostRedisplay();
+}
+
+
+int
+main(int argc, char** argv)
+{
+ glutInit(&argc, argv);
+ glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
+ glutInitWindowSize (500, 500);
+ glutCreateWindow (argv[0]);
+ glutReshapeFunc (reshape);
+ glutDisplayFunc(display);
+ glutKeyboardFunc(key);
+
+ printf("Main quad: perspective projection\n");
+ printf("Middle stripe: linear interpolation\n");
+ printf("Press 'i' to toggle interpolation hint\n");
+ init();
+
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/tests/prim.c b/progs/tests/prim.c
new file mode 100644
index 0000000000..3e006e823d
--- /dev/null
+++ b/progs/tests/prim.c
@@ -0,0 +1,559 @@
+#define GL_GLEXT_PROTOTYPES
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define PIXEL_CENTER(x) ((long)(x) + 0.5)
+
+#define GAP 10
+#define ROWS 3
+#define COLS 4
+
+#define OPENGL_WIDTH 48
+#define OPENGL_HEIGHT 13
+
+
+GLenum provoking = GL_LAST_VERTEX_CONVENTION_EXT;
+GLenum rgb, doubleBuffer, windType;
+GLint windW, windH;
+
+GLenum mode1, mode2;
+GLint boxW, boxH;
+GLubyte OpenGL_bits[] = {
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x7f, 0xfb, 0xff, 0xff, 0xff, 0x01,
+ 0x7f, 0xfb, 0xff, 0xff, 0xff, 0x01,
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x3e, 0x8f, 0xb7, 0xf9, 0xfc, 0x01,
+ 0x63, 0xdb, 0xb0, 0x8d, 0x0d, 0x00,
+ 0x63, 0xdb, 0xb7, 0x8d, 0x0d, 0x00,
+ 0x63, 0xdb, 0xb6, 0x8d, 0x0d, 0x00,
+ 0x63, 0x8f, 0xf3, 0xcc, 0x0d, 0x00,
+ 0x63, 0x00, 0x00, 0x0c, 0x4c, 0x0a,
+ 0x63, 0x00, 0x00, 0x0c, 0x4c, 0x0e,
+ 0x63, 0x00, 0x00, 0x8c, 0xed, 0x0e,
+ 0x3e, 0x00, 0x00, 0xf8, 0x0c, 0x00,
+};
+
+
+#include "tkmap.c"
+
+static void Init(void)
+{
+
+ mode1 = GL_TRUE;
+ mode2 = GL_TRUE;
+}
+
+static void Reshape(int width, int height)
+{
+
+ windW = (GLint)width;
+ windH = (GLint)height;
+}
+
+static void RotateColorMask(void)
+{
+ static GLint rotation = 0;
+
+ rotation = (rotation + 1) & 0x3;
+ switch (rotation) {
+ case 0:
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ glIndexMask( 0xff );
+ break;
+ case 1:
+ glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE);
+ glIndexMask(0xFE);
+ break;
+ case 2:
+ glColorMask(GL_TRUE, GL_FALSE, GL_TRUE, GL_TRUE);
+ glIndexMask(0xFD);
+ break;
+ case 3:
+ glColorMask(GL_TRUE, GL_TRUE, GL_FALSE, GL_TRUE);
+ glIndexMask(0xFB);
+ break;
+ }
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ case '1':
+ mode1 = !mode1;
+ break;
+ case '2':
+ mode2 = !mode2;
+ break;
+ case '3':
+ RotateColorMask();
+ break;
+ case 'p':
+ if (provoking == GL_FIRST_VERTEX_CONVENTION_EXT) {
+ printf("provoke last\n");
+ provoking = GL_LAST_VERTEX_CONVENTION_EXT;
+ }
+ else {
+ printf("provoke first\n");
+ provoking = GL_FIRST_VERTEX_CONVENTION_EXT;
+ }
+ glProvokingVertexEXT(provoking);
+ break;
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Viewport(GLint row, GLint column)
+{
+ GLint x, y;
+
+ boxW = (windW - (COLS + 1) * GAP) / COLS;
+ boxH = (windH - (ROWS + 1) * GAP) / ROWS;
+
+ x = GAP + column * (boxW + GAP);
+ y = GAP + row * (boxH + GAP);
+
+ glViewport(x, y, boxW, boxH);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-boxW/2, boxW/2, -boxH/2, boxH/2, 0.0, 1.0);
+ glMatrixMode(GL_MODELVIEW);
+
+ glEnable(GL_SCISSOR_TEST);
+ glScissor(x, y, boxW, boxH);
+}
+
+static void Point(void)
+{
+ GLint i;
+
+ glBegin(GL_POINTS);
+ SetColor(COLOR_WHITE);
+ glVertex2i(0, 0);
+ for (i = 1; i < 8; i++) {
+ GLint j = i * 2;
+ SetColor(COLOR_BLACK+i);
+ glVertex2i(-j, -j);
+ glVertex2i(-j, 0);
+ glVertex2i(-j, j);
+ glVertex2i(0, j);
+ glVertex2i(j, j);
+ glVertex2i(j, 0);
+ glVertex2i(j, -j);
+ glVertex2i(0, -j);
+ }
+ glEnd();
+}
+
+static void Lines(void)
+{
+ GLint i;
+
+ glPushMatrix();
+
+ glTranslatef(-12, 0, 0);
+ for (i = 1; i < 8; i++) {
+ glBegin(GL_LINES);
+ SetColor(COLOR_BLACK+i);
+ glVertex2i(-boxW/4, -boxH/4);
+ SetColor(COLOR_BLACK+i+1);
+ glVertex2i(boxW/4, boxH/4);
+ glEnd();
+ glTranslatef(4, 0, 0);
+ }
+
+ glPopMatrix();
+
+ glBegin(GL_LINES);
+ glVertex2i(0, 0);
+ glEnd();
+}
+
+static void LineStrip(void)
+{
+
+ glBegin(GL_LINE_STRIP);
+ SetColor(COLOR_RED);
+ glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(-boxH/4));
+ SetColor(COLOR_GREEN);
+ glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(boxH/4));
+ SetColor(COLOR_BLUE);
+ glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(boxH/4));
+ SetColor(COLOR_WHITE);
+ glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(-boxH/4));
+ glEnd();
+
+ glBegin(GL_LINE_STRIP);
+ glVertex2i(0, 0);
+ glEnd();
+}
+
+static void LineLoop(void)
+{
+
+ glBegin(GL_LINE_LOOP);
+ SetColor(COLOR_RED);
+ glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(-boxH/4));
+ SetColor(COLOR_GREEN);
+ glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(boxH/4));
+ SetColor(COLOR_BLUE);
+ glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(boxH/4));
+ SetColor(COLOR_WHITE);
+ glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(-boxH/4));
+ glEnd();
+
+ glEnable(GL_LOGIC_OP);
+ glLogicOp(GL_XOR);
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_ONE, GL_ONE);
+
+ SetColor(COLOR_MAGENTA);
+ glBegin(GL_LINE_LOOP);
+ glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(-boxH/8));
+ glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(boxH/8));
+ glEnd();
+ glBegin(GL_LINE_LOOP);
+ glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(boxH/8+5));
+ glVertex2f(PIXEL_CENTER(boxW/8), PIXEL_CENTER(boxH/8+5));
+ glEnd();
+ glDisable(GL_LOGIC_OP);
+ glDisable(GL_BLEND);
+
+ SetColor(COLOR_GREEN);
+ glBegin(GL_POINTS);
+ glVertex2i(0, 0);
+ glEnd();
+
+ glBegin(GL_LINE_LOOP);
+ glVertex2i(0, 0);
+ glEnd();
+}
+
+static void Bitmap(void)
+{
+
+ glBegin(GL_LINES);
+ SetColor(COLOR_GREEN);
+ glVertex2i(-boxW/2, 0);
+ glVertex2i(boxW/2, 0);
+ glVertex2i(0, -boxH/2);
+ glVertex2i(0, boxH/2);
+ SetColor(COLOR_RED);
+ glVertex2i(0, -3);
+ glVertex2i(0, -3+OPENGL_HEIGHT);
+ SetColor(COLOR_BLUE);
+ glVertex2i(0, -3);
+ glVertex2i(OPENGL_WIDTH, -3);
+ glEnd();
+
+ SetColor(COLOR_GREEN);
+
+ glPixelStorei(GL_UNPACK_LSB_FIRST, GL_TRUE);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ glRasterPos2i(0, 0);
+ glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, 0, 3, 0.0, 0.0, OpenGL_bits);
+}
+
+static void Triangles(void)
+{
+
+ glBegin(GL_TRIANGLES);
+ SetColor(COLOR_GREEN);
+ glVertex2i(-boxW/4, -boxH/4);
+ SetColor(COLOR_RED);
+ glVertex2i(-boxW/8, -boxH/16);
+ SetColor(COLOR_BLUE);
+ glVertex2i(boxW/8, -boxH/16);
+
+ SetColor(COLOR_GREEN);
+ glVertex2i(-boxW/4, boxH/4);
+ SetColor(COLOR_RED);
+ glVertex2i(-boxW/8, boxH/16);
+ SetColor(COLOR_BLUE);
+ glVertex2i(boxW/8, boxH/16);
+ glEnd();
+
+ glBegin(GL_TRIANGLES);
+ glVertex2i(0, 0);
+ glVertex2i(-100, 100);
+ glEnd();
+}
+
+static void TriangleStrip(void)
+{
+
+ glBegin(GL_TRIANGLE_STRIP);
+ SetColor(COLOR_GREEN);
+ glVertex2i(-boxW/4, -boxH/4);
+ SetColor(COLOR_RED);
+ glVertex2i(-boxW/4, boxH/4);
+ SetColor(COLOR_BLUE);
+ glVertex2i(0, -boxH/4);
+ SetColor(COLOR_WHITE);
+ glVertex2i(0, boxH/4);
+ SetColor(COLOR_CYAN);
+ glVertex2i(boxW/4, -boxH/4);
+ SetColor(COLOR_YELLOW);
+ glVertex2i(boxW/4, boxH/4);
+ glEnd();
+
+ glBegin(GL_TRIANGLE_STRIP);
+ glVertex2i(0, 0);
+ glVertex2i(-100, 100);
+ glEnd();
+}
+
+static void TriangleFan(void)
+{
+ GLint vx[8][2];
+ GLint x0, y0, x1, y1, x2, y2, x3, y3;
+ GLint i;
+
+ y0 = -boxH/4;
+ y1 = y0 + boxH/2/3;
+ y2 = y1 + boxH/2/3;
+ y3 = boxH/4;
+ x0 = -boxW/4;
+ x1 = x0 + boxW/2/3;
+ x2 = x1 + boxW/2/3;
+ x3 = boxW/4;
+
+ vx[0][0] = x0; vx[0][1] = y1;
+ vx[1][0] = x0; vx[1][1] = y2;
+ vx[2][0] = x1; vx[2][1] = y3;
+ vx[3][0] = x2; vx[3][1] = y3;
+ vx[4][0] = x3; vx[4][1] = y2;
+ vx[5][0] = x3; vx[5][1] = y1;
+ vx[6][0] = x2; vx[6][1] = y0;
+ vx[7][0] = x1; vx[7][1] = y0;
+
+ glBegin(GL_TRIANGLE_FAN);
+ SetColor(COLOR_WHITE);
+ glVertex2i(0, 0);
+ for (i = 0; i < 8; i++) {
+ SetColor(COLOR_WHITE-i);
+ glVertex2iv(vx[i]);
+ }
+ glEnd();
+
+ glBegin(GL_TRIANGLE_FAN);
+ glVertex2i(0, 0);
+ glVertex2i(-100, 100);
+ glEnd();
+}
+
+static void Rect(void)
+{
+
+ SetColor(COLOR_GREEN);
+ glRecti(-boxW/4, -boxH/4, boxW/4, boxH/4);
+}
+
+static void PolygonFunc(void)
+{
+ GLint vx[8][2];
+ GLint x0, y0, x1, y1, x2, y2, x3, y3;
+ GLint i;
+
+ y0 = -boxH/4;
+ y1 = y0 + boxH/2/3;
+ y2 = y1 + boxH/2/3;
+ y3 = boxH/4;
+ x0 = -boxW/4;
+ x1 = x0 + boxW/2/3;
+ x2 = x1 + boxW/2/3;
+ x3 = boxW/4;
+
+ vx[0][0] = x0; vx[0][1] = y1;
+ vx[1][0] = x0; vx[1][1] = y2;
+ vx[2][0] = x1; vx[2][1] = y3;
+ vx[3][0] = x2; vx[3][1] = y3;
+ vx[4][0] = x3; vx[4][1] = y2;
+ vx[5][0] = x3; vx[5][1] = y1;
+ vx[6][0] = x2; vx[6][1] = y0;
+ vx[7][0] = x1; vx[7][1] = y0;
+
+ glBegin(GL_POLYGON);
+ for (i = 0; i < 8; i++) {
+ SetColor(COLOR_WHITE-i);
+ glVertex2iv(vx[i]);
+ }
+ glEnd();
+
+ glBegin(GL_POLYGON);
+ glVertex2i(0, 0);
+ glVertex2i(100, 100);
+ glEnd();
+}
+
+static void Quads(void)
+{
+
+ glBegin(GL_QUADS);
+ SetColor(COLOR_GREEN);
+ glVertex2i(-boxW/4, -boxH/4);
+ SetColor(COLOR_RED);
+ glVertex2i(-boxW/8, -boxH/16);
+ SetColor(COLOR_BLUE);
+ glVertex2i(boxW/8, -boxH/16);
+ SetColor(COLOR_WHITE);
+ glVertex2i(boxW/4, -boxH/4);
+
+ SetColor(COLOR_GREEN);
+ glVertex2i(-boxW/4, boxH/4);
+ SetColor(COLOR_RED);
+ glVertex2i(-boxW/8, boxH/16);
+ SetColor(COLOR_BLUE);
+ glVertex2i(boxW/8, boxH/16);
+ SetColor(COLOR_WHITE);
+ glVertex2i(boxW/4, boxH/4);
+ glEnd();
+
+ glBegin(GL_QUADS);
+ glVertex2i(0, 0);
+ glVertex2i(100, 100);
+ glVertex2i(-100, 100);
+ glEnd();
+}
+
+static void QuadStrip(void)
+{
+
+ glBegin(GL_QUAD_STRIP);
+ SetColor(COLOR_GREEN);
+ glVertex2i(-boxW/4, -boxH/4);
+ SetColor(COLOR_RED);
+ glVertex2i(-boxW/4, boxH/4);
+ SetColor(COLOR_BLUE);
+ glVertex2i(0, -boxH/4);
+ SetColor(COLOR_WHITE);
+ glVertex2i(0, boxH/4);
+ SetColor(COLOR_CYAN);
+ glVertex2i(boxW/4, -boxH/4);
+ SetColor(COLOR_YELLOW);
+ glVertex2i(boxW/4, boxH/4);
+ glEnd();
+
+ glBegin(GL_QUAD_STRIP);
+ glVertex2i(0, 0);
+ glVertex2i(100, 100);
+ glVertex2i(-100, 100);
+ glEnd();
+}
+
+static void Draw(void)
+{
+
+ glViewport(0, 0, windW, windH);
+ glDisable(GL_SCISSOR_TEST);
+
+ glPushAttrib(GL_COLOR_BUFFER_BIT);
+
+ glColorMask(1, 1, 1, 1);
+ glIndexMask(~0);
+
+ glClearColor(0.0, 0.0, 0.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glPopAttrib();
+
+ if (mode1) {
+ glShadeModel(GL_SMOOTH);
+ } else {
+ glShadeModel(GL_FLAT);
+ }
+
+ if (mode2) {
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ } else {
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ }
+
+ 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();
+ Viewport(2, 1); PolygonFunc();
+ Viewport(2, 2); Quads();
+ Viewport(2, 3); QuadStrip();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ rgb = GL_TRUE;
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-ci") == 0) {
+ rgb = GL_FALSE;
+ } else if (strcmp(argv[i], "-rgb") == 0) {
+ rgb = GL_TRUE;
+ } else if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ printf("%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ windW = 600;
+ windH = 300;
+ glutInitWindowPosition(0, 0); glutInitWindowSize( windW, windH);
+
+ windType = (rgb) ? GLUT_RGB : GLUT_INDEX;
+ windType |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
+ glutInitDisplayMode(windType);
+
+ if (glutCreateWindow("Primitive Test") == GL_FALSE) {
+ exit(1);
+ }
+
+ InitMap();
+
+ Init();
+
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/tests/tkmap.c b/progs/tests/tkmap.c
new file mode 100644
index 0000000000..3ded79caca
--- /dev/null
+++ b/progs/tests/tkmap.c
@@ -0,0 +1,71 @@
+
+enum {
+ COLOR_BLACK = 0,
+ COLOR_RED,
+ COLOR_GREEN,
+ COLOR_YELLOW,
+ COLOR_BLUE,
+ COLOR_MAGENTA,
+ COLOR_CYAN,
+ COLOR_WHITE
+};
+
+static float RGBMap[9][3] = {
+ {0, 0, 0},
+ {1, 0, 0},
+ {0, 1, 0},
+ {1, 1, 0},
+ {0, 0, 1},
+ {1, 0, 1},
+ {0, 1, 1},
+ {1, 1, 1},
+ {0.5, 0.5, 0.5}
+};
+
+static void SetColor(int c)
+{
+ if (glutGet(GLUT_WINDOW_RGBA))
+ glColor3fv(RGBMap[c]);
+ else
+ glIndexf(c);
+}
+
+static void InitMap(void)
+{
+ int i;
+
+ if (rgb)
+ return;
+
+ for (i = 0; i < 9; i++)
+ glutSetColor(i, RGBMap[i][0], RGBMap[i][1], RGBMap[i][2]);
+}
+
+static void SetFogRamp(int density, int startIndex)
+{
+ int fogValues, colorValues;
+ int i, j, k;
+ float intensity;
+
+ fogValues = 1 << density;
+ colorValues = 1 << startIndex;
+ for (i = 0; i < colorValues; i++) {
+ for (j = 0; j < fogValues; j++) {
+ k = i * fogValues + j;
+ intensity = (i * fogValues + j * colorValues) / 255.0;
+ glutSetColor(k, intensity, intensity, intensity);
+ }
+ }
+}
+
+static void SetGreyRamp(void)
+{
+ int i;
+ float intensity;
+
+ for (i = 0; i < 255; i++) {
+ intensity = i / 255.0;
+ glutSetColor(i, intensity, intensity, intensity);
+ }
+}
+
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 0469e2f2c4..2bb57030a8 100644
--- a/progs/util/extfuncs.h
+++ b/progs/util/extfuncs.h
@@ -137,7 +137,6 @@ static PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample_
static PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer_func = NULL;
-
static void
GetExtensionFuncs(void)
{