summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <maraeo@gmail.com>2011-03-13 13:30:51 +0100
committerMarek Olšák <maraeo@gmail.com>2011-03-13 13:31:59 +0100
commit15cc46f84c183863f780aebcb23f103093643ff9 (patch)
tree7c4b169d0c411efc41adec8bc373c95874e64735
parent4e94936170b831a6071a7c5398b405588f8a81ff (diff)
Consolidate the code of the fbo-*-formats tests
-rw-r--r--tests/fbo/fbo-alphatest-formats.c119
-rw-r--r--tests/fbo/fbo-blending-formats.c119
-rw-r--r--tests/fbo/fbo-clear-formats.c125
-rw-r--r--tests/fbo/fbo-formats.h130
-rw-r--r--tests/fbo/fbo-generatemipmap-formats.c73
5 files changed, 142 insertions, 424 deletions
diff --git a/tests/fbo/fbo-alphatest-formats.c b/tests/fbo/fbo-alphatest-formats.c
index f8b1873df..f6bbb455d 100644
--- a/tests/fbo/fbo-alphatest-formats.c
+++ b/tests/fbo/fbo-alphatest-formats.c
@@ -34,9 +34,6 @@ int piglit_width = 128;
int piglit_height = 64;
int piglit_window_mode = GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE;
-static const struct test_desc *test_set;
-static int test_index;
-static int format_index;
static void alphatest(const float *rect, float alpha, GLenum func, float ref)
{
@@ -264,124 +261,12 @@ static enum piglit_result test_format(const struct format_desc *format, GLenum b
return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
-static void add_result(bool *all_skip, enum piglit_result *end_result,
- enum piglit_result new)
-{
- if (new != PIGLIT_SKIP)
- *all_skip = false;
-
- if (new == PIGLIT_FAILURE)
- *end_result = new;
-}
-
enum piglit_result piglit_display(void)
{
- enum piglit_result result, end_result = PIGLIT_SUCCESS;
- bool all_skip = true;
- int i;
-
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glClearColor(0.5, 0.5, 0.5, 0.5);
- glClear(GL_COLOR_BUFFER_BIT);
-
- if (piglit_automatic) {
- for (i = 0; i < test_set->num_formats; i++) {
- result = test_format(&test_set->format[i],
- test_set->base);
- add_result(&all_skip, &end_result, result);
- }
- } else {
- result = test_format(&test_sets[test_index].format[format_index],
- test_sets[test_index].base);
- add_result(&all_skip, &end_result, result);
- }
-
- glutSwapBuffers();
-
- if (all_skip)
- return PIGLIT_SKIP;
- return end_result;
-}
-
-static void key_func(unsigned char key, int x, int y)
-{
- switch (key) {
- case 'n': /* next test set */
- do {
- test_index++;
- if (test_index >= ARRAY_SIZE(test_sets)) {
- test_index = 0;
- }
- } while (!supported(&test_sets[test_index]));
- format_index = 0;
- printf("Using test set: %s\n", test_sets[test_index].param);
- break;
-
- case 'N': /* previous test set */
- do {
- test_index--;
- if (test_index < 0) {
- test_index = ARRAY_SIZE(test_sets) - 1;
- }
- } while (!supported(&test_sets[test_index]));
- format_index = 0;
- printf("Using test set: %s\n", test_sets[test_index].param);
- break;
-
- case 'm': /* next format */
- format_index++;
- if (format_index >= test_sets[test_index].num_formats) {
- format_index = 0;
- }
- break;
-
- case 'M': /* previous format */
- format_index--;
- if (format_index < 0) {
- format_index = test_sets[test_index].num_formats - 1;
- }
- break;
- }
-
- piglit_escape_exit_key(key, x, y);
+ return fbo_formats_display(test_format);
}
void piglit_init(int argc, char **argv)
{
- int i, j, k;
-
- glutKeyboardFunc(key_func);
-
- piglit_require_extension("GL_EXT_framebuffer_object");
- piglit_require_extension("GL_ARB_texture_env_combine");
-
- test_set = &test_sets[0];
-
- for (i = 1; i < argc; i++) {
- for (j = 1; j < ARRAY_SIZE(test_sets); j++) {
- if (!strcmp(argv[i], test_sets[j].param)) {
- for (k = 0; k < 3; k++) {
- if (test_sets[j].ext[k]) {
- piglit_require_extension(test_sets[j].ext[k]);
- }
- }
-
- test_set = &test_sets[j];
- break;
- }
- }
- if (j == ARRAY_SIZE(test_sets)) {
- fprintf(stderr, "Unknown argument: %s\n", argv[i]);
- exit(1);
- }
- }
-
- if (!piglit_automatic) {
- printf(" -n Next test set.\n"
- " -N Previous test set.\n"
- " -m Next format in the set.\n"
- " -M Previous format in the set.\n");
- }
-
- printf("Using test set: %s\n", test_set->param);
+ fbo_formats_init(argc, argv, GL_TRUE);
}
diff --git a/tests/fbo/fbo-blending-formats.c b/tests/fbo/fbo-blending-formats.c
index d11be3442..d45889168 100644
--- a/tests/fbo/fbo-blending-formats.c
+++ b/tests/fbo/fbo-blending-formats.c
@@ -34,9 +34,6 @@ int piglit_width = 128;
int piglit_height = 64;
int piglit_window_mode = GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE;
-static const struct test_desc *test_set;
-static int test_index;
-static int format_index;
static void blend(const float *rect, const float *src, const float *dst, const float *blendcol,
GLenum blendsrc, GLenum blenddst)
@@ -311,124 +308,12 @@ static enum piglit_result test_format(const struct format_desc *format, GLenum b
return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
-static void add_result(bool *all_skip, enum piglit_result *end_result,
- enum piglit_result new)
-{
- if (new != PIGLIT_SKIP)
- *all_skip = false;
-
- if (new == PIGLIT_FAILURE)
- *end_result = new;
-}
-
enum piglit_result piglit_display(void)
{
- enum piglit_result result, end_result = PIGLIT_SUCCESS;
- bool all_skip = true;
- int i;
-
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glClearColor(0.5, 0.5, 0.5, 0.5);
- glClear(GL_COLOR_BUFFER_BIT);
-
- if (piglit_automatic) {
- for (i = 0; i < test_set->num_formats; i++) {
- result = test_format(&test_set->format[i],
- test_set->base);
- add_result(&all_skip, &end_result, result);
- }
- } else {
- result = test_format(&test_sets[test_index].format[format_index],
- test_sets[test_index].base);
- add_result(&all_skip, &end_result, result);
- }
-
- glutSwapBuffers();
-
- if (all_skip)
- return PIGLIT_SKIP;
- return end_result;
-}
-
-static void key_func(unsigned char key, int x, int y)
-{
- switch (key) {
- case 'n': /* next test set */
- do {
- test_index++;
- if (test_index >= ARRAY_SIZE(test_sets)) {
- test_index = 0;
- }
- } while (!supported(&test_sets[test_index]));
- format_index = 0;
- printf("Using test set: %s\n", test_sets[test_index].param);
- break;
-
- case 'N': /* previous test set */
- do {
- test_index--;
- if (test_index < 0) {
- test_index = ARRAY_SIZE(test_sets) - 1;
- }
- } while (!supported(&test_sets[test_index]));
- format_index = 0;
- printf("Using test set: %s\n", test_sets[test_index].param);
- break;
-
- case 'm': /* next format */
- format_index++;
- if (format_index >= test_sets[test_index].num_formats) {
- format_index = 0;
- }
- break;
-
- case 'M': /* previous format */
- format_index--;
- if (format_index < 0) {
- format_index = test_sets[test_index].num_formats - 1;
- }
- break;
- }
-
- piglit_escape_exit_key(key, x, y);
+ return fbo_formats_display(test_format);
}
void piglit_init(int argc, char **argv)
{
- int i, j, k;
-
- glutKeyboardFunc(key_func);
-
- piglit_require_extension("GL_EXT_framebuffer_object");
- piglit_require_extension("GL_ARB_texture_env_combine");
-
- test_set = &test_sets[0];
-
- for (i = 1; i < argc; i++) {
- for (j = 1; j < ARRAY_SIZE(test_sets); j++) {
- if (!strcmp(argv[i], test_sets[j].param)) {
- for (k = 0; k < 3; k++) {
- if (test_sets[j].ext[k]) {
- piglit_require_extension(test_sets[j].ext[k]);
- }
- }
-
- test_set = &test_sets[j];
- break;
- }
- }
- if (j == ARRAY_SIZE(test_sets)) {
- fprintf(stderr, "Unknown argument: %s\n", argv[i]);
- exit(1);
- }
- }
-
- if (!piglit_automatic) {
- printf(" -n Next test set.\n"
- " -N Previous test set.\n"
- " -m Next format in the set.\n"
- " -M Previous format in the set.\n");
- }
-
- printf("Using test set: %s\n", test_set->param);
+ fbo_formats_init(argc, argv, GL_TRUE);
}
diff --git a/tests/fbo/fbo-clear-formats.c b/tests/fbo/fbo-clear-formats.c
index 83408f5e8..1a3a0dbf4 100644
--- a/tests/fbo/fbo-clear-formats.c
+++ b/tests/fbo/fbo-clear-formats.c
@@ -40,54 +40,6 @@ int piglit_width = 700;
int piglit_height = 300;
int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA;
-static const struct test_desc *test_set;
-static int test_index;
-static int format_index;
-
-static void
-key_func(unsigned char key, int x, int y)
-{
- switch (key) {
- case 'n': /* next test set */
- do {
- test_index++;
- if (test_index >= ARRAY_SIZE(test_sets)) {
- test_index = 0;
- }
- } while (!supported(&test_sets[test_index]));
- format_index = 0;
- printf("Using test set: %s\n", test_sets[test_index].param);
- break;
-
- case 'N': /* previous test set */
- do {
- test_index--;
- if (test_index < 0) {
- test_index = ARRAY_SIZE(test_sets) - 1;
- }
- } while (!supported(&test_sets[test_index]));
- format_index = 0;
- printf("Using test set: %s\n", test_sets[test_index].param);
- break;
-
- case 'm': /* next format */
- format_index++;
- if (format_index >= test_sets[test_index].num_formats) {
- format_index = 0;
- }
- break;
-
- case 'M': /* previous format */
- format_index--;
- if (format_index < 0) {
- format_index = test_sets[test_index].num_formats - 1;
- }
- break;
- }
-
- piglit_escape_exit_key(key, x, y);
-}
-
/* Do piglit_rgbw_texture() image but using glClear */
static bool
do_rgba_clear(GLenum format, GLuint tex, int level, int size)
@@ -427,83 +379,12 @@ test_format(const struct format_desc *format, GLenum baseformat)
return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
-static void
-add_result(bool *all_skip, enum piglit_result *end_result,
- enum piglit_result new)
+enum piglit_result piglit_display(void)
{
- if (new != PIGLIT_SKIP)
- *all_skip = false;
-
- if (new == PIGLIT_FAILURE)
- *end_result = new;
+ return fbo_formats_display(test_format);
}
-enum piglit_result
-piglit_display(void)
-{
- enum piglit_result result, end_result = PIGLIT_SUCCESS;
- bool all_skip = true;
- int i;
-
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glClearColor(0.5, 0.5, 0.5, 0.5);
- glClear(GL_COLOR_BUFFER_BIT);
-
- if (piglit_automatic) {
- for (i = 0; i < test_set->num_formats; i++) {
- result = test_format(&test_set->format[i],
- test_set->base);
- add_result(&all_skip, &end_result, result);
- }
- } else {
- result = test_format(&test_sets[test_index].format[format_index],
- test_sets[test_index].base);
- add_result(&all_skip, &end_result, result);
- }
-
- glutSwapBuffers();
-
- if (all_skip)
- return PIGLIT_SKIP;
- return end_result;
-}
-
-
void piglit_init(int argc, char **argv)
{
- int i, j, k;
-
- glutKeyboardFunc(key_func);
-
- piglit_require_extension("GL_EXT_framebuffer_object");
-
- test_set = &test_sets[0];
-
- for (i = 1; i < argc; i++) {
- for (j = 1; j < ARRAY_SIZE(test_sets); j++) {
- if (!strcmp(argv[i], test_sets[j].param)) {
- for (k = 0; k < 3; k++) {
- if (test_sets[j].ext[k]) {
- piglit_require_extension(test_sets[j].ext[k]);
- }
- }
-
- test_set = &test_sets[j];
- break;
- }
- }
- if (j == ARRAY_SIZE(test_sets)) {
- fprintf(stderr, "Unknown argument: %s\n", argv[i]);
- exit(1);
- }
- }
-
- if (!piglit_automatic) {
- printf(" -n Next test set.\n"
- " -N Previous test set.\n"
- " -m Next format in the set.\n"
- " -M Previous format in the set.\n");
- }
-
- printf("Using test set: %s\n", test_set->param);
+ fbo_formats_init(argc, argv, GL_TRUE);
}
diff --git a/tests/fbo/fbo-formats.h b/tests/fbo/fbo-formats.h
index 249e3a3f2..18109ca3d 100644
--- a/tests/fbo/fbo-formats.h
+++ b/tests/fbo/fbo-formats.h
@@ -476,3 +476,133 @@ supported(const struct test_desc *test)
return GL_TRUE;
}
+
+static const struct test_desc *test_set;
+static int test_index;
+static int format_index;
+
+static void fbo_formats_key_func(unsigned char key, int x, int y)
+{
+ switch (key) {
+ case 'n': /* next test set */
+ do {
+ test_index++;
+ if (test_index >= ARRAY_SIZE(test_sets)) {
+ test_index = 0;
+ }
+ } while (!supported(&test_sets[test_index]));
+ format_index = 0;
+ printf("Using test set: %s\n", test_sets[test_index].param);
+ break;
+
+ case 'N': /* previous test set */
+ do {
+ test_index--;
+ if (test_index < 0) {
+ test_index = ARRAY_SIZE(test_sets) - 1;
+ }
+ } while (!supported(&test_sets[test_index]));
+ format_index = 0;
+ printf("Using test set: %s\n", test_sets[test_index].param);
+ break;
+
+ case 'm': /* next format */
+ format_index++;
+ if (format_index >= test_sets[test_index].num_formats) {
+ format_index = 0;
+ }
+ break;
+
+ case 'M': /* previous format */
+ format_index--;
+ if (format_index < 0) {
+ format_index = test_sets[test_index].num_formats - 1;
+ }
+ break;
+
+ default:
+ piglit_escape_exit_key(key, x, y);
+ }
+}
+
+static void fbo_formats_init(int argc, char **argv, GLboolean print_options)
+{
+ int i, j, k;
+
+ glutKeyboardFunc(fbo_formats_key_func);
+
+ piglit_require_extension("GL_EXT_framebuffer_object");
+ piglit_require_extension("GL_ARB_texture_env_combine");
+
+ test_set = &test_sets[0];
+
+ for (i = 1; i < argc; i++) {
+ for (j = 1; j < ARRAY_SIZE(test_sets); j++) {
+ if (!strcmp(argv[i], test_sets[j].param)) {
+ for (k = 0; k < 3; k++) {
+ if (test_sets[j].ext[k]) {
+ piglit_require_extension(test_sets[j].ext[k]);
+ }
+ }
+
+ test_set = &test_sets[j];
+ test_index = j;
+ break;
+ }
+ }
+ if (j == ARRAY_SIZE(test_sets)) {
+ fprintf(stderr, "Unknown argument: %s\n", argv[i]);
+ exit(1);
+ }
+ }
+
+ if (!piglit_automatic && print_options) {
+ printf(" -n Next test set.\n"
+ " -N Previous test set.\n"
+ " -m Next format in the set.\n"
+ " -M Previous format in the set.\n");
+ }
+
+ printf("Using test set: %s\n", test_set->param);
+}
+
+static void add_result(bool *all_skip, enum piglit_result *end_result,
+ enum piglit_result new)
+{
+ if (new != PIGLIT_SKIP)
+ *all_skip = false;
+
+ if (new == PIGLIT_FAILURE)
+ *end_result = new;
+}
+
+typedef enum piglit_result (*test_func)(const struct format_desc *format, GLenum baseformat);
+
+static enum piglit_result fbo_formats_display(test_func test_format)
+{
+ enum piglit_result result, end_result = PIGLIT_SUCCESS;
+ bool all_skip = true;
+ int i;
+
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ glClearColor(0.5, 0.5, 0.5, 0.5);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ if (piglit_automatic) {
+ for (i = 0; i < test_set->num_formats; i++) {
+ result = test_format(&test_set->format[i],
+ test_set->base);
+ add_result(&all_skip, &end_result, result);
+ }
+ } else {
+ result = test_format(&test_sets[test_index].format[format_index],
+ test_sets[test_index].base);
+ add_result(&all_skip, &end_result, result);
+ }
+
+ glutSwapBuffers();
+
+ if (all_skip)
+ return PIGLIT_SKIP;
+ return end_result;
+}
diff --git a/tests/fbo/fbo-generatemipmap-formats.c b/tests/fbo/fbo-generatemipmap-formats.c
index 3619a1ee9..a3c098240 100644
--- a/tests/fbo/fbo-generatemipmap-formats.c
+++ b/tests/fbo/fbo-generatemipmap-formats.c
@@ -40,9 +40,6 @@ int piglit_width = 700;
int piglit_height = 300;
int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA;
-static const struct test_desc *test_set;
-static int test_index;
-static int format_index;
static void set_npot(GLboolean npot)
{
@@ -59,47 +56,13 @@ static void
key_func(unsigned char key, int x, int y)
{
switch (key) {
- case 'n': /* next test set */
- do {
- test_index++;
- if (test_index >= ARRAY_SIZE(test_sets)) {
- test_index = 0;
- }
- } while (!supported(&test_sets[test_index]));
- format_index = 0;
- printf("Using test set: %s\n", test_sets[test_index].param);
- break;
-
- case 'N': /* previous test set */
- do {
- test_index--;
- if (test_index < 0) {
- test_index = ARRAY_SIZE(test_sets) - 1;
- }
- } while (!supported(&test_sets[test_index]));
- format_index = 0;
- printf("Using test set: %s\n", test_sets[test_index].param);
- break;
-
- case 'm': /* next format */
- format_index++;
- if (format_index >= test_sets[test_index].num_formats) {
- format_index = 0;
- }
- break;
-
- case 'M': /* previous format */
- format_index--;
- if (format_index < 0) {
- format_index = test_sets[test_index].num_formats - 1;
- }
- break;
case 'd':
set_npot(tex_width == 256 && GLEW_ARB_texture_non_power_of_two);
break;
- }
- piglit_escape_exit_key(key, x, y);
+ default:
+ fbo_formats_key_func(key, x, y);
+ }
}
static int
@@ -466,6 +429,7 @@ piglit_display(void)
{
GLboolean pass = GL_TRUE;
int i;
+ (void)fbo_formats_display;
glClearColor(0.5, 0.5, 0.5, 0.5);
glClear(GL_COLOR_BUFFER_BIT);
@@ -496,35 +460,10 @@ piglit_display(void)
void piglit_init(int argc, char **argv)
{
- int i, j, k;
+ fbo_formats_init(argc, argv, GL_FALSE);
glutKeyboardFunc(key_func);
- piglit_require_extension("GL_EXT_framebuffer_object");
- piglit_require_extension("GL_ARB_texture_env_combine");
-
- test_set = &test_sets[0];
-
- for (i = 1; i < argc; i++) {
- for (j = 1; j < ARRAY_SIZE(test_sets); j++) {
- if (!strcmp(argv[i], test_sets[j].param)) {
- for (k = 0; k < 3; k++) {
- if (test_sets[j].ext[k]) {
- piglit_require_extension(test_sets[j].ext[k]);
- }
- }
-
- test_set = &test_sets[j];
- test_index = j;
- break;
- }
- }
- if (j == ARRAY_SIZE(test_sets)) {
- fprintf(stderr, "Unknown argument: %s\n", argv[i]);
- exit(1);
- }
- }
-
if (!piglit_automatic) {
printf(" -n Next test set.\n"
" -N Previous test set.\n"
@@ -532,6 +471,4 @@ void piglit_init(int argc, char **argv)
" -M Previous format in the set.\n"
" -d Switch between POT and NPOT\n");
}
-
- printf("Using test set: %s\n", test_set->param);
}