[Piglit] [PATCH 1/2] Move minmax test infrastructure to piglitutil.
Eric Anholt
eric at anholt.net
Mon May 14 16:28:27 PDT 2012
This also uses an obvious default value in the getters in case there's
a GL error and the value isn't written to the pointer.
---
tests/spec/arb_texture_buffer_object/minmax.c | 28 +--
tests/spec/gl-2.1/minmax.c | 199 +++++-------------
tests/spec/gl-3.0/minmax.c | 278 +++++-------------------
tests/spec/gl-3.1/minmax.c | 280 +++++--------------------
tests/util/CMakeLists.gl.txt | 1 +
tests/util/minmax-test.c | 249 ++++++++++++++++++++++
tests/util/minmax-test.h | 33 +++
7 files changed, 447 insertions(+), 621 deletions(-)
create mode 100644 tests/util/minmax-test.c
create mode 100644 tests/util/minmax-test.h
diff --git a/tests/spec/arb_texture_buffer_object/minmax.c b/tests/spec/arb_texture_buffer_object/minmax.c
index 36dd6b6..698e73d 100644
--- a/tests/spec/arb_texture_buffer_object/minmax.c
+++ b/tests/spec/arb_texture_buffer_object/minmax.c
@@ -26,6 +26,7 @@
*/
#include "piglit-util.h"
+#include "minmax-test.h"
int piglit_width = 32;
int piglit_height = 32;
@@ -38,34 +39,13 @@ piglit_display(void)
return PIGLIT_FAIL;
}
-static bool pass = true;
-
-static void
-min_test_i(GLenum token, GLint min, const char *name)
-{
- GLint val = 0;
-
- glGetIntegerv(token, &val);
-
- if (val < min) {
- fprintf(stderr, "%-50s %8d %8d (ERROR)\n",
- name, min, val);
- pass = false;
- } else {
- printf("%-50s %8d %8d\n", name, min, val);
- }
-}
-
-#define MIN_INTEGER_TEST(token, min) min_test_i(token, min, #token)
-
void
piglit_init(int argc, char **argv)
{
piglit_require_extension("GL_ARB_texture_buffer_object");
- printf("%-50s %8s %8s\n", "token", "minimum", "value");
-
- MIN_INTEGER_TEST(GL_MAX_TEXTURE_BUFFER_SIZE, 65536);
+ piglit_print_minmax_header();
+ piglit_test_min_int(GL_MAX_TEXTURE_BUFFER_SIZE, 65536);
- piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+ piglit_report_result(piglit_minmax_pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
diff --git a/tests/spec/gl-2.1/minmax.c b/tests/spec/gl-2.1/minmax.c
index 7073968..64f4a09 100644
--- a/tests/spec/gl-2.1/minmax.c
+++ b/tests/spec/gl-2.1/minmax.c
@@ -27,6 +27,7 @@
*/
#include "piglit-util.h"
+#include "minmax-test.h"
int piglit_width = 32;
int piglit_height = 32;
@@ -39,170 +40,66 @@ piglit_display(void)
return PIGLIT_FAIL;
}
-static bool pass = true;
-
-static void
-min_test_i(GLenum token, GLint min, const char *name)
-{
- GLint vals[2];
-
- glGetIntegerv(token, vals);
-
- if (vals[0] < min) {
- fprintf(stderr, "%-50s %8d %8d (ERROR)\n",
- name, min, vals[0]);
- pass = false;
- } else {
- printf("%-50s %8d %8d\n", name, min, vals[0]);
- }
-}
-
-static void
-min_test_f(GLenum token, GLfloat min, const char *name)
+void
+piglit_init(int argc, char **argv)
{
- GLfloat val;
-
- glGetFloatv(token, &val);
-
- if (val < min) {
- fprintf(stderr, "%-50s %8f %8f (ERROR)\n",
- name, min, val);
- pass = false;
- } else {
- printf("%-50s %8f %8f\n", name, min, val);
- }
-}
+ piglit_require_gl_version(21);
-/* All the size requirements happen to only require a range covering
- * [1.0, 1.0].
- */
-static void
-size_range_test(GLenum token, const char *name)
-{
- GLfloat vals[2];
+ piglit_print_minmax_header();
- glGetFloatv(token, vals);
+ piglit_test_min_int(GL_MAX_LIGHTS, 8);
+ piglit_test_min_int(GL_MAX_CLIP_PLANES, 6);
+ if (piglit_is_extension_supported("GL_ARB_imaging"))
+ piglit_test_min_int(GL_MAX_COLOR_MATRIX_STACK_DEPTH, 2);
+ piglit_test_min_int(GL_MAX_MODELVIEW_STACK_DEPTH, 32);
+ piglit_test_min_int(GL_MAX_PROJECTION_STACK_DEPTH, 2);
+ piglit_test_min_int(GL_MAX_TEXTURE_STACK_DEPTH, 2);
+ piglit_test_min_int(GL_SUBPIXEL_BITS, 4);
- if (vals[0] > 1.0 || vals[1] < 1.0) {
- fprintf(stderr, "%-50s %8s %.1f-%.1f (ERROR)\n",
- name, "1-1", vals[0], vals[1]);
- pass = false;
- } else {
- printf("%-50s %8s %.1f-%.1f\n",
- name, "1-1", vals[0], vals[1]);
- }
-}
+ piglit_test_min_int(GL_MAX_3D_TEXTURE_SIZE, 16);
+ piglit_test_min_int(GL_MAX_TEXTURE_SIZE, 64);
+ piglit_test_min_float(GL_MAX_TEXTURE_LOD_BIAS, 2.0);
+ piglit_test_min_int(GL_MAX_CUBE_MAP_TEXTURE_SIZE, 16);
+ piglit_test_min_int(GL_MAX_PIXEL_MAP_TABLE, 32);
+ piglit_test_min_int(GL_MAX_NAME_STACK_DEPTH, 64);
+ piglit_test_min_int(GL_MAX_LIST_NESTING, 64);
+ piglit_test_min_int(GL_MAX_EVAL_ORDER, 8);
-static void
-test_oq_bits()
-{
- GLint dims[2];
- GLint minbits, oqbits;
-
- /* From the GL 2.1 specification:
- *
- * "The number of query counter bits may be zero, in which
- * case the counter contains no useful
- * information. Otherwise, the minimum number of bits
- * allowed is a function of the implementation’s maximum
- * viewport dimensions (MAX_VIEWPORT_DIMS). In this case,
- * the counter must be able to represent at least two
- * overdraws for every pixel in the viewport The formula
- * to compute the allowable minimum value (where n is the
- * minimum number of bits) is:
- *
- * n = min{32, log2(maxViewportWidth ∗ maxViewportHeight * 2}"
- */
-
- glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims);
- minbits = log2((float)dims[0] * dims[1] * 2);
- if (minbits > 32)
- minbits = 32;
-
- glGetQueryiv(GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS, &oqbits);
- if (oqbits == 0 || oqbits >= minbits) {
- printf("%-50s 0 / %2d %8d\n",
- "GL_QUERY_COUNTER_BITS(GL_SAMPLES_PASSED)",
- minbits, oqbits);
- } else {
- fprintf(stderr,
- "%-50s 0 / %2d %8d\n",
- "GL_QUERY_COUNTER_BITS(GL_SAMPLES_PASSED)",
- minbits, oqbits);
- pass = false;
- }
-}
+ piglit_test_min_viewport_dimensions();
-#define MAX_INTEGER_TEST(token, max) max_test_i(token, max, #token)
-#define MIN_INTEGER_TEST(token, min) min_test_i(token, min, #token)
-#define MIN_FLOAT_TEST(token, min) min_test_f(token, min, #token)
-#define TEST_SIZE_RANGE(token) size_range_test(token, #token)
+ piglit_test_min_int(GL_MAX_ATTRIB_STACK_DEPTH, 16);
+ piglit_test_min_int(GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, 16);
-void
-piglit_init(int argc, char **argv)
-{
- piglit_require_gl_version(21);
+ piglit_test_range_float(GL_ALIASED_POINT_SIZE_RANGE, 1, 1);
+ piglit_test_range_float(GL_SMOOTH_POINT_SIZE_RANGE, 1, 1);
+ piglit_test_range_float(GL_ALIASED_LINE_WIDTH_RANGE, 1, 1);
+ piglit_test_range_float(GL_SMOOTH_LINE_WIDTH_RANGE, 1, 1);
- printf("%-50s %8s %8s\n", "token", "minimum", "value");
+ piglit_test_oq_bits();
- MIN_INTEGER_TEST(GL_MAX_LIGHTS, 8);
- MIN_INTEGER_TEST(GL_MAX_CLIP_PLANES, 6);
- if (piglit_is_extension_supported("GL_ARB_imaging"))
- MIN_INTEGER_TEST(GL_MAX_COLOR_MATRIX_STACK_DEPTH, 2);
- MIN_INTEGER_TEST(GL_MAX_MODELVIEW_STACK_DEPTH, 32);
- MIN_INTEGER_TEST(GL_MAX_PROJECTION_STACK_DEPTH, 2);
- MIN_INTEGER_TEST(GL_MAX_TEXTURE_STACK_DEPTH, 2);
- MIN_INTEGER_TEST(GL_SUBPIXEL_BITS, 4);
-
- MIN_INTEGER_TEST(GL_MAX_3D_TEXTURE_SIZE, 16);
- MIN_INTEGER_TEST(GL_MAX_TEXTURE_SIZE, 64);
- MIN_FLOAT_TEST(GL_MAX_TEXTURE_LOD_BIAS, 2.0);
- MIN_INTEGER_TEST(GL_MAX_CUBE_MAP_TEXTURE_SIZE, 16);
- MIN_INTEGER_TEST(GL_MAX_PIXEL_MAP_TABLE, 32);
- MIN_INTEGER_TEST(GL_MAX_NAME_STACK_DEPTH, 64);
- MIN_INTEGER_TEST(GL_MAX_LIST_NESTING, 64);
- MIN_INTEGER_TEST(GL_MAX_EVAL_ORDER, 8);
-
- /* FINISHME:
- *
- * "The maximum viewport dimensions must be greater than
- * or equal to the visible dimensions of the display
- * being rendered to."
- *
- * Surely the screen is at least 1024x768, right?
- */
- MIN_INTEGER_TEST(GL_MAX_VIEWPORT_DIMS, 1024);
-
- MIN_INTEGER_TEST(GL_MAX_ATTRIB_STACK_DEPTH, 16);
- MIN_INTEGER_TEST(GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, 16);
-
- TEST_SIZE_RANGE(GL_ALIASED_POINT_SIZE_RANGE);
- TEST_SIZE_RANGE(GL_SMOOTH_POINT_SIZE_RANGE);
- TEST_SIZE_RANGE(GL_ALIASED_LINE_WIDTH_RANGE);
- TEST_SIZE_RANGE(GL_SMOOTH_LINE_WIDTH_RANGE);
-
- test_oq_bits();
-
- MIN_INTEGER_TEST(GL_AUX_BUFFERS, 0);
+ piglit_test_min_int(GL_AUX_BUFFERS, 0);
if (piglit_is_extension_supported("GL_ARB_imaging")) {
/* FINISHME: GL_MAX_CONVOLUTION_WIDTH */
/* FINISHME: GL_MAX_CONVOLUTION_HEIGHT */
}
- MIN_INTEGER_TEST(GL_SAMPLE_BUFFERS, 0);
- MIN_INTEGER_TEST(GL_SAMPLES, 0);
-
- MIN_INTEGER_TEST(GL_MAX_TEXTURE_UNITS, 2);
- MIN_INTEGER_TEST(GL_MAX_VERTEX_ATTRIBS, 16);
- MIN_INTEGER_TEST(GL_MAX_VERTEX_UNIFORM_COMPONENTS, 512);
- MIN_INTEGER_TEST(GL_MAX_VARYING_COMPONENTS, 32);
- MIN_INTEGER_TEST(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, 2);
- MIN_INTEGER_TEST(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, 0);
- MIN_INTEGER_TEST(GL_MAX_TEXTURE_IMAGE_UNITS, 2);
- MIN_INTEGER_TEST(GL_MAX_TEXTURE_COORDS, 2);
- MIN_INTEGER_TEST(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, 64);
- MIN_INTEGER_TEST(GL_MAX_DRAW_BUFFERS, 1);
-
- piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+ piglit_test_min_int(GL_SAMPLE_BUFFERS, 0);
+ piglit_test_min_int(GL_SAMPLES, 0);
+
+ piglit_test_min_int(GL_MAX_TEXTURE_UNITS, 2);
+ piglit_test_min_int(GL_MAX_VERTEX_ATTRIBS, 16);
+ piglit_test_min_int(GL_MAX_VERTEX_UNIFORM_COMPONENTS, 512);
+ piglit_test_min_int(GL_MAX_VARYING_COMPONENTS, 32);
+ piglit_test_min_int(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, 2);
+ piglit_test_min_int(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, 0);
+ piglit_test_min_int(GL_MAX_TEXTURE_IMAGE_UNITS, 2);
+ piglit_test_min_int(GL_MAX_TEXTURE_COORDS, 2);
+ piglit_test_min_int(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, 64);
+ piglit_test_min_int(GL_MAX_DRAW_BUFFERS, 1);
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ piglit_report_result(PIGLIT_FAIL);
+
+ piglit_report_result(piglit_minmax_pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
diff --git a/tests/spec/gl-3.0/minmax.c b/tests/spec/gl-3.0/minmax.c
index c2175de..0e40ee1 100644
--- a/tests/spec/gl-3.0/minmax.c
+++ b/tests/spec/gl-3.0/minmax.c
@@ -27,6 +27,7 @@
*/
#include "piglit-util.h"
+#include "minmax-test.h"
int piglit_width = 32;
int piglit_height = 32;
@@ -39,246 +40,81 @@ piglit_display(void)
return PIGLIT_FAIL;
}
-static bool pass = true;
-
-static void
-max_test_i(GLenum token, GLint max, const char *name)
-{
- GLint val[2];
-
- glGetIntegerv(token, val);
-
- if (val[0] > max) {
- fprintf(stderr, "%-50s %8d %8d (ERROR)\n",
- name, max, val[0]);
- pass = false;
- } else {
- printf("%-50s %8d %8d\n", name, max, val[0]);
- }
-}
-
-static void
-min_test_i(GLenum token, GLint min, const char *name)
-{
- GLint val;
-
- glGetIntegerv(token, &val);
-
- if (val < min) {
- fprintf(stderr, "%-50s %8d %8d (ERROR)\n",
- name, min, val);
- pass = false;
- } else {
- printf("%-50s %8d %8d\n", name, min, val);
- }
-}
-
-static void
-min_test_f(GLenum token, GLfloat min, const char *name)
-{
- GLfloat val;
-
- glGetFloatv(token, &val);
-
- if (val < min) {
- fprintf(stderr, "%-50s %8f %8f (ERROR)\n",
- name, min, val);
- pass = false;
- } else {
- printf("%-50s %8f %8f\n", name, min, val);
- }
-}
-
-/* All the size requirements happen to only require a range covering
- * [1.0, 1.0].
- */
-static void
-size_range_test(GLenum token, const char *name)
-{
- GLfloat vals[2];
-
- glGetFloatv(token, vals);
-
- if (vals[0] > 1.0 || vals[1] < 1.0) {
- fprintf(stderr, "%-50s %8s %.1f-%.1f (ERROR)\n",
- name, "1-1", vals[0], vals[1]);
- pass = false;
- } else {
- printf("%-50s %8s %.1f-%.1f\n",
- name, "1-1", vals[0], vals[1]);
- }
-}
-
-static void
-test_oq_bits()
-{
- GLint dims[2];
- GLint minbits, oqbits;
-
- /* From the GL 3.0 specification, page 329:
- *
- * "If pname is QUERY_COUNTER_BITS, the
- * implementation-dependent number of query counter bits
- * may be zero, in which case the counter contains no
- * useful information.
- *
- * For occlusion queries (SAMPLES PASSED), if the number
- * of bits is non-zero, the minimum number of bits
- * allowed is a function of the implementation’s maximum
- * viewport dimensions (MAX VIEWPORT DIMS). The counter
- * must be able to represent at least two overdraws for
- * every pixel in the viewport. The formula to compute
- * the allowable minimum value (where n is the minimum
- * number of bits) is
- *
- * n = min{32, log2(maxViewportWidth ∗ maxViewportHeight * 2}"
- */
-
- glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims);
- minbits = log2((float)dims[0] * dims[1] * 2);
- if (minbits > 32)
- minbits = 32;
-
- glGetQueryiv(GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS, &oqbits);
- if (oqbits == 0 || oqbits >= minbits) {
- printf("%-50s 0 / %2d %8d\n",
- "GL_QUERY_COUNTER_BITS(GL_SAMPLES_PASSED)",
- minbits, oqbits);
- } else {
- fprintf(stderr,
- "%-50s 0 / %2d %8d\n",
- "GL_QUERY_COUNTER_BITS(GL_SAMPLES_PASSED)",
- minbits, oqbits);
- pass = false;
- }
-}
-
-static void
-test_tf_bits(GLenum target)
-{
- GLint bits = -1;
- const char *name;
-
- if (target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN)
- name = "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN bits";
- else
- name = "GL_PRIMITIVES_GENERATED bits";
-
- /* From the GL 3.0 specification, page 329:
- *
- * "If pname is QUERY_COUNTER_BITS, the
- * implementation-dependent number of query counter bits
- * may be zero, in which case the counter contains no
- * useful information.
- *
- * For primitive queries (PRIMITIVES GENERATED and
- * TRANSFORM FEEDBACK PRIMITIVES WRITTEN) if the number
- * of bits is non-zero, the minimum number of bits
- * allowed is 32."
- */
-
- glGetQueryiv(target, GL_QUERY_COUNTER_BITS, &bits);
- if (bits == 0 || bits >= 32) {
- printf("%-50s %8s %8d\n", name, "0 / 32", bits);
- } else {
- fprintf(stderr, "%-50s %8s %8d (ERROR)\n",
- name, "0 / 32", bits);
- pass = false;
- }
-}
-
-#define MAX_INTEGER_TEST(token, max) max_test_i(token, max, #token)
-#define MIN_INTEGER_TEST(token, min) min_test_i(token, min, #token)
-#define MIN_FLOAT_TEST(token, min) min_test_f(token, min, #token)
-#define TEST_SIZE_RANGE(token) size_range_test(token, #token)
-
void
piglit_init(int argc, char **argv)
{
- int rb_size;
-
piglit_require_gl_version(30);
- printf("%-50s %8s %8s\n", "token", "minimum", "value");
+ piglit_print_minmax_header();
/* These should be in the section with "Minimum Value" but
* appear in the section with "Initial Value".
*/
- MIN_INTEGER_TEST(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, 64);
- MIN_INTEGER_TEST(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, 4);
- MIN_INTEGER_TEST(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, 4);
+ piglit_test_min_int(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, 64);
+ piglit_test_min_int(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, 4);
+ piglit_test_min_int(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, 4);
- MIN_INTEGER_TEST(GL_MAX_LIGHTS, 8);
- MIN_INTEGER_TEST(GL_MAX_CLIP_PLANES, 6);
+ piglit_test_min_int(GL_MAX_LIGHTS, 8);
+ piglit_test_min_int(GL_MAX_CLIP_PLANES, 6);
if (piglit_is_extension_supported("GL_ARB_imaging"))
- MIN_INTEGER_TEST(GL_MAX_COLOR_MATRIX_STACK_DEPTH, 2);
- MIN_INTEGER_TEST(GL_MAX_MODELVIEW_STACK_DEPTH, 32);
- MIN_INTEGER_TEST(GL_MAX_PROJECTION_STACK_DEPTH, 2);
- MIN_INTEGER_TEST(GL_MAX_TEXTURE_STACK_DEPTH, 2);
- MIN_INTEGER_TEST(GL_SUBPIXEL_BITS, 4);
- MIN_INTEGER_TEST(GL_MAX_3D_TEXTURE_SIZE, 256);
- MIN_INTEGER_TEST(GL_MAX_TEXTURE_SIZE, 1024);
- MIN_FLOAT_TEST(GL_MAX_TEXTURE_LOD_BIAS, 2.0);
- MIN_INTEGER_TEST(GL_MAX_ARRAY_TEXTURE_LAYERS, 256);
- MIN_INTEGER_TEST(GL_MAX_CUBE_MAP_TEXTURE_SIZE, 1024);
- MIN_INTEGER_TEST(GL_MAX_RENDERBUFFER_SIZE, 1024);
- MIN_INTEGER_TEST(GL_MAX_PIXEL_MAP_TABLE, 32);
- MIN_INTEGER_TEST(GL_MAX_NAME_STACK_DEPTH, 64);
- MIN_INTEGER_TEST(GL_MAX_LIST_NESTING, 64);
- MIN_INTEGER_TEST(GL_MAX_EVAL_ORDER, 8);
-
- /* FINISHME:
- *
- * "The maximum viewport dimensions must be greater than
- * or equal to the larger of the visible dimensions of
- * the display being rendered to (if a display exists),
- * and the largest renderbuffer image which can be
- * successfully created and attached to a framebuffer
- * object (see chapter 4). INVALID VALUE is generated if
- * either w or h is negative."
- *
- * We're only looking at RB limits here.
- */
- glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &rb_size);
- MIN_INTEGER_TEST(GL_MAX_VIEWPORT_DIMS, rb_size);
-
- MIN_INTEGER_TEST(GL_MAX_ATTRIB_STACK_DEPTH, 16);
- MIN_INTEGER_TEST(GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, 16);
-
- TEST_SIZE_RANGE(GL_ALIASED_POINT_SIZE_RANGE);
- TEST_SIZE_RANGE(GL_SMOOTH_POINT_SIZE_RANGE);
- TEST_SIZE_RANGE(GL_ALIASED_LINE_WIDTH_RANGE);
- TEST_SIZE_RANGE(GL_SMOOTH_LINE_WIDTH_RANGE);
-
- test_tf_bits(GL_PRIMITIVES_GENERATED);
- test_tf_bits(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
- test_oq_bits();
+ piglit_test_min_int(GL_MAX_COLOR_MATRIX_STACK_DEPTH, 2);
+ piglit_test_min_int(GL_MAX_MODELVIEW_STACK_DEPTH, 32);
+ piglit_test_min_int(GL_MAX_PROJECTION_STACK_DEPTH, 2);
+ piglit_test_min_int(GL_MAX_TEXTURE_STACK_DEPTH, 2);
+ piglit_test_min_int(GL_SUBPIXEL_BITS, 4);
+ piglit_test_min_int(GL_MAX_3D_TEXTURE_SIZE, 256);
+ piglit_test_min_int(GL_MAX_TEXTURE_SIZE, 1024);
+ piglit_test_min_float(GL_MAX_TEXTURE_LOD_BIAS, 2.0);
+ piglit_test_min_int(GL_MAX_ARRAY_TEXTURE_LAYERS, 256);
+ piglit_test_min_int(GL_MAX_CUBE_MAP_TEXTURE_SIZE, 1024);
+ piglit_test_min_int(GL_MAX_RENDERBUFFER_SIZE, 1024);
+ piglit_test_min_int(GL_MAX_PIXEL_MAP_TABLE, 32);
+ piglit_test_min_int(GL_MAX_NAME_STACK_DEPTH, 64);
+ piglit_test_min_int(GL_MAX_LIST_NESTING, 64);
+ piglit_test_min_int(GL_MAX_EVAL_ORDER, 8);
+
+ piglit_test_min_viewport_dimensions();
+
+ piglit_test_min_int(GL_MAX_ATTRIB_STACK_DEPTH, 16);
+ piglit_test_min_int(GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, 16);
+
+ piglit_test_range_float(GL_ALIASED_POINT_SIZE_RANGE, 1, 1);
+ piglit_test_range_float(GL_SMOOTH_POINT_SIZE_RANGE, 1, 1);
+ piglit_test_range_float(GL_ALIASED_LINE_WIDTH_RANGE, 1, 1);
+ piglit_test_range_float(GL_SMOOTH_LINE_WIDTH_RANGE, 1, 1);
+
+ piglit_test_tf_bits(GL_PRIMITIVES_GENERATED);
+ piglit_test_tf_bits(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
+ piglit_test_oq_bits();
if (piglit_is_extension_supported("GL_ARB_imaging")) {
/* FINISHME: GL_MAX_CONVOLUTION_WIDTH */
/* FINISHME: GL_MAX_CONVOLUTION_HEIGHT */
}
- MIN_INTEGER_TEST(GL_MAX_TEXTURE_UNITS, 2);
- MIN_INTEGER_TEST(GL_MAX_VERTEX_ATTRIBS, 16);
- MIN_INTEGER_TEST(GL_MAX_VERTEX_UNIFORM_COMPONENTS, 1024);
- MIN_INTEGER_TEST(GL_MAX_VARYING_COMPONENTS, 64);
- MIN_INTEGER_TEST(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, 16);
- MIN_INTEGER_TEST(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, 16);
- MIN_INTEGER_TEST(GL_MAX_TEXTURE_IMAGE_UNITS, 16);
- MIN_INTEGER_TEST(GL_MAX_TEXTURE_COORDS, 8);
- MIN_INTEGER_TEST(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, 1024);
+ piglit_test_min_int(GL_MAX_TEXTURE_UNITS, 2);
+ piglit_test_min_int(GL_MAX_VERTEX_ATTRIBS, 16);
+ piglit_test_min_int(GL_MAX_VERTEX_UNIFORM_COMPONENTS, 1024);
+ piglit_test_min_int(GL_MAX_VARYING_COMPONENTS, 64);
+ piglit_test_min_int(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, 16);
+ piglit_test_min_int(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, 16);
+ piglit_test_min_int(GL_MAX_TEXTURE_IMAGE_UNITS, 16);
+ piglit_test_min_int(GL_MAX_TEXTURE_COORDS, 8);
+ piglit_test_min_int(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, 1024);
+
+ piglit_test_max_int(GL_MIN_PROGRAM_TEXEL_OFFSET, -8);
+ piglit_test_min_int(GL_MAX_PROGRAM_TEXEL_OFFSET, 7);
- MAX_INTEGER_TEST(GL_MIN_PROGRAM_TEXEL_OFFSET, -8);
- MIN_INTEGER_TEST(GL_MAX_PROGRAM_TEXEL_OFFSET, 7);
+ piglit_test_min_int(GL_AUX_BUFFERS, 0);
+ piglit_test_min_int(GL_MAX_DRAW_BUFFERS, 8);
- MIN_INTEGER_TEST(GL_AUX_BUFFERS, 0);
- MIN_INTEGER_TEST(GL_MAX_DRAW_BUFFERS, 8);
+ piglit_test_min_int(GL_SAMPLE_BUFFERS, 0);
+ piglit_test_min_int(GL_SAMPLES, 0);
+ piglit_test_min_int(GL_MAX_COLOR_ATTACHMENTS, 8);
+ piglit_test_min_int(GL_MAX_SAMPLES, 4);
- MIN_INTEGER_TEST(GL_SAMPLE_BUFFERS, 0);
- MIN_INTEGER_TEST(GL_SAMPLES, 0);
- MIN_INTEGER_TEST(GL_MAX_COLOR_ATTACHMENTS, 8);
- MIN_INTEGER_TEST(GL_MAX_SAMPLES, 4);
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ piglit_report_result(PIGLIT_FAIL);
- piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+ piglit_report_result(piglit_minmax_pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
diff --git a/tests/spec/gl-3.1/minmax.c b/tests/spec/gl-3.1/minmax.c
index 4a83e9d..d59c3cc 100644
--- a/tests/spec/gl-3.1/minmax.c
+++ b/tests/spec/gl-3.1/minmax.c
@@ -27,6 +27,7 @@
*/
#include "piglit-util.h"
+#include "minmax-test.h"
int piglit_width = 32;
int piglit_height = 32;
@@ -39,234 +40,63 @@ piglit_display(void)
return PIGLIT_FAIL;
}
-static bool pass = true;
-
-static void
-report_int(const char *name, GLint requirement, GLint val, bool error)
-{
- if (error) {
- fprintf(stderr, "%-50s %8d %8d (ERROR)\n",
- name, requirement, val);
- pass = false;
- } else {
- printf("%-50s %8d %8d\n", name, requirement, val);
- }
-}
-
-static void
-max_test_i(GLenum token, GLint max, const char *name)
-{
- GLint val = 0;
-
- glGetIntegerv(token, &val);
-
- report_int(name, val, max, val > max);
-}
-
-static void
-min_test_i(GLenum token, GLint min, const char *name)
-{
- GLint val = 0;
-
- glGetIntegerv(token, &val);
-
- report_int(name, val, min, val < min);
-}
-
-static void
-min_test_f(GLenum token, GLfloat min, const char *name)
-{
- GLfloat val = 0.0;
-
- glGetFloatv(token, &val);
-
- if (val < min) {
- fprintf(stderr, "%-50s %8f %8f (ERROR)\n",
- name, min, val);
- pass = false;
- } else {
- printf("%-50s %8f %8f\n", name, min, val);
- }
-}
-
-/* All the size requirements happen to only require a range covering
- * [1.0, 1.0].
- */
-static void
-size_range_test(GLenum token, const char *name)
-{
- GLfloat vals[2];
-
- glGetFloatv(token, vals);
-
- if (vals[0] > 1.0 || vals[1] < 1.0) {
- fprintf(stderr, "%-50s %8s %.1f-%.1f (ERROR)\n",
- name, "1-1", vals[0], vals[1]);
- pass = false;
- } else {
- printf("%-50s %8s %.1f-%.1f\n",
- name, "1-1", vals[0], vals[1]);
- }
-}
-
-static void
-test_oq_bits()
-{
- GLint dims[2];
- GLint minbits, oqbits;
-
- /* From the GL 3.0 specification, page 329:
- *
- * "If pname is QUERY_COUNTER_BITS, the
- * implementation-dependent number of query counter bits
- * may be zero, in which case the counter contains no
- * useful information.
- *
- * For occlusion queries (SAMPLES PASSED), if the number
- * of bits is non-zero, the minimum number of bits
- * allowed is a function of the implementation’s maximum
- * viewport dimensions (MAX VIEWPORT DIMS). The counter
- * must be able to represent at least two overdraws for
- * every pixel in the viewport. The formula to compute
- * the allowable minimum value (where n is the minimum
- * number of bits) is
- *
- * n = min{32, log2(maxViewportWidth ∗ maxViewportHeight * 2}"
- */
-
- glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims);
- minbits = log2((float)dims[0] * dims[1] * 2);
- if (minbits > 32)
- minbits = 32;
-
- glGetQueryiv(GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS, &oqbits);
- if (oqbits == 0 || oqbits >= minbits) {
- printf("%-50s 0 / %2d %8d\n",
- "GL_QUERY_COUNTER_BITS(GL_SAMPLES_PASSED)",
- minbits, oqbits);
- } else {
- fprintf(stderr,
- "%-50s 0 / %2d %8d\n",
- "GL_QUERY_COUNTER_BITS(GL_SAMPLES_PASSED)",
- minbits, oqbits);
- pass = false;
- }
-}
-
-static void
-test_tf_bits(GLenum target)
-{
- GLint bits = -1;
- const char *name;
-
- if (target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN)
- name = "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN bits";
- else
- name = "GL_PRIMITIVES_GENERATED bits";
-
- /* From the GL 3.0 specification, page 329:
- *
- * "If pname is QUERY_COUNTER_BITS, the
- * implementation-dependent number of query counter bits
- * may be zero, in which case the counter contains no
- * useful information.
- *
- * For primitive queries (PRIMITIVES GENERATED and
- * TRANSFORM FEEDBACK PRIMITIVES WRITTEN) if the number
- * of bits is non-zero, the minimum number of bits
- * allowed is 32."
- */
-
- glGetQueryiv(target, GL_QUERY_COUNTER_BITS, &bits);
- if (bits == 0 || bits >= 32) {
- printf("%-50s %8s %8d\n", name, "0 / 32", bits);
- } else {
- fprintf(stderr, "%-50s %8s %8d (ERROR)\n",
- name, "0 / 32", bits);
- pass = false;
- }
-}
-
-#define MAX_INTEGER_TEST(token, max) max_test_i(token, max, #token)
-#define MIN_INTEGER_TEST(token, min) min_test_i(token, min, #token)
-#define MIN_FLOAT_TEST(token, min) min_test_f(token, min, #token)
-#define TEST_SIZE_RANGE(token) size_range_test(token, #token)
-
void
piglit_init(int argc, char **argv)
{
- int rb_size, dims[2] = { 0 };
int vuniforms = 0, vblocks = 0;
int funiforms = 0, fblocks = 0;
int blocksize = 0;
piglit_require_gl_version(31);
- printf("%-50s %8s %8s\n", "token", "minimum", "value");
+ piglit_print_minmax_header();
/* These should be in the section with "Minimum Value" but
* appear in the section with "Initial Value".
*/
- MIN_INTEGER_TEST(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, 64);
- MIN_INTEGER_TEST(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, 4);
- MIN_INTEGER_TEST(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, 4);
-
- MIN_INTEGER_TEST(GL_MAX_CLIP_DISTANCES, 8);
- MIN_INTEGER_TEST(GL_SUBPIXEL_BITS, 4);
- MIN_INTEGER_TEST(GL_MAX_3D_TEXTURE_SIZE, 256);
- MIN_INTEGER_TEST(GL_MAX_TEXTURE_SIZE, 1024);
- MIN_INTEGER_TEST(GL_MAX_ARRAY_TEXTURE_LAYERS, 256);
- MIN_FLOAT_TEST(GL_MAX_TEXTURE_LOD_BIAS, 2.0);
- MIN_INTEGER_TEST(GL_MAX_CUBE_MAP_TEXTURE_SIZE, 1024);
- MIN_INTEGER_TEST(GL_MAX_RENDERBUFFER_SIZE, 1024);
-
- /* FINISHME:
- *
- * "The maximum viewport dimensions must be greater than
- * or equal to the larger of the visible dimensions of
- * the display being rendered to (if a display exists),
- * and the largest renderbuffer image which can be
- * successfully created and attached to a framebuffer
- * object (see chapter 4). INVALID VALUE is generated if
- * either w or h is negative."
- *
- * We're only looking at RB limits here.
- */
- glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &rb_size);
- glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims);
- report_int("GL_MAX_VIEWPORT_DIMS[0]",
- rb_size, dims[0], dims[0] < rb_size);
- report_int("GL_MAX_VIEWPORT_DIMS[1]",
- rb_size, dims[1], dims[1] < rb_size);
-
- TEST_SIZE_RANGE(GL_POINT_SIZE_RANGE);
- TEST_SIZE_RANGE(GL_ALIASED_LINE_WIDTH_RANGE);
- TEST_SIZE_RANGE(GL_SMOOTH_LINE_WIDTH_RANGE);
- MIN_INTEGER_TEST(GL_NUM_COMPRESSED_TEXTURE_FORMATS, 4);
- MIN_INTEGER_TEST(GL_MAX_TEXTURE_BUFFER_SIZE, 65536);
- MIN_INTEGER_TEST(GL_MAX_RECTANGLE_TEXTURE_SIZE, 1024);
-
- test_tf_bits(GL_PRIMITIVES_GENERATED);
- test_tf_bits(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
- test_oq_bits();
-
- MIN_INTEGER_TEST(GL_MAX_VERTEX_ATTRIBS, 16);
- MIN_INTEGER_TEST(GL_MAX_VERTEX_UNIFORM_COMPONENTS, 1024);
- MIN_INTEGER_TEST(GL_MAX_VARYING_COMPONENTS, 64);
- MIN_INTEGER_TEST(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, 32);
- MIN_INTEGER_TEST(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, 16);
- MIN_INTEGER_TEST(GL_MAX_TEXTURE_IMAGE_UNITS, 16);
- MIN_INTEGER_TEST(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, 1024);
-
- MAX_INTEGER_TEST(GL_MIN_PROGRAM_TEXEL_OFFSET, -8);
- MIN_INTEGER_TEST(GL_MAX_PROGRAM_TEXEL_OFFSET, 7);
-
- MIN_INTEGER_TEST(GL_MAX_VERTEX_UNIFORM_BLOCKS, 12);
- MIN_INTEGER_TEST(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, 12);
- MIN_INTEGER_TEST(GL_MAX_COMBINED_UNIFORM_BLOCKS, 24);
- MIN_INTEGER_TEST(GL_MAX_UNIFORM_BUFFER_BINDINGS, 24);
- MIN_INTEGER_TEST(GL_MAX_UNIFORM_BLOCK_SIZE, 16384);
- MIN_INTEGER_TEST(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, 1);
+ piglit_test_min_int(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, 64);
+ piglit_test_min_int(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, 4);
+ piglit_test_min_int(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, 4);
+
+ piglit_test_min_int(GL_MAX_CLIP_DISTANCES, 8);
+ piglit_test_min_int(GL_SUBPIXEL_BITS, 4);
+ piglit_test_min_int(GL_MAX_3D_TEXTURE_SIZE, 256);
+ piglit_test_min_int(GL_MAX_TEXTURE_SIZE, 1024);
+ piglit_test_min_int(GL_MAX_ARRAY_TEXTURE_LAYERS, 256);
+ piglit_test_min_float(GL_MAX_TEXTURE_LOD_BIAS, 2.0);
+ piglit_test_min_int(GL_MAX_CUBE_MAP_TEXTURE_SIZE, 1024);
+ piglit_test_min_int(GL_MAX_RENDERBUFFER_SIZE, 1024);
+
+ piglit_test_min_viewport_dimensions();
+
+ piglit_test_range_float(GL_POINT_SIZE_RANGE, 1, 1);
+ piglit_test_range_float(GL_ALIASED_LINE_WIDTH_RANGE, 1, 1);
+ piglit_test_range_float(GL_SMOOTH_LINE_WIDTH_RANGE, 1, 1);
+ piglit_test_min_int(GL_NUM_COMPRESSED_TEXTURE_FORMATS, 4);
+ piglit_test_min_int(GL_MAX_TEXTURE_BUFFER_SIZE, 65536);
+ piglit_test_min_int(GL_MAX_RECTANGLE_TEXTURE_SIZE, 1024);
+
+ piglit_test_tf_bits(GL_PRIMITIVES_GENERATED);
+ piglit_test_tf_bits(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
+ piglit_test_oq_bits();
+
+ piglit_test_min_int(GL_MAX_VERTEX_ATTRIBS, 16);
+ piglit_test_min_int(GL_MAX_VERTEX_UNIFORM_COMPONENTS, 1024);
+ piglit_test_min_int(GL_MAX_VARYING_COMPONENTS, 64);
+ piglit_test_min_int(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, 32);
+ piglit_test_min_int(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, 16);
+ piglit_test_min_int(GL_MAX_TEXTURE_IMAGE_UNITS, 16);
+ piglit_test_min_int(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, 1024);
+
+ piglit_test_max_int(GL_MIN_PROGRAM_TEXEL_OFFSET, -8);
+ piglit_test_min_int(GL_MAX_PROGRAM_TEXEL_OFFSET, 7);
+
+ piglit_test_min_int(GL_MAX_VERTEX_UNIFORM_BLOCKS, 12);
+ piglit_test_min_int(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, 12);
+ piglit_test_min_int(GL_MAX_COMBINED_UNIFORM_BLOCKS, 24);
+ piglit_test_min_int(GL_MAX_UNIFORM_BUFFER_BINDINGS, 24);
+ piglit_test_min_int(GL_MAX_UNIFORM_BLOCK_SIZE, 16384);
+ piglit_test_min_int(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, 1);
glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS, &vblocks);
glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &vuniforms);
@@ -278,8 +108,8 @@ piglit_init(int argc, char **argv)
* above, with realistic minimum values. This appears to be a
* typo and was dropped in 3.2.
*/
- /* MIN_INTEGER_TEST(GL_MAX_VERTEX_UNIFORM_COMPONENTS, 1); */
- /* MIN_INTEGER_TEST(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, 1); */
+ /* piglit_test_min_int(GL_MAX_VERTEX_UNIFORM_COMPONENTS, 1); */
+ /* piglit_test_min_int(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, 1); */
/* In this case, the "1" in the table refers to the footnote:
*
@@ -288,21 +118,21 @@ piglit_init(int argc, char **argv)
* MAX_stage_UNIFORM_BLOCK_SIZE +
* MAX_stage_UNIFORM_COMPONENTS"
*/
- MIN_INTEGER_TEST(GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS,
+ piglit_test_min_int(GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS,
vblocks * blocksize + vuniforms);
- MIN_INTEGER_TEST(GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS,
+ piglit_test_min_int(GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS,
fblocks * blocksize + funiforms);
- MIN_INTEGER_TEST(GL_MAX_DRAW_BUFFERS, 8);
+ piglit_test_min_int(GL_MAX_DRAW_BUFFERS, 8);
- MIN_INTEGER_TEST(GL_SAMPLE_BUFFERS, 0);
- MIN_INTEGER_TEST(GL_SAMPLES, 0);
+ piglit_test_min_int(GL_SAMPLE_BUFFERS, 0);
+ piglit_test_min_int(GL_SAMPLES, 0);
- MIN_INTEGER_TEST(GL_MAX_COLOR_ATTACHMENTS, 8);
- MIN_INTEGER_TEST(GL_MAX_SAMPLES, 4);
+ piglit_test_min_int(GL_MAX_COLOR_ATTACHMENTS, 8);
+ piglit_test_min_int(GL_MAX_SAMPLES, 4);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
- piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+ piglit_report_result(piglit_minmax_pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
diff --git a/tests/util/CMakeLists.gl.txt b/tests/util/CMakeLists.gl.txt
index 7790e4f..3d08b97 100644
--- a/tests/util/CMakeLists.gl.txt
+++ b/tests/util/CMakeLists.gl.txt
@@ -14,6 +14,7 @@ set(UTIL_SOURCES
piglit-util-gl.c
piglit-vbo.cpp
sized-internalformats.c
+ minmax-test.c
)
IF(BUILD_GLX_TESTS)
diff --git a/tests/util/minmax-test.c b/tests/util/minmax-test.c
new file mode 100644
index 0000000..4fa2d98
--- /dev/null
+++ b/tests/util/minmax-test.c
@@ -0,0 +1,249 @@
+/* Copyright © 2011-2012 Intel Corporation
+ *
+ * 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
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+
+/** @file minmax-test.c
+ *
+ * Helpers for performing minimuTest for the minimum maximum values in section 6.2 "State Tables"
+ * of the GL 3.0 spec.
+ */
+
+#define _GNU_SOURCE
+#include <string.h>
+
+#include "piglit-util.h"
+#include "minmax-test.h"
+
+bool piglit_minmax_pass = true;
+
+void piglit_print_minmax_header(void)
+{
+ printf("%-50s %8s %8s\n", "token", "minimum", "value");
+}
+
+static void
+piglit_report_int(const char *name, GLint limit, GLint val, bool pass)
+{
+ if (pass) {
+ printf("%-50s %8d %8d\n", name, limit, val);
+ } else {
+ fprintf(stderr, "%-50s %8d %8d (ERROR)\n",
+ name, limit, val);
+ piglit_minmax_pass = false;
+ }
+}
+
+static void
+piglit_report_float(const char *name, GLfloat limit, GLfloat val, bool pass)
+{
+ if (pass) {
+ printf("%-50s %8.1f %8.1f\n", name, limit, val);
+ } else {
+ fprintf(stderr, "%-50s %8f %8f (ERROR)\n",
+ name, limit, val);
+ piglit_minmax_pass = false;
+ }
+}
+
+static void
+piglit_test_int(GLenum token, GLint limit, bool max)
+{
+ const char *name = piglit_get_gl_enum_name(token);
+ GLint val = 9999;
+
+ glGetIntegerv(token, &val);
+
+ piglit_report_int(name, limit, val,
+ (max && val <= limit) ||
+ (!max && val >= limit));
+}
+
+void piglit_test_min_int(GLenum token, GLint min)
+{
+ piglit_test_int(token, min, false);
+}
+
+void piglit_test_max_int(GLenum token, GLint max)
+{
+ piglit_test_int(token, max, true);
+}
+
+
+static void
+piglit_test_float(GLenum token, GLfloat limit, bool max)
+{
+ const char *name = piglit_get_gl_enum_name(token);
+ GLfloat val = -9999;
+
+ glGetFloatv(token, &val);
+
+ piglit_report_float(name, limit, val,
+ (max && val <= limit) ||
+ (!max && val >= limit));
+}
+
+void piglit_test_min_float(GLenum token, GLfloat min)
+{
+ piglit_test_float(token, min, false);
+}
+
+void piglit_test_max_float(GLenum token, GLfloat max)
+{
+ piglit_test_float(token, max, true);
+}
+
+/** Tests tha the range referneced by the token covers at least low-high. */
+void piglit_test_range_float(GLenum token, GLfloat low, GLfloat high)
+{
+ const char *name = piglit_get_gl_enum_name(token);
+ char *temp;
+ GLfloat vals[2] = {9999, 9999};
+
+ glGetFloatv(token, vals);
+
+ asprintf(&temp, "%s[0]", name);
+ piglit_report_float(temp, low, vals[0], vals[0] <= low);
+ free(temp);
+
+ asprintf(&temp, "%s[1]", name);
+ piglit_report_float(temp, high, vals[1], vals[1] >= high);
+ free(temp);
+}
+
+void piglit_test_min_viewport_dimensions(void)
+{
+ int min_w, min_h;
+ GLint dims[2] = {9999, 9999};
+
+ if (piglit_get_gl_version() < 30) {
+ /* FINISHME:
+ *
+ * "The maximum viewport dimensions must be
+ * greater than or equal to the larger of the
+ * visible dimensions of the display being
+ * rendered to (if a display exists), and the
+ * largest renderbuffer image which can be
+ * successfully created and attached to a
+ * framebuffer object (see chapter 4). INVALID
+ * VALUE is generated if either w or h is
+ * negative."
+ *
+ * We're only looking at RB limits here.
+ */
+ int rb_size = 9999;
+ glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &rb_size);
+
+ min_w = rb_size;
+ min_h = rb_size;
+ } else {
+ /* FINISHME:
+ *
+ * "The maximum viewport dimensions must be
+ * greater than or equal to the visible
+ * dimensions of the display being rendered to."
+ *
+ * Surely the screen is at least 1024x768, right?
+ */
+ min_w = 1024;
+ min_h = 768;
+ }
+
+ glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims);
+
+ piglit_report_int("GL_MAX_VIEWPORT_DIMS[0]", min_w, dims[0],
+ dims[0] >= min_w);
+ piglit_report_int("GL_MAX_VIEWPORT_DIMS[1]", min_h, dims[1],
+ dims[1] >= min_h);
+}
+
+void
+piglit_test_oq_bits()
+{
+ GLint dims[2] = {9999, 9999};
+ GLint minbits, oqbits = 9999;
+
+ /* From the GL 2.1 specification:
+ *
+ * "The number of query counter bits may be zero, in which
+ * case the counter contains no useful
+ * information. Otherwise, the minimum number of bits
+ * allowed is a function of the implementation’s maximum
+ * viewport dimensions (MAX_VIEWPORT_DIMS). In this case,
+ * the counter must be able to represent at least two
+ * overdraws for every pixel in the viewport The formula
+ * to compute the allowable minimum value (where n is the
+ * minimum number of bits) is:
+ *
+ * n = min{32, log2(maxViewportWidth ∗ maxViewportHeight * 2}"
+ */
+
+ glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims);
+ minbits = log2((float)dims[0] * dims[1] * 2);
+ if (minbits > 32)
+ minbits = 32;
+
+ glGetQueryiv(GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS, &oqbits);
+ if (oqbits == 0 || oqbits >= minbits) {
+ printf("%-50s 0 / %2d %8d\n",
+ "GL_QUERY_COUNTER_BITS(GL_SAMPLES_PASSED)",
+ minbits, oqbits);
+ } else {
+ fprintf(stderr,
+ "%-50s 0 / %2d %8d\n",
+ "GL_QUERY_COUNTER_BITS(GL_SAMPLES_PASSED)",
+ minbits, oqbits);
+ piglit_minmax_pass = false;
+ }
+}
+
+void
+piglit_test_tf_bits(GLenum target)
+{
+ GLint bits = 9999;
+ const char *name;
+
+ if (target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN)
+ name = "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN bits";
+ else
+ name = "GL_PRIMITIVES_GENERATED bits";
+
+ /* From the GL 3.0 specification, page 329:
+ *
+ * "If pname is QUERY_COUNTER_BITS, the
+ * implementation-dependent number of query counter bits
+ * may be zero, in which case the counter contains no
+ * useful information.
+ *
+ * For primitive queries (PRIMITIVES GENERATED and
+ * TRANSFORM FEEDBACK PRIMITIVES WRITTEN) if the number
+ * of bits is non-zero, the minimum number of bits
+ * allowed is 32."
+ */
+
+ glGetQueryiv(target, GL_QUERY_COUNTER_BITS, &bits);
+ if (bits == 0 || bits >= 32) {
+ printf("%-50s %8s %8d\n", name, "0 / 32", bits);
+ } else {
+ fprintf(stderr, "%-50s %8s %8d (ERROR)\n",
+ name, "0 / 32", bits);
+ piglit_minmax_pass = false;
+ }
+}
diff --git a/tests/util/minmax-test.h b/tests/util/minmax-test.h
new file mode 100644
index 0000000..698b9e6
--- /dev/null
+++ b/tests/util/minmax-test.h
@@ -0,0 +1,33 @@
+/* Copyright © 2012 Intel Corporation
+ *
+ * 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
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+
+extern bool piglit_minmax_pass;
+
+void piglit_print_minmax_header(void);
+void piglit_test_min_int(GLenum token, GLint val);
+void piglit_test_max_int(GLenum token, GLint val);
+void piglit_test_min_float(GLenum token, GLfloat val);
+void piglit_test_max_float(GLenum token, GLfloat val);
+void piglit_test_range_float(GLenum token, GLfloat low, GLfloat high);
+void piglit_test_min_viewport_dimensions();
+void piglit_test_oq_bits(void);
+void piglit_test_tf_bits(GLenum target);
--
1.7.10
More information about the Piglit
mailing list