3 # Copyright 2022 Google LLC
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # A test for a coverage-gap found by the GraphicsFuzz project.
20 # Short description: A fragment shader that covers specific LLVM code paths
22 # The test passes because the shader always writes red.
24 # Optimized using spirv-opt with the following arguments:
26 # spirv-opt commit hash: a0370efd589be33d5d9a85cfde2f85841b3755af
30 SHADER vertex variant_vertex_shader PASSTHROUGH
32 # variant_fragment_shader is derived from the following GLSL:
34 # #define _int_1 _GLF_uniform_int_values[0]
35 # #define _int_0 _GLF_uniform_int_values[1]
36 # #define _float_0_0 _GLF_uniform_float_values[0]
38 # precision highp float;
39 # precision highp int;
41 # // Contents of _GLF_uniform_int_values: [1, 0]
42 # layout(set = 0, binding = 0) uniform buf0
44 # int _GLF_uniform_int_values[2];
47 # // Contents of _GLF_uniform_float_values: 0.0
48 # layout(set = 0, binding = 1) uniform buf1
50 # float _GLF_uniform_float_values[1];
53 # layout(location = 0) out vec4 _GLF_color;
57 # // Always true. The line below simplifies to
58 # // min(vec2(1, 1), vec2(transpose(mat2(1)))).y = min(vec2(1, 1), vec2(mat2(1))).y
59 # // = min(vec2(1, 1), vec2(1, 0)).y = vec2(1, 0).y = 0.
60 # if(min(vec2(1), vec2(transpose(mat2(_int_1)))).y == _float_0_0)
62 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
66 # _GLF_color = vec4(_int_0);
69 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
72 ; Generator: Khronos Glslang Reference Front End; 10
76 %1 = OpExtInstImport "GLSL.std.450"
77 OpMemoryModel Logical GLSL450
78 OpEntryPoint Fragment %4 "main" %47
79 OpExecutionMode %4 OriginUpperLeft
83 OpMemberName %14 0 "_GLF_uniform_int_values"
86 OpMemberName %35 0 "_GLF_uniform_float_values"
88 OpName %47 "_GLF_color"
89 OpDecorate %13 ArrayStride 16
90 OpMemberDecorate %14 0 Offset 0
92 OpDecorate %16 DescriptorSet 0
93 OpDecorate %16 Binding 0
94 OpDecorate %34 ArrayStride 16
95 OpMemberDecorate %35 0 Offset 0
97 OpDecorate %37 DescriptorSet 0
98 OpDecorate %37 Binding 1
99 OpDecorate %47 Location 0
101 %3 = OpTypeFunction %2
103 %7 = OpTypeVector %6 2
105 %9 = OpConstantComposite %7 %8 %8
108 %12 = OpConstant %11 2
109 %13 = OpTypeArray %10 %12
110 %14 = OpTypeStruct %13
111 %15 = OpTypePointer Uniform %14
112 %16 = OpVariable %15 Uniform
113 %17 = OpConstant %10 0
114 %18 = OpTypePointer Uniform %10
115 %22 = OpTypeMatrix %7 2
116 %23 = OpConstant %6 0
117 %32 = OpConstant %11 1
118 %34 = OpTypeArray %6 %32
119 %35 = OpTypeStruct %34
120 %36 = OpTypePointer Uniform %35
121 %37 = OpVariable %36 Uniform
122 %38 = OpTypePointer Uniform %6
124 %45 = OpTypeVector %6 4
125 %46 = OpTypePointer Output %45
126 %47 = OpVariable %46 Output
127 %51 = OpConstant %10 1
129 %4 = OpFunction %2 None %3
131 %19 = OpAccessChain %18 %16 %17 %17
133 %21 = OpConvertSToF %6 %20
134 %24 = OpCompositeConstruct %7 %21 %23
135 %25 = OpCompositeConstruct %7 %23 %21
136 %26 = OpCompositeConstruct %22 %24 %25
137 %27 = OpTranspose %22 %26
138 %29 = OpCompositeExtract %6 %27 0 1
139 %30 = OpCompositeConstruct %7 %67 %29
140 %31 = OpExtInst %7 %1 FMin %9 %30
141 %33 = OpCompositeExtract %6 %31 1
142 %39 = OpAccessChain %38 %37 %17 %17
144 %42 = OpFOrdEqual %41 %33 %40
145 OpSelectionMerge %44 None
146 OpBranchConditional %42 %43 %62
148 %52 = OpAccessChain %18 %16 %17 %51
150 %54 = OpConvertSToF %6 %53
151 %61 = OpCompositeConstruct %45 %21 %54 %54 %21
155 %63 = OpAccessChain %18 %16 %17 %51
157 %65 = OpConvertSToF %6 %64
158 %66 = OpCompositeConstruct %45 %65 %65 %65 %65
166 # uniforms for variant
168 # _GLF_uniform_float_values
169 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
172 # _GLF_uniform_int_values
173 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
177 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
179 PIPELINE graphics variant_pipeline
180 ATTACH variant_vertex_shader
181 ATTACH variant_fragment_shader
182 FRAMEBUFFER_SIZE 32 32
183 BIND BUFFER variant_framebuffer AS color LOCATION 0
184 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
185 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
187 CLEAR_COLOR variant_pipeline 0 0 0 255
189 CLEAR variant_pipeline
190 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
192 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255