Exemplo n.º 1
0
def main():
    """ Main function """

    for signature, test_vectors in six.iteritems(test_suite):
        arg_float_check = all(arg.base_type == glsl_float
                              for arg in signature.argtypes)
        arg_mat_check = any(arg.is_matrix for arg in signature.argtypes)
        # Filter the test vectors down to only those which deal exclusively in
        # non-matrix float types and are specified in the spec
        if (signature.rettype.base_type == glsl_float and arg_float_check
                and signature.name in shader_precision_spec_fns
                and not arg_mat_check):
            # replace the tolerances in each test_vector with
            # our own tolerances specified in ulps
            refined_test_vectors = []
            complex_tol_type = signature.rettype
            for test_vector in test_vectors:
                tolerance = _gen_tolerance(signature.name, signature.rettype,
                                           test_vector.arguments)
                result = drop_signbit(test_vector.result)
                refined_test_vectors.append(
                    TestVector(test_vector.arguments, result, tolerance))
            # Then generate the shader_test scripts
            for shader_stage in ('vs', 'fs', 'gs'):
                template = template_file('gen_shader_precision_tests',
                                         '{0}.mako'.format(shader_stage))
                output_filename = os.path.join(
                    'spec', 'arb_shader_precision',
                    '{0}-{1}-{2}.shader_test'.format(
                        shader_stage, signature.name, '-'.join(
                            str(argtype) for argtype in signature.argtypes)))
                print(output_filename)
                dirname = os.path.dirname(output_filename)
                if not os.path.exists(dirname):
                    os.makedirs(dirname)
                indexers = make_indexers(signature)
                num_elements = signature.rettype.num_cols * signature.rettype.num_rows
                invocation = signature.template.format(*[
                    'arg{0}'.format(i) for i in range(len(signature.argtypes))
                ])
                with open(output_filename, 'w') as f:
                    f.write(
                        template.render_unicode(
                            signature=signature,
                            is_complex_tolerance=_is_sequence(tolerance),
                            complex_tol_type=signature.rettype,
                            test_vectors=refined_test_vectors,
                            invocation=invocation,
                            num_elements=num_elements,
                            indexers=indexers,
                            shader_runner_type=shader_runner_type,
                            shader_runner_format=shader_runner_format,
                            column_major_values=column_major_values))
def main():
    """ Main function """

    for signature, test_vectors in six.iteritems(test_suite):
        arg_float_check = all(arg.base_type == glsl_float for arg in signature.argtypes)
        arg_mat_check = any(arg.is_matrix for arg in signature.argtypes)
        # Filter the test vectors down to only those which deal exclusively in
        # non-matrix float types and are specified in the spec
        if (signature.rettype.base_type == glsl_float and
            arg_float_check and
            signature.name in shader_precision_spec_fns and
            not arg_mat_check):
            # replace the tolerances in each test_vector with
            # our own tolerances specified in ulps
            refined_test_vectors = []
            complex_tol_type = signature.rettype
            for test_vector in test_vectors:
                tolerance = _gen_tolerance(signature.name, signature.rettype, test_vector.arguments)
                result = drop_signbit(test_vector.result)
                refined_test_vectors.append(TestVector(test_vector.arguments, result, tolerance))
            # Then generate the shader_test scripts
            for shader_stage in ('vs', 'fs', 'gs'):
                template = template_file('gen_shader_precision_tests', '{0}.mako'.format(shader_stage))
                output_filename = os.path.join( 'spec', 'arb_shader_precision',
                                                '{0}-{1}-{2}.shader_test'.format(
                                                shader_stage, signature.name,
                                                '-'.join(str(argtype)
                                                for argtype in signature.argtypes)))
                print(output_filename)
                dirname = os.path.dirname(output_filename)
                if not os.path.exists(dirname):
                    os.makedirs(dirname)
                indexers = make_indexers(signature)
                num_elements = signature.rettype.num_cols * signature.rettype.num_rows
                invocation = signature.template.format( *['arg{0}'.format(i)
                                                        for i in range(len(signature.argtypes))])
                with open(output_filename, 'w') as f:
                    f.write(template.render_unicode( signature=signature,
                                                     is_complex_tolerance=_is_sequence(tolerance),
                                                     complex_tol_type=signature.rettype,
                                                     test_vectors=refined_test_vectors,
                                                     invocation=invocation,
                                                     num_elements=num_elements,
                                                     indexers=indexers,
                                                     shader_runner_type=shader_runner_type,
                                                     shader_runner_format=shader_runner_format,
                                                     column_major_values=column_major_values ))
