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 combine compares 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_0 _GLF_uniform_int_values[0]
29 # #define _int_1 _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_float_values: 0.0
36 # layout(set = 0, binding = 0) uniform buf0
38 # float _GLF_uniform_float_values[1];
41 # // Contents of _GLF_uniform_int_values: [0, 1]
42 # layout(set = 0, binding = 1) uniform buf1
44 # int _GLF_uniform_int_values[2];
47 # layout(location = 0) out vec4 _GLF_color;
51 # if (ldexp(_float_0_0, 10000) == _float_0_0)
53 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
57 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
60 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
63 ; Generator: Khronos Glslang Reference Front End; 8
67 %1 = OpExtInstImport "GLSL.std.450"
68 OpMemoryModel Logical GLSL450
69 OpEntryPoint Fragment %4 "main" %28
70 OpExecutionMode %4 OriginUpperLeft
74 OpMemberName %10 0 "_GLF_uniform_float_values"
76 OpName %28 "_GLF_color"
78 OpMemberName %31 0 "_GLF_uniform_int_values"
80 OpDecorate %9 ArrayStride 16
81 OpMemberDecorate %10 0 Offset 0
83 OpDecorate %12 DescriptorSet 0
84 OpDecorate %12 Binding 0
85 OpDecorate %28 Location 0
86 OpDecorate %30 ArrayStride 16
87 OpMemberDecorate %31 0 Offset 0
89 OpDecorate %33 DescriptorSet 0
90 OpDecorate %33 Binding 1
92 %3 = OpTypeFunction %2
96 %9 = OpTypeArray %6 %8
98 %11 = OpTypePointer Uniform %10
99 %12 = OpVariable %11 Uniform
101 %14 = OpConstant %13 0
102 %15 = OpTypePointer Uniform %6
103 %18 = OpConstant %13 10000
105 %26 = OpTypeVector %6 4
106 %27 = OpTypePointer Output %26
107 %28 = OpVariable %27 Output
108 %29 = OpConstant %7 2
109 %30 = OpTypeArray %13 %29
110 %31 = OpTypeStruct %30
111 %32 = OpTypePointer Uniform %31
112 %33 = OpVariable %32 Uniform
113 %34 = OpConstant %13 1
114 %35 = OpTypePointer Uniform %13
115 %4 = OpFunction %2 None %3
117 %16 = OpAccessChain %15 %12 %14 %14
119 %19 = OpExtInst %6 %1 Ldexp %17 %18
120 %20 = OpAccessChain %15 %12 %14 %14
122 %23 = OpFOrdEqual %22 %19 %21
123 OpSelectionMerge %25 None
124 OpBranchConditional %23 %24 %49
126 %36 = OpAccessChain %35 %33 %14 %34
128 %38 = OpConvertSToF %6 %37
129 %39 = OpAccessChain %35 %33 %14 %14
131 %41 = OpConvertSToF %6 %40
132 %42 = OpAccessChain %35 %33 %14 %14
134 %44 = OpConvertSToF %6 %43
135 %45 = OpAccessChain %35 %33 %14 %34
137 %47 = OpConvertSToF %6 %46
138 %48 = OpCompositeConstruct %26 %38 %41 %44 %47
142 %50 = OpAccessChain %35 %33 %14 %34
144 %52 = OpConvertSToF %6 %51
145 %53 = OpAccessChain %35 %33 %14 %14
147 %55 = OpConvertSToF %6 %54
148 %56 = OpAccessChain %35 %33 %14 %14
150 %58 = OpConvertSToF %6 %57
151 %59 = OpAccessChain %35 %33 %14 %34
153 %61 = OpConvertSToF %6 %60
154 %62 = OpCompositeConstruct %26 %52 %55 %58 %61
162 # uniforms for variant
164 # _GLF_uniform_int_values
165 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
168 # _GLF_uniform_float_values
169 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
173 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
175 PIPELINE graphics variant_pipeline
176 ATTACH variant_vertex_shader
177 ATTACH variant_fragment_shader
178 FRAMEBUFFER_SIZE 256 256
179 BIND BUFFER variant_framebuffer AS color LOCATION 0
180 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
181 BIND BUFFER variant__GLF_uniform_float_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 256 256
188 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255