[Piglit] [PATCH 3/5] GL_ARB_texture_buffer_object/formats: Add real support for testing GL core.
Eric Anholt
eric at anholt.net
Thu Nov 1 11:36:55 PDT 2012
Thanks to waffle we can finally do this.
---
tests/spec/arb_texture_buffer_object/formats.c | 95 +++++++++++++++++-------
1 file changed, 68 insertions(+), 27 deletions(-)
diff --git a/tests/spec/arb_texture_buffer_object/formats.c b/tests/spec/arb_texture_buffer_object/formats.c
index 610c2fa..d1ff57d 100644
--- a/tests/spec/arb_texture_buffer_object/formats.c
+++ b/tests/spec/arb_texture_buffer_object/formats.c
@@ -28,16 +28,6 @@
#define _GNU_SOURCE
#include "piglit-util-gl-common.h"
-PIGLIT_GL_TEST_CONFIG_BEGIN
-
- config.supports_gl_compat_version = 10;
-
- config.window_width = 200;
- config.window_height = 500;
- config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_ALPHA;
-
-PIGLIT_GL_TEST_CONFIG_END
-
enum channels {
A,
L,
@@ -146,12 +136,12 @@ struct program {
GLuint prog;
int pos_location;
int expected_location;
- int vertex_location;
};
struct program prog_f;
struct program prog_i;
struct program prog_u;
+static int vertex_location;
static int y_index;
@@ -497,10 +487,8 @@ test_format(int format_index)
glUniform1i(prog->pos_location, i);
- glVertexAttribPointer(prog->vertex_location, 2, GL_FLOAT,
- GL_FALSE, 0, &verts);
- glEnableVertexAttribArray(prog->vertex_location);
-
+ glBufferData(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts,
+ GL_STREAM_DRAW);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
if (pass &&
@@ -536,16 +524,33 @@ piglit_display(void)
{
enum piglit_result result = PIGLIT_SKIP;
int i;
+ GLuint vao, vbo;
glClearColor(0.5, 0.5, 0.5, 0.5);
glClear(GL_COLOR_BUFFER_BIT);
y_index = 0;
+ /* For GL core, we need to have a vertex array object bound.
+ * Otherwise, we don't particularly have to. Always use a
+ * vertex buffer object, though.
+ */
+ glGenBuffers(1, &vbo);
+ glBindBuffer(GL_ARRAY_BUFFER_ARB, vbo);
+ if (piglit_get_gl_version() >= 31) {
+ glGenVertexArrays(1, &vao);
+ glBindVertexArray(vao);
+ }
+ glVertexAttribPointer(vertex_location, 2, GL_FLOAT, GL_FALSE, 0, 0);
+ glEnableVertexAttribArray(vertex_location);
+
for (i = 0; i < ARRAY_SIZE(formats); i++) {
piglit_merge_result(&result, test_format(i));
}
+ glDeleteBuffers(1, &vbo);
+ glDeleteVertexArrays(1, &vao);
+
piglit_present_results();
return result;
@@ -647,7 +652,8 @@ create_program(struct program *program, const char *type)
program->pos_location = piglit_GetUniformLocation(prog, "pos");
program->expected_location = piglit_GetUniformLocation(prog,
"expected");
- program->vertex_location = glGetAttribLocation(prog, "vertex");
+ vertex_location = glGetAttribLocation(prog, "vertex");
+ assert(vertex_location == 0);
}
static void
@@ -670,17 +676,6 @@ piglit_init(int argc, char **argv)
{
piglit_require_GLSL_version(140);
- if (argc != 3)
- usage(argv[0]);
-
- test_vs = strcmp(argv[1], "vs") == 0;
- if (!test_vs && strcmp(argv[1], "fs") != 0)
- usage(argv[0]);
-
- test_arb = strcmp(argv[2], "arb") == 0;
- if (!test_arb && strcmp(argv[2], "core") != 0)
- usage(argv[0]);
-
piglit_require_extension("GL_EXT_texture_integer");
piglit_require_extension("GL_ARB_texture_rg");
@@ -693,3 +688,49 @@ piglit_init(int argc, char **argv)
init_programs();
}
+
+static bool
+find_arg(int argc, char *argv[], const char *str)
+{
+ int i;
+
+ for (i = 0; i < argc; i++) {
+ if (strcmp(argv[i], str) == 0)
+ return true;
+ }
+
+ return false;
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct piglit_gl_test_config config;
+
+ test_vs = find_arg(argc, argv, "vs");
+ if (!test_vs && !find_arg(argc, argv, "fs"))
+ usage(argv[0]);
+
+ test_arb = find_arg(argc, argv, "arb");
+ if (!test_arb && !find_arg(argc, argv, "core"))
+ usage(argv[0]);
+
+ piglit_gl_test_config_init(&config);
+
+ config.init = piglit_init;
+ config.display = piglit_display;
+
+ if (test_arb)
+ config.supports_gl_compat_version = 10;
+ else
+ config.supports_gl_core_version = 31;
+
+ config.window_width = 200;
+ config.window_height = 500;
+ config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_ALPHA;
+
+ piglit_gl_test_run(argc, argv, &config);
+
+ assert(false);
+ return 0;
+}
--
1.7.10.4
More information about the Piglit
mailing list