• 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 BRW 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_0 _GLF_uniform_int_values[0]
29# #define _int_1 _GLF_uniform_int_values[1]
30# #define _float_4_0 _GLF_uniform_float_values[0]
31# #define _float_0_25 _GLF_uniform_float_values[1]
32#
33# precision highp int;
34# precision highp float;
35#
36# // Contents of _GLF_uniform_int_values: [0, 1]
37# layout(set = 0, binding = 0) uniform buf0
38# {
39#     int _GLF_uniform_int_values[2];
40# };
41#
42# // Contents of _GLF_uniform_float_values: [4.0, 0.25]
43# layout(set = 0, binding = 1) uniform buf1
44# {
45#     float _GLF_uniform_float_values[2];
46# };
47#
48# layout(location = 0) out vec4 _GLF_color;
49#
50# void main()
51# {
52#     float a = 1.0;
53#     float b = clamp(_float_0_25, false ? a : 0.0, 1.0);
54#
55#     // Always true.
56#     if(b == _float_0_25)
57#     {
58#         _GLF_color = vec4(b * _float_4_0, _int_0, _int_0, _int_1);
59#     }
60#     else
61#     {
62#         _GLF_color = vec4(_int_0);
63#     }
64# }
65SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
66; SPIR-V
67; Version: 1.0
68; Generator: Khronos Glslang Reference Front End; 10
69; Bound: 62
70; Schema: 0
71               OpCapability Shader
72          %1 = OpExtInstImport "GLSL.std.450"
73               OpMemoryModel Logical GLSL450
74               OpEntryPoint Fragment %4 "main" %37
75               OpExecutionMode %4 OriginUpperLeft
76               OpSource ESSL 320
77               OpName %4 "main"
78               OpName %8 "a"
79               OpName %10 "b"
80               OpName %14 "buf1"
81               OpMemberName %14 0 "_GLF_uniform_float_values"
82               OpName %16 ""
83               OpName %37 "_GLF_color"
84               OpName %43 "buf0"
85               OpMemberName %43 0 "_GLF_uniform_int_values"
86               OpName %45 ""
87               OpDecorate %13 ArrayStride 16
88               OpMemberDecorate %14 0 Offset 0
89               OpDecorate %14 Block
90               OpDecorate %16 DescriptorSet 0
91               OpDecorate %16 Binding 1
92               OpDecorate %37 Location 0
93               OpDecorate %42 ArrayStride 16
94               OpMemberDecorate %43 0 Offset 0
95               OpDecorate %43 Block
96               OpDecorate %45 DescriptorSet 0
97               OpDecorate %45 Binding 0
98          %2 = OpTypeVoid
99          %3 = OpTypeFunction %2
100          %6 = OpTypeFloat 32
101          %7 = OpTypePointer Function %6
102          %9 = OpConstant %6 1
103         %11 = OpTypeInt 32 0
104         %12 = OpConstant %11 2
105         %13 = OpTypeArray %6 %12
106         %14 = OpTypeStruct %13
107         %15 = OpTypePointer Uniform %14
108         %16 = OpVariable %15 Uniform
109         %17 = OpTypeInt 32 1
110         %18 = OpConstant %17 0
111         %19 = OpConstant %17 1
112         %20 = OpTypePointer Uniform %6
113         %23 = OpTypeBool
114         %24 = OpConstantFalse %23
115         %26 = OpConstant %6 0
116         %35 = OpTypeVector %6 4
117         %36 = OpTypePointer Output %35
118         %37 = OpVariable %36 Output
119         %42 = OpTypeArray %17 %12
120         %43 = OpTypeStruct %42
121         %44 = OpTypePointer Uniform %43
122         %45 = OpVariable %44 Uniform
123         %46 = OpTypePointer Uniform %17
124          %4 = OpFunction %2 None %3
125          %5 = OpLabel
126          %8 = OpVariable %7 Function
127         %10 = OpVariable %7 Function
128               OpStore %8 %9
129         %21 = OpAccessChain %20 %16 %18 %19
130         %22 = OpLoad %6 %21
131         %25 = OpLoad %6 %8
132         %27 = OpSelect %6 %24 %25 %26
133         %28 = OpExtInst %6 %1 FClamp %22 %27 %9
134               OpStore %10 %28
135         %29 = OpLoad %6 %10
136         %30 = OpAccessChain %20 %16 %18 %19
137         %31 = OpLoad %6 %30
138         %32 = OpFOrdEqual %23 %29 %31
139               OpSelectionMerge %34 None
140               OpBranchConditional %32 %33 %57
141         %33 = OpLabel
142         %38 = OpLoad %6 %10
143         %39 = OpAccessChain %20 %16 %18 %18
144         %40 = OpLoad %6 %39
145         %41 = OpFMul %6 %38 %40
146         %47 = OpAccessChain %46 %45 %18 %18
147         %48 = OpLoad %17 %47
148         %49 = OpConvertSToF %6 %48
149         %50 = OpAccessChain %46 %45 %18 %18
150         %51 = OpLoad %17 %50
151         %52 = OpConvertSToF %6 %51
152         %53 = OpAccessChain %46 %45 %18 %19
153         %54 = OpLoad %17 %53
154         %55 = OpConvertSToF %6 %54
155         %56 = OpCompositeConstruct %35 %41 %49 %52 %55
156               OpStore %37 %56
157               OpBranch %34
158         %57 = OpLabel
159         %58 = OpAccessChain %46 %45 %18 %18
160         %59 = OpLoad %17 %58
161         %60 = OpConvertSToF %6 %59
162         %61 = OpCompositeConstruct %35 %60 %60 %60 %60
163               OpStore %37 %61
164               OpBranch %34
165         %34 = OpLabel
166               OpReturn
167               OpFunctionEnd
168END
169
170# uniforms for variant
171
172# _GLF_uniform_float_values
173BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
174 4.0 0.25
175END
176# _GLF_uniform_int_values
177BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
178 0 1
179END
180
181BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
182
183PIPELINE graphics variant_pipeline
184  ATTACH variant_vertex_shader
185  ATTACH variant_fragment_shader
186  FRAMEBUFFER_SIZE 256 256
187  BIND BUFFER variant_framebuffer AS color LOCATION 0
188  BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
189  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
190END
191CLEAR_COLOR variant_pipeline 0 0 0 255
192
193CLEAR variant_pipeline
194RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
195
196EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
197