class TestFLimitFileSetsLowerMinTexelOffset(expect.ValidObjectFile):
    """Tests -flimit-file with lower than default argument.  The shader uses that offset."""

    limits_file = File('limits.txt', 'MinProgramTexelOffset -9')
    shader = File('shader.vert', shader_source_with_tex_offset(-9))
    environment = Directory('.', [limits_file, shader])
    glslc_args = ['-c', shader.name, '-flimit-file', limits_file.name]
Example #2
0
class TestDashCapMDMultipleFile(expect.ValidNamedObjectFile,
                                DependencyInfoFileMatch):
    """Tests that -MD generates dependency info file for multiple files.
    e.g. glslc -MD a.vert b.vert -c
      => <a.vert.spv: valid SPIR-V object file>
      => <a.vert.spv.d: dependency info: "a.vert.spv: a.vert">
      => <b.vert.spv: valid SPIR-V object file>
      => <b.vert.spv.d: dependency info: "b.vert.spv: b.vert">
    """
    environment = Directory(
        '.', [File('a.vert', MINIMAL_SHADER),
              File('b.vert', MINIMAL_SHADER)])
    glslc_args = ['-MD', 'a.vert', 'b.vert', '-c']
    expected_object_filenames = (
        'a.vert.spv',
        'b.vert.spv',
    )

    dependency_info_filenames = ['a.vert.spv.d', 'b.vert.spv.d']
    dependency_info_files_expected_contents = []
    dependency_info_files_expected_contents.append([{
        'target': 'a.vert.spv',
        'dependency': {'a.vert'}
    }])
    dependency_info_files_expected_contents.append([{
        'target': 'b.vert.spv',
        'dependency': {'b.vert'}
    }])
Example #3
0
class TestDashCapMDMultipleFilePreprocessingOnlyMode(expect.StdoutMatch,
                                                     DependencyInfoFileMatch):
    """Tests that -MD generates dependency info file for multiple files in
    preprocessing only mode.
    e.g. glslc -MD a.vert b.vert -E
      => stdout: preprocess result of a.vert and b.vert
      => <a.vert.spv.d: dependency info: "a.vert.spv: a.vert">
      => <b.vert.spv.d: dependency info: "b.vert.spv: b.vert">
    """
    environment = Directory(
        '.', [File('a.vert', MINIMAL_SHADER),
              File('b.vert', MINIMAL_SHADER)])
    glslc_args = ['-MD', 'a.vert', 'b.vert', '-E']
    dependency_info_filenames = ['a.vert.spv.d', 'b.vert.spv.d']
    dependency_info_files_expected_contents = []
    dependency_info_files_expected_contents.append([{
        'target': 'a.vert.spv',
        'dependency': {'a.vert'}
    }])
    dependency_info_files_expected_contents.append([{
        'target': 'b.vert.spv',
        'dependency': {'b.vert'}
    }])
    expected_stdout = ("#version 140\nvoid main(){ }\n"
                       "#version 140\nvoid main(){ }\n")
Example #4
0
class TestDashCapMDMultipleFileDisassemblyMode(expect.ValidNamedAssemblyFile,
                                               DependencyInfoFileMatch):
    """Tests that -MD generates dependency info file for multiple files in
    disassembly mode.
    e.g. glslc -MD a.vert b.vert -S
      => <a.vert.spvasm: valid SPIR-V assembly file>
      => <a.vert.spvasm.d: dependency info: "a.vert.spvasm: a.vert">
      => <b.vert.spvasm: valid SPIR-V assembly file>
      => <b.vert.spvasm.d: dependency info: "b.vert.spvasm: b.vert">
    """
    environment = Directory(
        '.', [File('a.vert', MINIMAL_SHADER),
              File('b.vert', MINIMAL_SHADER)])
    glslc_args = ['-MD', 'a.vert', 'b.vert', '-S']
    expected_assembly_filenames = (
        'a.vert.spvasm',
        'b.vert.spvasm',
    )
    dependency_info_filenames = ['a.vert.spvasm.d', 'b.vert.spvasm.d']

    dependency_info_files_expected_contents = []
    dependency_info_files_expected_contents.append([{
        'target': 'a.vert.spvasm',
        'dependency': {'a.vert'}
    }])
    dependency_info_files_expected_contents.append([{
        'target': 'b.vert.spvasm',
        'dependency': {'b.vert'}
    }])
