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