Ejemplo n.º 1
0
/*
 * Prints the info of a failing case. If expected_value is smaller
 * that 0, it is not printed.
*/
void print_failing_case_full(const GLenum target, const GLenum internalformat,
                             const GLenum pname, GLint64 expected_value,
                             test_data *data)
{
        /* Knowing if it is supported is interesting in order to know
         * if the test is being too restrictive */
        bool supported = test_data_check_supported(data, target, internalformat);
        GLint64 current_value = test_data_value_at_index(data, 0);

        if (data->testing64) {
                fprintf(stderr,  "    64 bit failing case: ");
        } else {
                fprintf(stderr,  "    32 bit failing case: ");
        }

        fprintf(stderr, "pname = %s, "
                "target = %s, internalformat = %s, ",
                piglit_get_gl_enum_name(pname),
                piglit_get_gl_enum_name(target),
                piglit_get_gl_enum_name(internalformat));

        if (expected_value >= 0)
                fprintf(stderr, "expected value = (%" PRIi64 "), ",
                        expected_value);

        fprintf(stderr, "params[0] = (%" PRIi64 ",%s), "
                "supported=%i\n",
                current_value,
                piglit_get_gl_enum_name(current_value),
                supported);
}
Ejemplo n.º 2
0
bool
test_data_check_possible_values(test_data *data,
                                const GLint *possible_values,
                                const unsigned num_possible_values)
{
        return value_on_set(possible_values, num_possible_values,
                            test_data_value_at_index(data, 0));
}
Ejemplo n.º 3
0
/*
 * Builds a a texture using @target and @internalformat, and compares
 * the result of calling GetTexLevelParameter using @pname with the
 * result included at @data.params.
 *
 * At this point it is assumed that @target/@internalformat is a valid
 * combination to create a texture unless it is not supported by the
 * implementation. If the call to create_texture with those parameters
 * fails, it is assumed that the resource is unsupported, so the check
 * only compares against zero (the unsupported value).
 *
 * Returns true if the value is the same, false otherwise
 */
bool
test_data_check_against_get_tex_level_parameter(test_data *data,
                                                const GLenum target,
                                                const GLenum pname,
                                                const GLenum internalformat)
{
        GLint param;
        bool result = true;
        GLuint tex;
        GLuint buffer;
        GLenum real_target = target;

        result = create_texture(target, internalformat, &tex, &buffer);
        if (!result)
                return test_data_is_unsupported_response(data, pname);

        /* For cube maps GetTexLevelParameter receives one of the face
         * targets, or proxy */
        if (target == GL_TEXTURE_CUBE_MAP) {
                real_target = GL_TEXTURE_CUBE_MAP_POSITIVE_X;
        }
        glGetTexLevelParameteriv(real_target, 0, pname, &param);
        if (!piglit_check_gl_error(GL_NO_ERROR)) {
                result = false;
                fprintf(stderr, "\tError calling glGetTexLevelParameter\n");
                goto cleanup;
        }

        result = test_data_value_at_index(data, 0) == param;

        if (!result) {
                fprintf(stderr, "\tError comparing glGetInternalformat "
                        "and glGetTexLevelParameter, params value=%" PRIi64 ", "
                        "expected value=%i\n",
                        test_data_value_at_index(data, 0), param);
        }

cleanup:
        glDeleteTextures(1, &tex);
        glDeleteBuffers(1, &buffer);

        return result;
}
/* From the spec:
 *
 * "- IMAGE_FORMAT_COMPATIBILITY_TYPE: The matching criteria use for
 *   the resource when used as an image textures is returned in
 *   <params>. This is equivalent to calling GetTexParameter with
 *   <value> set to IMAGE_FORMAT_COMPATIBILITY_TYPE. Possible values
 *   are IMAGE_FORMAT_COMPATIBILITY_BY_SIZE or
 *   IMAGE_FORMAT_COMPATIBILITY_BY_CLASS.  If the resource is not
 *   supported for image textures, or if image textures are not
 *   supported, NONE is returned."
 *
 * So try_local is equivalent to try_basic, except that instead of
 * checking against a list of possible value, we test against the
 * value returned by GetTexParameter, or against GL_NONE if not
 * supported of if it is not a texture.
 */
