• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2021 Google LLC
4#
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
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
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.
16
17
18# A test for a coverage-gap found by the GraphicsFuzz project.
19
20# Short description: A fragment shader that covers specific LLVM code paths
21
22# The test passes because the shader always writes red.
23
24SHADER vertex variant_vertex_shader PASSTHROUGH
25
26# variant_fragment_shader is derived from the following GLSL:
27# #version 320 es
28# #define _int_1 _GLF_uniform_int_values[0]
29# #define _int_0 _GLF_uniform_int_values[1]
30#
31# precision highp int;
32# precision highp float;
33#
34# // Contents of _GLF_uniform_int_values: [1, 0]
35# layout(set = 0, binding = 0) uniform buf0
36# {
37#     int _GLF_uniform_int_values[2];
38# };
39#
40# layout(location = 0) out vec4 _GLF_color;
41#
42# int func()
43# {
44#     int a = 1;
45#     return (1 + a) - 1;
46# }
47#
48# void main()
49# {
50#     // Always true.
51#     if(func() == 1)
52#     {
53#         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
54#     }
55#     else
56#     {
57#         _GLF_color = vec4(_int_0);
58#     }
59# }
60SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
61; SPIR-V
62; Version: 1.0
63; Generator: Khronos Glslang Reference Front End; 10
64; Bound: 53
65; Schema: 0
66               OpCapability Shader
67          %1 = OpExtInstImport "GLSL.std.450"
68               OpMemoryModel Logical GLSL450
69               OpEntryPoint Fragment %4 "main" %26
70               OpExecutionMode %4 OriginUpperLeft
71               OpSource ESSL 320
72               OpName %4 "main"
73               OpName %8 "func("
74               OpName %11 "a"
75               OpName %26 "_GLF_color"
76               OpName %30 "buf0"
77               OpMemberName %30 0 "_GLF_uniform_int_values"
78               OpName %32 ""
79               OpDecorate %26 Location 0
80               OpDecorate %29 ArrayStride 16
81               OpMemberDecorate %30 0 Offset 0
82               OpDecorate %30 Block
83               OpDecorate %32 DescriptorSet 0
84               OpDecorate %32 Binding 0
85          %2 = OpTypeVoid
86          %3 = OpTypeFunction %2
87          %6 = OpTypeInt 32 1
88          %7 = OpTypeFunction %6
89         %10 = OpTypePointer Function %6
90         %12 = OpConstant %6 1
91         %19 = OpTypeBool
92         %23 = OpTypeFloat 32
93         %24 = OpTypeVector %23 4
94         %25 = OpTypePointer Output %24
95         %26 = OpVariable %25 Output
96         %27 = OpTypeInt 32 0
97         %28 = OpConstant %27 2
98         %29 = OpTypeArray %6 %28
99         %30 = OpTypeStruct %29
100         %31 = OpTypePointer Uniform %30
101         %32 = OpVariable %31 Uniform
102         %33 = OpConstant %6 0
103         %34 = OpTypePointer Uniform %6
104          %4 = OpFunction %2 None %3
105          %5 = OpLabel
106         %18 = OpFunctionCall %6 %8
107         %20 = OpIEqual %19 %18 %12
108               OpSelectionMerge %22 None
109               OpBranchConditional %20 %21 %48
110         %21 = OpLabel
111         %35 = OpAccessChain %34 %32 %33 %33
112         %36 = OpLoad %6 %35
113         %37 = OpConvertSToF %23 %36
114         %38 = OpAccessChain %34 %32 %33 %12
115         %39 = OpLoad %6 %38
116         %40 = OpConvertSToF %23 %39
117         %41 = OpAccessChain %34 %32 %33 %12
118         %42 = OpLoad %6 %41
119         %43 = OpConvertSToF %23 %42
120         %44 = OpAccessChain %34 %32 %33 %33
121         %45 = OpLoad %6 %44
122         %46 = OpConvertSToF %23 %45
123         %47 = OpCompositeConstruct %24 %37 %40 %43 %46
124               OpStore %26 %47
125               OpBranch %22
126         %48 = OpLabel
127         %49 = OpAccessChain %34 %32 %33 %12
128         %50 = OpLoad %6 %49
129         %51 = OpConvertSToF %23 %50
130         %52 = OpCompositeConstruct %24 %51 %51 %51 %51
131               OpStore %26 %52
132               OpBranch %22
133         %22 = OpLabel
134               OpReturn
135               OpFunctionEnd
136          %8 = OpFunction %6 None %7
137          %9 = OpLabel
138         %11 = OpVariable %10 Function
139               OpStore %11 %12
140         %13 = OpLoad %6 %11
141         %14 = OpIAdd %6 %12 %13
142         %15 = OpISub %6 %14 %12
143               OpReturnValue %15
144               OpFunctionEnd
145END
146
147# uniforms for variant
148
149# _GLF_uniform_int_values
150BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
151 1 0
152END
153
154BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
155
156PIPELINE graphics variant_pipeline
157  ATTACH variant_vertex_shader
158  ATTACH variant_fragment_shader
159  FRAMEBUFFER_SIZE 256 256
160  BIND BUFFER variant_framebuffer AS color LOCATION 0
161  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
162END
163CLEAR_COLOR variant_pipeline 0 0 0 255
164
165CLEAR variant_pipeline
166RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
167
168EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
169