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:
29 # #define _int_1 _GLF_uniform_int_values[0]
31 # precision highp float;
32 # precision highp int;
34 # // Contents of _GLF_uniform_int_values: 1
35 # layout(set = 0, binding = 0) uniform buf0
37 # int _GLF_uniform_int_values[1];
40 # layout(location = 0) out vec4 _GLF_color;
45 # _GLF_color = vec4(0.0, 1.0, 0.0, 1.0);
47 # vec4 v = _GLF_color;
48 # v[i - _int_1] = v[i];
49 # v[i] = v[i + _int_1];
52 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
55 ; Generator: Khronos Glslang Reference Front End; 10
59 %1 = OpExtInstImport "GLSL.std.450"
60 OpMemoryModel Logical GLSL450
61 OpEntryPoint Fragment %4 "main" %22
62 OpExecutionMode %4 OriginUpperLeft
67 OpMemberName %12 0 "_GLF_uniform_int_values"
69 OpName %22 "_GLF_color"
71 OpDecorate %11 ArrayStride 16
72 OpMemberDecorate %12 0 Offset 0
74 OpDecorate %14 DescriptorSet 0
75 OpDecorate %14 Binding 0
76 OpDecorate %22 Location 0
78 %3 = OpTypeFunction %2
80 %7 = OpTypePointer Function %6
83 %11 = OpTypeArray %6 %10
84 %12 = OpTypeStruct %11
85 %13 = OpTypePointer Uniform %12
86 %14 = OpVariable %13 Uniform
88 %16 = OpTypePointer Uniform %6
90 %20 = OpTypeVector %19 4
91 %21 = OpTypePointer Output %20
92 %22 = OpVariable %21 Output
93 %23 = OpConstant %19 0
94 %24 = OpConstant %19 1
95 %25 = OpConstantComposite %20 %23 %24 %23 %24
96 %26 = OpTypePointer Function %20
97 %34 = OpTypePointer Function %19
98 %4 = OpFunction %2 None %3
100 %8 = OpVariable %7 Function
101 %27 = OpVariable %26 Function
102 %17 = OpAccessChain %16 %14 %15 %15
109 %30 = OpAccessChain %16 %14 %15 %15
111 %32 = OpISub %6 %29 %31
113 %35 = OpAccessChain %34 %27 %33
115 %37 = OpAccessChain %34 %27 %32
119 %40 = OpAccessChain %16 %14 %15 %15
121 %42 = OpIAdd %6 %39 %41
122 %43 = OpAccessChain %34 %27 %42
124 %45 = OpAccessChain %34 %27 %38
132 # uniforms for variant
134 # _GLF_uniform_int_values
135 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
139 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
141 PIPELINE graphics variant_pipeline
142 ATTACH variant_vertex_shader
143 ATTACH variant_fragment_shader
144 FRAMEBUFFER_SIZE 256 256
145 BIND BUFFER variant_framebuffer AS color LOCATION 0
146 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
148 CLEAR_COLOR variant_pipeline 0 0 0 255
150 CLEAR variant_pipeline
151 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
153 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255