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 calculates modulo of an acosh result
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_0 _GLF_uniform_int_values[0]
29 # #define _int_1 _GLF_uniform_int_values[1]
30 # #define _float_2_6 _GLF_uniform_float_values[0]
31 # #define _float_1_61 _GLF_uniform_float_values[1]
32 # #define _float_0_1 _GLF_uniform_float_values[2]
34 # precision highp float;
35 # precision highp int;
37 # // Contents of _GLF_uniform_float_values: [2.6, 1.61, 0.1]
38 # layout(set = 0, binding = 0) uniform buf0
40 # float _GLF_uniform_float_values[3];
43 # // Contents of _GLF_uniform_int_values: [0, 1]
44 # layout(set = 0, binding = 1) uniform buf1
46 # int _GLF_uniform_int_values[2];
49 # layout(location = 0) out vec4 _GLF_color;
53 # float f = mod(acosh(_float_2_6), 7938.0);
54 # if (abs(f - _float_1_61) < _float_0_1)
56 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
60 # _GLF_color = vec4(_int_0);
63 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
66 ; Generator: Khronos Glslang Reference Front End; 8
70 %1 = OpExtInstImport "GLSL.std.450"
71 OpMemoryModel Logical GLSL450
72 OpEntryPoint Fragment %4 "main" %38
73 OpExecutionMode %4 OriginUpperLeft
78 OpMemberName %12 0 "_GLF_uniform_float_values"
80 OpName %38 "_GLF_color"
82 OpMemberName %41 0 "_GLF_uniform_int_values"
84 OpDecorate %11 ArrayStride 16
85 OpMemberDecorate %12 0 Offset 0
87 OpDecorate %14 DescriptorSet 0
88 OpDecorate %14 Binding 0
89 OpDecorate %38 Location 0
90 OpDecorate %40 ArrayStride 16
91 OpMemberDecorate %41 0 Offset 0
93 OpDecorate %43 DescriptorSet 0
94 OpDecorate %43 Binding 1
96 %3 = OpTypeFunction %2
98 %7 = OpTypePointer Function %6
100 %10 = OpConstant %9 3
101 %11 = OpTypeArray %6 %10
102 %12 = OpTypeStruct %11
103 %13 = OpTypePointer Uniform %12
104 %14 = OpVariable %13 Uniform
106 %16 = OpConstant %15 0
107 %17 = OpTypePointer Uniform %6
108 %21 = OpConstant %6 7938
109 %24 = OpConstant %15 1
110 %29 = OpConstant %15 2
112 %36 = OpTypeVector %6 4
113 %37 = OpTypePointer Output %36
114 %38 = OpVariable %37 Output
115 %39 = OpConstant %9 2
116 %40 = OpTypeArray %15 %39
117 %41 = OpTypeStruct %40
118 %42 = OpTypePointer Uniform %41
119 %43 = OpVariable %42 Uniform
120 %44 = OpTypePointer Uniform %15
121 %4 = OpFunction %2 None %3
123 %8 = OpVariable %7 Function
124 %18 = OpAccessChain %17 %14 %16 %16
126 %20 = OpExtInst %6 %1 Acosh %19
127 %22 = OpFMod %6 %20 %21
130 %25 = OpAccessChain %17 %14 %16 %24
132 %27 = OpFSub %6 %23 %26
133 %28 = OpExtInst %6 %1 FAbs %27
134 %30 = OpAccessChain %17 %14 %16 %29
136 %33 = OpFOrdLessThan %32 %28 %31
137 OpSelectionMerge %35 None
138 OpBranchConditional %33 %34 %58
140 %45 = OpAccessChain %44 %43 %16 %24
142 %47 = OpConvertSToF %6 %46
143 %48 = OpAccessChain %44 %43 %16 %16
145 %50 = OpConvertSToF %6 %49
146 %51 = OpAccessChain %44 %43 %16 %16
148 %53 = OpConvertSToF %6 %52
149 %54 = OpAccessChain %44 %43 %16 %24
151 %56 = OpConvertSToF %6 %55
152 %57 = OpCompositeConstruct %36 %47 %50 %53 %56
156 %59 = OpAccessChain %44 %43 %16 %16
158 %61 = OpConvertSToF %6 %60
159 %62 = OpCompositeConstruct %36 %61 %61 %61 %61
167 # uniforms for variant
169 # _GLF_uniform_int_values
170 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
173 # _GLF_uniform_float_values
174 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
178 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
180 PIPELINE graphics variant_pipeline
181 ATTACH variant_vertex_shader
182 ATTACH variant_fragment_shader
183 FRAMEBUFFER_SIZE 16 16
184 BIND BUFFER variant_framebuffer AS color LOCATION 0
185 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
186 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
188 CLEAR_COLOR variant_pipeline 0 0 0 255
190 CLEAR variant_pipeline
191 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
193 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255