1e5c31af7Sopenharmony_ci# -*- coding: utf-8 -*- 2e5c31af7Sopenharmony_ci 3e5c31af7Sopenharmony_ci#------------------------------------------------------------------------- 4e5c31af7Sopenharmony_ci# drawElements Quality Program utilities 5e5c31af7Sopenharmony_ci# -------------------------------------- 6e5c31af7Sopenharmony_ci# 7e5c31af7Sopenharmony_ci# Copyright 2015 The Android Open Source Project 8e5c31af7Sopenharmony_ci# 9e5c31af7Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 10e5c31af7Sopenharmony_ci# you may not use this file except in compliance with the License. 11e5c31af7Sopenharmony_ci# You may obtain a copy of the License at 12e5c31af7Sopenharmony_ci# 13e5c31af7Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 14e5c31af7Sopenharmony_ci# 15e5c31af7Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 16e5c31af7Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 17e5c31af7Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18e5c31af7Sopenharmony_ci# See the License for the specific language governing permissions and 19e5c31af7Sopenharmony_ci# limitations under the License. 20e5c31af7Sopenharmony_ci# 21e5c31af7Sopenharmony_ci#------------------------------------------------------------------------- 22e5c31af7Sopenharmony_ci 23e5c31af7Sopenharmony_ciimport sys 24e5c31af7Sopenharmony_ciimport random 25e5c31af7Sopenharmony_ciimport operator 26e5c31af7Sopenharmony_ciimport itertools 27e5c31af7Sopenharmony_ci 28e5c31af7Sopenharmony_cifrom genutil import * 29e5c31af7Sopenharmony_ci 30e5c31af7Sopenharmony_cirandom.seed(1234567) 31e5c31af7Sopenharmony_ciindices = xrange(sys.maxint) 32e5c31af7Sopenharmony_ci 33e5c31af7Sopenharmony_ci# Constructors: 34e5c31af7Sopenharmony_ci# 35e5c31af7Sopenharmony_ci# - scalars types 36e5c31af7Sopenharmony_ci# * int <-> float <-> bool (also float(float) etc.) 37e5c31af7Sopenharmony_ci# * to bool: zero means false, others true 38e5c31af7Sopenharmony_ci# * from bool: false==0, true==1 39e5c31af7Sopenharmony_ci# * \todo [petri] float<->int rounding rules? 40e5c31af7Sopenharmony_ci# - scalar type from vector 41e5c31af7Sopenharmony_ci# * choose the first component 42e5c31af7Sopenharmony_ci# - vectors & matrices 43e5c31af7Sopenharmony_ci# * vector from scalar: broadcast to all components 44e5c31af7Sopenharmony_ci# * matrix from scalar: broadcast scalar to diagonal, other components zero 45e5c31af7Sopenharmony_ci# * vector from vector: copy existing components 46e5c31af7Sopenharmony_ci# + illegal: vector from smaller vector 47e5c31af7Sopenharmony_ci# * mat from mat: copy existing components, other components from identity matrix 48e5c31af7Sopenharmony_ci# * from components: consumed by-component in column-major order, must have same 49e5c31af7Sopenharmony_ci# number of components, 50e5c31af7Sopenharmony_ci# + note: vec4(mat2) valid 51e5c31af7Sopenharmony_ci# \todo [petri] Implement! 52e5c31af7Sopenharmony_ci# - notes: 53e5c31af7Sopenharmony_ci# * type conversions are always allowed: mat3(ivec3, bvec3, bool, int, float) is valid! 54e5c31af7Sopenharmony_ci# 55e5c31af7Sopenharmony_ci# Accessors: 56e5c31af7Sopenharmony_ci# 57e5c31af7Sopenharmony_ci# - vector components 58e5c31af7Sopenharmony_ci# * .xyzw, .rgba, .stpq 59e5c31af7Sopenharmony_ci# * illegal to mix 60e5c31af7Sopenharmony_ci# * now allowed for scalar types 61e5c31af7Sopenharmony_ci# * legal to chain: vec4.rgba.xyzw.stpq 62e5c31af7Sopenharmony_ci# * illegal to select more than 4 components 63e5c31af7Sopenharmony_ci# * array indexing with [] operator 64e5c31af7Sopenharmony_ci# * can also write! 65e5c31af7Sopenharmony_ci# - matrix columns 66e5c31af7Sopenharmony_ci# * [] accessor 67e5c31af7Sopenharmony_ci# * note: mat4[0].x = 1.0; vs mat4[0][0] = 1.0; ?? 68e5c31af7Sopenharmony_ci# * out-of-bounds accesses 69e5c31af7Sopenharmony_ci# 70e5c31af7Sopenharmony_ci# \todo [petri] Accessors! 71e5c31af7Sopenharmony_ci# 72e5c31af7Sopenharmony_ci# Spec issues: 73e5c31af7Sopenharmony_ci# 74e5c31af7Sopenharmony_ci# - constructing larger vector from smaller: vec3(vec2) ? 75e5c31af7Sopenharmony_ci# - base type and size conversion at same time: vec4(bool), int(vec3) allowed? 76e5c31af7Sopenharmony_ci 77e5c31af7Sopenharmony_cidef combineVec(comps): 78e5c31af7Sopenharmony_ci res = [] 79e5c31af7Sopenharmony_ci for ndx in range(len(comps[0])): 80e5c31af7Sopenharmony_ci# for x in comps: 81e5c31af7Sopenharmony_ci# print x[ndx].toFloat().getScalars() , 82e5c31af7Sopenharmony_ci scalars = reduce(operator.add, [x[ndx].toFloat().getScalars() for x in comps]) 83e5c31af7Sopenharmony_ci# print "->", scalars 84e5c31af7Sopenharmony_ci res.append(Vec.fromScalarList(scalars)) 85e5c31af7Sopenharmony_ci return res 86e5c31af7Sopenharmony_ci 87e5c31af7Sopenharmony_cidef combineIVec(comps): 88e5c31af7Sopenharmony_ci res = [] 89e5c31af7Sopenharmony_ci for ndx in range(len(comps[0])): 90e5c31af7Sopenharmony_ci res.append(Vec.fromScalarList(reduce(operator.add, [x[ndx].toInt().getScalars() for x in comps]))) 91e5c31af7Sopenharmony_ci return res 92e5c31af7Sopenharmony_ci 93e5c31af7Sopenharmony_cidef combineBVec(comps): 94e5c31af7Sopenharmony_ci res = [] 95e5c31af7Sopenharmony_ci for ndx in range(len(comps[0])): 96e5c31af7Sopenharmony_ci res.append(Vec.fromScalarList(reduce(operator.add, [x[ndx].toBool().getScalars() for x in comps]))) 97e5c31af7Sopenharmony_ci return res 98e5c31af7Sopenharmony_ci 99e5c31af7Sopenharmony_cidef combineMat(numCols, numRows, comps): 100e5c31af7Sopenharmony_ci res = [] 101e5c31af7Sopenharmony_ci for ndx in range(len(comps[0])): 102e5c31af7Sopenharmony_ci scalars = reduce(operator.add, [x[ndx].toFloat().getScalars() for x in comps]) 103e5c31af7Sopenharmony_ci res.append(Mat(numCols, numRows, scalars)) 104e5c31af7Sopenharmony_ci return res 105e5c31af7Sopenharmony_ci 106e5c31af7Sopenharmony_cidef combineMat2(comps): return combineMat(2, 2, comps) 107e5c31af7Sopenharmony_cidef combineMat3(comps): return combineMat(3, 3, comps) 108e5c31af7Sopenharmony_cidef combineMat4(comps): return combineMat(4, 4, comps) 109e5c31af7Sopenharmony_ci 110e5c31af7Sopenharmony_ci# 0 \+ [f*f for f in lst] 111e5c31af7Sopenharmony_ci# r = 0 \+ [f in lst -> f*f] 112e5c31af7Sopenharmony_ci# r = 0 \+ lst 113e5c31af7Sopenharmony_ci 114e5c31af7Sopenharmony_ci# Templates. 115e5c31af7Sopenharmony_ci 116e5c31af7Sopenharmony_cis_simpleCaseTemplate = """ 117e5c31af7Sopenharmony_cicase ${{NAME}} 118e5c31af7Sopenharmony_ci values 119e5c31af7Sopenharmony_ci { 120e5c31af7Sopenharmony_ci ${{VALUES}} 121e5c31af7Sopenharmony_ci } 122e5c31af7Sopenharmony_ci 123e5c31af7Sopenharmony_ci both "" 124e5c31af7Sopenharmony_ci precision mediump float; 125e5c31af7Sopenharmony_ci precision mediump int; 126e5c31af7Sopenharmony_ci 127e5c31af7Sopenharmony_ci ${DECLARATIONS} 128e5c31af7Sopenharmony_ci 129e5c31af7Sopenharmony_ci void main() 130e5c31af7Sopenharmony_ci { 131e5c31af7Sopenharmony_ci ${SETUP} 132e5c31af7Sopenharmony_ci ${{OP}} 133e5c31af7Sopenharmony_ci ${OUTPUT} 134e5c31af7Sopenharmony_ci } 135e5c31af7Sopenharmony_ci "" 136e5c31af7Sopenharmony_ciend 137e5c31af7Sopenharmony_ci"""[1:] 138e5c31af7Sopenharmony_ci 139e5c31af7Sopenharmony_cis_simpleIllegalCaseTemplate = """ 140e5c31af7Sopenharmony_cicase ${{NAME}} 141e5c31af7Sopenharmony_ci expect compile_fail 142e5c31af7Sopenharmony_ci values {} 143e5c31af7Sopenharmony_ci 144e5c31af7Sopenharmony_ci both "" 145e5c31af7Sopenharmony_ci precision mediump float; 146e5c31af7Sopenharmony_ci precision mediump int; 147e5c31af7Sopenharmony_ci 148e5c31af7Sopenharmony_ci ${DECLARATIONS} 149e5c31af7Sopenharmony_ci 150e5c31af7Sopenharmony_ci void main() 151e5c31af7Sopenharmony_ci { 152e5c31af7Sopenharmony_ci ${SETUP} 153e5c31af7Sopenharmony_ci ${{OP}} 154e5c31af7Sopenharmony_ci ${OUTPUT} 155e5c31af7Sopenharmony_ci } 156e5c31af7Sopenharmony_ci "" 157e5c31af7Sopenharmony_ciend 158e5c31af7Sopenharmony_ci"""[1:] 159e5c31af7Sopenharmony_ci 160e5c31af7Sopenharmony_ciclass SimpleCase(ShaderCase): 161e5c31af7Sopenharmony_ci def __init__(self, name, inputs, outputs, op): 162e5c31af7Sopenharmony_ci self.name = name 163e5c31af7Sopenharmony_ci self.inputs = inputs 164e5c31af7Sopenharmony_ci self.outputs = outputs 165e5c31af7Sopenharmony_ci self.op = op 166e5c31af7Sopenharmony_ci 167e5c31af7Sopenharmony_ci def __str__(self): 168e5c31af7Sopenharmony_ci params = { 169e5c31af7Sopenharmony_ci "NAME": self.name, 170e5c31af7Sopenharmony_ci "VALUES": genValues(self.inputs, self.outputs), 171e5c31af7Sopenharmony_ci "OP": self.op 172e5c31af7Sopenharmony_ci } 173e5c31af7Sopenharmony_ci return fillTemplate(s_simpleCaseTemplate, params) 174e5c31af7Sopenharmony_ci 175e5c31af7Sopenharmony_ciclass ConversionCase(ShaderCase): 176e5c31af7Sopenharmony_ci def __init__(self, inValues, convFunc): 177e5c31af7Sopenharmony_ci outValues = convFunc(inValues) 178e5c31af7Sopenharmony_ci inType = inValues[0].typeString() 179e5c31af7Sopenharmony_ci outType = outValues[0].typeString() 180e5c31af7Sopenharmony_ci self.name = "%s_to_%s" % (inType, outType) 181e5c31af7Sopenharmony_ci self.op = "out0 = %s(in0);" % outType 182e5c31af7Sopenharmony_ci self.inputs = [("%s in0" % inType, inValues)] 183e5c31af7Sopenharmony_ci self.outputs = [("%s out0" % outType, outValues)] 184e5c31af7Sopenharmony_ci 185e5c31af7Sopenharmony_ci def __str__(self): 186e5c31af7Sopenharmony_ci params = { 187e5c31af7Sopenharmony_ci "NAME": self.name, 188e5c31af7Sopenharmony_ci "VALUES": genValues(self.inputs, self.outputs), 189e5c31af7Sopenharmony_ci "OP": self.op 190e5c31af7Sopenharmony_ci } 191e5c31af7Sopenharmony_ci return fillTemplate(s_simpleCaseTemplate, params) 192e5c31af7Sopenharmony_ci 193e5c31af7Sopenharmony_ciclass IllegalConversionCase(ShaderCase): 194e5c31af7Sopenharmony_ci def __init__(self, inValue, outValue): 195e5c31af7Sopenharmony_ci inType = inValue.typeString() 196e5c31af7Sopenharmony_ci outType = outValue.typeString() 197e5c31af7Sopenharmony_ci self.name = "%s_to_%s" % (inType, outType) 198e5c31af7Sopenharmony_ci self.op = "%s in0 = %s;\n%s out0 = %s(in0);" % (inType, str(inValue), outType, outType) 199e5c31af7Sopenharmony_ci self.inType = inType 200e5c31af7Sopenharmony_ci self.outType = outType 201e5c31af7Sopenharmony_ci 202e5c31af7Sopenharmony_ci def __str__(self): 203e5c31af7Sopenharmony_ci params = { 204e5c31af7Sopenharmony_ci "NAME": self.name, 205e5c31af7Sopenharmony_ci "OP": self.op 206e5c31af7Sopenharmony_ci } 207e5c31af7Sopenharmony_ci return fillTemplate(s_simpleIllegalCaseTemplate, params) 208e5c31af7Sopenharmony_ci 209e5c31af7Sopenharmony_ciclass CombineCase(ShaderCase): 210e5c31af7Sopenharmony_ci def __init__(self, inComps, combFunc): 211e5c31af7Sopenharmony_ci self.inComps = inComps 212e5c31af7Sopenharmony_ci self.outValues = combFunc(inComps) 213e5c31af7Sopenharmony_ci self.outType = self.outValues[0].typeString() 214e5c31af7Sopenharmony_ci inTypes = [values[0].typeString() for values in inComps] 215e5c31af7Sopenharmony_ci self.name = "%s_to_%s" % ("_".join(inTypes), self.outType) 216e5c31af7Sopenharmony_ci self.inputs = [("%s in%s" % (comp[0].typeString(), ndx), comp) for (comp, ndx) in zip(inComps, indices)] 217e5c31af7Sopenharmony_ci self.outputs = [("%s out0" % self.outType, self.outValues)] 218e5c31af7Sopenharmony_ci self.op = "out0 = %s(%s);" % (self.outType, ", ".join(["in%d" % x for x in range(len(inComps))])) 219e5c31af7Sopenharmony_ci 220e5c31af7Sopenharmony_ci def __str__(self): 221e5c31af7Sopenharmony_ci params = { 222e5c31af7Sopenharmony_ci "NAME": self.name, 223e5c31af7Sopenharmony_ci "VALUES": genValues(self.inputs, self.outputs), 224e5c31af7Sopenharmony_ci "OP": self.op 225e5c31af7Sopenharmony_ci } 226e5c31af7Sopenharmony_ci return fillTemplate(s_simpleCaseTemplate, params) 227e5c31af7Sopenharmony_ci 228e5c31af7Sopenharmony_ci# CASE DECLARATIONS 229e5c31af7Sopenharmony_ci 230e5c31af7Sopenharmony_ciinFloat = [Scalar(x) for x in [0.0, 1.0, 2.0, 3.5, -0.5, -8.25, -20.125, 36.8125]] 231e5c31af7Sopenharmony_ciinInt = [Scalar(x) for x in [0, 1, 2, 5, 8, 11, -12, -66, -192, 255]] 232e5c31af7Sopenharmony_ciinBool = [Scalar(x) for x in [True, False]] 233e5c31af7Sopenharmony_ci 234e5c31af7Sopenharmony_ciinVec4 = [Vec4(0.0, 0.5, 0.75, 0.825), Vec4(1.0, 1.25, 1.125, 1.75), 235e5c31af7Sopenharmony_ci Vec4(-0.5, -2.25, -4.875, 9.0), Vec4(-32.0, 64.0, -51.0, 24.0), 236e5c31af7Sopenharmony_ci Vec4(-0.75, -1.0/31.0, 1.0/19.0, 1.0/4.0)] 237e5c31af7Sopenharmony_ciinVec3 = toVec3(inVec4) 238e5c31af7Sopenharmony_ciinVec2 = toVec2(inVec4) 239e5c31af7Sopenharmony_ciinIVec4 = toIVec4(inVec4) 240e5c31af7Sopenharmony_ciinIVec3 = toIVec3(inVec4) 241e5c31af7Sopenharmony_ciinIVec2 = toIVec2(inVec4) 242e5c31af7Sopenharmony_ciinBVec4 = [Vec4(True, False, False, True), Vec4(False, False, False, True), Vec4(False, True, False, False), Vec4(True, True, True, True), Vec4(False, False, False, False)] 243e5c31af7Sopenharmony_ciinBVec3 = toBVec3(inBVec4) 244e5c31af7Sopenharmony_ciinBVec2 = toBVec2(inBVec4) 245e5c31af7Sopenharmony_ci 246e5c31af7Sopenharmony_ci# \todo [petri] Enable large values when epsilon adapts to the values. 247e5c31af7Sopenharmony_ciinMat4 = [Mat4(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0), 248e5c31af7Sopenharmony_ci Mat4(6.5, 12.5, -0.75, 9.975, 32.0, 1.0/48.0, -8.425, -6.542, 1.0/8.0, 1.0/16.0, 1.0/32.0, 1.0/64.0, -6.725, -0.5, -0.0125, 9.975), 249e5c31af7Sopenharmony_ci #Mat4(128.0, 256.0, -512.0, -1024.0, 2048.0, -4096.0, 8192.0, -8192.0, 192.0, -384.0, 768.0, -1536.0, 8192.0, -8192.0, 6144.0, -6144.0) 250e5c31af7Sopenharmony_ci ] 251e5c31af7Sopenharmony_ciinMat3 = [Mat3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0), 252e5c31af7Sopenharmony_ci Mat3(6.5, 12.5, -0.75, 32.0, 1.0/32.0, 1.0/64.0, 1.0/8.0, 1.0/16.0, 1.0/32.0), 253e5c31af7Sopenharmony_ci #Mat3(-18.725, -0.5, -0.0125, 19.975, -0.25, -17.75, 9.25, 65.125, -21.425), 254e5c31af7Sopenharmony_ci #Mat3(128.0, -4096.0, -8192.0, 192.0, 768.0, -1536.0, 8192.0, 6144.0, -6144.0) 255e5c31af7Sopenharmony_ci ] 256e5c31af7Sopenharmony_ciinMat2 = [Mat2(1.0, 0.0, 0.0, 1.0), 257e5c31af7Sopenharmony_ci Mat2(6.5, 12.5, -0.75, 9.975), 258e5c31af7Sopenharmony_ci Mat2(6.5, 12.5, -0.75, 9.975), 259e5c31af7Sopenharmony_ci Mat2(8.0, 16.0, -24.0, -16.0), 260e5c31af7Sopenharmony_ci Mat2(1.0/8.0, 1.0/16.0, 1.0/32.0, 1.0/64.0), 261e5c31af7Sopenharmony_ci Mat2(-18.725, -0.5, -0.0125, 19.975), 262e5c31af7Sopenharmony_ci #Mat2(128.0, -4096.0, 192.0, -1536.0), 263e5c31af7Sopenharmony_ci #Mat2(-1536.0, 8192.0, 6144.0, -6144.0) 264e5c31af7Sopenharmony_ci ] 265e5c31af7Sopenharmony_ci 266e5c31af7Sopenharmony_cidef genConversionCases(inValueList, convFuncList): 267e5c31af7Sopenharmony_ci combinations = list(itertools.product(inValueList, convFuncList)) 268e5c31af7Sopenharmony_ci return [ConversionCase(inValues, convFunc) for (inValues, convFunc) in combinations] 269e5c31af7Sopenharmony_ci 270e5c31af7Sopenharmony_cidef genIllegalConversionCases(inValueList, outValueList): 271e5c31af7Sopenharmony_ci inValues = [x[0] for x in inValueList] 272e5c31af7Sopenharmony_ci outValues = [x[0] for x in outValueList] 273e5c31af7Sopenharmony_ci combinations = list(itertools.product(inValues, outValues)) 274e5c31af7Sopenharmony_ci return [IllegalConversionCase(inVal, outVal) for (inVal, outVal) in combinations] 275e5c31af7Sopenharmony_ci 276e5c31af7Sopenharmony_cidef shuffleSubLists(outer): 277e5c31af7Sopenharmony_ci return [shuffled(inner) for inner in outer] 278e5c31af7Sopenharmony_ci 279e5c31af7Sopenharmony_ci# Generate all combinations of CombineCases. 280e5c31af7Sopenharmony_ci# inTupleList a list of tuples of value-lists 281e5c31af7Sopenharmony_ci# combFuncList a list of comb* functions to combine 282e5c31af7Sopenharmony_cidef genComponentCases(inCompLists, combFuncList): 283e5c31af7Sopenharmony_ci res = [] 284e5c31af7Sopenharmony_ci for comps in inCompLists: 285e5c31af7Sopenharmony_ci maxLen = reduce(max, [len(values) for values in comps]) 286e5c31af7Sopenharmony_ci comps = [repeatToLength(values, maxLen) for values in comps] 287e5c31af7Sopenharmony_ci comps = [shuffled(values) for values in comps] 288e5c31af7Sopenharmony_ci for combFunc in combFuncList: 289e5c31af7Sopenharmony_ci res += [CombineCase(comps, combFunc)] 290e5c31af7Sopenharmony_ci return res 291e5c31af7Sopenharmony_ci 292e5c31af7Sopenharmony_ciallConversionCases = [] 293e5c31af7Sopenharmony_ci 294e5c31af7Sopenharmony_ci# Scalar-to-scalar conversions. 295e5c31af7Sopenharmony_ciallConversionCases.append(CaseGroup("scalar_to_scalar", "Scalar to Scalar Conversions", 296e5c31af7Sopenharmony_ci genConversionCases([inFloat, inInt, inBool], [toFloat, toInt, toBool]))) 297e5c31af7Sopenharmony_ci 298e5c31af7Sopenharmony_ci# Scalar-to-vector conversions. 299e5c31af7Sopenharmony_ciallConversionCases.append(CaseGroup("scalar_to_vector", "Scalar to Vector Conversions", 300e5c31af7Sopenharmony_ci genConversionCases([inFloat, inInt, inBool], [toVec2, toVec3, toVec4, toIVec2, toIVec3, toIVec4, toBVec2, toBVec3, toBVec4]))) 301e5c31af7Sopenharmony_ci 302e5c31af7Sopenharmony_ci# Vector-to-scalar conversions. 303e5c31af7Sopenharmony_ciallConversionCases.append(CaseGroup("vector_to_scalar", "Vector to Scalar Conversions", 304e5c31af7Sopenharmony_ci genConversionCases([inVec2, inVec3, inVec4, inIVec2, inIVec3, inIVec4, inBVec2, inBVec3, inBVec4], [toFloat, toInt, toBool]))) 305e5c31af7Sopenharmony_ci 306e5c31af7Sopenharmony_ci# Illegal vector-to-vector conversions (to longer vec). 307e5c31af7Sopenharmony_ciallConversionCases.append(CaseGroup("vector_illegal", "Illegal Vector Conversions", 308e5c31af7Sopenharmony_ci genIllegalConversionCases([inVec2, inIVec2, inBVec2], [inVec3, inIVec3, inBVec3, inVec4, inIVec4, inBVec4]) +\ 309e5c31af7Sopenharmony_ci genIllegalConversionCases([inVec3, inIVec3, inBVec3], [inVec4, inIVec4, inBVec4]))) 310e5c31af7Sopenharmony_ci 311e5c31af7Sopenharmony_ci# Vector-to-vector conversions (type conversions, downcasts). 312e5c31af7Sopenharmony_ciallConversionCases.append(CaseGroup("vector_to_vector", "Vector to Vector Conversions", 313e5c31af7Sopenharmony_ci genConversionCases([inVec4, inIVec4, inBVec4], [toVec4, toVec3, toVec2, toIVec4, toIVec3, toIVec2, toBVec4, toBVec3, toBVec2]) +\ 314e5c31af7Sopenharmony_ci genConversionCases([inVec3, inIVec3, inBVec3], [toVec3, toVec2, toIVec3, toIVec2, toBVec3, toBVec2]) +\ 315e5c31af7Sopenharmony_ci genConversionCases([inVec2, inIVec2, inBVec2], [toVec2, toIVec2, toBVec2]))) 316e5c31af7Sopenharmony_ci 317e5c31af7Sopenharmony_ci# Scalar-to-matrix. 318e5c31af7Sopenharmony_ciallConversionCases.append(CaseGroup("scalar_to_matrix", "Scalar to Matrix Conversions", 319e5c31af7Sopenharmony_ci genConversionCases([inFloat, inInt, inBool], [toMat4, toMat3, toMat2]))) 320e5c31af7Sopenharmony_ci 321e5c31af7Sopenharmony_ci# Vector-to-matrix. 322e5c31af7Sopenharmony_ci#allConversionCases += genConversionCases([inVec4, inIVec4, inBVec4], [toMat4]) 323e5c31af7Sopenharmony_ci#allConversionCases += genConversionCases([inVec3, inIVec3, inBVec3], [toMat3]) 324e5c31af7Sopenharmony_ci#allConversionCases += genConversionCases([inVec2, inIVec2, inBVec2], [toMat2]) 325e5c31af7Sopenharmony_ci 326e5c31af7Sopenharmony_ci# Matrix-to-matrix. 327e5c31af7Sopenharmony_ciallConversionCases.append(CaseGroup("matrix_to_matrix", "Matrix to Matrix Conversions", 328e5c31af7Sopenharmony_ci genConversionCases([inMat4, inMat3, inMat2], [toMat4, toMat3, toMat2]))) 329e5c31af7Sopenharmony_ci 330e5c31af7Sopenharmony_ci# Vector-from-components, matrix-from-components. 331e5c31af7Sopenharmony_ciin2Comp = [[inFloat, inFloat], [inInt, inInt], [inBool, inBool], [inFloat, inInt], [inFloat, inBool], [inInt, inBool]] 332e5c31af7Sopenharmony_ciin3Comp = [[inFloat, inFloat, inFloat], [inInt, inInt, inInt], [inBool, inBool, inBool], [inBool, inFloat, inInt], [inVec2, inBool], [inBVec2, inFloat], [inBVec2, inInt], [inBool, inIVec2]] 333e5c31af7Sopenharmony_ciin4Comp = [[inVec2, inVec2], [inBVec2, inBVec2], [inFloat, inFloat, inFloat, inFloat], [inInt, inInt, inInt, inInt], [inBool, inBool, inBool, inBool], [inBool, inFloat, inInt, inBool], [inVec2, inIVec2], [inVec2, inBVec2], [inBVec3, inFloat], [inVec3, inFloat], [inInt, inIVec2, inInt], [inBool, inFloat, inIVec2]] 334e5c31af7Sopenharmony_ciin9Comp = [[inVec3, inVec3, inVec3], [inIVec3, inIVec3, inIVec3], [inVec2, inIVec2, inFloat, inFloat, inInt, inBool, inBool], [inBool, inFloat, inInt, inVec2, inBool, inBVec2, inFloat], [inBool, inBVec2, inInt, inVec4, inBool], [inFloat, inBVec4, inIVec2, inBool, inBool]] 335e5c31af7Sopenharmony_ciin16Comp = [[inVec4, inVec4, inVec4, inVec4], [inIVec4, inIVec4, inIVec4, inIVec4], [inBVec4, inBVec4, inBVec4, inBVec4], [inFloat, inIVec3, inBVec3, inVec4, inIVec2, inFloat, inVec2]] 336e5c31af7Sopenharmony_ci 337e5c31af7Sopenharmony_ciallConversionCases.append(CaseGroup("vector_combine", "Vector Combine Constructors", 338e5c31af7Sopenharmony_ci genComponentCases(in4Comp, [combineVec, combineIVec, combineBVec]) +\ 339e5c31af7Sopenharmony_ci genComponentCases(in3Comp, [combineVec, combineIVec, combineBVec]) +\ 340e5c31af7Sopenharmony_ci genComponentCases(in2Comp, [combineVec, combineIVec, combineBVec]))) 341e5c31af7Sopenharmony_ci 342e5c31af7Sopenharmony_ciallConversionCases.append(CaseGroup("matrix_combine", "Matrix Combine Constructors", 343e5c31af7Sopenharmony_ci genComponentCases(in4Comp, [combineMat2]) +\ 344e5c31af7Sopenharmony_ci genComponentCases(in9Comp, [combineMat3]) +\ 345e5c31af7Sopenharmony_ci genComponentCases(in16Comp, [combineMat4]) 346e5c31af7Sopenharmony_ci )) 347e5c31af7Sopenharmony_ci 348e5c31af7Sopenharmony_ci# Main program. 349e5c31af7Sopenharmony_ci 350e5c31af7Sopenharmony_ciif __name__ == "__main__": 351e5c31af7Sopenharmony_ci print("Generating shader case files.") 352e5c31af7Sopenharmony_ci writeAllCases("conversions.test", allConversionCases) 353