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: Covers a specific schedule dag register reduction list 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 _float_0_0446 _GLF_uniform_float_values[0]
29 # #define _float_0_0448 _GLF_uniform_float_values[1]
30 # #define _float_4_6 _GLF_uniform_float_values[2]
31 # #define _float_1_0 _GLF_uniform_float_values[3]
32 # #define _float_0_0 _GLF_uniform_float_values[4]
34 # precision highp float;
36 # // Contents of _GLF_uniform_float_values: [0.0446, 0.0448, 4.6, 1.0, 0.0]
37 # layout(set = 0, binding = 0) uniform buf0
39 # float _GLF_uniform_float_values[5];
42 # layout(location = 0) out vec4 _GLF_color;
47 # float a = mix(_float_4_6, _float_1_0, _float_1_0 > _float_4_6);
49 # float b = cos(log(a));
51 # _GLF_color = vec4(b);
53 # if (b > _float_0_0446 && b < _float_0_0448)
55 # _GLF_color = vec4(_float_1_0, _float_0_0, _float_0_0, _float_1_0);
58 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
61 ; Generator: Khronos Glslang Reference Front End; 10
65 %1 = OpExtInstImport "GLSL.std.450"
66 OpMemoryModel Logical GLSL450
67 OpEntryPoint Fragment %4 "main" %37
68 OpExecutionMode %4 OriginUpperLeft
73 OpMemberName %12 0 "_GLF_uniform_float_values"
76 OpName %37 "_GLF_color"
77 OpDecorate %11 ArrayStride 16
78 OpMemberDecorate %12 0 Offset 0
80 OpDecorate %14 DescriptorSet 0
81 OpDecorate %14 Binding 0
82 OpDecorate %37 Location 0
84 %3 = OpTypeFunction %2
86 %7 = OpTypePointer Function %6
89 %11 = OpTypeArray %6 %10
90 %12 = OpTypeStruct %11
91 %13 = OpTypePointer Uniform %12
92 %14 = OpVariable %13 Uniform
94 %16 = OpConstant %15 0
95 %17 = OpConstant %15 2
96 %18 = OpTypePointer Uniform %6
97 %21 = OpConstant %15 3
99 %35 = OpTypeVector %6 4
100 %36 = OpTypePointer Output %35
101 %37 = OpVariable %36 Output
102 %47 = OpConstant %15 1
103 %56 = OpConstant %15 4
104 %4 = OpFunction %2 None %3
106 %8 = OpVariable %7 Function
107 %31 = OpVariable %7 Function
108 %19 = OpAccessChain %18 %14 %16 %17
110 %22 = OpAccessChain %18 %14 %16 %21
112 %24 = OpAccessChain %18 %14 %16 %21
114 %26 = OpAccessChain %18 %14 %16 %17
116 %29 = OpFOrdGreaterThan %28 %25 %27
117 %30 = OpSelect %6 %29 %23 %20
120 %33 = OpExtInst %6 %1 Log %32
121 %34 = OpExtInst %6 %1 Cos %33
124 %39 = OpCompositeConstruct %35 %38 %38 %38 %38
127 %41 = OpAccessChain %18 %14 %16 %16
129 %43 = OpFOrdGreaterThan %28 %40 %42
130 OpSelectionMerge %45 None
131 OpBranchConditional %43 %44 %45
134 %48 = OpAccessChain %18 %14 %16 %47
136 %50 = OpFOrdLessThan %28 %46 %49
139 %51 = OpPhi %28 %43 %5 %50 %44
140 OpSelectionMerge %53 None
141 OpBranchConditional %51 %52 %53
143 %54 = OpAccessChain %18 %14 %16 %21
145 %57 = OpAccessChain %18 %14 %16 %56
147 %59 = OpAccessChain %18 %14 %16 %56
149 %61 = OpAccessChain %18 %14 %16 %21
151 %63 = OpCompositeConstruct %35 %55 %58 %60 %62
159 # uniforms for variant
161 # _GLF_uniform_float_values
162 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
163 0.0446 0.0448 4.6 1.0 0.0
166 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
168 PIPELINE graphics variant_pipeline
169 ATTACH variant_vertex_shader
170 ATTACH variant_fragment_shader
171 FRAMEBUFFER_SIZE 16 16
172 BIND BUFFER variant_framebuffer AS color LOCATION 0
173 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
175 CLEAR_COLOR variant_pipeline 0 0 0 255
177 CLEAR variant_pipeline
178 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
180 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255