Exemplo n.º 3
0
def main():
    """ Main function """

    for signature, test_vectors in sorted(six.iteritems(test_suite)):
        arg_float_check = tuple(arg.base_type == glsl_float
                                for arg in signature.argtypes)
        # Filter the test vectors down to only those which deal exclusively in float types
        #and are not trig functions or determinant()
        indexers = make_indexers(signature)
        num_elements = signature.rettype.num_cols * signature.rettype.num_rows
        invocation = signature.template.format(
            *['arg{0}'.format(i) for i in range(len(signature.argtypes))])
        if (signature.rettype.base_type == glsl_float and arg_float_check
                and all(arg_float_check)
                and signature.name not in trig_builtins
                and signature.name != 'determinant'):
            for shader_stage in ('vs', 'fs', 'gs'):
                template = template_file('gen_shader_precision_tests',
                                         '{0}.mako'.format(shader_stage))
                output_filename = os.path.join(
                    'spec', 'arb_shader_precision',
                    '{0}-{1}-{2}.shader_test'.format(
                        shader_stage, signature.name, '-'.join(
                            str(argtype) for argtype in signature.argtypes)))
                print(output_filename)
                dirname = os.path.dirname(output_filename)
                if not os.path.exists(dirname):
                    os.makedirs(dirname)
                with open(output_filename, 'w') as f:
                    f.write(
                        template.render_unicode(
                            signature=signature,
                            test_vectors=test_vectors,
                            tolerances=tolerances,
                            invocation=invocation,
                            num_elements=num_elements,
                            indexers=indexers,
                            shader_runner_type=shader_runner_type,
                            shader_runner_format=shader_runner_format,
                            column_major_values=column_major_values))
Exemplo n.º 4
0
def main():
    """ Main function """

    for signature, test_vectors in sorted(six.iteritems(test_suite)):
        arg_float_check = tuple(
                        arg.base_type == glsl_float for arg in signature.argtypes)
        # Filter the test vectors down to only those which deal exclusively in float types
        #and are not trig functions or determinant()
        indexers = make_indexers(signature)
        num_elements = signature.rettype.num_cols*signature.rettype.num_rows
        invocation = signature.template.format( *['arg{0}'.format(i) 
                                                for i in range(len(signature.argtypes))])
        if (signature.rettype.base_type == glsl_float and
            arg_float_check and
            all(arg_float_check) and
            signature.name not in trig_builtins and
            signature.name != 'determinant'): 
            for shader_stage in ('vs', 'fs', 'gs'):
                template = template_file('gen_shader_precision_tests', '{0}.mako'.format(shader_stage))
                output_filename = os.path.join( 'spec', 'arb_shader_precision',
                                                '{0}-{1}-{2}.shader_test'.format(
                                                shader_stage, signature.name, 
                                                '-'.join(str(argtype) 
                                                for argtype in signature.argtypes)))
                print(output_filename)
                dirname = os.path.dirname(output_filename)
                if not os.path.exists(dirname):
                    os.makedirs(dirname)
                with open(output_filename, 'w') as f:
                    f.write(template.render_unicode( signature=signature, 
                                                     test_vectors=test_vectors,
                                                     tolerances=tolerances,
                                                     invocation=invocation,
                                                     num_elements=num_elements,
                                                     indexers=indexers,
                                                     shader_runner_type=shader_runner_type,
                                                     shader_runner_format=shader_runner_format,
                                                     column_major_values=column_major_values ))
Exemplo n.º 5
0
def main():
    """main function."""
    dirname = os.path.join('spec', 'intel_shader_integer_functions2',
                           'execution', 'built-in-functions')
    utils.safe_makedirs(dirname)

    for func, attrib in FUNCS.items():

        TEMPLATE = template_file(
            os.path.basename(os.path.splitext(__file__)[0]),
            attrib['template'])

        for execution_stage in ('vs', 'fs'):
            filename = os.path.join(
                dirname, "{0}-{1}.shader_test".format(execution_stage, func))
            print(filename)

            extension_list = ["GL_INTEL_shader_integer_functions2"]
            if isinstance(attrib['extensions'], str):
                extension_list += [attrib['extensions']]
            elif attrib['extensions'] is not None:
                extension_list += attrib['extensions']

            with open(filename, 'w') as f:
                f.write(
                    TEMPLATE.render_unicode(
                        execution_stage=execution_stage,
                        version=attrib['version'],
                        extensions=sorted(extension_list),
                        input_type=attrib['input'],
                        output_type=attrib['output'],
                        sources=attrib['sources'](),
                        results=attrib['results'](attrib['sources'](),
                                                  attrib['operator']),
                        func=attrib['func']))
    return
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

