[Piglit] [PATCH v2 1/5] arb_uniform_buffer_object: Random test generation infrastructure
Dylan Baker
baker.dylan.c at gmail.com
Thu Sep 25 15:54:35 PDT 2014
On Friday, September 26, 2014 12:28:09 AM Daniel Martin wrote:
> Hi Ian,
>
> I haven't tested the code, but while scroling through I've found at
> least one mistake (the second comment below):
>
> On Thu, Sep 25, 2014 at 01:36:40PM -0700, Ian Romanick wrote:
> > From: Ian Romanick <ian.d.romanick at intel.com>
> ...
> > +def vector_base_type(type):
> > + """Return the type of an element from a vector."""
> > + if not isvector(type):
> > + raise Exception("Non-vector type {}".format(type))
> > +
> > + if type[0] == 'v':
> > + return "float"
> > + elif type[0] == 'i':
> > + return "int"
> > + elif type[0] == 'u':
> > + return "uint"
> > + elif type[0] == 'b':
> > + return "bool"
> > + elif type[0] == 'd':
> > + return "double"
> > + else:
> > + raise Exception("Unknown vector type {}".format(type))
>
> Imho it would look better if you replace the if/elif/else with a
> dictionary lookup:
>
> type_map = {'v':"float", 'i':"int", ...}
>
> try:
> return type_map[type[0]]
> except KeyError:
> pass
>
> raise Exception("Unknown vector type {}".format(type))
>
> ...
> > +class unique_name_dict:
> > + """Helper class to generate a unique name for each field.
> > +
> > + Fields for each particular type have names based on the type. Each name
> > + is suffixed by a number, and the number is incremented each time a field
> > + of that type is created. For example, the first int field will be named
> > + "i1", and the second will be named "i2".
> > + """
> > +
> > + def __init__(self):
> > + self.names = {}
> > +
> > + def trim_name(self, type):
> > + """Internal method to reduce a type name to a canonical form
> > +
> > + These names are used to track the type in the self.names dict.
> > +
> > + Array types have the arrayness stripped. Vector types have vector
> > + count stripped. Matrix types are converted to canonical "mat#x#"
> > + form. All other type names are unmodified.
> > + """
> > + if isarray(type):
> > + t = array_base_type(type)
> > + else:
> > + t = type
> > +
> > + if ismatrix(t):
> > + # Canonicalize matrix type names.
> > + c, r = matrix_dimensions(t)
> > +
> > + name = "mat{}x{}".format(c, r)
> > + if t[0] == "d":
> > + name = "d" + name
> > +
> > + return name
> > + elif isscalar(t):
> > + return t
> > + elif isvector:
>
> isvector misses a (t) here.
>
> ...
> > +if __name__ == "__main__":
> ...
> > + blocks = generate_block_list(
> > + glsl_version,
> > + packing,
> > + fields,
> > + layouts)
> > +
> > + print emit_shader_test(
> > + blocks,
> > + packing,
> > + glsl_version,
> > + extensions)
>
> This print statement doesn't work with python3, but a print() would (as
> well as with python2(.6)).
We use the __future__ print_function throughout piglit, I would recommend
using that instead.
>
>
> Cheers,
> Daniel Martin
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140925/55bd39c0/attachment.sig>
More information about the Piglit
mailing list