[Piglit] [PATCH 00/40] Replace vpfp-generic with shader_runner.
Kenneth Graunke
kenneth at whitecape.org
Sat Jun 6 19:11:26 PDT 2015
Hi all,
This patch series ports all vpfp-generic tests to shader_runner,
and then deletes vpfp-generic.
A bit of history:
- vpfp-generic was introduced by Nicolai Hähnle in 2009, as a generic
ARB_vertex|fragment_program test runner.
- shader_runner was introduced by Ian Romanick in 2010, as a generic
GLSL shader runner.
- shader_runner gained ARB program support in 2011 (courtesy of Eric Anholt).
At this point, vpfp-generic is fairly redundant - shader_runner can do
everything we need, and is much more widespread (12000+ tests). I've
been meaning to delete it for a few years, but never got around to it.
One difference is that the new tests don't glClear() before drawing. Since
they draw the entire window, it's pretty unnecessary, and just makes the
tests harder to debug. Many shader_runner tests don't bother clearing.
Most of these commits were autogenerated by bash and python scripts.
The first three and last one were manual. One required an all.py squash
to prevent python breakage (which is noted in the commit message).
Here are the (write-once, read-never) scripts in case anyone is curious
(you have to run them from tests/shaders/generic):
=== convert-all ===
#! /bin/bash
for file in [^n]*.vpfp; do
case "$file" in
vp*) ;&
arl*) ;&
big-param*) ;&
dataflow*) ;&
fogcoord*)
dir='../../spec/arb_vertex_program' ;;
fp-arb-fragment*)
dir='../../spec/arb_fragment_coord_conventions' ;;
fp*) ;&
fdo*)
dir='../../spec/arb_fragment_program' ;;
*)
dir='.' ;;
esac
file_no_ext=$(basename $file .vpfp)
shader_file=$dir/$file_no_ext.shader_test
echo "Converting $file to $shader_file"
./convert-vpfp.py $file > $shader_file
git add $shader_file
git rm $file
grep -v "add_vpfpgeneric(g, '$file_no_ext')" ../../all.py > t && mv t ../../all.py
git add ../../all.py
git commit -m "Port $file to shader_runner" -m "This commit was autogenerated by Python and Bash scripting."
done
=== convert-vpfp.py ===
#! /usr/bin/python3
import re
import sys
template = '''{comments}[require]
GL >= 1.3
ARB_vertex_program
ARB_fragment_program
[vertex program]
{vptext}
[fragment program]
{fptext}
[test]
ortho 0 1 0 1
{script}'''
def convert(infile):
with open(infile, 'r') as f:
vpfp = f.read()
vpfp = re.sub('^;', '#', vpfp, flags=re.MULTILINE)
doublebang = vpfp.find('!!')
comments = vpfp[0:doublebang]
vpfp = vpfp[doublebang:]
parse = re.match('(^!!ARBvp1.0$.*^END$)\s*(^!!ARBfp1.0$.*^END$)\s*!!test\n(.*)', vpfp, re.MULTILINE | re.DOTALL)
vptext, fptext, vpfp_test = parse.groups()
script = ''
for line in vpfp_test.splitlines():
line = ' '.join(line.split()) # collapse whitespace
if line == '' or line == '!!test':
continue
if line.startswith('expected'):
script += 'draw rect 0 0 1 1\nprobe all rgba {}\n'.format(line[len('expected'):])
continue
parse = re.match('^(fragment|vertex).(local|environment)\[([0-9]+)\] ([^\s]+) ([^\s]+) ([^\s]+) ([^\s]+)', line)
if parse is not None:
params = parse.groups()
script += 'parameter {}_{}p {} ({}, {}, {}, {})\n'.format(params[1].replace('environment', 'env'), params[0][0], *params[2:])
continue
parse = re.match('^texcoord\[([0-9]+)\] ([^\s]+) ([^\s]+) ([^\s]+) ([^\s]+)', line)
if parse is not None:
script += 'texcoord {} ({}, {}, {}, {})\n'.format(*parse.groups())
continue
raise Exception("unknown line: " + line)
print(template.format(comments=comments, vptext=vptext, fptext=fptext, script=script))
if __name__ == '__main__':
convert(sys.argv[1])
--Ken
More information about the Piglit
mailing list