Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / max-mix-conditional-discard.amber
1 #!amber
2
3 # Copyright 2019 Google LLC
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17
18 # A test for a bug found by GraphicsFuzz.
19
20 # Short description: A fragment shader with an expression used in two discard guards
21
22 # The test passes because most of the code never executes; the shader just writes the color red.
23
24 SHADER vertex variant_vertex_shader PASSTHROUGH
25
26 # variant_fragment_shader is derived from the following GLSL:
27 # #version 310 es
28 # precision highp float;
29 # precision highp int;
30 #
31 # layout(set = 0, binding = 0) uniform buf0
32 # {
33 #   vec2 injectionSwitch;
34 # };
35 # layout(location = 0) out vec4 _GLF_color;
36 #
37 # mediump vec4 gv;
38 #
39 # void main()
40 # {
41 #   if (injectionSwitch.x > 2.0) // always false
42 #   {
43 #     int temp = int(max(mix(vec4(1.0), vec4(1.0), gv), 8.6)[1]);
44 #
45 #     if (temp < 150)
46 #     {
47 #       discard;
48 #     }
49 #
50 #     if (temp < 180)
51 #     {
52 #       discard;
53 #     }
54 #   }
55 #   _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
56 # }
57 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
58 ; SPIR-V
59 ; Version: 1.0
60 ; Generator: Khronos Glslang Reference Front End; 7
61 ; Bound: 54
62 ; Schema: 0
63                OpCapability Shader
64           %1 = OpExtInstImport "GLSL.std.450"
65                OpMemoryModel Logical GLSL450
66                OpEntryPoint Fragment %4 "main" %51
67                OpExecutionMode %4 OriginUpperLeft
68                OpSource ESSL 310
69                OpName %4 "main"
70                OpName %8 "buf0"
71                OpMemberName %8 0 "injectionSwitch"
72                OpName %10 ""
73                OpName %24 "temp"
74                OpName %29 "gv"
75                OpName %51 "_GLF_color"
76                OpMemberDecorate %8 0 Offset 0
77                OpDecorate %8 Block
78                OpDecorate %10 DescriptorSet 0
79                OpDecorate %10 Binding 0
80                OpDecorate %29 RelaxedPrecision
81                OpDecorate %30 RelaxedPrecision
82                OpDecorate %31 RelaxedPrecision
83                OpDecorate %33 RelaxedPrecision
84                OpDecorate %34 RelaxedPrecision
85                OpDecorate %36 RelaxedPrecision
86                OpDecorate %51 Location 0
87           %2 = OpTypeVoid
88           %3 = OpTypeFunction %2
89           %6 = OpTypeFloat 32
90           %7 = OpTypeVector %6 2
91           %8 = OpTypeStruct %7
92           %9 = OpTypePointer Uniform %8
93          %10 = OpVariable %9 Uniform
94          %11 = OpTypeInt 32 1
95          %12 = OpConstant %11 0
96          %13 = OpTypeInt 32 0
97          %14 = OpConstant %13 0
98          %15 = OpTypePointer Uniform %6
99          %18 = OpConstant %6 2
100          %19 = OpTypeBool
101          %23 = OpTypePointer Function %11
102          %25 = OpTypeVector %6 4
103          %26 = OpConstant %6 1
104          %27 = OpConstantComposite %25 %26 %26 %26 %26
105          %28 = OpTypePointer Private %25
106          %29 = OpVariable %28 Private
107          %32 = OpConstant %6 8.60000038
108          %35 = OpConstant %13 1
109          %39 = OpConstant %11 150
110          %45 = OpConstant %11 180
111          %50 = OpTypePointer Output %25
112          %51 = OpVariable %50 Output
113          %52 = OpConstant %6 0
114          %53 = OpConstantComposite %25 %26 %52 %52 %26
115           %4 = OpFunction %2 None %3
116           %5 = OpLabel
117          %24 = OpVariable %23 Function
118          %16 = OpAccessChain %15 %10 %12 %14
119          %17 = OpLoad %6 %16
120          %20 = OpFOrdGreaterThan %19 %17 %18
121                OpSelectionMerge %22 None
122                OpBranchConditional %20 %21 %22
123          %21 = OpLabel
124          %30 = OpLoad %25 %29
125          %31 = OpExtInst %25 %1 FMix %27 %27 %30
126          %33 = OpCompositeConstruct %25 %32 %32 %32 %32
127          %34 = OpExtInst %25 %1 FMax %31 %33
128          %36 = OpCompositeExtract %6 %34 1
129          %37 = OpConvertFToS %11 %36
130                OpStore %24 %37
131          %38 = OpLoad %11 %24
132          %40 = OpSLessThan %19 %38 %39
133                OpSelectionMerge %42 None
134                OpBranchConditional %40 %41 %42
135          %41 = OpLabel
136                OpKill
137          %42 = OpLabel
138          %44 = OpLoad %11 %24
139          %46 = OpSLessThan %19 %44 %45
140                OpSelectionMerge %48 None
141                OpBranchConditional %46 %47 %48
142          %47 = OpLabel
143                OpKill
144          %48 = OpLabel
145                OpBranch %22
146          %22 = OpLabel
147                OpStore %51 %53
148                OpReturn
149                OpFunctionEnd
150 END
151
152 # uniforms for variant
153
154 # injectionSwitch
155 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
156  0.0 1.0
157 END
158
159 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
160
161 PIPELINE graphics variant_pipeline
162   ATTACH variant_vertex_shader
163   ATTACH variant_fragment_shader
164   FRAMEBUFFER_SIZE 256 256
165   BIND BUFFER variant_framebuffer AS color LOCATION 0
166   BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
167 END
168 CLEAR_COLOR variant_pipeline 0 0 0 255
169
170 CLEAR variant_pipeline
171 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
172
173 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255