bool
try_local(const GLenum *targets, unsigned num_targets,
          const GLenum *internalformats, unsigned num_internalformats,
          const GLenum pname,
          test_data *data)
{
        bool pass = true;
        unsigned i;
        unsigned j;
        GLint param;

	for (i = 0; i < num_targets; i++) {
                for (j = 0; j < num_internalformats; j++) {
                        bool error_test;
                        bool value_test;
                        bool supported;
                        bool is_texture;

                        supported = check_query2_dependencies(pname, targets[i])
                                && test_data_check_supported(data, targets[i],
                                                             internalformats[j]);

                        test_data_execute(data, targets[i], internalformats[j], pname);

                        error_test =
                                piglit_check_gl_error(GL_NO_ERROR);

                        is_texture = value_on_set((const GLint*)texture_targets, ARRAY_SIZE(texture_targets),
                                                  (GLint) targets[i]);

                        if (is_texture && supported) {
                                param = get_tex_parameter_value(targets[i], internalformats[j]);
                                error_test = error_test &&
                                        piglit_check_gl_error(GL_NO_ERROR);

                                value_test = test_data_value_at_index(data, 0) == param;
                        } else {
                                value_test = test_data_is_unsupported_response(data, pname);
                        }

                        if (error_test && value_test)
                                continue;

                        print_failing_case(targets[i], internalformats[j],
                                           pname, data);

                        pass = false;
                }
        }

	return pass;
}
Ejemplo n.º 5
0
bool
test_data_equal_at_index(test_data *data,
                         test_data *data_copy,
                         unsigned index)
{
        if (data->testing64 != data_copy->testing64) {
                fprintf(stderr, "ERROR: trying to compare imcompatible"
                        " auxiliar test data structures\n");
                return false;
        }
        if (data->params_size != data_copy->params_size) {
                fprintf(stderr, "ERROR: trying to compare imcompatible"
                        " auxiliar test data structures\n");
                return false;
        }
        if (index > data->params_size) {
                fprintf(stderr, "ERROR: invalid index while setting"
                        " auxiliar test data\n");
                return false;
        }

        return (test_data_value_at_index(data, index) ==
                test_data_value_at_index(data_copy, index));
}
Ejemplo n.º 6
0
static bool
check_params_against_get_integer(test_data *data,
                                 GLenum pname)
{
        GLint size;
        GLint size_at_params;

        glGetIntegerv(pname, &size);
        size_at_params = test_data_value_at_index(data, 0);

        if (size != size_at_params) {
                fprintf(stderr, "GetInternalformat returns %i while GetInteger returns %i\n",
                        size_at_params, size);
        }

        return size == size_at_params;
}
Ejemplo n.º 7
0
/*
 * Returns if @target/@internalformat is supported using
 * INTERNALFORMAT_SUPPORTED for @target and @internalformat.
 *
 * @data is only used to known if we are testing the 32-bit or the
 * 64-bit query, so the content of @data will not be modified due this
 * call.
 */
