Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-color-overwrite-identity-matrix-multiply.amber
1 #!amber
2
3 # Copyright 2020 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 coverage-gap found by the GraphicsFuzz project.
19
20 # Short description: A fragment shader that covers a specific DAG code paths
21
22 # The test passes because the shader always writes red.
23
24 # Optimized using spirv-opt with the following arguments:
25 # '-O'
26 # spirv-opt commit hash: a187dd58a0485988841d325a85c8e6063f53500a
27
28
29
30 SHADER vertex variant_vertex_shader PASSTHROUGH
31
32 # variant_fragment_shader is derived from the following GLSL:
33 # #version 310 es
34 # #define _float_1_0 _GLF_uniform_float_values[0]
35 # #define _float_0_0 _GLF_uniform_float_values[1]
36 # #define _float_0_1 _GLF_uniform_float_values[2]
37 # #define _float_0_3 _GLF_uniform_float_values[3]
38 # #define _float_0_2 _GLF_uniform_float_values[4]
39 #
40 # precision highp float;
41 #
42 # precision highp int;
43 #
44 # // Contents of _GLF_uniform_float_values: [1.0, 0.0, 0.1, 0.3, 0.2]
45 # layout(set = 0, binding = 0) uniform buf0
46 # {
47 #     float _GLF_uniform_float_values[5];
48 # };
49 #
50 # layout(location = 0) out vec4 _GLF_color;
51 #
52 # void main()
53 # {
54 #     // These conditions don't matter since the color
55 #     // gets overwritten right after.
56 #     if(gl_FragCoord.x > _float_1_0)
57 #     {
58 #         _GLF_color = vec4(_float_0_1);
59 #         if(gl_FragCoord.y > _float_1_0)
60 #         {
61 #             _GLF_color = vec4(_float_0_2);
62 #         }
63 #         _GLF_color = vec4(_float_0_3);
64 #     }
65 #
66 #     _GLF_color = vec4(_float_1_0, _float_0_0, _float_0_0, 10.0);
67 #     // Multiplying by an identity matrix doesn't change the vector value.
68 #     _GLF_color = mat4(_float_1_0) * _GLF_color;
69 # }
70 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
71 ; SPIR-V
72 ; Version: 1.0
73 ; Generator: Khronos Glslang Reference Front End; 10
74 ; Bound: 72
75 ; Schema: 0
76                OpCapability Shader
77           %1 = OpExtInstImport "GLSL.std.450"
78                OpMemoryModel Logical GLSL450
79                OpEntryPoint Fragment %4 "main" %9 %30
80                OpExecutionMode %4 OriginUpperLeft
81                OpSource ESSL 310
82                OpName %4 "main"
83                OpName %9 "gl_FragCoord"
84                OpName %17 "buf0"
85                OpMemberName %17 0 "_GLF_uniform_float_values"
86                OpName %19 ""
87                OpName %30 "_GLF_color"
88                OpDecorate %9 BuiltIn FragCoord
89                OpDecorate %16 ArrayStride 16
90                OpMemberDecorate %17 0 Offset 0
91                OpDecorate %17 Block
92                OpDecorate %19 DescriptorSet 0
93                OpDecorate %19 Binding 0
94                OpDecorate %30 Location 0
95           %2 = OpTypeVoid
96           %3 = OpTypeFunction %2
97           %6 = OpTypeFloat 32
98           %7 = OpTypeVector %6 4
99           %8 = OpTypePointer Input %7
100           %9 = OpVariable %8 Input
101          %10 = OpTypeInt 32 0
102          %11 = OpConstant %10 0
103          %12 = OpTypePointer Input %6
104          %15 = OpConstant %10 5
105          %16 = OpTypeArray %6 %15
106          %17 = OpTypeStruct %16
107          %18 = OpTypePointer Uniform %17
108          %19 = OpVariable %18 Uniform
109          %20 = OpTypeInt 32 1
110          %21 = OpConstant %20 0
111          %22 = OpTypePointer Uniform %6
112          %25 = OpTypeBool
113          %29 = OpTypePointer Output %7
114          %30 = OpVariable %29 Output
115          %31 = OpConstant %20 2
116          %35 = OpConstant %10 1
117          %43 = OpConstant %20 4
118          %47 = OpConstant %20 3
119          %53 = OpConstant %20 1
120          %58 = OpConstant %6 10
121          %62 = OpTypeMatrix %7 4
122          %64 = OpConstant %6 0
123           %4 = OpFunction %2 None %3
124           %5 = OpLabel
125          %13 = OpAccessChain %12 %9 %11
126          %14 = OpLoad %6 %13
127          %23 = OpAccessChain %22 %19 %21 %21
128          %24 = OpLoad %6 %23
129          %26 = OpFOrdGreaterThan %25 %14 %24
130                OpSelectionMerge %28 None
131                OpBranchConditional %26 %27 %28
132          %27 = OpLabel
133          %32 = OpAccessChain %22 %19 %21 %31
134          %33 = OpLoad %6 %32
135          %34 = OpCompositeConstruct %7 %33 %33 %33 %33
136                OpStore %30 %34
137          %36 = OpAccessChain %12 %9 %35
138          %37 = OpLoad %6 %36
139          %40 = OpFOrdGreaterThan %25 %37 %24
140                OpSelectionMerge %42 None
141                OpBranchConditional %40 %41 %42
142          %41 = OpLabel
143          %44 = OpAccessChain %22 %19 %21 %43
144          %45 = OpLoad %6 %44
145          %46 = OpCompositeConstruct %7 %45 %45 %45 %45
146                OpStore %30 %46
147                OpBranch %42
148          %42 = OpLabel
149          %48 = OpAccessChain %22 %19 %21 %47
150          %49 = OpLoad %6 %48
151          %50 = OpCompositeConstruct %7 %49 %49 %49 %49
152                OpStore %30 %50
153                OpBranch %28
154          %28 = OpLabel
155          %54 = OpAccessChain %22 %19 %21 %53
156          %55 = OpLoad %6 %54
157          %59 = OpCompositeConstruct %7 %24 %55 %55 %58
158                OpStore %30 %59
159          %65 = OpCompositeConstruct %7 %24 %64 %64 %64
160          %66 = OpCompositeConstruct %7 %64 %24 %64 %64
161          %67 = OpCompositeConstruct %7 %64 %64 %24 %64
162          %68 = OpCompositeConstruct %7 %64 %64 %64 %24
163          %69 = OpCompositeConstruct %62 %65 %66 %67 %68
164          %70 = OpLoad %7 %30
165          %71 = OpMatrixTimesVector %7 %69 %70
166                OpStore %30 %71
167                OpReturn
168                OpFunctionEnd
169 END
170
171 # uniforms for variant
172
173 # _GLF_uniform_float_values
174 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
175  1.0 0.0 0.1 0.3 0.2
176 END
177
178 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
179
180 PIPELINE graphics variant_pipeline
181   ATTACH variant_vertex_shader
182   ATTACH variant_fragment_shader
183   FRAMEBUFFER_SIZE 16 16
184   BIND BUFFER variant_framebuffer AS color LOCATION 0
185   BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
186 END
187 CLEAR_COLOR variant_pipeline 0 0 0 255
188
189 CLEAR variant_pipeline
190 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
191
192 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255