• 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: A fragment shader that covers a specific value tracking path
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 _float_0_0 _GLF_uniform_float_values[0]
29# #define _float_1_0 _GLF_uniform_float_values[1]
30#
31# precision highp float;
32#
33# // Contents of _GLF_uniform_float_values: [0.0, 1.0]
34# layout(set = 0, binding = 0) uniform buf0
35# {
36#     float _GLF_uniform_float_values[2];
37# };
38#
39# layout(location = 0) out vec4 _GLF_color;
40#
41# void main()
42# {
43#     // Always false.
44#     if (inversesqrt(_float_1_0) < -1.0)
45#     {
46#         _GLF_color = vec4(_float_0_0);
47#     }
48#     else
49#     {
50#         _GLF_color = vec4(_float_1_0, _float_0_0, _float_0_0, _float_1_0);
51#     }
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; 8
57; Bound: 41
58; Schema: 0
59               OpCapability Shader
60          %1 = OpExtInstImport "GLSL.std.450"
61               OpMemoryModel Logical GLSL450
62               OpEntryPoint Fragment %4 "main" %27
63               OpExecutionMode %4 OriginUpperLeft
64               OpSource ESSL 310
65               OpName %4 "main"
66               OpName %10 "buf0"
67               OpMemberName %10 0 "_GLF_uniform_float_values"
68               OpName %12 ""
69               OpName %27 "_GLF_color"
70               OpDecorate %9 ArrayStride 16
71               OpMemberDecorate %10 0 Offset 0
72               OpDecorate %10 Block
73               OpDecorate %12 DescriptorSet 0
74               OpDecorate %12 Binding 0
75               OpDecorate %27 Location 0
76          %2 = OpTypeVoid
77          %3 = OpTypeFunction %2
78          %6 = OpTypeFloat 32
79          %7 = OpTypeInt 32 0
80          %8 = OpConstant %7 2
81          %9 = OpTypeArray %6 %8
82         %10 = OpTypeStruct %9
83         %11 = OpTypePointer Uniform %10
84         %12 = OpVariable %11 Uniform
85         %13 = OpTypeInt 32 1
86         %14 = OpConstant %13 0
87         %15 = OpConstant %13 1
88         %16 = OpTypePointer Uniform %6
89         %20 = OpConstant %6 -1
90         %21 = OpTypeBool
91         %25 = OpTypeVector %6 4
92         %26 = OpTypePointer Output %25
93         %27 = OpVariable %26 Output
94          %4 = OpFunction %2 None %3
95          %5 = OpLabel
96         %17 = OpAccessChain %16 %12 %14 %15
97         %18 = OpLoad %6 %17
98         %19 = OpExtInst %6 %1 InverseSqrt %18
99         %22 = OpFOrdLessThan %21 %19 %20
100               OpSelectionMerge %24 None
101               OpBranchConditional %22 %23 %31
102         %23 = OpLabel
103         %28 = OpAccessChain %16 %12 %14 %14
104         %29 = OpLoad %6 %28
105         %30 = OpCompositeConstruct %25 %29 %29 %29 %29
106               OpStore %27 %30
107               OpBranch %24
108         %31 = OpLabel
109         %32 = OpAccessChain %16 %12 %14 %15
110         %33 = OpLoad %6 %32
111         %34 = OpAccessChain %16 %12 %14 %14
112         %35 = OpLoad %6 %34
113         %36 = OpAccessChain %16 %12 %14 %14
114         %37 = OpLoad %6 %36
115         %38 = OpAccessChain %16 %12 %14 %15
116         %39 = OpLoad %6 %38
117         %40 = OpCompositeConstruct %25 %33 %35 %37 %39
118               OpStore %27 %40
119               OpBranch %24
120         %24 = OpLabel
121               OpReturn
122               OpFunctionEnd
123END
124
125# uniforms for variant
126
127# _GLF_uniform_float_values
128BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
129 0.0 1.0
130END
131
132BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
133
134PIPELINE graphics variant_pipeline
135  ATTACH variant_vertex_shader
136  ATTACH variant_fragment_shader
137  FRAMEBUFFER_SIZE 256 256
138  BIND BUFFER variant_framebuffer AS color LOCATION 0
139  BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
140END
141CLEAR_COLOR variant_pipeline 0 0 0 255
142
143CLEAR variant_pipeline
144RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
145
146EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
147