Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / discard-in-loop-in-function.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 shader with a discard nested in a loop in a function
21
22 # The test passes because the discard is always reached, so we end up with the background color, black.
23
24 # Optimized using spirv-opt with the following arguments:
25 # '--simplify-instructions'
26 # '--eliminate-dead-inserts'
27 # '--redundancy-elimination'
28 # '--inline-entry-points-exhaustive'
29 # '--eliminate-dead-branches'
30 # '--merge-blocks'
31 # '--convert-local-access-chains'
32 # '--convert-local-access-chains'
33 # '--eliminate-dead-code-aggressive'
34 # '--eliminate-local-single-store'
35 # '--if-conversion'
36 # '--simplify-instructions'
37 # spirv-opt commit hash: 6b072126595dd8c2448eb1fda616251c5e6d7079
38
39
40
41 SHADER vertex variant_vertex_shader PASSTHROUGH
42
43 # variant_fragment_shader is derived from the following GLSL:
44 # #version 310 es
45 # precision highp float;
46 #
47 # layout(location = 0) out vec4 _GLF_color;
48 #
49 # layout(set = 0, binding = 0) uniform buf0 {
50 #  vec2 injectionSwitch;
51 # };
52 # void f()
53 # {
54 #  do
55 #   {
56 #    if(1.0 > injectionSwitch.y)
57 #     {
58 #      if(gl_FragCoord.y < 0.0)
59 #       {
60 #       }
61 #      continue;
62 #     }
63 #    discard;
64 #   }
65 #  while(false);
66 # }
67 # void main()
68 # {
69 #  f();
70 #  _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
71 # }
72 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
73 ; SPIR-V
74 ; Version: 1.0
75 ; Generator: Khronos Glslang Reference Front End; 7
76 ; Bound: 47
77 ; Schema: 0
78                OpCapability Shader
79           %1 = OpExtInstImport "GLSL.std.450"
80                OpMemoryModel Logical GLSL450
81                OpEntryPoint Fragment %4 "main" %31 %44
82                OpExecutionMode %4 OriginUpperLeft
83                OpSource ESSL 310
84                OpName %4 "main"
85                OpName %6 "f("
86                OpName %15 "buf0"
87                OpMemberName %15 0 "injectionSwitch"
88                OpName %17 ""
89                OpName %31 "gl_FragCoord"
90                OpName %44 "_GLF_color"
91                OpMemberDecorate %15 0 Offset 0
92                OpDecorate %15 Block
93                OpDecorate %17 DescriptorSet 0
94                OpDecorate %17 Binding 0
95                OpDecorate %31 BuiltIn FragCoord
96                OpDecorate %44 Location 0
97           %2 = OpTypeVoid
98           %3 = OpTypeFunction %2
99          %12 = OpTypeFloat 32
100          %13 = OpConstant %12 1
101          %14 = OpTypeVector %12 2
102          %15 = OpTypeStruct %14
103          %16 = OpTypePointer Uniform %15
104          %17 = OpVariable %16 Uniform
105          %18 = OpTypeInt 32 1
106          %19 = OpConstant %18 0
107          %20 = OpTypeInt 32 0
108          %21 = OpConstant %20 1
109          %22 = OpTypePointer Uniform %12
110          %25 = OpTypeBool
111          %29 = OpTypeVector %12 4
112          %30 = OpTypePointer Input %29
113          %31 = OpVariable %30 Input
114          %32 = OpTypePointer Input %12
115          %35 = OpConstant %12 0
116          %41 = OpConstantFalse %25
117          %43 = OpTypePointer Output %29
118          %44 = OpVariable %43 Output
119          %45 = OpConstantComposite %29 %13 %35 %35 %13
120           %4 = OpFunction %2 None %3
121           %5 = OpLabel
122          %42 = OpFunctionCall %2 %6
123                OpStore %44 %45
124                OpReturn
125                OpFunctionEnd
126           %6 = OpFunction %2 None %3
127           %7 = OpLabel
128                OpBranch %8
129           %8 = OpLabel
130                OpLoopMerge %10 %38 None
131                OpBranch %9
132           %9 = OpLabel
133          %23 = OpAccessChain %22 %17 %19 %21
134          %24 = OpLoad %12 %23
135          %26 = OpFOrdGreaterThan %25 %13 %24
136                OpSelectionMerge %28 None
137                OpBranchConditional %26 %27 %28
138          %27 = OpLabel
139          %33 = OpAccessChain %32 %31 %21
140          %34 = OpLoad %12 %33
141          %36 = OpFOrdLessThan %25 %34 %35
142                OpSelectionMerge %46 None
143                OpBranchConditional %36 %37 %38
144          %37 = OpLabel
145                OpBranch %38
146          %46 = OpLabel
147                OpBranch %38
148          %38 = OpLabel
149                OpBranchConditional %41 %8 %10
150          %28 = OpLabel
151                OpKill
152          %10 = OpLabel
153                OpReturn
154                OpFunctionEnd
155 END
156
157 # uniforms for variant
158
159 # injectionSwitch
160 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
161  0.0 1.0
162 END
163
164 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
165
166 PIPELINE graphics variant_pipeline
167   ATTACH variant_vertex_shader
168   ATTACH variant_fragment_shader
169   FRAMEBUFFER_SIZE 256 256
170   BIND BUFFER variant_framebuffer AS color LOCATION 0
171   BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
172 END
173 CLEAR_COLOR variant_pipeline 0 0 0 255
174
175 CLEAR variant_pipeline
176 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
177
178 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 0 0 0 255