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 instruction simplification 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_0_0 _GLF_uniform_float_values[0]
30 # #define _float_10_0 _GLF_uniform_float_values[0]
32 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_float_values: [0.0, 10.0]
37 # layout(set = 0, binding = 0) uniform buf0
39 # float _GLF_uniform_float_values[2];
42 # // Contents of _GLF_uniform_int_values: 1
43 # layout(set = 0, binding = 1) uniform buf1
45 # int _GLF_uniform_int_values[1];
48 # layout(location = 0) out vec4 _GLF_color;
52 # float a = mod(_float_10_0, 1.);
54 # if (a == _float_0_0)
56 # _GLF_color = vec4(_int_1, a, a, _int_1);
60 # _GLF_color = vec4(a);
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" %31
73 OpExecutionMode %4 OriginUpperLeft
78 OpMemberName %12 0 "_GLF_uniform_float_values"
80 OpName %31 "_GLF_color"
82 OpMemberName %34 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 %31 Location 0
90 OpDecorate %33 ArrayStride 16
91 OpMemberDecorate %34 0 Offset 0
93 OpDecorate %36 DescriptorSet 0
94 OpDecorate %36 Binding 1
96 %3 = OpTypeFunction %2
98 %7 = OpTypePointer Function %6
100 %10 = OpConstant %9 2
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 %20 = OpConstant %6 1
110 %29 = OpTypeVector %6 4
111 %30 = OpTypePointer Output %29
112 %31 = OpVariable %30 Output
113 %32 = OpConstant %9 1
114 %33 = OpTypeArray %15 %32
115 %34 = OpTypeStruct %33
116 %35 = OpTypePointer Uniform %34
117 %36 = OpVariable %35 Uniform
118 %37 = OpTypePointer Uniform %15
119 %4 = OpFunction %2 None %3
121 %8 = OpVariable %7 Function
122 %18 = OpAccessChain %17 %14 %16 %16
124 %21 = OpFMod %6 %19 %20
127 %23 = OpAccessChain %17 %14 %16 %16
129 %26 = OpFOrdEqual %25 %22 %24
130 OpSelectionMerge %28 None
131 OpBranchConditional %26 %27 %47
133 %38 = OpAccessChain %37 %36 %16 %16
135 %40 = OpConvertSToF %6 %39
138 %43 = OpAccessChain %37 %36 %16 %16
140 %45 = OpConvertSToF %6 %44
141 %46 = OpCompositeConstruct %29 %40 %41 %42 %45
146 %49 = OpCompositeConstruct %29 %48 %48 %48 %48
154 # uniforms for variant
156 # _GLF_uniform_int_values
157 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
160 # _GLF_uniform_float_values
161 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
165 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
167 PIPELINE graphics variant_pipeline
168 ATTACH variant_vertex_shader
169 ATTACH variant_fragment_shader
170 FRAMEBUFFER_SIZE 16 16
171 BIND BUFFER variant_framebuffer AS color LOCATION 0
172 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
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