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 specific constant fold and selection dag 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 _float_1_0 _GLF_uniform_float_values[0]
29 # #define _float_0_0 _GLF_uniform_float_values[1]
31 # precision highp float;
33 # // Contents of _GLF_uniform_float_values: [1.0, 0.0]
34 # layout(set = 0, binding = 0) uniform buf0
36 # float _GLF_uniform_float_values[2];
39 # layout(location = 0) out vec4 _GLF_color;
46 # // c becomes undefined since a < 0. This results in an undefined value, but not in undefined behavior.
47 # float c = pow(a, b);
49 # _GLF_color = vec4(c);
51 # if (a == -1.0 && b == 1.7)
53 # _GLF_color = vec4(_float_1_0, _float_0_0, _float_0_0, _float_1_0);
57 # _GLF_color = vec4(_float_1_0);
60 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
63 ; Generator: Khronos Glslang Reference Front End; 10
67 %1 = OpExtInstImport "GLSL.std.450"
68 OpMemoryModel Logical GLSL450
69 OpEntryPoint Fragment %4 "main" %18
70 OpExecutionMode %4 OriginUpperLeft
76 OpName %18 "_GLF_color"
78 OpMemberName %32 0 "_GLF_uniform_float_values"
80 OpDecorate %18 Location 0
81 OpDecorate %31 ArrayStride 16
82 OpMemberDecorate %32 0 Offset 0
84 OpDecorate %34 DescriptorSet 0
85 OpDecorate %34 Binding 0
87 %3 = OpTypeFunction %2
89 %7 = OpTypePointer Function %6
91 %11 = OpConstant %6 1.70000005
92 %16 = OpTypeVector %6 4
93 %17 = OpTypePointer Output %16
94 %18 = OpVariable %17 Output
97 %30 = OpConstant %29 2
98 %31 = OpTypeArray %6 %30
99 %32 = OpTypeStruct %31
100 %33 = OpTypePointer Uniform %32
101 %34 = OpVariable %33 Uniform
103 %36 = OpConstant %35 0
104 %37 = OpTypePointer Uniform %6
105 %40 = OpConstant %35 1
106 %4 = OpFunction %2 None %3
108 %8 = OpVariable %7 Function
109 %10 = OpVariable %7 Function
110 %12 = OpVariable %7 Function
115 %15 = OpExtInst %6 %1 Pow %13 %14
118 %20 = OpCompositeConstruct %16 %19 %19 %19 %19
121 %23 = OpFOrdEqual %22 %21 %9
123 %25 = OpFOrdEqual %22 %24 %11
124 %26 = OpLogicalAnd %22 %23 %25
125 OpSelectionMerge %28 None
126 OpBranchConditional %26 %27 %48
128 %38 = OpAccessChain %37 %34 %36 %36
130 %41 = OpAccessChain %37 %34 %36 %40
132 %43 = OpAccessChain %37 %34 %36 %40
134 %45 = OpAccessChain %37 %34 %36 %36
136 %47 = OpCompositeConstruct %16 %39 %42 %44 %46
140 %49 = OpAccessChain %37 %34 %36 %36
142 %51 = OpCompositeConstruct %16 %50 %50 %50 %50
150 # uniforms for variant
152 # _GLF_uniform_float_values
153 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
157 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
159 PIPELINE graphics variant_pipeline
160 ATTACH variant_vertex_shader
161 ATTACH variant_fragment_shader
162 FRAMEBUFFER_SIZE 256 256
163 BIND BUFFER variant_framebuffer AS color LOCATION 0
164 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
166 CLEAR_COLOR variant_pipeline 0 0 0 255
168 CLEAR variant_pipeline
169 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
171 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255