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 peephole optimizer code 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 _float_1_2 _GLF_uniform_float_values[0]
30 # #define _float_0_0 _GLF_uniform_float_values[1]
31 # #define _float_1_0 _GLF_uniform_float_values[2]
33 # precision highp float;
35 # precision highp int;
37 # // Contents of _GLF_uniform_int_values: 1
38 # layout(set = 0, binding = 0) uniform buf0
40 # int _GLF_uniform_int_values[1];
43 # // Contents of _GLF_uniform_float_values: [1.2, 0.0, 1.0]
44 # layout(set = 0, binding = 1) uniform buf1
46 # float _GLF_uniform_float_values[3];
49 # layout(location = 0) out vec4 _GLF_color;
53 # float a = _float_1_2;
56 # if (!(gl_FragCoord.x < _float_0_0))
59 # if (!(gl_FragCoord.x < _float_0_0))
62 # if (!(gl_FragCoord.x > _float_0_0))
69 # _GLF_color = vec4(_int_1, acosh(a), acosh(a), _int_1);
71 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
74 ; Generator: Khronos Glslang Reference Front End; 8
78 %1 = OpExtInstImport "GLSL.std.450"
79 OpMemoryModel Logical GLSL450
80 OpEntryPoint Fragment %4 "main" %22 %56
81 OpExecutionMode %4 OriginUpperLeft
86 OpMemberName %12 0 "_GLF_uniform_float_values"
88 OpName %22 "gl_FragCoord"
89 OpName %56 "_GLF_color"
91 OpMemberName %59 0 "_GLF_uniform_int_values"
93 OpDecorate %11 ArrayStride 16
94 OpMemberDecorate %12 0 Offset 0
96 OpDecorate %14 DescriptorSet 0
97 OpDecorate %14 Binding 1
98 OpDecorate %22 BuiltIn FragCoord
99 OpDecorate %56 Location 0
100 OpDecorate %58 ArrayStride 16
101 OpMemberDecorate %59 0 Offset 0
103 OpDecorate %61 DescriptorSet 0
104 OpDecorate %61 Binding 0
106 %3 = OpTypeFunction %2
108 %7 = OpTypePointer Function %6
110 %10 = OpConstant %9 3
111 %11 = OpTypeArray %6 %10
112 %12 = OpTypeStruct %11
113 %13 = OpTypePointer Uniform %12
114 %14 = OpVariable %13 Uniform
116 %16 = OpConstant %15 0
117 %17 = OpTypePointer Uniform %6
118 %20 = OpTypeVector %6 4
119 %21 = OpTypePointer Input %20
120 %22 = OpVariable %21 Input
121 %23 = OpConstant %9 0
122 %24 = OpTypePointer Input %6
123 %27 = OpConstant %15 1
125 %52 = OpConstant %15 2
126 %55 = OpTypePointer Output %20
127 %56 = OpVariable %55 Output
128 %57 = OpConstant %9 1
129 %58 = OpTypeArray %15 %57
130 %59 = OpTypeStruct %58
131 %60 = OpTypePointer Uniform %59
132 %61 = OpVariable %60 Uniform
133 %62 = OpTypePointer Uniform %15
134 %4 = OpFunction %2 None %3
136 %8 = OpVariable %7 Function
137 %18 = OpAccessChain %17 %14 %16 %16
140 %25 = OpAccessChain %24 %22 %23
142 %28 = OpAccessChain %17 %14 %16 %27
144 %31 = OpFOrdLessThan %30 %26 %29
145 %32 = OpLogicalNot %30 %31
146 OpSelectionMerge %34 None
147 OpBranchConditional %32 %33 %34
149 %35 = OpAccessChain %24 %22 %23
151 %37 = OpAccessChain %17 %14 %16 %27
153 %39 = OpFOrdLessThan %30 %36 %38
154 %40 = OpLogicalNot %30 %39
155 OpSelectionMerge %42 None
156 OpBranchConditional %40 %41 %42
158 %43 = OpAccessChain %24 %22 %23
160 %45 = OpAccessChain %17 %14 %16 %27
162 %47 = OpFOrdGreaterThan %30 %44 %46
163 %48 = OpLogicalNot %30 %47
164 OpSelectionMerge %50 None
165 OpBranchConditional %48 %49 %50
169 %53 = OpAccessChain %17 %14 %16 %52
176 %63 = OpAccessChain %62 %61 %16 %16
178 %65 = OpConvertSToF %6 %64
180 %67 = OpExtInst %6 %1 Acosh %66
182 %69 = OpExtInst %6 %1 Acosh %68
183 %70 = OpAccessChain %62 %61 %16 %16
185 %72 = OpConvertSToF %6 %71
186 %73 = OpCompositeConstruct %20 %65 %67 %69 %72
192 # uniforms for variant
194 # _GLF_uniform_float_values
195 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
198 # _GLF_uniform_int_values
199 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
203 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
205 PIPELINE graphics variant_pipeline
206 ATTACH variant_vertex_shader
207 ATTACH variant_fragment_shader
208 FRAMEBUFFER_SIZE 256 256
209 BIND BUFFER variant_framebuffer AS color LOCATION 0
210 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
211 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
213 CLEAR_COLOR variant_pipeline 0 0 0 255
215 CLEAR variant_pipeline
216 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
218 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255