[Piglit] [PATCH 2/2] arb_gpu_shader_int64: add builtin test generator.

Dylan Baker dylan at pnwbakers.com
Thu Jun 9 21:52:49 UTC 2016

Quoting Dave Airlie (2016-06-08 19:50:14)
> From: Dave Airlie <airlied at redhat.com>


> +# This source file defines a set of test vectors that can be used to
> +# test GLSL's built-in functions and operators.  It is intended to be
> +# used by Python code that generates Piglit tests.
> +#
> +# The key export is the dictionary test_suite.  It contains an entry
> +# for each possible overload of every pure built-in function and
> +# operator.  By iterating through this dictionary you can find a set
> +# of test vectors for testing nearly every built-in GLSL function.
> +#
> +# The following functions are not included, since they are not pure,
> +# so they can't be tested using simple vectors:
> +# - dFdx()
> +# - dFdy()
> +# - fwidth()
> +# - ftransform()
> +# - Increment and decrement operators
> +#
> +# The following functions are not included, since they need to be
> +# tested in specialized ways:
> +# - modf(): not tested because it has an out parameter
> +# - isnan() and isinf(): not tested because special effort is required
> +#   to create values that cause these functions to return true.
> +#
> +# Also not tested are array subscripting, field/method selection,
> +# swizzling, the function call operator, assignment, and the sequence
> +# operator.

This docstring is wrong.

> +
> +from __future__ import print_function, division, absolute_import
> +import collections
> +import itertools
> +import functools
> +
> +from six.moves import range
> +import numpy as np
> +
> +
> +# Floating point types used by Python and numpy
> +INT32_TYPES = (int, np.int32)
> +UINT32_TYPES = (int, np.uint32)
> +INT64_TYPES = (long, np.int64)
> +UINT64_TYPES = (long, np.uint64)

No, you can't use int and long here, python 3 doesn't have a long type
at all, and it's int will grow until it uses all of your memory if you
ask it to, while python2 has an int and long that are equivalent to int
and long in C for your architecture. You'll need to use the numpy types
exclusively. As-is this doesn't work with python 3.x it raises a
NameError, so that at least needs to be fixed.

Also, some of the helper functions in here seem either useless, wrong,
or at least need to have their documentation updated. Many of of them
use floats, which will cause your numpy.integer types to get converted
to their numpy.float equivalent, which you probably don't want, unless
the code casts back, this code is pretty complicated.

There's also a heck of a lot of this code that is duplicated or nearly
duplicated between builtin_function.py, builtin_function_fp64.py and
this, although I don't have a good solution and I don't really want to
to de-duplicate all of that code myself, so I guess you can just ignore
this comment, consider it me complaining to no one in particular.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/piglit/attachments/20160609/b89278d7/attachment.sig>

More information about the Piglit mailing list