• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2022 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 float;
32# precision highp int;
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# vec4 func()
43# {
44#     int a = _int_1;
45#     min(a, a << 24323);
46#     return vec4(_int_1, _int_0, _int_0, _int_1);
47# }
48#
49# void main()
50# {
51#     _GLF_color = func();
52# }
53SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
54; SPIR-V
55; Version: 1.0
56; Generator: Khronos Glslang Reference Front End; 10
57; Bound: 48
58; Schema: 0
59               OpCapability Shader
60          %1 = OpExtInstImport "GLSL.std.450"
61               OpMemoryModel Logical GLSL450
62               OpEntryPoint Fragment %4 "main" %46
63               OpExecutionMode %4 OriginUpperLeft
64               OpSource ESSL 320
65               OpName %4 "main"
66               OpName %9 "func("
67               OpName %13 "a"
68               OpName %17 "buf0"
69               OpMemberName %17 0 "_GLF_uniform_int_values"
70               OpName %19 ""
71               OpName %46 "_GLF_color"
72               OpDecorate %16 ArrayStride 16
73               OpMemberDecorate %17 0 Offset 0
74               OpDecorate %17 Block
75               OpDecorate %19 DescriptorSet 0
76               OpDecorate %19 Binding 0
77               OpDecorate %46 Location 0
78          %2 = OpTypeVoid
79          %3 = OpTypeFunction %2
80          %6 = OpTypeFloat 32
81          %7 = OpTypeVector %6 4
82          %8 = OpTypeFunction %7
83         %11 = OpTypeInt 32 1
84         %12 = OpTypePointer Function %11
85         %14 = OpTypeInt 32 0
86         %15 = OpConstant %14 2
87         %16 = OpTypeArray %11 %15
88         %17 = OpTypeStruct %16
89         %18 = OpTypePointer Uniform %17
90         %19 = OpVariable %18 Uniform
91         %20 = OpConstant %11 0
92         %21 = OpTypePointer Uniform %11
93         %26 = OpConstant %11 24323
94         %32 = OpConstant %11 1
95         %45 = OpTypePointer Output %7
96         %46 = OpVariable %45 Output
97          %4 = OpFunction %2 None %3
98          %5 = OpLabel
99         %47 = OpFunctionCall %7 %9
100               OpStore %46 %47
101               OpReturn
102               OpFunctionEnd
103          %9 = OpFunction %7 None %8
104         %10 = OpLabel
105         %13 = OpVariable %12 Function
106         %22 = OpAccessChain %21 %19 %20 %20
107         %23 = OpLoad %11 %22
108               OpStore %13 %23
109         %24 = OpLoad %11 %13
110         %25 = OpLoad %11 %13
111         %27 = OpShiftLeftLogical %11 %25 %26
112         %28 = OpExtInst %11 %1 SMin %24 %27
113         %29 = OpAccessChain %21 %19 %20 %20
114         %30 = OpLoad %11 %29
115         %31 = OpConvertSToF %6 %30
116         %33 = OpAccessChain %21 %19 %20 %32
117         %34 = OpLoad %11 %33
118         %35 = OpConvertSToF %6 %34
119         %36 = OpAccessChain %21 %19 %20 %32
120         %37 = OpLoad %11 %36
121         %38 = OpConvertSToF %6 %37
122         %39 = OpAccessChain %21 %19 %20 %20
123         %40 = OpLoad %11 %39
124         %41 = OpConvertSToF %6 %40
125         %42 = OpCompositeConstruct %7 %31 %35 %38 %41
126               OpReturnValue %42
127               OpFunctionEnd
128END
129
130# uniforms for variant
131
132# _GLF_uniform_int_values
133BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
134 1 0
135END
136
137BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
138
139PIPELINE graphics variant_pipeline
140  ATTACH variant_vertex_shader
141  ATTACH variant_fragment_shader
142  FRAMEBUFFER_SIZE 32 32
143  BIND BUFFER variant_framebuffer AS color LOCATION 0
144  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
145END
146CLEAR_COLOR variant_pipeline 0 0 0 255
147
148CLEAR variant_pipeline
149RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
150
151EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255
152