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