Example #5
0
class TestPSSfromIncludedFile(expect.ValidObjectFile):
    """Tests that #pragma shader_stage() from included files works."""

    environment = Directory('.', [
        File('a.glsl', '#include "b.glsl"\n'
             'void main() { gl_Position = vec4(1.); }\n'),
        File('b.glsl', '#pragma shader_stage(vertex)')])
    glslc_args = ['-c', 'a.glsl']
class TestFLimitFileInvalidContents(expect.ErrorMessage):
    """Tests -flimit-file bad file contents."""

    limits_file = File('limits.txt', 'thisIsBad')
    shader = File('shader.vert', shader_source_with_tex_offset(-9))
    environment = Directory('.', [limits_file, shader])
    glslc_args = ['-c', shader.name, '-flimit-file', limits_file.name]
    expected_error = 'glslc: error: -flimit-file error: invalid resource limit: thisIsBad\n'
Example #7
0
class VerifyCompileIncludeOneSibling(expect.ValidObjectFile):
    """Tests #including a sibling file via full compilation."""

    environment = Directory('.', [
        File('a.vert', '#version 140\nvoid foo(){}\n#include "b"\n'),
        File('b', 'void main(){foo();}\n')])

    glslc_args = ['a.vert']
Example #8
0
class TestErrorDashCapMTWithMultipleInputFiles(expect.StderrMatch):
    """Tests that when -MT option is specified, only one input file should be
    provided."""
    environment = Directory('.', [File('a.vert', MINIMAL_SHADER),
                                  File('b.vert', MINIMAL_SHADER)])
    glslc_args = ['-M', 'a.vert', 'b.vert', '-c', '-MT', 'target']
    expected_stderr = ['glslc: error: '
                       'to specify dependency info file name or dependency '
                       'info target, only one input file is allowed.\n']
Example #9
0
class VerifyIncludeWithoutNewline(expect.ErrorMessageSubstr):
    """Tests a #include without a newline."""

    environment = Directory('.', [
        File('a.vert', '#version 140\n#include "b"'),
        File('b', 'content b\n')])

    glslc_args = ['-E', 'a.vert']

    expected_error_substr = 'expected newline after header name: b'
Example #10
0
class VerifyIncludeOneSibling(expect.StdoutMatch):
    """Tests #including a sibling file."""

    environment = Directory('.', [
        File('a.vert', 'content a\n#include "b"\n'),
        File('b', 'content b\n')])

    glslc_args = ['-E', 'a.vert']

    expected_stdout = \
"""#extension GL_GOOGLE_include_directive : enable
Example #11
0
class VerifyIncludeSubdir(expect.StdoutMatch):
    """Tests #including a file from a subdirectory."""

    environment = Directory('.', [
        File('a.vert', '#version 140\ncontent a1\n#include "subdir/a"\ncontent a2\n'),
        Directory('subdir', [File('a', 'content suba\n')])])

    glslc_args = ['-E', 'a.vert']

    expected_stdout = \
"""#version 140
Example #12
0
class VerifyIncludeWithoutNewline(expect.StdoutMatch):
    """Tests a #include without a newline."""

    environment = Directory('.', [
        File('a.vert', '#include "b"'),
        File('b', 'content b\n')])

    glslc_args = ['-E', 'a.vert']

    expected_stdout = \
"""#extension GL_GOOGLE_include_directive : enable
Example #13
0
class VerifyIncludeOneSibling(expect.StdoutMatch):
    """Tests #including a sibling file."""

    environment = Directory('.', [
        File('a.vert', '#version 140\ncontent a\n#include "b"\n'),
        File('b', 'content b\n')])

    glslc_args = ['-E', 'a.vert']

    expected_stdout = \
"""#version 140
Example #14
0
class VerifyCompileIncludeSubdir(expect.ValidObjectFile):
    """Tests #including a file from a subdirectory via full compilation."""

    environment = Directory('.', [
        File('a.vert',
             """#define BODY {}
             #include "subdir/a"
             void afun()BODY
             """),
        Directory('subdir', [File('a', 'void main() BODY\n')])])

    glslc_args = ['a.vert']