""" Generate glsl 1.20 outerproduct tests """

from __future__ import print_function, division, absolute_import
import os
import itertools
import collections

from six.moves import range

from templates import template_file
from modules import utils

TEMPLATE = template_file(os.path.splitext(os.path.basename(__file__))[0],
                         'template.shader_test.mako')

Parameters = collections.namedtuple(
    'Paramters', ['columns', 'rows', 'vec_type', 'matrix'])


def main():
    """ Generate tests """
    dirname = os.path.join('spec', 'glsl-1.20', 'execution')
    utils.safe_makedirs(dirname)


    for c, r in itertools.product(range(2, 5), repeat=2):
        vecs = [
            Parameters(c, r, 'vec', 'mat{0}x{1}'.format(r, c)),
            Parameters(c, r, 'ivec', 'mat{0}x{1}'.format(r, c))
Exemplo n.º 7
0
#
# 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 NONINFRINGEMENT.  IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS 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 os.path

from templates import template_file
from modules import utils

TEMPLATE = template_file(os.path.basename(os.path.splitext(__file__)[0]),
                         'template.glsl_parser_test.mako')

SAMPLER_TYPE_TO_COORD_TYPE = {
    'sampler1D': 'float',
    'isampler1D': 'float',
    'usampler1D': 'float',
    'sampler2D': 'vec2',
    'isampler2D': 'vec2',
    'usampler2D': 'vec2',
    'sampler3D': 'vec3',
    'isampler3D': 'vec3',
    'usampler3D': 'vec3',
    'samplerCube': 'vec3',
    'isamplerCube': 'vec3',
    'usamplerCube': 'vec3',
    'sampler1DArray': 'float',
# 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 NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS 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

from templates import template_file
from modules import utils

TEMPLATE = template_file(os.path.basename(os.path.splitext(__file__)[0]),
                         'template.vert.mako')


def main():
    """ Generate tests """
    dirname = os.path.join('spec', 'glsl-1.20', 'compiler',
                           'built-in-functions')
    utils.safe_makedirs(dirname)

    for type_ in [
            'int', 'float', 'bool', 'bvec2', 'bvec3', 'bvec4', 'mat2',
            'mat2x2', 'mat2x3', 'mat2x4', 'mat3', 'mat3x2', 'mat3x3', 'mat3x4',
            'mat4', 'mat4x2', 'mat4x3', 'mat4x4'
    ]:
        name = os.path.join(dirname, 'outerProduct-{0}.vert'.format(type_))
        print(name)
Exemplo n.º 9
0
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
""" Generate glsl 1.20 outerproduct tests """

from __future__ import print_function, division, absolute_import
import os
import itertools
import collections

from six.moves import range

from templates import template_file
from modules import utils

TEMPLATE = template_file(
    os.path.splitext(os.path.basename(__file__))[0],
    'template.shader_test.mako')

Parameters = collections.namedtuple('Paramters',
                                    ['columns', 'rows', 'vec_type', 'matrix'])


def main():
    """ Generate tests """
    dirname = os.path.join('spec', 'glsl-1.20', 'execution')
    utils.safe_makedirs(dirname)

    for c, r in itertools.product(range(2, 5), repeat=2):
        vecs = [
            Parameters(c, r, 'vec', 'mat{0}x{1}'.format(r, c)),
            Parameters(c, r, 'ivec', 'mat{0}x{1}'.format(r, c))
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS 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 __future__ import print_function, division, absolute_import
import os
import os.path

import six

from templates import template_file
from modules import utils

TEMPLATE = template_file(os.path.basename(os.path.splitext(__file__)[0]),
                         'template.glsl_parser_test.mako')

SAMPLER_TYPE_TO_COORD_TYPE = {
    'sampler1D':              'float',
    'isampler1D':             'float',
    'usampler1D':             'float',

    'sampler2D':              'vec2',
    'isampler2D':             'vec2',
    'usampler2D':             'vec2',

    'sampler3D':              'vec3',
    'isampler3D':             'vec3',
    'usampler3D':             'vec3',

    'samplerCube':            'vec3',
# 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 NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS 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 __future__ import print_function, division, absolute_import
import os

from templates import template_file
from modules import utils

TEMPLATE = template_file(os.path.basename(os.path.splitext(__file__)[0]), "template.vert.mako")


def main():
    """ Generate tests """
    dirname = os.path.join("spec", "glsl-1.20", "compiler", "built-in-functions")
    utils.safe_makedirs(dirname)

    for type_ in [
        "int",
        "float",
        "bool",
        "bvec2",
        "bvec3",
        "bvec4",
        "mat2",