diff options
Diffstat (limited to 'progs/gallium/python/tests')
69 files changed, 0 insertions, 3070 deletions
diff --git a/progs/gallium/python/tests/.gitignore b/progs/gallium/python/tests/.gitignore deleted file mode 100644 index 0dbbaeea16b..00000000000 --- a/progs/gallium/python/tests/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.txt -*.tsv -*.dot diff --git a/progs/gallium/python/tests/base.py b/progs/gallium/python/tests/base.py deleted file mode 100755 index d8cf84db363..00000000000 --- a/progs/gallium/python/tests/base.py +++ /dev/null @@ -1,399 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2009 VMware, Inc. -# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. -# All Rights Reserved. -# -# 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, sub license, 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 NON-INFRINGEMENT. -# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. -# -########################################################################## - - -"""Base classes for tests. - -Loosely inspired on Python's unittest module. -""" - - -import os.path -import sys - -from gallium import * - - -# Enumerate all pixel formats -formats = {} -for name, value in globals().items(): - if name.startswith("PIPE_FORMAT_") and isinstance(value, int) and name not in ("PIPE_FORMAT_NONE", "PIPE_FORMAT_COUNT"): - formats[value] = name - -def make_image(width, height, rgba): - import Image - outimage = Image.new( - mode='RGB', - size=(width, height), - color=(0,0,0)) - outpixels = outimage.load() - for y in range(0, height): - for x in range(0, width): - offset = (y*width + x)*4 - r, g, b, a = [int(min(max(rgba[offset + ch], 0.0), 1.0)*255) for ch in range(4)] - outpixels[x, y] = r, g, b - return outimage - -def save_image(width, height, rgba, filename): - outimage = make_image(width, height, rgba) - outimage.save(filename, "PNG") - -def show_image(width, height, **rgbas): - import Tkinter as tk - from PIL import Image, ImageTk - - root = tk.Tk() - - x = 64 - y = 64 - - labels = rgbas.keys() - labels.sort() - for i in range(len(labels)): - label = labels[i] - outimage = make_image(width, height, rgbas[label]) - - if i: - window = tk.Toplevel(root) - else: - window = root - window.title(label) - image1 = ImageTk.PhotoImage(outimage) - w = image1.width() - h = image1.height() - window.geometry("%dx%d+%d+%d" % (w, h, x, y)) - panel1 = tk.Label(window, image=image1) - panel1.pack(side='top', fill='both', expand='yes') - panel1.image = image1 - x += w + 2 - - root.mainloop() - - -class TestFailure(Exception): - - pass - -class TestSkip(Exception): - - pass - - -class Test: - - def __init__(self): - pass - - def _run(self, result): - raise NotImplementedError - - def run(self): - result = TestResult() - self._run(result) - result.report() - - def assert_rgba(self, ctx, surface, x, y, w, h, expected_rgba, pixel_tol=4.0/256, surface_tol=0.85): - total = h*w - different = ctx.surface_compare_rgba(surface, x, y, w, h, expected_rgba, tol=pixel_tol) - if different: - sys.stderr.write("%u out of %u pixels differ\n" % (different, total)) - - if float(total - different)/float(total) < surface_tol: - if 0: - rgba = FloatArray(h*w*4) - ctx.surface_read_rgba(surface, x, y, w, h, rgba) - show_image(w, h, Result=rgba, Expected=expected_rgba) - save_image(w, h, rgba, "result.png") - save_image(w, h, expected_rgba, "expected.png") - #sys.exit(0) - - raise TestFailure - - -class TestCase(Test): - - tags = () - - def __init__(self, dev, **kargs): - Test.__init__(self) - self.dev = dev - self.__dict__.update(kargs) - - def description(self): - descriptions = [] - for tag in self.tags: - value = self.get(tag) - if value is not None and value != '': - descriptions.append(tag + '=' + str(value)) - return ' '.join(descriptions) - - def get(self, tag): - try: - method = getattr(self, '_get_' + tag) - except AttributeError: - return getattr(self, tag, None) - else: - return method() - - def _get_target(self): - return { - PIPE_TEXTURE_1D: "1d", - PIPE_TEXTURE_2D: "2d", - PIPE_TEXTURE_3D: "3d", - PIPE_TEXTURE_CUBE: "cube", - }[self.target] - - def _get_format(self): - name = formats[self.format] - if name.startswith('PIPE_FORMAT_'): - name = name[12:] - name = name.lower() - return name - - def _get_face(self): - if self.target == PIPE_TEXTURE_CUBE: - return { - PIPE_TEX_FACE_POS_X: "+x", - PIPE_TEX_FACE_NEG_X: "-x", - PIPE_TEX_FACE_POS_Y: "+y", - PIPE_TEX_FACE_NEG_Y: "-y", - PIPE_TEX_FACE_POS_Z: "+z", - PIPE_TEX_FACE_NEG_Z: "-z", - }[self.face] - else: - return '' - - def test(self): - raise NotImplementedError - - def _run(self, result): - result.test_start(self) - try: - self.test() - except KeyboardInterrupt: - raise - except TestSkip: - result.test_skipped(self) - except TestFailure: - result.test_failed(self) - else: - result.test_passed(self) - - -class TestSuite(Test): - - def __init__(self, tests = None): - Test.__init__(self) - if tests is None: - self.tests = [] - else: - self.tests = tests - - def add_test(self, test): - self.tests.append(test) - - def _run(self, result): - for test in self.tests: - test._run(result) - - -class TestResult: - - def __init__(self): - self.tests = 0 - self.passed = 0 - self.skipped = 0 - self.failed = 0 - - self.names = ['result'] - self.types = ['pass skip fail'] - self.rows = [] - - def test_start(self, test): - sys.stdout.write("Running %s...\n" % test.description()) - sys.stdout.flush() - self.tests += 1 - - def test_passed(self, test): - sys.stdout.write("PASS\n") - sys.stdout.flush() - self.passed += 1 - self.log_result(test, 'pass') - - def test_skipped(self, test): - sys.stdout.write("SKIP\n") - sys.stdout.flush() - self.skipped += 1 - self.log_result(test, 'skip') - - def test_failed(self, test): - sys.stdout.write("FAIL\n") - sys.stdout.flush() - self.failed += 1 - self.log_result(test, 'fail') - - def log_result(self, test, result): - row = ['']*len(self.names) - - # add result - assert self.names[0] == 'result' - assert result in ('pass', 'skip', 'fail') - row[0] = result - - # add tags - for tag in test.tags: - value = test.get(tag) - - # infer type - if value is None: - continue - elif isinstance(value, (int, float)): - value = str(value) - type = 'c' # continous - elif isinstance(value, basestring): - type = 'd' # discrete - else: - assert False - value = str(value) - type = 'd' # discrete - - # insert value - try: - col = self.names.index(tag, 1) - except ValueError: - self.names.append(tag) - self.types.append(type) - row.append(value) - else: - row[col] = value - assert self.types[col] == type - - self.rows.append(row) - - def report(self): - sys.stdout.write("%u tests, %u passed, %u skipped, %u failed\n\n" % (self.tests, self.passed, self.skipped, self.failed)) - sys.stdout.flush() - - name, ext = os.path.splitext(os.path.basename(sys.argv[0])) - - tree = self.report_tree(name) - self.report_junit(name, stdout=tree) - - def report_tree(self, name): - filename = name + '.tsv' - stream = file(filename, 'wt') - - # header - stream.write('\t'.join(self.names) + '\n') - stream.write('\t'.join(self.types) + '\n') - stream.write('class\n') - - # rows - for row in self.rows: - if row[0] == 'skip': - continue - row += ['']*(len(self.names) - len(row)) - stream.write('\t'.join(row) + '\n') - - stream.close() - - # See http://www.ailab.si/orange/doc/ofb/c_otherclass.htm - try: - import orange - import orngTree - except ImportError: - sys.stderr.write('Install Orange from http://www.ailab.si/orange/ for a classification tree.\n') - return None - - data = orange.ExampleTable(filename) - - tree = orngTree.TreeLearner(data, sameMajorityPruning=1, mForPruning=2) - - orngTree.printTxt(tree, maxDepth=4) - - text_tree = orngTree.dumpTree(tree) - - file(name + '.txt', 'wt').write(text_tree) - - orngTree.printDot(tree, fileName=name+'.dot', nodeShape='ellipse', leafShape='box') - - return text_tree - - def report_junit(self, name, stdout=None, stderr=None): - """Write test results in ANT's junit XML format, to use with Hudson CI. - - See also: - - http://fisheye.hudson-ci.org/browse/Hudson/trunk/hudson/main/core/src/test/resources/hudson/tasks/junit - - http://www.junit.org/node/399 - - http://wiki.apache.org/ant/Proposals/EnhancedTestReports - """ - - stream = file(name + '.xml', 'wt') - - stream.write('<?xml version="1.0" encoding="UTF-8" ?>\n') - stream.write('<testsuite name="%s">\n' % self.escape_xml(name)) - stream.write(' <properties>\n') - stream.write(' </properties>\n') - - names = self.names[1:] - - for row in self.rows: - - test_name = ' '.join(['%s=%s' % pair for pair in zip(self.names[1:], row[1:])]) - - stream.write(' <testcase name="%s">\n' % (self.escape_xml(test_name))) - - result = row[0] - if result == 'pass': - pass - elif result == 'skip': - stream.write(' <skipped/>\n') - else: - stream.write(' <failure/>\n') - - stream.write(' </testcase>\n') - - if stdout: - stream.write(' <system-out>%s</system-out>\n' % self.escape_xml(stdout)) - if stderr: - stream.write(' <system-err>%s</system-err>\n' % self.escape_xml(stderr)) - - stream.write('</testsuite>\n') - - stream.close() - - def escape_xml(self, s): - '''Escape a XML string.''' - s = s.replace('&', '&') - s = s.replace('<', '<') - s = s.replace('>', '>') - s = s.replace('"', '"') - s = s.replace("'", ''') - return s - diff --git a/progs/gallium/python/tests/regress/fragment-shader/.gitignore b/progs/gallium/python/tests/regress/fragment-shader/.gitignore deleted file mode 100644 index e33609d251c..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.png diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-abs.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-abs.sh deleted file mode 100644 index 103d7497f48..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-abs.sh +++ /dev/null @@ -1,13 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { -0.5, -0.4, -0.6, 0.0 } - -ADD TEMP[0], IN[0], IMM[0] -ABS OUT[0], TEMP[0] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-add.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-add.sh deleted file mode 100644 index bcb94205963..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-add.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -ADD OUT[0], IN[0], IN[0] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-cb-1d.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-cb-1d.sh deleted file mode 100644 index 85fb9ea4e7f..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-cb-1d.sh +++ /dev/null @@ -1,13 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR -DCL CONST[1] -DCL CONST[3] -DCL TEMP[0..1] - -ADD TEMP[0], IN[0], CONST[1] -RCP TEMP[1], CONST[3].xxxx -MUL OUT[0], TEMP[0], TEMP[1] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-cb-2d.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-cb-2d.sh deleted file mode 100644 index f70a5146f4e..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-cb-2d.sh +++ /dev/null @@ -1,9 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR -DCL CONST[1][1..2] - -MAD OUT[0], IN[0], CONST[1][2], CONST[1][1] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-dp3.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-dp3.sh deleted file mode 100644 index b5281975d4a..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-dp3.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DP3 OUT[0], IN[0], IN[0] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-dp4.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-dp4.sh deleted file mode 100644 index d59df76e70b..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-dp4.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DP4 OUT[0], IN[0].xyzx, IN[0].xyzx - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-dst.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-dst.sh deleted file mode 100644 index fbb20fa9f62..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-dst.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DST OUT[0], IN[0], IN[0] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-ex2.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-ex2.sh deleted file mode 100644 index b511288f4b6..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-ex2.sh +++ /dev/null @@ -1,11 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -EX2 TEMP[0], IN[0].xxxx -MUL OUT[0], TEMP[0], IN[0] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-flr.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-flr.sh deleted file mode 100644 index 99a2f96103a..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-flr.sh +++ /dev/null @@ -1,15 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { 2.5, 4.0, 2.0, 1.0 } -IMM FLT32 { 0.4, 0.25, 0.5, 1.0 } - -MUL TEMP[0], IN[0], IMM[0] -FLR TEMP[0], TEMP[0] -MUL OUT[0], TEMP[0], IMM[1] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-frc.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-frc.sh deleted file mode 100644 index a54c2623b0a..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-frc.sh +++ /dev/null @@ -1,13 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { 2.7, 3.1, 4.5, 1.0 } - -MUL TEMP[0], IN[0], IMM[0] -FRC OUT[0], TEMP[0] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-lg2.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-lg2.sh deleted file mode 100644 index 5f5b4be1092..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-lg2.sh +++ /dev/null @@ -1,15 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { 1.0, 0.0, 0.0, 0.0 } -IMM FLT32 { 0.5, 0.0, 0.0, 0.0 } - -ADD TEMP[0], IN[0], IMM[0] -LG2 TEMP[0].x, TEMP[0].xxxx -ADD OUT[0], TEMP[0], IMM[1] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-lit.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-lit.sh deleted file mode 100644 index 6323c4712dc..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-lit.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -LIT OUT[0], IN[0] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-lrp.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-lrp.sh deleted file mode 100644 index 740809d22e0..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-lrp.sh +++ /dev/null @@ -1,11 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -ABS TEMP[0], IN[0] -LRP OUT[0], TEMP[0], IN[0].xxxx, IN[0].yyyy - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-mad.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-mad.sh deleted file mode 100644 index 413b9dc3916..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-mad.sh +++ /dev/null @@ -1,11 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -IMM FLT32 { 0.5, 0.4, 0.6, 1.0 } -IMM FLT32 { 0.5, 0.4, 0.6, 0.0 } - -MAD OUT[0], IN[0], IMM[0], IMM[1] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-max.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-max.sh deleted file mode 100644 index b69f2132612..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-max.sh +++ /dev/null @@ -1,10 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -IMM FLT32 { 0.4, 0.4, 0.4, 0.0 } - -MAX OUT[0], IN[0], IMM[0] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-min.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-min.sh deleted file mode 100644 index df284f49e71..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-min.sh +++ /dev/null @@ -1,10 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -IMM FLT32 { 0.6, 0.6, 0.6, 1.0 } - -MIN OUT[0], IN[0], IMM[0] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-mov.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-mov.sh deleted file mode 100644 index 64af72f381b..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-mov.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -MOV OUT[0], IN[0] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-mul.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-mul.sh deleted file mode 100644 index bdd0b0026b9..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-mul.sh +++ /dev/null @@ -1,10 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -IMM FLT32 { 0.5, 0.6, 0.7, 1.0 } - -MUL OUT[0], IN[0], IMM[0] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-rcp.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-rcp.sh deleted file mode 100644 index f4b611b26ab..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-rcp.sh +++ /dev/null @@ -1,15 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { 1.0, 0.0, 0.0, 0.0 } -IMM FLT32 { 1.5, 0.0, 0.0, 0.0 } - -ADD TEMP[0], IN[0], IMM[0] -RCP TEMP[0].x, TEMP[0].xxxx -SUB OUT[0], TEMP[0], IMM[1] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-rsq.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-rsq.sh deleted file mode 100644 index d1e9b0b53be..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-rsq.sh +++ /dev/null @@ -1,15 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { 1.0, 0.0, 0.0, 0.0 } -IMM FLT32 { 1.5, 0.0, 0.0, 0.0 } - -ADD TEMP[0], IN[0], IMM[0] -RSQ TEMP[0].x, TEMP[0].xxxx -SUB OUT[0], TEMP[0], IMM[1] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-sge.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-sge.sh deleted file mode 100644 index 1f33fac4727..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-sge.sh +++ /dev/null @@ -1,13 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { 0.6, 0.6, 0.6, 0.0 } - -SGE TEMP[0], IN[0], IMM[0] -MUL OUT[0], IN[0], TEMP[0] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-slt.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-slt.sh deleted file mode 100644 index d58b7886a12..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-slt.sh +++ /dev/null @@ -1,13 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { 0.6, 0.6, 0.6, 0.0 } - -SLT TEMP[0], IN[0], IMM[0] -MUL OUT[0], IN[0], TEMP[0] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-srcmod-abs.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-srcmod-abs.sh deleted file mode 100644 index ecd19248c64..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-srcmod-abs.sh +++ /dev/null @@ -1,13 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { -0.3, -0.5, -0.4, 0.0 } - -ADD TEMP[0], IN[0], IMM[0] -MOV OUT[0], |TEMP[0]| - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-srcmod-absneg.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-srcmod-absneg.sh deleted file mode 100644 index c2d99ddd15b..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-srcmod-absneg.sh +++ /dev/null @@ -1,15 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -IMM FLT32 { -0.2, -0.3, -0.4, 0.0 } -IMM FLT32 { -1.0, -1.0, -1.0, -1.0 } - -ADD TEMP[0], IN[0], IMM[0] -MOV TEMP[0], -|TEMP[0]| -MUL OUT[0], TEMP[0], IMM[1] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-srcmod-neg.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-srcmod-neg.sh deleted file mode 100644 index a08ab6d2dcb..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-srcmod-neg.sh +++ /dev/null @@ -1,11 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -DCL TEMP[0] - -SUB TEMP[0], IN[0], IN[0].yzxw -MOV OUT[0], -TEMP[0] - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-srcmod-swz.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-srcmod-swz.sh deleted file mode 100644 index 6110647d979..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-srcmod-swz.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -MOV OUT[0], IN[0].yxzw - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-sub.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-sub.sh deleted file mode 100644 index 673fca139aa..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-sub.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -SUB OUT[0], IN[0], IN[0].yzxw - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/frag-xpd.sh b/progs/gallium/python/tests/regress/fragment-shader/frag-xpd.sh deleted file mode 100644 index 6ec8b1184cc..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/frag-xpd.sh +++ /dev/null @@ -1,8 +0,0 @@ -FRAG - -DCL IN[0], COLOR, LINEAR -DCL OUT[0], COLOR - -XPD OUT[0], IN[0], IN[0].yzxw - -END diff --git a/progs/gallium/python/tests/regress/fragment-shader/fragment-shader.py b/progs/gallium/python/tests/regress/fragment-shader/fragment-shader.py deleted file mode 100644 index ef65a9c5a1b..00000000000 --- a/progs/gallium/python/tests/regress/fragment-shader/fragment-shader.py +++ /dev/null @@ -1,257 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2009 VMware, Inc. -# All Rights Reserved. -# -# 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, sub license, 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 NON-INFRINGEMENT. -# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. -# -########################################################################## - -import struct - -from gallium import * - -def make_image(surface): - data = surface.get_tile_rgba8(0, 0, surface.width, surface.height) - - import Image - outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1) - return outimage - -def save_image(filename, surface): - outimage = make_image(surface) - outimage.save(filename, "PNG") - -def test(dev, name): - ctx = dev.context_create() - - width = 320 - height = 320 - minz = 0.0 - maxz = 1.0 - - # disabled blending/masking - blend = Blend() - blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].colormask = PIPE_MASK_RGBA - ctx.set_blend(blend) - - # depth/stencil/alpha - depth_stencil_alpha = DepthStencilAlpha() - depth_stencil_alpha.depth.enabled = 0 - depth_stencil_alpha.depth.writemask = 1 - depth_stencil_alpha.depth.func = PIPE_FUNC_LESS - ctx.set_depth_stencil_alpha(depth_stencil_alpha) - - # rasterizer - rasterizer = Rasterizer() - rasterizer.front_winding = PIPE_WINDING_CW - rasterizer.cull_mode = PIPE_WINDING_NONE - rasterizer.scissor = 1 - ctx.set_rasterizer(rasterizer) - - # viewport - viewport = Viewport() - scale = FloatArray(4) - scale[0] = width / 2.0 - scale[1] = -height / 2.0 - scale[2] = (maxz - minz) / 2.0 - scale[3] = 1.0 - viewport.scale = scale - translate = FloatArray(4) - translate[0] = width / 2.0 - translate[1] = height / 2.0 - translate[2] = (maxz - minz) / 2.0 - translate[3] = 0.0 - viewport.translate = translate - ctx.set_viewport(viewport) - - # samplers - sampler = Sampler() - sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE - sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.normalized_coords = 1 - ctx.set_fragment_sampler(0, sampler) - - # scissor - scissor = Scissor() - scissor.minx = 0 - scissor.miny = 0 - scissor.maxx = width - scissor.maxy = height - ctx.set_scissor(scissor) - - clip = Clip() - clip.nr = 0 - ctx.set_clip(clip) - - # framebuffer - cbuf = dev.resource_create( - PIPE_FORMAT_B8G8R8X8_UNORM, - width, height, - bind=PIPE_BIND_RENDER_TARGET, - ).get_surface() - fb = Framebuffer() - fb.width = width - fb.height = height - fb.nr_cbufs = 1 - fb.set_cbuf(0, cbuf) - ctx.set_framebuffer(fb) - rgba = FloatArray(4); - rgba[0] = 0.5 - rgba[1] = 0.5 - rgba[2] = 0.5 - rgba[3] = 0.5 - ctx.clear(PIPE_CLEAR_COLOR, rgba, 0.0, 0) - - # vertex shader - vs = Shader(''' - VERT - DCL IN[0], POSITION - DCL IN[1], COLOR - DCL OUT[0], POSITION - DCL OUT[1], COLOR - MOV OUT[0], IN[0] - MOV OUT[1], IN[1] - END - ''') - ctx.set_vertex_shader(vs) - - # fragment shader - fs = Shader(file('frag-' + name + '.sh', 'rt').read()) - ctx.set_fragment_shader(fs) - - constbuf0 = dev.buffer_create(64, - (PIPE_BUFFER_USAGE_CONSTANT | - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE), - 4 * 4 * 4) - - cbdata = '' - cbdata += struct.pack('4f', 0.4, 0.0, 0.0, 1.0) - cbdata += struct.pack('4f', 1.0, 1.0, 1.0, 1.0) - cbdata += struct.pack('4f', 2.0, 2.0, 2.0, 2.0) - cbdata += struct.pack('4f', 4.0, 8.0, 16.0, 32.0) - - constbuf0.write(cbdata, 0) - - ctx.set_constant_buffer(PIPE_SHADER_FRAGMENT, - 0, - constbuf0) - - constbuf1 = dev.buffer_create(64, - (PIPE_BUFFER_USAGE_CONSTANT | - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE), - 4 * 4 * 4) - - cbdata = '' - cbdata += struct.pack('4f', 0.1, 0.1, 0.1, 0.1) - cbdata += struct.pack('4f', 0.25, 0.25, 0.25, 0.25) - cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5) - cbdata += struct.pack('4f', 0.75, 0.75, 0.75, 0.75) - - constbuf1.write(cbdata, 0) - - ctx.set_constant_buffer(PIPE_SHADER_FRAGMENT, - 1, - constbuf1) - - xy = [ - -0.8, -0.8, - 0.8, -0.8, - 0.0, 0.8, - ] - color = [ - 1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0, - ] - - nverts = 3 - nattrs = 2 - verts = FloatArray(nverts * nattrs * 4) - - for i in range(0, nverts): - verts[i * nattrs * 4 + 0] = xy[i * 2 + 0] # x - verts[i * nattrs * 4 + 1] = xy[i * 2 + 1] # y - verts[i * nattrs * 4 + 2] = 0.5 # z - verts[i * nattrs * 4 + 3] = 1.0 # w - verts[i * nattrs * 4 + 4] = color[i * 3 + 0] # r - verts[i * nattrs * 4 + 5] = color[i * 3 + 1] # g - verts[i * nattrs * 4 + 6] = color[i * 3 + 2] # b - verts[i * nattrs * 4 + 7] = 1.0 # a - - ctx.draw_vertices(PIPE_PRIM_TRIANGLES, - nverts, - nattrs, - verts) - - ctx.flush() - - save_image('frag-' + name + '.png', cbuf) - -def main(): - tests = [ - 'abs', - 'add', - 'cb-1d', - 'cb-2d', - 'dp3', - 'dp4', - 'dst', - 'ex2', - 'flr', - 'frc', - 'lg2', - 'lit', - 'lrp', - 'mad', - 'max', - 'min', - 'mov', - 'mul', - 'rcp', - 'rsq', - 'sge', - 'slt', - 'srcmod-abs', - 'srcmod-absneg', - 'srcmod-neg', - 'srcmod-swz', - 'sub', - 'xpd', - ] - - dev = Device() - for t in tests: - test(dev, t) - -if __name__ == '__main__': - main() diff --git a/progs/gallium/python/tests/regress/vertex-shader/.gitignore b/progs/gallium/python/tests/regress/vertex-shader/.gitignore deleted file mode 100644 index e33609d251c..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.png diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-abs.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-abs.sh deleted file mode 100644 index 79c9ca69fb1..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-abs.sh +++ /dev/null @@ -1,15 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR -DCL TEMP[0] - -IMM FLT32 { 0.2, 0.2, 0.0, 0.0 } - -ADD TEMP[0], IN[0], IMM[0] -ABS OUT[0], TEMP[0] -MOV OUT[1], IN[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-add.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-add.sh deleted file mode 100644 index ca97ad05df0..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-add.sh +++ /dev/null @@ -1,13 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -IMM FLT32 { 0.2, -0.1, 0.0, 0.0 } - -ADD OUT[0], IN[0], IMM[0] -MOV OUT[1], IN[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-arl.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-arl.sh deleted file mode 100644 index 321140e89e8..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-arl.sh +++ /dev/null @@ -1,23 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -DCL TEMP[0] - -DCL ADDR[0] - -IMM FLT32 { 3.0, 1.0, 1.0, 1.0 } -IMM FLT32 { 1.0, 0.0, 0.0, 1.0 } -IMM FLT32 { 0.0, 1.0, 0.0, 1.0 } -IMM FLT32 { 0.0, 0.0, 1.0, 1.0 } -IMM FLT32 { 1.0, 1.0, 0.0, 1.0 } -IMM FLT32 { 0.0, 1.0, 1.0, 1.0 } - -MOV OUT[0], IN[0] -MUL TEMP[0], IN[0], IMM[0] -ARL ADDR[0].x, TEMP[0] -MOV OUT[1], IMM[ADDR[0].x + 3] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-arr.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-arr.sh deleted file mode 100644 index d60ea46b367..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-arr.sh +++ /dev/null @@ -1,23 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -DCL TEMP[0] - -DCL ADDR[0] - -IMM FLT32 { 3.0, 1.0, 1.0, 1.0 } -IMM FLT32 { 1.0, 0.0, 0.0, 1.0 } -IMM FLT32 { 0.0, 1.0, 0.0, 1.0 } -IMM FLT32 { 0.0, 0.0, 1.0, 1.0 } -IMM FLT32 { 1.0, 1.0, 0.0, 1.0 } -IMM FLT32 { 0.0, 1.0, 1.0, 1.0 } - -MOV OUT[0], IN[0] -MUL TEMP[0], IN[0], IMM[0] -ARR ADDR[0].x, TEMP[0] -MOV OUT[1], IMM[ADDR[0].x + 3] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-cb-1d.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-cb-1d.sh deleted file mode 100644 index b41fe5dd38f..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-cb-1d.sh +++ /dev/null @@ -1,16 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR -DCL CONST[1] -DCL CONST[3] -DCL TEMP[0..1] - -MOV OUT[0], IN[0] -ADD TEMP[0], IN[1], CONST[1] -RCP TEMP[1], CONST[3].xxxx -MUL OUT[1], TEMP[0], TEMP[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-cb-2d.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-cb-2d.sh deleted file mode 100644 index 45f5e6b7299..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-cb-2d.sh +++ /dev/null @@ -1,12 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR -DCL CONST[1][1..2] - -MOV OUT[0], IN[0] -MAD OUT[1], IN[1], CONST[1][2], CONST[1][1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-dp3.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-dp3.sh deleted file mode 100644 index caff622fe61..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-dp3.sh +++ /dev/null @@ -1,16 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR -DCL TEMP[0] - -IMM FLT32 { 0.0, 0.0, 1.0, 1.0 } - -DP3 TEMP[0].xy, IN[0], IN[0] -MOV TEMP[0].zw, IMM[0] -MUL OUT[0], IN[0], TEMP[0] -MOV OUT[1], IN[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-dp4.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-dp4.sh deleted file mode 100644 index 3dd2fd1c2f7..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-dp4.sh +++ /dev/null @@ -1,16 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR -DCL TEMP[0] - -IMM FLT32 { 0.0, 0.0, 1.0, 1.0 } - -DP4 TEMP[0].xy, IN[0], IN[0] -MOV TEMP[0].zw, IMM[0] -MUL OUT[0], IN[0], TEMP[0] -MOV OUT[1], IN[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-dst.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-dst.sh deleted file mode 100644 index da9cc18dfc0..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-dst.sh +++ /dev/null @@ -1,11 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -MOV OUT[0], IN[0] -DST OUT[1], IN[1], IN[0] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-ex2.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-ex2.sh deleted file mode 100644 index 4637227e5c4..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-ex2.sh +++ /dev/null @@ -1,18 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -DCL TEMP[0..1] - -IMM FLT32 { 0.3, 0.3, 0.3, 1.0 } - -EX2 TEMP[0], IN[0] -EX2 TEMP[1], IN[1].yyyy -MUL TEMP[0], TEMP[0], IMM[0] -MOV OUT[0], IN[0] -MUL OUT[1], TEMP[0], TEMP[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-flr.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-flr.sh deleted file mode 100644 index aa80d6e394c..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-flr.sh +++ /dev/null @@ -1,23 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -DCL TEMP[0] - -DCL ADDR[0] - -IMM FLT32 { 3.0, 1.0, 1.0, 1.0 } -IMM FLT32 { 1.0, 0.0, 0.0, 1.0 } -IMM FLT32 { 0.0, 1.0, 0.0, 1.0 } -IMM FLT32 { 0.0, 0.0, 1.0, 1.0 } -IMM FLT32 { 1.0, 1.0, 0.0, 1.0 } -IMM FLT32 { 0.0, 1.0, 1.0, 1.0 } - -MOV OUT[0], IN[0] -MUL TEMP[0], IN[0], IMM[0] -FLR ADDR[0].x, TEMP[0] -MOV OUT[1], IMM[ADDR[0].x + 3] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-frc.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-frc.sh deleted file mode 100644 index 64d1a494e13..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-frc.sh +++ /dev/null @@ -1,15 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -DCL TEMP[0] - -IMM FLT32 { 2.7, 3.1, 4.5, 1.0 } - -MUL TEMP[0], IN[0].xyxw, IMM[0] -MOV OUT[0], IN[0] -FRC OUT[1], TEMP[0] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-lg2.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-lg2.sh deleted file mode 100644 index 5cf16fd1aa8..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-lg2.sh +++ /dev/null @@ -1,18 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -DCL TEMP[0] - -IMM FLT32 { 1.0, 0.0, 0.0, 0.0 } -IMM FLT32 { 0.5, 0.0, 0.0, 0.0 } - -ADD TEMP[0], IN[0], IMM[0] -LG2 TEMP[0].x, TEMP[0].xxxx -ADD OUT[0], TEMP[0], IMM[1] -MOV OUT[1], IN[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-lit.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-lit.sh deleted file mode 100644 index a4a752d4d23..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-lit.sh +++ /dev/null @@ -1,11 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -MOV OUT[0], IN[0] -LIT OUT[1], IN[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-lrp.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-lrp.sh deleted file mode 100644 index 4bb5f3ec3f4..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-lrp.sh +++ /dev/null @@ -1,14 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -DCL TEMP[0] - -ABS TEMP[0], IN[0] -MOV OUT[0], IN[0] -LRP OUT[1], TEMP[0], IN[1].xxxx, IN[1].yyyy - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-mad.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-mad.sh deleted file mode 100644 index daaa941f15f..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-mad.sh +++ /dev/null @@ -1,14 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -IMM FLT32 { 0.5, 1.0, 1.0, 1.0 } -IMM FLT32 { 0.5, 0.0, 0.0, 0.0 } - -MAD OUT[0], IN[0], IMM[0], IMM[1] -MOV OUT[1], IN[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-max.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-max.sh deleted file mode 100644 index af279ec7f4a..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-max.sh +++ /dev/null @@ -1,13 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -IMM FLT32 { 0.5, 0.5, 0.5, 0.0 } - -MOV OUT[0], IN[0] -MAX OUT[1], IN[1], IMM[0] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-min.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-min.sh deleted file mode 100644 index 46d886c55b8..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-min.sh +++ /dev/null @@ -1,13 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -IMM FLT32 { 0.5, 0.5, 0.5, 0.0 } - -MOV OUT[0], IN[0] -MIN OUT[1], IN[1], IMM[0] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-mov.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-mov.sh deleted file mode 100644 index 0ef91637e03..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-mov.sh +++ /dev/null @@ -1,11 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -MOV OUT[0], IN[0] -MOV OUT[1], IN[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-mul.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-mul.sh deleted file mode 100644 index d34f6cd6e3c..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-mul.sh +++ /dev/null @@ -1,13 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -IMM FLT32 { 0.6, 0.6, 1.0, 1.0 } - -MUL OUT[0], IN[0], IMM[0] -MOV OUT[1], IN[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-rcp.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-rcp.sh deleted file mode 100644 index cfb3ec37dc2..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-rcp.sh +++ /dev/null @@ -1,18 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -DCL TEMP[0] - -IMM FLT32 { 1.0, 0.0, 0.0, 0.0 } -IMM FLT32 { 1.5, 0.0, 0.0, 0.0 } - -ADD TEMP[0], IN[0], IMM[0] -RCP TEMP[0].x, TEMP[0].xxxx -SUB OUT[0], TEMP[0], IMM[1] -MOV OUT[1], IN[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-rsq.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-rsq.sh deleted file mode 100644 index faf1e6e7d41..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-rsq.sh +++ /dev/null @@ -1,18 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -DCL TEMP[0] - -IMM FLT32 { 1.0, 0.0, 0.0, 0.0 } -IMM FLT32 { 1.5, 0.0, 0.0, 0.0 } - -ADD TEMP[0], IN[0], IMM[0] -RSQ TEMP[0].x, TEMP[0].xxxx -SUB OUT[0], TEMP[0], IMM[1] -MOV OUT[1], IN[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-sge.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-sge.sh deleted file mode 100644 index 6de1d071ef4..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-sge.sh +++ /dev/null @@ -1,16 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -DCL TEMP[0] - -IMM FLT32 { -0.1, -0.1, 1.0, 0.0 } - -SGE TEMP[0], IN[0], IMM[0] -MOV OUT[0], IN[0] -MUL OUT[1], IN[1], TEMP[0] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-slt.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-slt.sh deleted file mode 100644 index 9a524229845..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-slt.sh +++ /dev/null @@ -1,16 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -DCL TEMP[0] - -IMM FLT32 { 0.6, 0.6, 0.0, 0.0 } - -SLT TEMP[0], IN[0], IMM[0] -MOV OUT[0], IN[0] -MUL OUT[1], IN[1], TEMP[0] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-srcmod-abs.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-srcmod-abs.sh deleted file mode 100644 index dc87ce4ae70..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-srcmod-abs.sh +++ /dev/null @@ -1,15 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR -DCL TEMP[0] - -IMM FLT32 { 0.1, 0.1, 0.0, 0.0 } - -ADD TEMP[0], IN[0], IMM[0] -MOV OUT[0], |TEMP[0]| -MOV OUT[1], IN[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-srcmod-absneg.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-srcmod-absneg.sh deleted file mode 100644 index d82eb08fd30..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-srcmod-absneg.sh +++ /dev/null @@ -1,16 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR -DCL TEMP[0] - -IMM FLT32 { -0.2, -0.2, 0.0, 0.0 } - -ADD TEMP[0], IN[0], IMM[0] -MOV OUT[0].xy, -|TEMP[0]| -MOV OUT[0].zw, IN[0] -MOV OUT[1], IN[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-srcmod-neg.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-srcmod-neg.sh deleted file mode 100644 index e39bebcd9f1..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-srcmod-neg.sh +++ /dev/null @@ -1,12 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -MOV OUT[0].xy, -IN[0] -MOV OUT[0].zw, IN[0] -MOV OUT[1], IN[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-srcmod-swz.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-srcmod-swz.sh deleted file mode 100644 index 6f20552f212..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-srcmod-swz.sh +++ /dev/null @@ -1,11 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -MOV OUT[0], IN[0].yxzw -MOV OUT[1], IN[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-sub.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-sub.sh deleted file mode 100644 index 0f9678b8a3e..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-sub.sh +++ /dev/null @@ -1,13 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -IMM FLT32 { 0.1, 0.1, 0.0, 0.0 } - -SUB OUT[0], IN[0], IMM[0] -MOV OUT[1], IN[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vert-xpd.sh b/progs/gallium/python/tests/regress/vertex-shader/vert-xpd.sh deleted file mode 100644 index 39d42ae2a0d..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vert-xpd.sh +++ /dev/null @@ -1,11 +0,0 @@ -VERT - -DCL IN[0], POSITION -DCL IN[1], COLOR -DCL OUT[0], POSITION -DCL OUT[1], COLOR - -MOV OUT[0], IN[0] -XPD OUT[1], IN[0], IN[1] - -END diff --git a/progs/gallium/python/tests/regress/vertex-shader/vertex-shader.py b/progs/gallium/python/tests/regress/vertex-shader/vertex-shader.py deleted file mode 100644 index 05e40dbd5f1..00000000000 --- a/progs/gallium/python/tests/regress/vertex-shader/vertex-shader.py +++ /dev/null @@ -1,287 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2009 VMware, Inc. -# All Rights Reserved. -# -# 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, sub license, 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 NON-INFRINGEMENT. -# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. -# -########################################################################## - - -import struct - -from gallium import * - -def make_image(surface): - data = surface.get_tile_rgba8(0, 0, surface.width, surface.height) - - import Image - outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1) - return outimage - -def save_image(filename, surface): - outimage = make_image(surface) - outimage.save(filename, "PNG") - -def test(dev, name): - ctx = dev.context_create() - - width = 320 - height = 320 - minz = 0.0 - maxz = 1.0 - - # disabled blending/masking - blend = Blend() - blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].colormask = PIPE_MASK_RGBA - ctx.set_blend(blend) - - # depth/stencil/alpha - depth_stencil_alpha = DepthStencilAlpha() - depth_stencil_alpha.depth.enabled = 0 - depth_stencil_alpha.depth.writemask = 1 - depth_stencil_alpha.depth.func = PIPE_FUNC_LESS - ctx.set_depth_stencil_alpha(depth_stencil_alpha) - - # rasterizer - rasterizer = Rasterizer() - rasterizer.front_winding = PIPE_WINDING_CW - rasterizer.cull_mode = PIPE_WINDING_NONE - rasterizer.scissor = 1 - ctx.set_rasterizer(rasterizer) - - # viewport - viewport = Viewport() - scale = FloatArray(4) - scale[0] = width / 2.0 - scale[1] = -height / 2.0 - scale[2] = (maxz - minz) / 2.0 - scale[3] = 1.0 - viewport.scale = scale - translate = FloatArray(4) - translate[0] = width / 2.0 - translate[1] = height / 2.0 - translate[2] = (maxz - minz) / 2.0 - translate[3] = 0.0 - viewport.translate = translate - ctx.set_viewport(viewport) - - # samplers - sampler = Sampler() - sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE - sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.normalized_coords = 1 - ctx.set_fragment_sampler(0, sampler) - - # scissor - scissor = Scissor() - scissor.minx = 0 - scissor.miny = 0 - scissor.maxx = width - scissor.maxy = height - ctx.set_scissor(scissor) - - clip = Clip() - clip.nr = 0 - ctx.set_clip(clip) - - # framebuffer - cbuf = dev.resource_create( - PIPE_FORMAT_B8G8R8X8_UNORM, - width, height, - bind=PIPE_BIND_RENDER_TARGET, - ).get_surface() - fb = Framebuffer() - fb.width = width - fb.height = height - fb.nr_cbufs = 1 - fb.set_cbuf(0, cbuf) - ctx.set_framebuffer(fb) - rgba = FloatArray(4); - rgba[0] = 0.5 - rgba[1] = 0.5 - rgba[2] = 0.5 - rgba[3] = 0.5 - ctx.clear(PIPE_CLEAR_COLOR, rgba, 0.0, 0) - - # vertex shader - vs = Shader(file('vert-' + name + '.sh', 'rt').read()) - ctx.set_vertex_shader(vs) - - # fragment shader - fs = Shader(''' - FRAG - DCL IN[0], COLOR, LINEAR - DCL OUT[0], COLOR, CONSTANT - 0:MOV OUT[0], IN[0] - 1:END - ''') - ctx.set_fragment_shader(fs) - - constbuf0 = dev.buffer_create(64, - (PIPE_BUFFER_USAGE_CONSTANT | - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE), - 4 * 4 * 4) - - cbdata = '' - cbdata += struct.pack('4f', 0.4, 0.0, 0.0, 1.0) - cbdata += struct.pack('4f', 1.0, 1.0, 1.0, 1.0) - cbdata += struct.pack('4f', 2.0, 2.0, 2.0, 2.0) - cbdata += struct.pack('4f', 4.0, 8.0, 16.0, 32.0) - - constbuf0.write(cbdata, 0) - - ctx.set_constant_buffer(PIPE_SHADER_VERTEX, - 0, - constbuf0) - - constbuf1 = dev.buffer_create(64, - (PIPE_BUFFER_USAGE_CONSTANT | - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE), - 4 * 4 * 4) - - cbdata = '' - cbdata += struct.pack('4f', 0.1, 0.1, 0.1, 0.1) - cbdata += struct.pack('4f', 0.25, 0.25, 0.25, 0.25) - cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5) - cbdata += struct.pack('4f', 0.75, 0.75, 0.75, 0.75) - - constbuf1.write(cbdata, 0) - - ctx.set_constant_buffer(PIPE_SHADER_VERTEX, - 1, - constbuf1) - - xy = [ - 0.0, 0.8, - -0.2, 0.4, - 0.2, 0.4, - -0.4, 0.0, - 0.0, 0.0, - 0.4, 0.0, - -0.6, -0.4, - -0.2, -0.4, - 0.2, -0.4, - 0.6, -0.4, - -0.8, -0.8, - -0.4, -0.8, - 0.0, -0.8, - 0.4, -0.8, - 0.8, -0.8, - ] - color = [ - 1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0, - ] - tri = [ - 1, 2, 0, - 3, 4, 1, - 4, 2, 1, - 4, 5, 2, - 6, 7, 3, - 7, 4, 3, - 7, 8, 4, - 8, 5, 4, - 8, 9, 5, - 10, 11, 6, - 11, 7, 6, - 11, 12, 7, - 12, 8, 7, - 12, 13, 8, - 13, 9, 8, - 13, 14, 9, - ] - - nverts = 16 * 3 - nattrs = 2 - verts = FloatArray(nverts * nattrs * 4) - - for i in range(0, nverts): - verts[i * nattrs * 4 + 0] = xy[tri[i] * 2 + 0] # x - verts[i * nattrs * 4 + 1] = xy[tri[i] * 2 + 1] # y - verts[i * nattrs * 4 + 2] = 0.5 # z - verts[i * nattrs * 4 + 3] = 1.0 # w - verts[i * nattrs * 4 + 4] = color[(i % 3) * 3 + 0] # r - verts[i * nattrs * 4 + 5] = color[(i % 3) * 3 + 1] # g - verts[i * nattrs * 4 + 6] = color[(i % 3) * 3 + 2] # b - verts[i * nattrs * 4 + 7] = 1.0 # a - - ctx.draw_vertices(PIPE_PRIM_TRIANGLES, - nverts, - nattrs, - verts) - - ctx.flush() - - save_image('vert-' + name + '.png', cbuf) - -def main(): - tests = [ - 'abs', - 'add', - 'arl', - 'arr', - 'cb-1d', - 'cb-2d', - 'dp3', - 'dp4', - 'dst', - 'ex2', - 'flr', - 'frc', - 'lg2', - 'lit', - 'lrp', - 'mad', - 'max', - 'min', - 'mov', - 'mul', - 'rcp', - 'rsq', - 'sge', - 'slt', - 'srcmod-abs', - 'srcmod-absneg', - 'srcmod-neg', - 'srcmod-swz', - 'sub', - 'xpd', - ] - - dev = Device() - for t in tests: - test(dev, t) - -if __name__ == '__main__': - main() diff --git a/progs/gallium/python/tests/surface_copy.py b/progs/gallium/python/tests/surface_copy.py deleted file mode 100755 index 8d841644035..00000000000 --- a/progs/gallium/python/tests/surface_copy.py +++ /dev/null @@ -1,200 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2009 VMware, Inc. -# All Rights Reserved. -# -# 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, sub license, 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 NON-INFRINGEMENT. -# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. -# -########################################################################## - - -import os -import random - -from gallium import * -from base import * - - -def lods(*dims): - size = max(dims) - lods = 0 - while size: - lods += 1 - size >>= 1 - return lods - - -class TextureTest(TestCase): - - tags = ( - 'target', - 'format', - 'width', - 'height', - 'depth', - 'last_level', - 'face', - 'level', - 'zslice', - ) - - def test(self): - dev = self.dev - ctx = self.ctx - - target = self.target - format = self.format - width = self.width - height = self.height - depth = self.depth - last_level = self.last_level - face = self.face - level = self.level - zslice = self.zslice - - bind = PIPE_BIND_SAMPLER_VIEW - geom_flags = 0 - if not dev.is_format_supported(format, target, bind, geom_flags): - raise TestSkip - - if not dev.is_format_supported(format, target, bind, geom_flags): - raise TestSkip - - # textures - dst_texture = dev.resource_create( - target = target, - format = format, - width = width, - height = height, - depth = depth, - last_level = last_level, - bind = bind, - ) - - dst_surface = dst_texture.get_surface(face = face, level = level, zslice = zslice) - - src_texture = dev.resource_create( - target = target, - format = format, - width = dst_surface.width, - height = dst_surface.height, - depth = 1, - last_level = 0, - bind = PIPE_BIND_SAMPLER_VIEW, - ) - - src_surface = src_texture.get_surface() - - w = dst_surface.width - h = dst_surface.height - - stride = util_format_get_stride(format, w) - size = util_format_get_nblocksy(format, h) * stride - src_raw = os.urandom(size) - - ctx.surface_write_raw(src_surface, 0, 0, w, h, src_raw, stride) - - ctx.surface_copy(dst_surface, 0, 0, - src_surface, 0, 0, w, h) - - dst_raw = ctx.surface_read_raw(dst_surface, 0, 0, w, h) - - if dst_raw != src_raw: - raise TestFailure - - -def main(): - dev = Device() - ctx = dev.context_create() - suite = TestSuite() - - targets = [ - PIPE_TEXTURE_2D, - PIPE_TEXTURE_CUBE, - PIPE_TEXTURE_3D, - ] - - sizes = [64, 32, 16, 8, 4, 2, 1] - #sizes = [1020, 508, 252, 62, 30, 14, 6, 3] - #sizes = [64] - #sizes = [63] - - faces = [ - PIPE_TEX_FACE_POS_X, - PIPE_TEX_FACE_NEG_X, - PIPE_TEX_FACE_POS_Y, - PIPE_TEX_FACE_NEG_Y, - PIPE_TEX_FACE_POS_Z, - PIPE_TEX_FACE_NEG_Z, - ] - - try: - n = int(sys.argv[1]) - except: - n = 10000 - - for i in range(n): - format = random.choice(formats.keys()) - if not util_format_is_depth_or_stencil(format): - is_depth_or_stencil = util_format_is_depth_or_stencil(format) - - if is_depth_or_stencil: - target = PIPE_TEXTURE_2D - else: - target = random.choice(targets) - - size = random.choice(sizes) - - if target == PIPE_TEXTURE_3D: - depth = size - else: - depth = 1 - - if target == PIPE_TEXTURE_CUBE: - face = random.choice(faces) - else: - face = PIPE_TEX_FACE_POS_X - - levels = lods(size) - last_level = random.randint(0, levels - 1) - level = random.randint(0, last_level) - zslice = random.randint(0, max(depth >> level, 1) - 1) - - test = TextureTest( - dev = dev, - ctx = ctx, - target = target, - format = format, - width = size, - height = size, - depth = depth, - last_level = last_level, - face = face, - level = level, - zslice = zslice, - ) - suite.add_test(test) - suite.run() - - -if __name__ == '__main__': - main() diff --git a/progs/gallium/python/tests/texture_blit.py b/progs/gallium/python/tests/texture_blit.py deleted file mode 100755 index 77f006ea04e..00000000000 --- a/progs/gallium/python/tests/texture_blit.py +++ /dev/null @@ -1,636 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2009 VMware, Inc. -# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. -# All Rights Reserved. -# -# 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, sub license, 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 NON-INFRINGEMENT. -# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. -# -########################################################################## - - -import random - -from gallium import * -from base import * - - -def lods(*dims): - size = max(dims) - lods = 0 - while size: - lods += 1 - size >>= 1 - return lods - - -def minify(dims, level = 1): - return [max(dim>>level, 1) for dim in dims] - - -def tex_coords(texture, face, level, zslice): - st = [ - [0.0, 0.0], - [1.0, 0.0], - [1.0, 1.0], - [0.0, 1.0], - ] - - if texture.target == PIPE_TEXTURE_2D: - return [[s, t, 0.0] for s, t in st] - elif texture.target == PIPE_TEXTURE_3D: - depth = texture.get_depth(level) - if depth > 1: - r = float(zslice)/float(depth - 1) - else: - r = 0.0 - return [[s, t, r] for s, t in st] - elif texture.target == PIPE_TEXTURE_CUBE: - result = [] - for s, t in st: - # See http://developer.nvidia.com/object/cube_map_ogl_tutorial.html - sc = 2.0*s - 1.0 - tc = 2.0*t - 1.0 - if face == PIPE_TEX_FACE_POS_X: - rx = 1.0 - ry = -tc - rz = -sc - if face == PIPE_TEX_FACE_NEG_X: - rx = -1.0 - ry = -tc - rz = sc - if face == PIPE_TEX_FACE_POS_Y: - rx = sc - ry = 1.0 - rz = tc - if face == PIPE_TEX_FACE_NEG_Y: - rx = sc - ry = -1.0 - rz = -tc - if face == PIPE_TEX_FACE_POS_Z: - rx = sc - ry = -tc - rz = 1.0 - if face == PIPE_TEX_FACE_NEG_Z: - rx = -sc - ry = -tc - rz = -1.0 - result.append([rx, ry, rz]) - return result - -def is_pot(n): - return n & (n - 1) == 0 - - -class TextureColorSampleTest(TestCase): - - tags = ( - 'target', - 'format', - 'width', - 'height', - 'depth', - 'last_level', - 'face', - 'level', - 'zslice', - ) - - def test(self): - dev = self.dev - ctx = self.ctx - - target = self.target - format = self.format - width = self.width - height = self.height - depth = self.depth - last_level = self.last_level - face = self.face - level = self.level - zslice = self.zslice - minz = 0.0 - maxz = 1.0 - - bind = PIPE_BIND_SAMPLER_VIEW - geom_flags = 0 - if width != height: - geom_flags |= PIPE_TEXTURE_GEOM_NON_SQUARE - if not is_pot(width) or not is_pot(height) or not is_pot(depth): - geom_flags |= PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO - - if not dev.is_format_supported(format, target, bind, geom_flags): - raise TestSkip - - # disabled blending/masking - blend = Blend() - blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].colormask = PIPE_MASK_RGBA - ctx.set_blend(blend) - - # no-op depth/stencil/alpha - depth_stencil_alpha = DepthStencilAlpha() - ctx.set_depth_stencil_alpha(depth_stencil_alpha) - - # rasterizer - rasterizer = Rasterizer() - rasterizer.front_winding = PIPE_WINDING_CW - rasterizer.cull_mode = PIPE_WINDING_NONE - ctx.set_rasterizer(rasterizer) - - # samplers - sampler = Sampler() - sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.normalized_coords = 1 - sampler.min_lod = 0 - sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1 - ctx.set_fragment_sampler(0, sampler) - - # texture - texture = dev.resource_create( - target = target, - format = format, - width = width, - height = height, - depth = depth, - last_level = last_level, - bind = bind, - ) - - expected_rgba = FloatArray(height*width*4) - surface = texture.get_surface( - face = face, - level = level, - zslice = zslice, - ) - - ctx.surface_sample_rgba(surface, expected_rgba, True) - - ctx.set_fragment_sampler_texture(0, texture) - - # viewport - viewport = Viewport() - scale = FloatArray(4) - scale[0] = width - scale[1] = height - scale[2] = (maxz - minz) / 2.0 - scale[3] = 1.0 - viewport.scale = scale - translate = FloatArray(4) - translate[0] = 0.0 - translate[1] = 0.0 - translate[2] = (maxz - minz) / 2.0 - translate[3] = 0.0 - viewport.translate = translate - ctx.set_viewport(viewport) - - # scissor - scissor = Scissor() - scissor.minx = 0 - scissor.miny = 0 - scissor.maxx = width - scissor.maxy = height - ctx.set_scissor(scissor) - - # clip - clip = Clip() - clip.nr = 0 - ctx.set_clip(clip) - - # framebuffer - cbuf_tex = dev.resource_create( - PIPE_FORMAT_B8G8R8A8_UNORM, - width, - height, - bind = PIPE_BIND_RENDER_TARGET, - ) - - cbuf = cbuf_tex.get_surface() - fb = Framebuffer() - fb.width = width - fb.height = height - fb.nr_cbufs = 1 - fb.set_cbuf(0, cbuf) - ctx.set_framebuffer(fb) - rgba = FloatArray(4); - rgba[0] = 0.5 - rgba[1] = 0.5 - rgba[2] = 0.5 - rgba[3] = 0.5 - ctx.clear(PIPE_CLEAR_COLOR, rgba, 0.0, 0) - del fb - - # vertex shader - vs = Shader(''' - VERT - DCL IN[0], POSITION, CONSTANT - DCL IN[1], GENERIC, CONSTANT - DCL OUT[0], POSITION, CONSTANT - DCL OUT[1], GENERIC, CONSTANT - 0:MOV OUT[0], IN[0] - 1:MOV OUT[1], IN[1] - 2:END - ''') - #vs.dump() - ctx.set_vertex_shader(vs) - - # fragment shader - op = { - PIPE_TEXTURE_1D: "1D", - PIPE_TEXTURE_2D: "2D", - PIPE_TEXTURE_3D: "3D", - PIPE_TEXTURE_CUBE: "CUBE", - }[target] - fs = Shader(''' - FRAG - DCL IN[0], GENERIC[0], LINEAR - DCL OUT[0], COLOR, CONSTANT - DCL SAMP[0], CONSTANT - 0:TEX OUT[0], IN[0], SAMP[0], %s - 1:END - ''' % op) - #fs.dump() - ctx.set_fragment_shader(fs) - - nverts = 4 - nattrs = 2 - verts = FloatArray(nverts * nattrs * 4) - - x = 0 - y = 0 - w, h = minify((width, height), level) - - pos = [ - [x, y], - [x+w, y], - [x+w, y+h], - [x, y+h], - ] - - tex = tex_coords(texture, face, level, zslice) - - for i in range(0, 4): - j = 8*i - verts[j + 0] = pos[i][0]/float(width) # x - verts[j + 1] = pos[i][1]/float(height) # y - verts[j + 2] = 0.0 # z - verts[j + 3] = 1.0 # w - verts[j + 4] = tex[i][0] # s - verts[j + 5] = tex[i][1] # r - verts[j + 6] = tex[i][2] # q - verts[j + 7] = 1.0 - - ctx.draw_vertices(PIPE_PRIM_TRIANGLE_FAN, - nverts, - nattrs, - verts) - - ctx.flush() - - cbuf = cbuf_tex.get_surface() - - self.assert_rgba(ctx, cbuf, x, y, w, h, expected_rgba, 4.0/256, 0.85) - - -class TextureDepthSampleTest(TestCase): - - tags = ( - 'target', - 'format', - 'width', - 'height', - 'depth', - 'last_level', - 'face', - 'level', - 'zslice', - ) - - def test(self): - dev = self.dev - ctx = self.ctx - - target = self.target - format = self.format - width = self.width - height = self.height - depth = self.depth - last_level = self.last_level - face = self.face - level = self.level - zslice = self.zslice - minz = 0.0 - maxz = 1.0 - - bind = PIPE_BIND_SAMPLER_VIEW - geom_flags = 0 - if width != height: - geom_flags |= PIPE_TEXTURE_GEOM_NON_SQUARE - if not is_pot(width) or not is_pot(height) or not is_pot(depth): - geom_flags |= PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO - - if not dev.is_format_supported(format, target, bind, geom_flags): - raise TestSkip - - # disabled blending/masking - blend = Blend() - blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].colormask = PIPE_MASK_RGBA - ctx.set_blend(blend) - - # depth/stencil/alpha - depth_stencil_alpha = DepthStencilAlpha() - depth_stencil_alpha.depth.enabled = 1 - depth_stencil_alpha.depth.writemask = 1 - depth_stencil_alpha.depth.func = PIPE_FUNC_LESS - ctx.set_depth_stencil_alpha(depth_stencil_alpha) - - # rasterizer - rasterizer = Rasterizer() - rasterizer.front_winding = PIPE_WINDING_CW - rasterizer.cull_mode = PIPE_WINDING_NONE - ctx.set_rasterizer(rasterizer) - - # viewport - viewport = Viewport() - scale = FloatArray(4) - scale[0] = width - scale[1] = height - scale[2] = (maxz - minz) / 2.0 - scale[3] = 1.0 - viewport.scale = scale - translate = FloatArray(4) - translate[0] = 0.0 - translate[1] = 0.0 - translate[2] = (maxz - minz) / 2.0 - translate[3] = 0.0 - viewport.translate = translate - ctx.set_viewport(viewport) - - # samplers - sampler = Sampler() - sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.normalized_coords = 1 - sampler.min_lod = 0 - sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1 - ctx.set_fragment_sampler(0, sampler) - - # texture - texture = dev.resource_create( - target = target, - format = format, - width = width, - height = height, - depth = depth, - last_level = last_level, - bind = bind, - ) - - expected_rgba = FloatArray(height*width*4) - surface = texture.get_surface( - face = face, - level = level, - zslice = zslice, - ) - - ctx.surface_sample_rgba(surface, expected_rgba, True) - - ctx.set_fragment_sampler_texture(0, texture) - - # scissor - scissor = Scissor() - scissor.minx = 0 - scissor.miny = 0 - scissor.maxx = width - scissor.maxy = height - ctx.set_scissor(scissor) - - # clip - clip = Clip() - clip.nr = 0 - ctx.set_clip(clip) - - # framebuffer - cbuf_tex = dev.resource_create( - PIPE_FORMAT_B8G8R8A8_UNORM, - width, - height, - bind = PIPE_BIND_RENDER_TARGET, - ) - - zsbuf_tex = dev.resource_create( - PIPE_FORMAT_X8Z24_UNORM, - width, - height, - bind = PIPE_BIND_RENDER_TARGET, - ) - - cbuf = cbuf_tex.get_surface() - zsbuf = zsbuf_tex.get_surface() - fb = Framebuffer() - fb.width = width - fb.height = height - fb.nr_cbufs = 1 - fb.set_cbuf(0, cbuf) - fb.set_zsbuf(zsbuf) - ctx.set_framebuffer(fb) - rgba = FloatArray(4); - rgba[0] = 0.5 - rgba[1] = 0.5 - rgba[2] = 0.5 - rgba[3] = 0.5 - ctx.clear(PIPE_CLEAR_DEPTHSTENCIL, rgba, 1.0, 0) - del fb - - # vertex shader - vs = Shader(''' - VERT - DCL IN[0], POSITION, CONSTANT - DCL IN[1], GENERIC, CONSTANT - DCL OUT[0], POSITION, CONSTANT - DCL OUT[1], GENERIC, CONSTANT - 0:MOV OUT[0], IN[0] - 1:MOV OUT[1], IN[1] - 2:END - ''') - #vs.dump() - ctx.set_vertex_shader(vs) - - # fragment shader - op = { - PIPE_TEXTURE_1D: "1D", - PIPE_TEXTURE_2D: "2D", - PIPE_TEXTURE_3D: "3D", - PIPE_TEXTURE_CUBE: "CUBE", - }[target] - fs = Shader(''' - FRAG - DCL IN[0], GENERIC[0], LINEAR - DCL SAMP[0], CONSTANT - DCL OUT[0].z, POSITION - 0:TEX OUT[0].z, IN[0], SAMP[0], %s - 1:END - ''' % op) - #fs.dump() - ctx.set_fragment_shader(fs) - - nverts = 4 - nattrs = 2 - verts = FloatArray(nverts * nattrs * 4) - - x = 0 - y = 0 - w, h = minify((width, height), level) - - pos = [ - [x, y], - [x+w, y], - [x+w, y+h], - [x, y+h], - ] - - tex = tex_coords(texture, face, level, zslice) - - for i in range(0, 4): - j = 8*i - verts[j + 0] = pos[i][0]/float(width) # x - verts[j + 1] = pos[i][1]/float(height) # y - verts[j + 2] = 0.0 # z - verts[j + 3] = 1.0 # w - verts[j + 4] = tex[i][0] # s - verts[j + 5] = tex[i][1] # r - verts[j + 6] = tex[i][2] # q - verts[j + 7] = 1.0 - - ctx.draw_vertices(PIPE_PRIM_TRIANGLE_FAN, - nverts, - nattrs, - verts) - - ctx.flush() - - zsbuf = zsbuf_tex.get_surface() - - self.assert_rgba(ctx, zsbuf, x, y, w, h, expected_rgba, 4.0/256, 0.85) - - - - -def main(): - random.seed(0xdead3eef) - - dev = Device() - ctx = dev.context_create() - suite = TestSuite() - - targets = [ - PIPE_TEXTURE_2D, - PIPE_TEXTURE_CUBE, - PIPE_TEXTURE_3D, - ] - - #sizes = [64, 32, 16, 8, 4, 2, 1] - #sizes = [1020, 508, 252, 62, 30, 14, 6, 3] - sizes = [64] - #sizes = [63] - - faces = [ - PIPE_TEX_FACE_POS_X, - PIPE_TEX_FACE_NEG_X, - PIPE_TEX_FACE_POS_Y, - PIPE_TEX_FACE_NEG_Y, - PIPE_TEX_FACE_POS_Z, - PIPE_TEX_FACE_NEG_Z, - ] - - try: - n = int(sys.argv[1]) - except: - n = 10000 - - for i in range(n): - format = random.choice(formats.keys()) - if not util_format_is_depth_or_stencil(format): - is_depth_or_stencil = util_format_is_depth_or_stencil(format) - - if is_depth_or_stencil: - target = PIPE_TEXTURE_2D - else: - target = random.choice(targets) - - size = random.choice(sizes) - - if target == PIPE_TEXTURE_3D: - depth = size - else: - depth = 1 - - if target == PIPE_TEXTURE_CUBE: - face = random.choice(faces) - else: - face = PIPE_TEX_FACE_POS_X - - levels = lods(size) - last_level = random.randint(0, levels - 1) - level = random.randint(0, last_level) - zslice = random.randint(0, max(depth >> level, 1) - 1) - - if is_depth_or_stencil: - klass = TextureDepthSampleTest - else: - klass = TextureColorSampleTest - - test = klass( - dev = dev, - ctx = ctx, - target = target, - format = format, - width = size, - height = size, - depth = depth, - last_level = last_level, - face = face, - level = level, - zslice = zslice, - ) - suite.add_test(test) - suite.run() - - -if __name__ == '__main__': - main() diff --git a/progs/gallium/python/tests/texture_render.py b/progs/gallium/python/tests/texture_render.py deleted file mode 100755 index 23f3d2a57de..00000000000 --- a/progs/gallium/python/tests/texture_render.py +++ /dev/null @@ -1,320 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2009 VMware, Inc. -# All Rights Reserved. -# -# 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, sub license, 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 NON-INFRINGEMENT. -# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. -# -########################################################################## - - -from gallium import * -from base import * - - -def lods(*dims): - size = max(dims) - lods = 0 - while size: - lods += 1 - size >>= 1 - return lods - - -class TextureTest(TestCase): - - tags = ( - 'target', - 'format', - 'width', - 'height', - 'depth', - 'last_level', - 'face', - 'level', - 'zslice', - ) - - def test(self): - dev = self.dev - - target = self.target - format = self.format - width = self.width - height = self.height - depth = self.depth - last_level = self.last_level - face = self.face - level = self.level - zslice = self.zslice - - # textures - dst_texture = dev.resource_create( - target = target, - format = format, - width = width, - height = height, - depth = depth, - last_level = last_level, - bind = PIPE_BIND_RENDER_TARGET, - ) - if dst_texture is None: - raise TestSkip - - dst_surface = dst_texture.get_surface(face = face, level = level, zslice = zslice) - - ref_texture = dev.resource_create( - target = target, - format = format, - width = dst_surface.width, - height = dst_surface.height, - depth = 1, - last_level = 0, - bind = PIPE_BIND_SAMPLER_VIEW, - ) - - ref_surface = ref_texture.get_surface() - - src_texture = dev.resource_create( - target = target, - format = PIPE_FORMAT_B8G8R8A8_UNORM, - width = dst_surface.width, - height = dst_surface.height, - depth = 1, - last_level = 0, - bind = PIPE_BIND_SAMPLER_VIEW, - ) - - src_surface = src_texture.get_surface() - - expected_rgba = FloatArray(height*width*4) - ref_surface.sample_rgba(expected_rgba) - - src_surface.put_tile_rgba(0, 0, src_surface.width, src_surface.height, expected_rgba) - - ctx = self.dev.context_create() - - # disabled blending/masking - blend = Blend() - blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.rt[0].colormask = PIPE_MASK_RGBA - ctx.set_blend(blend) - - # no-op depth/stencil/alpha - depth_stencil_alpha = DepthStencilAlpha() - ctx.set_depth_stencil_alpha(depth_stencil_alpha) - - # rasterizer - rasterizer = Rasterizer() - rasterizer.front_winding = PIPE_WINDING_CW - rasterizer.cull_mode = PIPE_WINDING_NONE - rasterizer.bypass_vs_clip_and_viewport = 1 - ctx.set_rasterizer(rasterizer) - - # samplers - sampler = Sampler() - sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE - sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST - sampler.normalized_coords = 1 - sampler.min_lod = 0 - sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1 - ctx.set_fragment_sampler(0, sampler) - ctx.set_fragment_sampler_texture(0, src_texture) - - # framebuffer - cbuf_tex = dev.resource_create( - PIPE_FORMAT_B8G8R8A8_UNORM, - width, - height, - bind = PIPE_BIND_RENDER_TARGET, - ) - - fb = Framebuffer() - fb.width = dst_surface.width - fb.height = dst_surface.height - fb.nr_cbufs = 1 - fb.set_cbuf(0, dst_surface) - ctx.set_framebuffer(fb) - rgba = FloatArray(4); - rgba[0] = 0.0 - rgba[1] = 0.0 - rgba[2] = 0.0 - rgba[3] = 0.0 - ctx.clear(PIPE_CLEAR_COLOR, rgba, 0.0, 0) - del fb - - # vertex shader - vs = Shader(''' - VERT - DCL IN[0], POSITION, CONSTANT - DCL IN[1], GENERIC, CONSTANT - DCL OUT[0], POSITION, CONSTANT - DCL OUT[1], GENERIC, CONSTANT - 0:MOV OUT[0], IN[0] - 1:MOV OUT[1], IN[1] - 2:END - ''') - #vs.dump() - ctx.set_vertex_shader(vs) - - # fragment shader - fs = Shader(''' - FRAG - DCL IN[0], GENERIC[0], LINEAR - DCL OUT[0], COLOR, CONSTANT - DCL SAMP[0], CONSTANT - 0:TEX OUT[0], IN[0], SAMP[0], 2D - 1:END - ''') - #fs.dump() - ctx.set_fragment_shader(fs) - - nverts = 4 - nattrs = 2 - verts = FloatArray(nverts * nattrs * 4) - - x = 0 - y = 0 - w = dst_surface.width - h = dst_surface.height - - pos = [ - [x, y], - [x+w, y], - [x+w, y+h], - [x, y+h], - ] - - tex = [ - [0.0, 0.0], - [1.0, 0.0], - [1.0, 1.0], - [0.0, 1.0], - ] - - for i in range(0, 4): - j = 8*i - verts[j + 0] = pos[i][0] # x - verts[j + 1] = pos[i][1] # y - verts[j + 2] = 0.0 # z - verts[j + 3] = 1.0 # w - verts[j + 4] = tex[i][0] # s - verts[j + 5] = tex[i][1] # r - verts[j + 6] = 0.0 - verts[j + 7] = 1.0 - - ctx.draw_vertices(PIPE_PRIM_TRIANGLE_FAN, - nverts, - nattrs, - verts) - - ctx.flush() - - self.assert_rgba(dst_surface, x, y, w, h, expected_rgba, 4.0/256, 0.85) - - - -def main(): - dev = Device() - suite = TestSuite() - - targets = [ - PIPE_TEXTURE_2D, - PIPE_TEXTURE_CUBE, - #PIPE_TEXTURE_3D, - ] - - formats = [ - PIPE_FORMAT_B8G8R8A8_UNORM, - PIPE_FORMAT_B8G8R8X8_UNORM, - #PIPE_FORMAT_B8G8R8A8_SRGB, - PIPE_FORMAT_B5G6R5_UNORM, - PIPE_FORMAT_B5G5R5A1_UNORM, - PIPE_FORMAT_B4G4R4A4_UNORM, - #PIPE_FORMAT_Z32_UNORM, - #PIPE_FORMAT_S8_USCALED_Z24_UNORM, - #PIPE_FORMAT_X8Z24_UNORM, - #PIPE_FORMAT_Z16_UNORM, - #PIPE_FORMAT_S8_USCALED, - PIPE_FORMAT_A8_UNORM, - PIPE_FORMAT_L8_UNORM, - #PIPE_FORMAT_DXT1_RGB, - #PIPE_FORMAT_DXT1_RGBA, - #PIPE_FORMAT_DXT3_RGBA, - #PIPE_FORMAT_DXT5_RGBA, - ] - - sizes = [64, 32, 16, 8, 4, 2, 1] - #sizes = [1020, 508, 252, 62, 30, 14, 6, 3] - #sizes = [64] - #sizes = [63] - - faces = [ - PIPE_TEX_FACE_POS_X, - PIPE_TEX_FACE_NEG_X, - PIPE_TEX_FACE_POS_Y, - PIPE_TEX_FACE_NEG_Y, - PIPE_TEX_FACE_POS_Z, - PIPE_TEX_FACE_NEG_Z, - ] - - for target in targets: - for format in formats: - for size in sizes: - if target == PIPE_TEXTURE_3D: - depth = size - else: - depth = 1 - for face in faces: - if target != PIPE_TEXTURE_CUBE and face: - continue - levels = lods(size) - for last_level in range(levels): - for level in range(0, last_level + 1): - zslice = 0 - while zslice < depth >> level: - test = TextureTest( - dev = dev, - target = target, - format = format, - width = size, - height = size, - depth = depth, - last_level = last_level, - face = face, - level = level, - zslice = zslice, - ) - suite.add_test(test) - zslice = (zslice + 1)*2 - 1 - suite.run() - - -if __name__ == '__main__': - main() diff --git a/progs/gallium/python/tests/texture_transfer.py b/progs/gallium/python/tests/texture_transfer.py deleted file mode 100755 index 4aa3d6c709b..00000000000 --- a/progs/gallium/python/tests/texture_transfer.py +++ /dev/null @@ -1,181 +0,0 @@ -#!/usr/bin/env python -########################################################################## -# -# Copyright 2009 VMware, Inc. -# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. -# All Rights Reserved. -# -# 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, sub license, 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 NON-INFRINGEMENT. -# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. -# -########################################################################## - - -import os -import random - -from gallium import * -from base import * - - -def lods(*dims): - size = max(dims) - lods = 0 - while size: - lods += 1 - size >>= 1 - return lods - - -class TextureTest(TestCase): - - tags = ( - 'target', - 'format', - 'width', - 'height', - 'depth', - 'last_level', - 'face', - 'level', - 'zslice', - ) - - def test(self): - dev = self.dev - ctx = self.ctx - - target = self.target - format = self.format - width = self.width - height = self.height - depth = self.depth - last_level = self.last_level - face = self.face - level = self.level - zslice = self.zslice - - bind = PIPE_BIND_SAMPLER_VIEW - geom_flags = 0 - if not dev.is_format_supported(format, target, bind, geom_flags): - raise TestSkip - - # textures - texture = dev.resource_create( - target = target, - format = format, - width = width, - height = height, - depth = depth, - last_level = last_level, - bind = bind, - ) - - surface = texture.get_surface(face, level, zslice) - - stride = util_format_get_stride(format, surface.width) - size = util_format_get_nblocksy(format, surface.height) * stride - - in_raw = os.urandom(size) - - ctx.surface_write_raw(surface, 0, 0, surface.width, surface.height, in_raw, stride) - - out_raw = ctx.surface_read_raw(surface, 0, 0, surface.width, surface.height) - - if in_raw != out_raw: - raise TestFailure - - -def main(): - dev = Device() - ctx = dev.context_create() - suite = TestSuite() - - targets = [ - PIPE_TEXTURE_2D, - PIPE_TEXTURE_CUBE, - PIPE_TEXTURE_3D, - ] - - sizes = [64, 32, 16, 8, 4, 2, 1] - #sizes = [1020, 508, 252, 62, 30, 14, 6, 3] - #sizes = [64] - #sizes = [63] - - faces = [ - PIPE_TEX_FACE_POS_X, - PIPE_TEX_FACE_NEG_X, - PIPE_TEX_FACE_POS_Y, - PIPE_TEX_FACE_NEG_Y, - PIPE_TEX_FACE_POS_Z, - PIPE_TEX_FACE_NEG_Z, - ] - - try: - n = int(sys.argv[1]) - except: - n = 10000 - - for i in range(n): - format = random.choice(formats.keys()) - if not util_format_is_depth_or_stencil(format): - is_depth_or_stencil = util_format_is_depth_or_stencil(format) - - if is_depth_or_stencil: - target = PIPE_TEXTURE_2D - else: - target = random.choice(targets) - - size = random.choice(sizes) - - if target == PIPE_TEXTURE_3D: - depth = size - else: - depth = 1 - - if target == PIPE_TEXTURE_CUBE: - face = random.choice(faces) - else: - face = PIPE_TEX_FACE_POS_X - - levels = lods(size) - last_level = random.randint(0, levels - 1) - level = random.randint(0, last_level) - zslice = random.randint(0, max(depth >> level, 1) - 1) - - test = TextureTest( - dev = dev, - ctx = ctx, - target = target, - format = format, - width = size, - height = size, - depth = depth, - last_level = last_level, - face = face, - level = level, - zslice = zslice, - ) - suite.add_test(test) - suite.run() - - -if __name__ == '__main__': - main() diff --git a/progs/gallium/python/tests/tree.py b/progs/gallium/python/tests/tree.py deleted file mode 100755 index 0c1bcda4cf2..00000000000 --- a/progs/gallium/python/tests/tree.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python -# -# See also: -# http://www.ailab.si/orange/doc/ofb/c_otherclass.htm - -import os.path -import sys - -import orange -import orngTree - -for arg in sys.argv[1:]: - name, ext = os.path.splitext(arg) - - data = orange.ExampleTable(arg) - - tree = orngTree.TreeLearner(data, sameMajorityPruning=1, mForPruning=2) - - orngTree.printTxt(tree) - - file(name+'.txt', 'wt').write(orngTree.dumpTree(tree) + '\n') - - orngTree.printDot(tree, fileName=name+'.dot', nodeShape='ellipse', leafShape='box') |