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 floating point 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 _int_0 _GLF_uniform_int_values[1]
30 # #define _float_0_0 _GLF_uniform_float_values[0]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_int_values: [1, 0]
36 # layout(set = 0, binding = 0) uniform buf0
38 # int _GLF_uniform_int_values[2];
41 # // Contents of _GLF_uniform_float_values: 0.0
42 # layout(set = 0, binding = 1) uniform buf1
44 # float _GLF_uniform_float_values[1];
47 # layout(location = 0) out vec4 _GLF_color;
51 # float edge = determinant(mat3(1));
52 # if (step(edge, vec4(-3.0)) == vec4(_float_0_0))
54 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
58 # _GLF_color = vec4(_int_0);
61 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
64 ; Generator: Khronos Glslang Reference Front End; 8
68 %1 = OpExtInstImport "GLSL.std.450"
69 OpMemoryModel Logical GLSL450
70 OpEntryPoint Fragment %4 "main" %43
71 OpExecutionMode %4 OriginUpperLeft
76 OpMemberName %27 0 "_GLF_uniform_float_values"
78 OpName %43 "_GLF_color"
80 OpMemberName %46 0 "_GLF_uniform_int_values"
82 OpDecorate %26 ArrayStride 16
83 OpMemberDecorate %27 0 Offset 0
85 OpDecorate %29 DescriptorSet 0
86 OpDecorate %29 Binding 1
87 OpDecorate %43 Location 0
88 OpDecorate %45 ArrayStride 16
89 OpMemberDecorate %46 0 Offset 0
91 OpDecorate %48 DescriptorSet 0
92 OpDecorate %48 Binding 0
94 %3 = OpTypeFunction %2
96 %7 = OpTypePointer Function %6
97 %9 = OpTypeVector %6 3
98 %10 = OpTypeMatrix %9 3
100 %12 = OpConstant %6 0
101 %13 = OpConstantComposite %9 %11 %12 %12
102 %14 = OpConstantComposite %9 %12 %11 %12
103 %15 = OpConstantComposite %9 %12 %12 %11
104 %16 = OpConstantComposite %10 %13 %14 %15
105 %19 = OpTypeVector %6 4
106 %20 = OpConstant %6 -3
107 %21 = OpConstantComposite %19 %20 %20 %20 %20
109 %25 = OpConstant %24 1
110 %26 = OpTypeArray %6 %25
111 %27 = OpTypeStruct %26
112 %28 = OpTypePointer Uniform %27
113 %29 = OpVariable %28 Uniform
115 %31 = OpConstant %30 0
116 %32 = OpTypePointer Uniform %6
118 %37 = OpTypeVector %36 4
119 %42 = OpTypePointer Output %19
120 %43 = OpVariable %42 Output
121 %44 = OpConstant %24 2
122 %45 = OpTypeArray %30 %44
123 %46 = OpTypeStruct %45
124 %47 = OpTypePointer Uniform %46
125 %48 = OpVariable %47 Uniform
126 %49 = OpTypePointer Uniform %30
127 %53 = OpConstant %30 1
128 %4 = OpFunction %2 None %3
130 %8 = OpVariable %7 Function
131 %17 = OpExtInst %6 %1 Determinant %16
134 %22 = OpCompositeConstruct %19 %18 %18 %18 %18
135 %23 = OpExtInst %19 %1 Step %22 %21
136 %33 = OpAccessChain %32 %29 %31 %31
138 %35 = OpCompositeConstruct %19 %34 %34 %34 %34
139 %38 = OpFOrdEqual %37 %23 %35
141 OpSelectionMerge %41 None
142 OpBranchConditional %39 %40 %64
144 %50 = OpAccessChain %49 %48 %31 %31
146 %52 = OpConvertSToF %6 %51
147 %54 = OpAccessChain %49 %48 %31 %53
149 %56 = OpConvertSToF %6 %55
150 %57 = OpAccessChain %49 %48 %31 %53
152 %59 = OpConvertSToF %6 %58
153 %60 = OpAccessChain %49 %48 %31 %31
155 %62 = OpConvertSToF %6 %61
156 %63 = OpCompositeConstruct %19 %52 %56 %59 %62
160 %65 = OpAccessChain %49 %48 %31 %53
162 %67 = OpConvertSToF %6 %66
163 %68 = OpCompositeConstruct %19 %67 %67 %67 %67
171 # uniforms for variant
173 # _GLF_uniform_float_values
174 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
177 # _GLF_uniform_int_values
178 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
182 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
184 PIPELINE graphics variant_pipeline
185 ATTACH variant_vertex_shader
186 ATTACH variant_fragment_shader
187 FRAMEBUFFER_SIZE 256 256
188 BIND BUFFER variant_framebuffer AS color LOCATION 0
189 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
190 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
192 CLEAR_COLOR variant_pipeline 0 0 0 255
194 CLEAR variant_pipeline
195 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
197 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255