Example #15
0
class TestDashCapMOverridesOtherModes(DependencyInfoStdoutMatch):
    """Tests -M overrides other compiler mode options, includeing -E, -c and -S.
    """
    environment = Directory('.', [
        File('a.vert', MINIMAL_SHADER),
        File('b.vert', MINIMAL_SHADER),
    ])
    glslc_args = ['-M', '-E', '-c', '-S', 'a.vert', 'b.vert']
    dependency_rules_expected = [{'target': 'a.vert.spv',
                                  'dependency': {'a.vert'}},
                                 {'target': 'b.vert.spv',
                                  'dependency': {'b.vert'}}]
Example #16
0
class VerifyIncludeWithoutNewline(expect.StdoutMatch):
    """Tests a #include without a newline."""

    environment = Directory('.', [
        File('a.vert', '#version 140\n#include "b"'),
        File('b', 'content b\n')
    ])

    glslc_args = ['-E', 'a.vert']

    expected_stdout = \
"""#version 140
Example #17
0
class TestSpaceAroundPoundVersion150InIncludingFile(
    expect.ReturnCodeIsZero, expect.StdoutMatch, expect.StderrMatch):
    """Tests that spaces around #version & #include directive doesn't matter."""

    environment = Directory('.', [
        File('a.vert', '  \t #\t\tversion\t   150\t \n# include \t "b.glsl"\n'),
        File('b.glsl', 'void main() {}\n')])
    glslc_args = ['-E', 'a.vert']

    expected_stderr = ''
    expected_stdout = \
"""#version 150
Example #18
0
class VerifyNestedIncludeAmongSiblings(expect.StdoutMatch):
    """Tests #include inside #included sibling files."""

    environment = Directory('.', [
        File('a.vert', '#version 140\n#include "b"\ncontent a\n'),
        File('b', 'content b\n#include "c"\n'),
        File('c', 'content c\n')])

    glslc_args = ['-E', 'a.vert']

    expected_stdout = \
"""#version 140
Example #19
0
class VerifyIncludeTwoSiblings(expect.StdoutMatch):
    """Tests #including two sibling files."""

    environment = Directory('.', [
        File('b.vert', '#version 140\n#include "a"\ncontent b\n#include "c"\n'),
        File('a', 'content a\n'),
        File('c', 'content c\n')])

    glslc_args = ['-E', 'b.vert']

    expected_stdout = \
"""#version 140
Example #20
0
class VerifyRelativeParent(expect.StdoutMatch):
    """Tests #including a parent file."""

    environment = Directory('.', [
        File('a.vert', '#version 140\ncontent a\n#include "b.glsl"\n'),
        File('c.glsl', 'content c\n'),
        Directory('foo', [File('b.glsl', '#include "../c.glsl"\ncontent b\n')])
    ])

    glslc_args = ['-E', 'a.vert', '-Ifoo']

    expected_stdout = \
"""#version 140
Example #21
0
class TestPoundVersion310InIncludedFile(expect.ErrorMessageSubstr):
    """Tests that #line directives follows the behavior of version 310
    (specifying the line number for the next line) when we find a
    #version 310 directive in the included file."""

    environment = Directory('.', [
        File('a.vert', '#include "b.glsl"\nvoid main() {}'),
        File('b.glsl', '#version 310 es\n')])
    glslc_args = ['-E', 'a.vert']

    expected_error_substr = [
        "b.glsl:1: error: '#version' : must occur first in shader\n"
    ]
Example #22
0
class TestPoundLineWithForcedVersion150(
    expect.ReturnCodeIsZero, expect.StdoutMatch, expect.StderrMatch):
    """Tests that #line directives follows the behavior for the version
    specified via command-line."""

    environment = Directory('.', [
        File('a.vert', '#include "b.glsl"\n'),
        File('b.glsl', 'void main() {}\n')])
    glslc_args = ['-E', '-std=150', 'a.vert']

    expected_stderr = ''
    expected_stdout = \