bool
test_data_check_supported(const test_data *data,
                          const GLenum target,
                          const GLenum internalformat)
{
        bool result;
        test_data *local_data = test_data_new(data->testing64, 1);

        test_data_execute(local_data, target, internalformat,
                          GL_INTERNALFORMAT_SUPPORTED);

        if (!piglit_check_gl_error(GL_NO_ERROR))
                result = false;
        else
                result = test_data_value_at_index(local_data, 0) == GL_TRUE;

        test_data_clear(&local_data);

        return result;
}
Ejemplo n.º 8
0
static bool
real_try(GLenum target, GLenum format, GLint max_samples,
         const char *max_samples_name,
         test_data *data_counts,
         test_data *data_samples)
{
        bool pass = true;
        int buffer_size_in_elements = 0;
        unsigned i;
        GLint previous;

        test_data_set_params_size(data_counts, 1);
        test_data_execute(data_counts, target, format,
                          GL_NUM_SAMPLE_COUNTS);

        buffer_size_in_elements = test_data_value_at_index(data_counts, 0);
        pass = piglit_check_gl_error(0)
                && pass;

        /* The GL_ARB_internalformat_query spec says:
         *
         *     "Add new table 6.X Internalformat-specific
         *     Implementation Dependent Values after 6.52"
         *
         *                                                       Minimum
         *     Get Value         Type    Get Command              Value
         *     ---------         ----    -----------              -------
         *     SAMPLES           0*xZ+   GetInternalformativ       fn1
         *     NUM_SAMPLE_COUNTS Z+      GetInternalformativ       1
         *
         *     fn1: see section 6.X."
         */
        if (buffer_size_in_elements < 1) {
                ERROR_HEADER(data_counts);
                fprintf(stderr,
                        "GL_NUM_SAMPLE_COUNTS is %d for %s/%s\n",
                        buffer_size_in_elements,
                        piglit_get_gl_enum_name(target),
                        piglit_get_gl_enum_name(format));
                return false;
        }

        test_data_set_params_size(data_samples, buffer_size_in_elements);

        /* Try GL_SAMPLES
         */
        test_data_execute(data_samples, target,
                          format, GL_SAMPLES);
        pass = piglit_check_gl_error(0)
                && pass;

        /* The GL_ARB_internalformat_query spec says:
         *
         *     "- SAMPLES: The sample counts supported for this
         *        <format> and <target> are written into <params>, in
         *        descending order. Only positive values are
         *        returned."
         *
         * We take "positive" to mean greater than zero.  Zero isn't a
         * valid sample count for multisampling.  It's the special
         * value used to request non-multisampling.
         */
        previous = INT_MAX;
        for (i = 0; i < test_data_get_params_size(data_samples); i++) {
                if (test_data_value_at_index(data_samples, i) <= 0) {
                        ERROR_HEADER(data_samples);
                        fprintf(stderr,
                                "Invalid sample count [%u] = %" PRIi64 " returned "
                                "for %s/%s (num sample counts = %i)\n",
                                i, test_data_value_at_index(data_samples, i),
                                piglit_get_gl_enum_name(target),
                                piglit_get_gl_enum_name(format),
                                buffer_size_in_elements);
                        pass = false;
                }

                if (previous == test_data_value_at_index(data_samples, i)) {
                        ERROR_HEADER(data_samples);
                        fprintf(stderr,
                                "Duplicate values [%u] = [%u] = %" PRIi64 " returned "
                                "for %s/%s (num sample counts = %i)\n",
                                i - 1, i, test_data_value_at_index(data_samples, i),
                                piglit_get_gl_enum_name(target),
                                piglit_get_gl_enum_name(format),
                                buffer_size_in_elements);
                        pass = false;
                }

                if (previous < test_data_value_at_index(data_samples, i)) {
                        ERROR_HEADER(data_samples);
                        fprintf(stderr,
                                "Values not in descending order "
                                "([%u] = %d) < ([%u] = %" PRIi64 ") returned "
                                "for %s/%s (num sample counts = %i)\n",
                                i - 1, previous,
                                i, test_data_value_at_index(data_samples, i),
                                piglit_get_gl_enum_name(target),
                                piglit_get_gl_enum_name(format),
                                buffer_size_in_elements);
                        pass = false;
                }

                previous = test_data_value_at_index(data_samples, i);
        }

        /* The GL_ARB_internalformat_query spec says:
         *
         *     "The maximum value in SAMPLES is guaranteed to be at
         *     least the lowest of the following:
         *
         *       - The value of GetIntegerv(MAX_INTEGER_SAMPLES), if
         *         <internalformat> is a signed or unsigned integer format.
         *       - The value of GetIntegerv(MAX_DEPTH_TEXTURE_SAMPLES), if
         *         <internalformat> is a depth/stencil-renderable format and
         *         <target> is TEXTURE_2D_MULTISAMPLE or
         *         TEXTURE_2D_MULTISAMPLE_ARRAY.
         *       - The value of GetIntegerv(MAX_COLOR_TEXTURE_SAMPLES), if
         *         <internalformat> is a color-renderable format and <target>
         *         is TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY.
         *       - The value of GetIntegerv(MAX_SAMPLES)."
         *
         * Separate tests will verify the values for GL_MAX_*_SAMPLES.
         */
        if (test_data_value_at_index(data_samples, 0) < max_samples) {
                ERROR_HEADER(data_samples);
                fprintf(stderr,
                        "GL_SAMPLES (%" PRIi64 ") smaller than %s (%d) "
                        "for %s/%s\n",
                        test_data_value_at_index(data_samples, 0),
                        max_samples_name,
                        max_samples,
                        piglit_get_gl_enum_name(target),
                        piglit_get_gl_enum_name(format));
                pass = false;
        }

        return pass;
}
Ejemplo n.º 9
0
/*
 * Returns if the content of @data contains the unsupported value for
 * @pname. It is assumed that the pname would return just one value.
 */
bool
test_data_is_unsupported_response(test_data *data,
                                  GLenum pname)
{
        return test_data_value_at_index(data, 0) == get_unsupported_response(pname);
}