3 # Copyright 2021 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 specific LLVM code paths
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 _uint_2 _GLF_uniform_uint_values[0]
31 # #define _uint_1 _GLF_uniform_uint_values[1]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_uint_values: [2, 1]
37 # layout(set = 0, binding = 0) uniform buf0
39 # uint _GLF_uniform_uint_values[2];
41 # // Contents of _GLF_uniform_int_values: [1, 0]
42 # layout(set = 0, binding = 1) uniform buf1
44 # int _GLF_uniform_int_values[2];
46 # layout(location = 0) out vec4 _GLF_color;
53 # if(uaddCarry(1u, 1u, a) == _uint_2)
55 # _GLF_color = vec4(_int_1, float(a), _int_0, _int_1);
59 # _GLF_color = vec4(_int_0);
62 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
65 ; Generator: Khronos Glslang Reference Front End; 10
69 %1 = OpExtInstImport "GLSL.std.450"
70 OpMemoryModel Logical GLSL450
71 OpEntryPoint Fragment %4 "main" %34
72 OpExecutionMode %4 OriginUpperLeft
77 OpMemberName %11 0 "_GLF_uniform_uint_values"
80 OpName %34 "_GLF_color"
82 OpMemberName %36 0 "_GLF_uniform_int_values"
84 OpDecorate %10 ArrayStride 16
85 OpMemberDecorate %11 0 Offset 0
87 OpDecorate %13 DescriptorSet 0
88 OpDecorate %13 Binding 0
89 OpDecorate %34 Location 0
90 OpDecorate %35 ArrayStride 16
91 OpMemberDecorate %36 0 Offset 0
93 OpDecorate %38 DescriptorSet 0
94 OpDecorate %38 Binding 1
96 %3 = OpTypeFunction %2
98 %7 = OpTypePointer Function %6
100 %10 = OpTypeArray %6 %9
101 %11 = OpTypeStruct %10
102 %12 = OpTypePointer Uniform %11
103 %13 = OpVariable %12 Uniform
105 %15 = OpConstant %14 0
106 %16 = OpConstant %14 1
107 %17 = OpTypePointer Uniform %6
108 %20 = OpConstant %6 1
109 %21 = OpTypeStruct %6 %6
112 %32 = OpTypeVector %31 4
113 %33 = OpTypePointer Output %32
114 %34 = OpVariable %33 Output
115 %35 = OpTypeArray %14 %9
116 %36 = OpTypeStruct %35
117 %37 = OpTypePointer Uniform %36
118 %38 = OpVariable %37 Uniform
119 %39 = OpTypePointer Uniform %14
120 %4 = OpFunction %2 None %3
122 %8 = OpVariable %7 Function
123 %18 = OpAccessChain %17 %13 %15 %16
126 %22 = OpIAddCarry %21 %20 %20
127 %23 = OpCompositeExtract %6 %22 1
129 %24 = OpCompositeExtract %6 %22 0
130 %25 = OpAccessChain %17 %13 %15 %15
132 %28 = OpIEqual %27 %24 %26
133 OpSelectionMerge %30 None
134 OpBranchConditional %28 %29 %52
136 %40 = OpAccessChain %39 %38 %15 %15
138 %42 = OpConvertSToF %31 %41
140 %44 = OpConvertUToF %31 %43
141 %45 = OpAccessChain %39 %38 %15 %16
143 %47 = OpConvertSToF %31 %46
144 %48 = OpAccessChain %39 %38 %15 %15
146 %50 = OpConvertSToF %31 %49
147 %51 = OpCompositeConstruct %32 %42 %44 %47 %50
151 %53 = OpAccessChain %39 %38 %15 %16
153 %55 = OpConvertSToF %31 %54
154 %56 = OpCompositeConstruct %32 %55 %55 %55 %55
162 # uniforms for variant
164 # _GLF_uniform_int_values
165 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
168 # _GLF_uniform_uint_values
169 BUFFER variant__GLF_uniform_uint_values DATA_TYPE int32[] 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_uint_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