• 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 NIR 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# #define _int_2 _GLF_uniform_int_values[2]
31#
32# precision highp float;
33# precision highp int;
34#
35# // Contents of _GLF_uniform_int_values: [1, 0, 2]
36# layout(set = 0, binding = 0) uniform buf0
37# {
38#     int _GLF_uniform_int_values[3];
39# };
40#
41# layout(location = 0) out vec4 _GLF_color;
42#
43# void main()
44# {
45#     int a = _int_1;
46#     _GLF_color = vec4(_int_0);
47#
48#     // Always true.
49#     while((_int_2 == a) ^^ true)
50#     {
51#         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
52#         break;
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; 10
59; Bound: 55
60; Schema: 0
61               OpCapability Shader
62          %1 = OpExtInstImport "GLSL.std.450"
63               OpMemoryModel Logical GLSL450
64               OpEntryPoint Fragment %4 "main" %22
65               OpExecutionMode %4 OriginUpperLeft
66               OpSource ESSL 320
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 %22 "_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 %22 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 3
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         %19 = OpTypeFloat 32
92         %20 = OpTypeVector %19 4
93         %21 = OpTypePointer Output %20
94         %22 = OpVariable %21 Output
95         %23 = OpConstant %6 1
96         %33 = OpConstant %6 2
97         %37 = OpTypeBool
98         %39 = OpConstantTrue %37
99          %4 = OpFunction %2 None %3
100          %5 = OpLabel
101          %8 = OpVariable %7 Function
102         %17 = OpAccessChain %16 %14 %15 %15
103         %18 = OpLoad %6 %17
104               OpStore %8 %18
105         %24 = OpAccessChain %16 %14 %15 %23
106         %25 = OpLoad %6 %24
107         %26 = OpConvertSToF %19 %25
108         %27 = OpCompositeConstruct %20 %26 %26 %26 %26
109               OpStore %22 %27
110               OpBranch %28
111         %28 = OpLabel
112               OpLoopMerge %30 %31 None
113               OpBranch %32
114         %32 = OpLabel
115         %34 = OpAccessChain %16 %14 %15 %33
116         %35 = OpLoad %6 %34
117         %36 = OpLoad %6 %8
118         %38 = OpIEqual %37 %35 %36
119         %40 = OpLogicalNotEqual %37 %38 %39
120               OpBranchConditional %40 %29 %30
121         %29 = OpLabel
122         %41 = OpAccessChain %16 %14 %15 %15
123         %42 = OpLoad %6 %41
124         %43 = OpConvertSToF %19 %42
125         %44 = OpAccessChain %16 %14 %15 %23
126         %45 = OpLoad %6 %44
127         %46 = OpConvertSToF %19 %45
128         %47 = OpAccessChain %16 %14 %15 %23
129         %48 = OpLoad %6 %47
130         %49 = OpConvertSToF %19 %48
131         %50 = OpAccessChain %16 %14 %15 %15
132         %51 = OpLoad %6 %50
133         %52 = OpConvertSToF %19 %51
134         %53 = OpCompositeConstruct %20 %43 %46 %49 %52
135               OpStore %22 %53
136               OpBranch %30
137         %31 = OpLabel
138               OpBranch %28
139         %30 = OpLabel
140               OpReturn
141               OpFunctionEnd
142END
143
144# uniforms for variant
145
146# _GLF_uniform_int_values
147BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
148 1 0 2
149END
150
151BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
152
153PIPELINE graphics variant_pipeline
154  ATTACH variant_vertex_shader
155  ATTACH variant_fragment_shader
156  FRAMEBUFFER_SIZE 256 256
157  BIND BUFFER variant_framebuffer AS color LOCATION 0
158  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
159END
160CLEAR_COLOR variant_pipeline 0 0 0 255
161
162CLEAR variant_pipeline
163RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
164
165EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
166