Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/shaderc
Path: blob/main/glslc/test/option_dash_S.py
1560 views
1
# Copyright 2015 The Shaderc Authors. All rights reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
# http://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14
15
import expect
16
import os.path
17
from glslc_test_framework import inside_glslc_testsuite
18
from placeholder import FileShader, StdinShader
19
20
21
def simple_vertex_shader():
22
return """#version 310 es
23
void main() {
24
gl_Position = vec4(1., 2., 3., 4.);
25
}"""
26
27
28
def simple_fragment_shader():
29
return """#version 310 es
30
void main() {
31
gl_FragDepth = 10.;
32
}"""
33
34
35
def simple_compute_shader():
36
return """#version 310 es
37
void main() {
38
uvec3 temp = gl_WorkGroupID;
39
}"""
40
41
42
@inside_glslc_testsuite('OptionDashCapS')
43
class TestSingleDashCapSSingleFile(expect.ValidAssemblyFile):
44
"""Tests that -S works with a single file."""
45
46
shader = FileShader(simple_vertex_shader(), '.vert')
47
glslc_args = ['-S', shader]
48
49
50
@inside_glslc_testsuite('OptionDashCapS')
51
class TestSingleFileSingleDashCapS(expect.ValidAssemblyFile):
52
"""Tests that the position of -S doesn't matter."""
53
54
shader = FileShader(simple_vertex_shader(), '.vert')
55
glslc_args = [shader, '-S']
56
57
58
@inside_glslc_testsuite('OptionDashCapS')
59
class TestSingleDashCapSMultipleFiles(expect.ValidAssemblyFile):
60
"""Tests that -S works with multiple files."""
61
62
shader1 = FileShader(simple_vertex_shader(), '.vert')
63
shader2 = FileShader(simple_vertex_shader(), '.vert')
64
shader3 = FileShader(simple_fragment_shader(), '.frag')
65
glslc_args = ['-S', shader1, shader2, shader3]
66
67
68
@inside_glslc_testsuite('OptionDashCapS')
69
class TestMultipleDashCapSSingleFile(expect.ValidAssemblyFile):
70
"""Tests that multiple -Ss works as one."""
71
72
shader = FileShader(simple_vertex_shader(), '.vert')
73
glslc_args = ['-S', '-S', shader, '-S']
74
75
76
@inside_glslc_testsuite('OptionDashCapS')
77
class TestMultipleDashCapSMultipleFiles(expect.ValidAssemblyFile):
78
"""Tests a mix of -Ss and files."""
79
80
shader1 = FileShader(simple_fragment_shader(), '.frag')
81
shader2 = FileShader(simple_vertex_shader(), '.vert')
82
shader3 = FileShader(simple_compute_shader(), '.comp')
83
glslc_args = ['-S', shader1, '-S', '-S', shader2, '-S', shader3, '-S']
84
85
86
@inside_glslc_testsuite('OptionDashCapS')
87
class TestDashCapSWithDashC(expect.ValidAssemblyFile):
88
"""Tests that -S overwrites -c."""
89
90
shader1 = FileShader(simple_fragment_shader(), '.frag')
91
shader2 = FileShader(simple_vertex_shader(), '.vert')
92
glslc_args = ['-c', '-S', shader1, '-c', '-c', shader2]
93
94
95
@inside_glslc_testsuite('OptionDashCapS')
96
class TestDashCapSWithDashFShaderStage(expect.ValidAssemblyFile):
97
"""Tests that -S works with -fshader-stage=."""
98
99
shader1 = FileShader(simple_fragment_shader(), '.glsl')
100
shader2 = FileShader(simple_vertex_shader(), '.glsl')
101
shader3 = FileShader(simple_compute_shader(), '.glsl')
102
glslc_args = ['-S',
103
'-fshader-stage=fragment', shader1,
104
'-fshader-stage=vertex', shader2,
105
'-fshader-stage=compute', shader3]
106
107
108
@inside_glslc_testsuite('OptionDashCapS')
109
class TestDashCapSWithDashStd(expect.ValidAssemblyFileWithWarning):
110
"""Tests that -S works with -std=."""
111
112
shader1 = FileShader(simple_fragment_shader(), '.frag')
113
shader2 = FileShader(simple_vertex_shader(), '.vert')
114
shader3 = FileShader(simple_compute_shader(), '.comp')
115
glslc_args = ['-S', '-std=450', shader1, shader2, shader3]
116
117
w = (': warning: (version, profile) forced to be (450, none), '
118
'while in source code it is (310, es)\n')
119
expected_warning = [
120
shader1, w, shader2, w, shader3, w, '3 warnings generated.\n']
121
122
123
@inside_glslc_testsuite('OptionDashCapS')
124
class TestDashCapSWithDashOSingleFile(expect.SuccessfulReturn,
125
expect.CorrectAssemblyFilePreamble):
126
"""Tests that -S works with -o on a single file."""
127
128
shader = FileShader(simple_fragment_shader(), '.frag')
129
glslc_args = ['-S', '-o', 'blabla', shader]
130
131
def check_output_blabla(self, status):
132
output_name = os.path.join(status.directory, 'blabla')
133
return self.verify_assembly_file_preamble(output_name)
134
135
136
@inside_glslc_testsuite('OptionDashCapS')
137
class TestDashCapSWithDashOMultipleFiles(expect.ErrorMessage):
138
"""Tests that -S works with -o on a single file."""
139
140
shader1 = FileShader(simple_fragment_shader(), '.frag')
141
shader2 = FileShader(simple_vertex_shader(), '.vert')
142
glslc_args = ['-S', '-o', 'blabla', shader1, shader2]
143
144
expected_error = ['glslc: error: cannot specify -o when '
145
'generating multiple output files\n']
146
147
148
@inside_glslc_testsuite('OptionDashCapS')
149
class TestDashCapSWithStdIn(expect.ValidAssemblyFile):
150
"""Tests that -S works with stdin."""
151
152
shader = StdinShader(simple_fragment_shader())
153
glslc_args = ['-S', '-fshader-stage=fragment', shader]
154
155
156
@inside_glslc_testsuite('OptionDashCapS')
157
class TestDashCapSWithStdOut(
158
expect.ReturnCodeIsZero, expect.StdoutMatch, expect.StderrMatch):
159
"""Tests that -S works with stdout."""
160
161
shader = FileShader(simple_fragment_shader(), '.frag')
162
glslc_args = ['-S', '-o', '-', shader]
163
164
expected_stdout = True
165
expected_stderr = ''
166
167