"""#extension GL_GOOGLE_include_directive : enable
Example #23
0
class TestWrongPoundVersionInIncludingFile(expect.ValidObjectFileWithWarning):
    """Tests that warning message for #version directive in the including file
    has the correct filename."""

    environment = Directory('.', [
        File('a.vert', '#version 100000000\n#include "b.glsl"\n'),
        File('b.glsl', 'void main() {}\n')])
    glslc_args = ['-c', 'a.vert']

    expected_warning = [
        'a.vert: warning: version 100000000 is unknown.\n',
        '1 warning generated.\n'
    ]
Example #24
0
class TestWrongPoundVersionInIncludedFile(expect.ErrorMessage):
    """Tests that warning message for #version directive in the included file
    has the correct filename."""

    environment = Directory('.', [
        File('a.vert', '#version 140\n#include "b.glsl"\nvoid main() {}'),
        File('b.glsl', '#version 10000000\n')])
    glslc_args = ['-E', 'a.vert']

    expected_error = [
        "b.glsl:1: error: '#version' : must occur first in shader\n",
        '1 error generated.\n'
    ]
Example #25
0
class TestWrongPoundVersionInIncludingFile(expect.ValidObjectFileWithWarning):
    """Tests that warning message for #version directive in the including file
    has the correct filename."""

    environment = Directory('.', [
        File('a.vert', '#version 100000000\n#include "b.glsl"\n'),
        File('b.glsl', 'void main() {}\n')])
    glslc_args = ['-c', '-std=400', 'a.vert']

    expected_warning = [
        'a.vert: warning: (version, profile) forced to be (400, none),'
        ' while in source code it is (100000000, none)\n'
        '1 warning generated.\n'
    ]
Example #26
0
class TestPoundVersion150InIncludingFile(
    expect.ReturnCodeIsZero, expect.StdoutMatch, expect.StderrMatch):
    """Tests that #line directives follows the behavior of version 150
    (specifying the line number for itself) when we find a #version 150
    directive in the including file."""

    environment = Directory('.', [
        File('a.vert', '#version 150\n#include "b.glsl"\n'),
        File('b.glsl', 'void main() {}\n')])
    glslc_args = ['-E', 'a.vert']

    expected_stderr = ''
    expected_stdout = \
"""#version 150
Example #27
0
class TestPoundLineWithForcedDifferentVersion(
    expect.ReturnCodeIsZero, expect.StdoutMatch, expect.StderrMatch):
    """Tests that #line directives follows the behavior for the version
    specified via command-line, even if there is a version specification
    in the source code."""

    environment = Directory('.', [
        File('a.vert', '#version 150\n#include "b.glsl"\n'),
        File('b.glsl', 'void main() {}\n')])
    glslc_args = ['-E', '-std=310es', 'a.vert']

    expected_stderr = ''
    expected_stdout = \
"""#version 150
Example #28
0
class VerifyRelativeNeighbourDirectory(expect.StdoutMatch):
    """Tests #including a relative file in a neighbour directory."""

    environment = Directory('.', [
        File('a.vert', '#version 140\ncontent a\n#include "foo/b.glsl"\n'),
        Directory('foo',
                  [File('b.glsl', '#include "../bar/c.glsl"\ncontent b\n')]),
        Directory('bar', [File('c.glsl', 'content c\n')])
    ])

    glslc_args = ['-E', 'a.vert']

    expected_stdout = \
"""#version 140
Example #29
0
class VerifyIncludeDeepSubdir(expect.StdoutMatch):
    """Tests #including a file from a subdirectory nested a few levels down."""

    environment = Directory('.', [
        File('a.vert',
             '#version 140\ncontent a1\n#include "dir/subdir/subsubdir/a"\ncontent a2\n'),
        Directory('dir', [
            Directory('subdir', [
                Directory('subsubdir', [File('a', 'content incl\n')])])])])

    glslc_args = ['-E', 'a.vert']

    expected_stdout = \
"""#version 140
Example #30
0
class VerifyRelativeInclude(expect.StdoutMatch):
    """Tests #including a relative sibling."""

    environment = Directory('.', [
        File('a.vert', '#version 140\ncontent a\n#include "foo/b.glsl"\n'),
        Directory('foo', [
            File('b.glsl', '#include "c.glsl"\ncontent b\n'),
            File('c.glsl', 'content c\n')
        ])])

    glslc_args = ['-E', 'a.vert']

    expected_stdout = \
"""#version 140