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