3 # Copyright 2020 Google LLC
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # A test for a coverage-gap found by the GraphicsFuzz project.
20 # Short description: A fragment shader that covers a specific instruction combine compare code path
22 # The test passes because the shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # #define _int_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
31 # precision highp float;
33 # // Contents of _GLF_uniform_int_values: [1, 0]
34 # layout(set = 0, binding = 0) uniform buf0
36 # int _GLF_uniform_int_values[2];
39 # layout(location = 0) out vec4 _GLF_color;
43 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
44 # if (isnan((-_GLF_color).x))
46 # _GLF_color = vec4(_int_1);
49 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
52 ; Generator: Khronos Glslang Reference Front End; 8
56 %1 = OpExtInstImport "GLSL.std.450"
57 OpMemoryModel Logical GLSL450
58 OpEntryPoint Fragment %4 "main" %9
59 OpExecutionMode %4 OriginUpperLeft
62 OpName %9 "_GLF_color"
64 OpMemberName %14 0 "_GLF_uniform_int_values"
66 OpDecorate %9 Location 0
67 OpDecorate %13 ArrayStride 16
68 OpMemberDecorate %14 0 RelaxedPrecision
69 OpMemberDecorate %14 0 Offset 0
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
79 %3 = OpTypeFunction %2
81 %7 = OpTypeVector %6 4
82 %8 = OpTypePointer Output %7
83 %9 = OpVariable %8 Output
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
96 %4 = OpFunction %2 None %3
98 %19 = OpAccessChain %18 %16 %17 %17
100 %21 = OpConvertSToF %6 %20
101 %23 = OpAccessChain %18 %16 %17 %22
103 %25 = OpConvertSToF %6 %24
104 %26 = OpAccessChain %18 %16 %17 %22
106 %28 = OpConvertSToF %6 %27
107 %29 = OpAccessChain %18 %16 %17 %17
109 %31 = OpConvertSToF %6 %30
110 %32 = OpCompositeConstruct %7 %21 %25 %28 %31
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
119 %41 = OpAccessChain %18 %16 %17 %17
121 %43 = OpConvertSToF %6 %42
122 %44 = OpCompositeConstruct %7 %43 %43 %43 %43
130 # uniforms for variant
132 # _GLF_uniform_int_values
133 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
137 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
139 PIPELINE 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
146 CLEAR_COLOR variant_pipeline 0 0 0 255
148 CLEAR variant_pipeline
149 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
151 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255