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 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # #define _int_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _float_1_0 _GLF_uniform_float_values[0]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_float_values: 1.0
36 # layout(set = 0, binding = 0) uniform buf0
38 # float _GLF_uniform_float_values[1];
41 # // Contents of _GLF_uniform_int_values: [1, 0]
42 # layout(set = 0, binding = 1) uniform buf1
44 # int _GLF_uniform_int_values[2];
47 # // Contents of two: 2.0
48 # layout(push_constant) uniform buf_push
53 # layout(location = 0) out vec4 _GLF_color;
57 # // Always true: regardless of the condition a value of one can never become larger by clamping.
58 # if(clamp(1, _float_1_0 > two ? 1 : 0, 1) <= 1)
60 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
64 # _GLF_color = vec4(_int_0);
67 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
70 ; Generator: Khronos Glslang Reference Front End; 10
74 %1 = OpExtInstImport "GLSL.std.450"
75 OpMemoryModel Logical GLSL450
76 OpEntryPoint Fragment %4 "main" %34
77 OpExecutionMode %4 OriginUpperLeft
81 OpMemberName %12 0 "_GLF_uniform_float_values"
84 OpMemberName %19 0 "two"
86 OpName %34 "_GLF_color"
88 OpMemberName %37 0 "_GLF_uniform_int_values"
90 OpDecorate %11 ArrayStride 16
91 OpMemberDecorate %12 0 Offset 0
93 OpDecorate %14 DescriptorSet 0
94 OpDecorate %14 Binding 0
95 OpMemberDecorate %19 0 Offset 0
97 OpDecorate %34 Location 0
98 OpDecorate %36 ArrayStride 16
99 OpMemberDecorate %37 0 Offset 0
101 OpDecorate %39 DescriptorSet 0
102 OpDecorate %39 Binding 1
104 %3 = OpTypeFunction %2
109 %10 = OpConstant %9 1
110 %11 = OpTypeArray %8 %10
111 %12 = OpTypeStruct %11
112 %13 = OpTypePointer Uniform %12
113 %14 = OpVariable %13 Uniform
114 %15 = OpConstant %6 0
115 %16 = OpTypePointer Uniform %8
116 %19 = OpTypeStruct %8
117 %20 = OpTypePointer PushConstant %19
118 %21 = OpVariable %20 PushConstant
119 %22 = OpTypePointer PushConstant %8
121 %32 = OpTypeVector %8 4
122 %33 = OpTypePointer Output %32
123 %34 = OpVariable %33 Output
124 %35 = OpConstant %9 2
125 %36 = OpTypeArray %6 %35
126 %37 = OpTypeStruct %36
127 %38 = OpTypePointer Uniform %37
128 %39 = OpVariable %38 Uniform
129 %40 = OpTypePointer Uniform %6
130 %4 = OpFunction %2 None %3
132 %17 = OpAccessChain %16 %14 %15 %15
134 %23 = OpAccessChain %22 %21 %15
136 %26 = OpFOrdGreaterThan %25 %18 %24
137 %27 = OpSelect %6 %26 %7 %15
138 %28 = OpExtInst %6 %1 SClamp %7 %27 %7
139 %29 = OpSLessThanEqual %25 %28 %7
140 OpSelectionMerge %31 None
141 OpBranchConditional %29 %30 %54
143 %41 = OpAccessChain %40 %39 %15 %15
145 %43 = OpConvertSToF %8 %42
146 %44 = OpAccessChain %40 %39 %15 %7
148 %46 = OpConvertSToF %8 %45
149 %47 = OpAccessChain %40 %39 %15 %7
151 %49 = OpConvertSToF %8 %48
152 %50 = OpAccessChain %40 %39 %15 %15
154 %52 = OpConvertSToF %8 %51
155 %53 = OpCompositeConstruct %32 %43 %46 %49 %52
159 %55 = OpAccessChain %40 %39 %15 %7
161 %57 = OpConvertSToF %8 %56
162 %58 = OpCompositeConstruct %32 %57 %57 %57 %57
170 # uniforms for variant
173 BUFFER variant_two DATA_TYPE float STD140 DATA
176 # _GLF_uniform_int_values
177 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
180 # _GLF_uniform_float_values
181 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
185 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
187 PIPELINE graphics variant_pipeline
188 ATTACH variant_vertex_shader
189 ATTACH variant_fragment_shader
190 FRAMEBUFFER_SIZE 32 32
191 BIND BUFFER variant_framebuffer AS color LOCATION 0
192 BIND BUFFER variant_two AS push_constant
193 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
194 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
196 CLEAR_COLOR variant_pipeline 0 0 0 255
198 CLEAR variant_pipeline
199 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
201 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255