1 # -*- coding: utf-8 -*-
3 #-------------------------------------------------------------------------
4 # drawElements Quality Program utilities
5 # --------------------------------------
7 # Copyright (c) 2016 The Khronos Group Inc.
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
21 #-------------------------------------------------------------------------
29 INVALID_IMPLICIT_CONVESION_TEMPLATE0 = """
34 precision mediump float;
35 precision mediump int;
44 ${{TYPE0}} c = a ${{OPERATION}} b;
50 INVALID_IMPLICIT_CONVESION_TEMPLATE1 = """
55 precision mediump float;
56 precision mediump int;
65 ${{TYPE1}} c = a ${{OPERATION}} b;
71 arithOperations = {'+': 'add', '*':'mul', '/': 'div', '-':'sub'}
73 class InvalidImplicitConversionCase(ShaderCase):
74 def __init__(self, operation, type0, type1):
75 self.name = arithOperations[operation] + '_' + type0 + '_' + type1
76 self.operation = operation
81 params0 = { "NAME": self.name + '_' + self.type0, "TYPE0": self.type0, "TYPE1": self.type1, "OPERATION": self.operation }
82 params1 = { "NAME": self.name + '_' + self.type1, "TYPE0": self.type0, "TYPE1": self.type1, "OPERATION": self.operation }
83 return fillTemplate(INVALID_IMPLICIT_CONVESION_TEMPLATE0, params0) + '\n' + fillTemplate(INVALID_IMPLICIT_CONVESION_TEMPLATE1, params1)
85 def createCase(operation, type0, type1):
89 case = InvalidImplicitConversionCase(operation, t0, t1)
93 floats = ['float', 'vec2', 'vec3', 'vec4']
94 sintegers = ['int', 'ivec2', 'ivec3', 'ivec4']
96 for op in arithOperations:
97 caseFpInt = createCase(op, floats, sintegers)
98 cases = cases + caseFpInt
100 invalidImplicitConversionCases = [
101 CaseGroup("invalid_implicit_conversions", "Invalid Implicit Conversions", cases),
104 if __name__ == "__main__":
105 print "Generating shader case files."
106 writeAllCases("invalid_implicit_conversions.test", invalidImplicitConversionCases)