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