am 613ce462: (-s ours) am 15f67207: Use RGBA8888 base config for EGL image functional...
[platform/upstream/VK-GL-CTS.git] / modules / gles3 / scripts / gen-invalid-texture-funcs.py
1 # -*- coding: utf-8 -*-
2
3 #-------------------------------------------------------------------------
4 # drawElements Quality Program utilities
5 # --------------------------------------
6 #
7 # Copyright 2015 The Android Open Source Project
8 #
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
12 #
13 #      http://www.apache.org/licenses/LICENSE-2.0
14 #
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.
20 #
21 #-------------------------------------------------------------------------
22
23 import sys
24 import string
25 from genutil import *
26
27 # Templates
28
29 INVALID_TEXTURE_FUNC_TEMPLATE = """
30 case ${{NAME}}
31         expect compile_fail
32         values {}
33         version 300 es
34
35         both ""
36                 #version 300 es
37                 precision mediump float;
38                 ${DECLARATIONS}
39                 uniform mediump ${{SAMPLERTYPE}} s;
40
41                 void main()
42                 {
43                         ${SETUP}
44                         ${POSITION_FRAG_COLOR} = vec4(${{LOOKUP}});
45                         ${OUTPUT}
46                 }
47         ""
48 end
49 """[1:-1]
50
51 # Classes
52
53 def getValueExpr (argType):
54         return "%s(0)" % argType
55
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
60                 self.args               = args
61
62         def __str__(self):
63                 samplerType     = self.args[0]
64
65                 lookup = self.funcname + "(s"
66                 for arg in self.args[1:]:
67                         lookup += ", %s" % getValueExpr(arg)
68                 lookup += ")"
69
70                 params = { "NAME": self.name, "SAMPLERTYPE": samplerType, "LOOKUP": lookup }
71                 return fillTemplate(INVALID_TEXTURE_FUNC_TEMPLATE, params)
72
73 # Invalid lookup cases
74 # \note Does not include cases that don't make sense
75
76 INVALID_TEX_FUNC_CASES = [
77         # texture
78         InvalidTexFuncCase("texture",                           ["sampler3DShadow",     "vec4"]),
79         InvalidTexFuncCase("texture",                           ["sampler2DArrayShadow", "vec4", "float"]),
80
81         # textureProj
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"]),
90
91         # textureLod
92         InvalidTexFuncCase("textureLod",                        ["samplerCubeShadow", "vec4", "float"]),
93         InvalidTexFuncCase("textureLod",                        ["sampler2DArrayShadow", "vec4", "float"]),
94
95         # textureOffset
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"]),
110
111         # texelFetch
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"]),
118
119         # texelFetchOffset
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"]),
124
125         # textureProjOffset
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"]),
131
132         # textureLodOffset
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"]),
138
139         # textureProjLod
140         InvalidTexFuncCase("textureProjLod",            ["samplerCube", "vec4", "float"]),
141         InvalidTexFuncCase("textureProjLod",            ["sampler2DArray", "vec4", "float"]),
142         InvalidTexFuncCase("textureProjLod",            ["sampler2DArrayShadow", "vec4", "float"]),
143
144         # textureGrad
145         InvalidTexFuncCase("textureGrad",                       ["sampler2DArray", "vec3", "vec3", "vec3"]),
146
147         # textureGradOffset
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"]),
152
153         # textureProjGrad
154         InvalidTexFuncCase("textureProjGrad",           ["samplerCube", "vec4", "vec3", "vec3"]),
155         InvalidTexFuncCase("textureProjGrad",           ["sampler2DArray", "vec4", "vec2", "vec2"]),
156
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"])
162 ]
163
164 if __name__ == "__main__":
165         print "Generating shader case files."
166         writeAllCases("invalid_texture_functions.test", INVALID_TEX_FUNC_CASES)