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 _int_5 _GLF_uniform_int_values[2]
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[3];
42 # layout(location = 0) out vec4 _GLF_color;
46 # for (int i = _int_0; i < _int_5; i++)
48 # vec4 v = unpackUnorm4x8(100u);
53 # _GLF_color = vec4(_int_0);
57 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
59 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
62 ; Generator: Khronos Glslang Reference Front End; 8
66 %1 = OpExtInstImport "GLSL.std.450"
67 OpMemoryModel Logical GLSL450
68 OpEntryPoint Fragment %4 "main" %47
69 OpExecutionMode %4 OriginUpperLeft
74 OpMemberName %12 0 "_GLF_uniform_int_values"
77 OpName %47 "_GLF_color"
78 OpDecorate %11 ArrayStride 16
79 OpMemberDecorate %12 0 Offset 0
81 OpDecorate %14 DescriptorSet 0
82 OpDecorate %14 Binding 0
83 OpDecorate %47 Location 0
85 %3 = OpTypeFunction %2
87 %7 = OpTypePointer Function %6
90 %11 = OpTypeArray %6 %10
91 %12 = OpTypeStruct %11
92 %13 = OpTypePointer Uniform %12
93 %14 = OpVariable %13 Uniform
96 %17 = OpTypePointer Uniform %6
100 %32 = OpTypeVector %31 4
101 %33 = OpTypePointer Function %32
102 %35 = OpConstant %9 100
103 %37 = OpConstant %9 0
104 %38 = OpTypePointer Function %31
105 %46 = OpTypePointer Output %32
106 %47 = OpVariable %46 Output
107 %4 = OpFunction %2 None %3
109 %8 = OpVariable %7 Function
110 %34 = OpVariable %33 Function
111 %18 = OpAccessChain %17 %14 %15 %16
116 OpLoopMerge %22 %23 None
120 %27 = OpAccessChain %17 %14 %15 %26
122 %30 = OpSLessThan %29 %25 %28
123 OpBranchConditional %30 %21 %22
125 %36 = OpExtInst %32 %1 UnpackUnorm4x8 %35
127 %39 = OpAccessChain %38 %34 %37
129 %41 = OpConvertFToS %6 %40
131 %43 = OpSGreaterThan %29 %41 %42
132 OpSelectionMerge %45 None
133 OpBranchConditional %43 %44 %45
135 %48 = OpAccessChain %17 %14 %15 %16
137 %50 = OpConvertSToF %31 %49
138 %51 = OpCompositeConstruct %32 %50 %50 %50 %50
145 %54 = OpIAdd %6 %53 %16
149 %55 = OpAccessChain %17 %14 %15 %15
151 %57 = OpConvertSToF %31 %56
152 %58 = OpAccessChain %17 %14 %15 %16
154 %60 = OpConvertSToF %31 %59
155 %61 = OpAccessChain %17 %14 %15 %16
157 %63 = OpConvertSToF %31 %62
158 %64 = OpAccessChain %17 %14 %15 %15
160 %66 = OpConvertSToF %31 %65
161 %67 = OpCompositeConstruct %32 %57 %60 %63 %66
167 # uniforms for variant
169 # _GLF_uniform_int_values
170 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
174 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
176 PIPELINE graphics variant_pipeline
177 ATTACH variant_vertex_shader
178 ATTACH variant_fragment_shader
179 FRAMEBUFFER_SIZE 16 16
180 BIND BUFFER variant_framebuffer AS color LOCATION 0
181 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
183 CLEAR_COLOR variant_pipeline 0 0 0 255
185 CLEAR variant_pipeline
186 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
188 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255