3 # Copyright 2020 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 a specific const folding path
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_0_0 _GLF_uniform_float_values[0]
32 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_int_values: [1, 0]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[2];
42 # // Contents of _GLF_uniform_float_values: 0.0
43 # layout(set = 0, binding = 1) uniform buf1
45 # float _GLF_uniform_float_values[1];
48 # layout(location = 0) out vec4 _GLF_color;
52 # // This results in an undefined value, but not in undefined behavior.
53 # float f = pow(40.33, ldexp(1.0, 98980));
55 # if (_int_1 == (_int_1 + _int_0) || f > _float_0_0)
56 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
58 # _GLF_color = vec4(_int_0);
60 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
63 ; Generator: Khronos Glslang Reference Front End; 8
67 %1 = OpExtInstImport "GLSL.std.450"
68 OpMemoryModel Logical GLSL450
69 OpEntryPoint Fragment %4 "main" %51
70 OpExecutionMode %4 OriginUpperLeft
75 OpMemberName %19 0 "_GLF_uniform_int_values"
78 OpMemberName %39 0 "_GLF_uniform_float_values"
80 OpName %51 "_GLF_color"
81 OpDecorate %18 ArrayStride 16
82 OpMemberDecorate %19 0 Offset 0
84 OpDecorate %21 DescriptorSet 0
85 OpDecorate %21 Binding 0
86 OpDecorate %38 ArrayStride 16
87 OpMemberDecorate %39 0 Offset 0
89 OpDecorate %41 DescriptorSet 0
90 OpDecorate %41 Binding 1
91 OpDecorate %51 Location 0
93 %3 = OpTypeFunction %2
95 %7 = OpTypePointer Function %6
96 %9 = OpConstant %6 40.3300018
99 %12 = OpConstant %11 98980
102 %17 = OpConstant %16 2
103 %18 = OpTypeArray %11 %17
104 %19 = OpTypeStruct %18
105 %20 = OpTypePointer Uniform %19
106 %21 = OpVariable %20 Uniform
107 %22 = OpConstant %11 0
108 %23 = OpTypePointer Uniform %11
109 %28 = OpConstant %11 1
110 %37 = OpConstant %16 1
111 %38 = OpTypeArray %6 %37
112 %39 = OpTypeStruct %38
113 %40 = OpTypePointer Uniform %39
114 %41 = OpVariable %40 Uniform
115 %42 = OpTypePointer Uniform %6
116 %49 = OpTypeVector %6 4
117 %50 = OpTypePointer Output %49
118 %51 = OpVariable %50 Output
119 %4 = OpFunction %2 None %3
121 %8 = OpVariable %7 Function
122 %13 = OpExtInst %6 %1 Ldexp %10 %12
123 %14 = OpExtInst %6 %1 Pow %9 %13
125 %24 = OpAccessChain %23 %21 %22 %22
127 %26 = OpAccessChain %23 %21 %22 %22
129 %29 = OpAccessChain %23 %21 %22 %28
131 %31 = OpIAdd %11 %27 %30
132 %32 = OpIEqual %15 %25 %31
133 %33 = OpLogicalNot %15 %32
134 OpSelectionMerge %35 None
135 OpBranchConditional %33 %34 %35
138 %43 = OpAccessChain %42 %41 %22 %22
140 %45 = OpFOrdGreaterThan %15 %36 %44
143 %46 = OpPhi %15 %32 %5 %45 %34
144 OpSelectionMerge %48 None
145 OpBranchConditional %46 %47 %65
147 %52 = OpAccessChain %23 %21 %22 %22
149 %54 = OpConvertSToF %6 %53
150 %55 = OpAccessChain %23 %21 %22 %28
152 %57 = OpConvertSToF %6 %56
153 %58 = OpAccessChain %23 %21 %22 %28
155 %60 = OpConvertSToF %6 %59
156 %61 = OpAccessChain %23 %21 %22 %22
158 %63 = OpConvertSToF %6 %62
159 %64 = OpCompositeConstruct %49 %54 %57 %60 %63
163 %66 = OpAccessChain %23 %21 %22 %28
165 %68 = OpConvertSToF %6 %67
166 %69 = OpCompositeConstruct %49 %68 %68 %68 %68
174 # uniforms for variant
176 # _GLF_uniform_float_values
177 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
180 # _GLF_uniform_int_values
181 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] 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 256 256
191 BIND BUFFER variant_framebuffer AS color LOCATION 0
192 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
193 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
195 CLEAR_COLOR variant_pipeline 0 0 0 255
197 CLEAR variant_pipeline
198 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
200 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255