1 # -*- coding: utf-8 -*-
3 #-------------------------------------------------------------------------
4 # drawElements Quality Program utilities
5 # --------------------------------------
7 # Copyright 2015 The Android Open Source Project
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_TEXTURE_FUNC_TEMPLATE = """
37 precision mediump float;
39 uniform mediump ${{SAMPLERTYPE}} s;
44 ${POSITION_FRAG_COLOR} = vec4(${{LOOKUP}});
53 def getValueExpr (argType):
54 return "%s(0)" % argType
56 class InvalidTexFuncCase(ShaderCase):
57 def __init__(self, funcname, args):
58 self.name = string.join([s.lower() for s in [funcname] + args], "_")
59 self.funcname = funcname
63 samplerType = self.args[0]
65 lookup = self.funcname + "(s"
66 for arg in self.args[1:]:
67 lookup += ", %s" % getValueExpr(arg)
70 params = { "NAME": self.name, "SAMPLERTYPE": samplerType, "LOOKUP": lookup }
71 return fillTemplate(INVALID_TEXTURE_FUNC_TEMPLATE, params)
73 # Invalid lookup cases
74 # \note Does not include cases that don't make sense
76 INVALID_TEX_FUNC_CASES = [
78 InvalidTexFuncCase("texture", ["sampler3DShadow", "vec4"]),
79 InvalidTexFuncCase("texture", ["sampler2DArrayShadow", "vec4", "float"]),
82 InvalidTexFuncCase("textureProj", ["samplerCube", "vec4"]),
83 InvalidTexFuncCase("textureProj", ["isamplerCube", "vec4"]),
84 InvalidTexFuncCase("textureProj", ["usamplerCube", "vec4"]),
85 InvalidTexFuncCase("textureProj", ["samplerCube", "vec4", "float"]),
86 InvalidTexFuncCase("textureProj", ["isamplerCube", "vec4", "float"]),
87 InvalidTexFuncCase("textureProj", ["usamplerCube", "vec4", "float"]),
88 InvalidTexFuncCase("textureProj", ["sampler2DArrayShadow", "vec4"]),
89 InvalidTexFuncCase("textureProj", ["sampler2DArrayShadow", "vec4", "float"]),
92 InvalidTexFuncCase("textureLod", ["samplerCubeShadow", "vec4", "float"]),
93 InvalidTexFuncCase("textureLod", ["sampler2DArrayShadow", "vec4", "float"]),
96 InvalidTexFuncCase("textureOffset", ["samplerCube", "vec3", "ivec2"]),
97 InvalidTexFuncCase("textureOffset", ["isamplerCube", "vec3", "ivec2"]),
98 InvalidTexFuncCase("textureOffset", ["usamplerCube", "vec3", "ivec2"]),
99 InvalidTexFuncCase("textureOffset", ["samplerCube", "vec3", "ivec3"]),
100 InvalidTexFuncCase("textureOffset", ["isamplerCube", "vec3", "ivec3"]),
101 InvalidTexFuncCase("textureOffset", ["usamplerCube", "vec3", "ivec3"]),
102 InvalidTexFuncCase("textureOffset", ["samplerCube", "vec3", "ivec2", "float"]),
103 InvalidTexFuncCase("textureOffset", ["samplerCube", "vec3", "ivec3", "float"]),
104 InvalidTexFuncCase("textureOffset", ["sampler2DArray", "vec3", "ivec3"]),
105 InvalidTexFuncCase("textureOffset", ["sampler2DArray", "vec3", "ivec3", "float"]),
106 InvalidTexFuncCase("textureOffset", ["samplerCubeShadow", "vec4", "ivec2"]),
107 InvalidTexFuncCase("textureOffset", ["samplerCubeShadow", "vec4", "ivec3"]),
108 InvalidTexFuncCase("textureOffset", ["sampler2DArrayShadow", "vec4", "ivec2"]),
109 InvalidTexFuncCase("textureOffset", ["sampler2DArrayShadow", "vec4", "ivec2", "float"]),
112 InvalidTexFuncCase("texelFetch", ["samplerCube", "ivec3", "int"]),
113 InvalidTexFuncCase("texelFetch", ["isamplerCube", "ivec3", "int"]),
114 InvalidTexFuncCase("texelFetch", ["usamplerCube", "ivec3", "int"]),
115 InvalidTexFuncCase("texelFetch", ["sampler2DShadow", "ivec2", "int"]),
116 InvalidTexFuncCase("texelFetch", ["samplerCubeShadow", "ivec3", "int"]),
117 InvalidTexFuncCase("texelFetch", ["sampler2DArrayShadow", "ivec3", "int"]),
120 InvalidTexFuncCase("texelFetch", ["samplerCube", "ivec3", "int", "ivec3"]),
121 InvalidTexFuncCase("texelFetch", ["sampler2DShadow", "ivec2", "int", "ivec2"]),
122 InvalidTexFuncCase("texelFetch", ["samplerCubeShadow", "ivec3", "int", "ivec3"]),
123 InvalidTexFuncCase("texelFetch", ["sampler2DArrayShadow", "ivec3", "int", "ivec3"]),
126 InvalidTexFuncCase("textureProjOffset", ["samplerCube", "vec4", "ivec2"]),
127 InvalidTexFuncCase("textureProjOffset", ["samplerCube", "vec4", "ivec3"]),
128 InvalidTexFuncCase("textureProjOffset", ["samplerCubeShadow", "vec4", "ivec3"]),
129 InvalidTexFuncCase("textureProjOffset", ["sampler2DArrayShadow", "vec4", "ivec2"]),
130 InvalidTexFuncCase("textureProjOffset", ["sampler2DArrayShadow", "vec4", "ivec3"]),
133 InvalidTexFuncCase("textureLodOffset", ["samplerCube", "vec3", "float", "ivec2"]),
134 InvalidTexFuncCase("textureLodOffset", ["samplerCube", "vec3", "float", "ivec3"]),
135 InvalidTexFuncCase("textureLodOffset", ["samplerCubeShadow", "vec3", "float", "ivec3"]),
136 InvalidTexFuncCase("textureLodOffset", ["sampler2DArrayShadow", "vec3", "float", "ivec2"]),
137 InvalidTexFuncCase("textureLodOffset", ["sampler2DArrayShadow", "vec3", "float", "ivec3"]),
140 InvalidTexFuncCase("textureProjLod", ["samplerCube", "vec4", "float"]),
141 InvalidTexFuncCase("textureProjLod", ["sampler2DArray", "vec4", "float"]),
142 InvalidTexFuncCase("textureProjLod", ["sampler2DArrayShadow", "vec4", "float"]),
145 InvalidTexFuncCase("textureGrad", ["sampler2DArray", "vec3", "vec3", "vec3"]),
148 InvalidTexFuncCase("textureGradOffset", ["samplerCube", "vec3", "vec3", "vec3", "ivec2"]),
149 InvalidTexFuncCase("textureGradOffset", ["samplerCube", "vec3", "vec3", "vec3", "ivec3"]),
150 InvalidTexFuncCase("textureGradOffset", ["samplerCubeShadow", "vec4", "vec3", "vec3", "ivec2"]),
151 InvalidTexFuncCase("textureGradOffset", ["samplerCubeShadow", "vec4", "vec3", "vec3", "ivec3"]),
154 InvalidTexFuncCase("textureProjGrad", ["samplerCube", "vec4", "vec3", "vec3"]),
155 InvalidTexFuncCase("textureProjGrad", ["sampler2DArray", "vec4", "vec2", "vec2"]),
157 # textureProjGradOffset
158 InvalidTexFuncCase("textureProjGradOffset", ["samplerCube", "vec4", "vec3", "vec3", "ivec2"]),
159 InvalidTexFuncCase("textureProjGradOffset", ["samplerCube", "vec4", "vec3", "vec3", "ivec3"]),
160 InvalidTexFuncCase("textureProjGradOffset", ["sampler2DArray", "vec4", "vec2", "vec2", "ivec2"]),
161 InvalidTexFuncCase("textureProjGradOffset", ["sampler2DArray", "vec4", "vec2", "vec2", "ivec3"])
164 if __name__ == "__main__":
165 print "Generating shader case files."
166 writeAllCases("invalid_texture_functions.test", INVALID_TEX_FUNC_CASES)