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 simplification 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]
30 # #define _float_0_0 _GLF_uniform_float_values[0]
31 # #define _float_1_0 _GLF_uniform_float_values[1]
33 # precision highp float;
35 # // Contents of _GLF_uniform_int_values: [1, 0]
36 # layout(set = 0, binding = 0) uniform buf0
38 # int _GLF_uniform_int_values[2];
41 # // Contents of _GLF_uniform_float_values: [0.0, 1.0]
42 # layout(set = 0, binding = 1) uniform buf1
44 # float _GLF_uniform_float_values[2];
46 # layout(location = 0) out vec4 _GLF_color;
50 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
52 # float a = mod(sqrt(-1.), _float_1_0);
53 # if (a != _float_0_0)
55 # _GLF_color.g = _float_0_0;
58 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
61 ; Generator: Khronos Glslang Reference Front End; 8
65 %1 = OpExtInstImport "GLSL.std.450"
66 OpMemoryModel Logical GLSL450
67 OpEntryPoint Fragment %4 "main" %9
68 OpExecutionMode %4 OriginUpperLeft
71 OpName %9 "_GLF_color"
73 OpMemberName %14 0 "_GLF_uniform_int_values"
77 OpMemberName %37 0 "_GLF_uniform_float_values"
79 OpDecorate %9 Location 0
80 OpDecorate %13 ArrayStride 16
81 OpMemberDecorate %14 0 RelaxedPrecision
82 OpMemberDecorate %14 0 Offset 0
84 OpDecorate %16 DescriptorSet 0
85 OpDecorate %16 Binding 0
86 OpDecorate %20 RelaxedPrecision
87 OpDecorate %24 RelaxedPrecision
88 OpDecorate %27 RelaxedPrecision
89 OpDecorate %30 RelaxedPrecision
90 OpDecorate %36 ArrayStride 16
91 OpMemberDecorate %37 0 Offset 0
93 OpDecorate %39 DescriptorSet 0
94 OpDecorate %39 Binding 1
96 %3 = OpTypeFunction %2
98 %7 = OpTypeVector %6 4
99 %8 = OpTypePointer Output %7
100 %9 = OpVariable %8 Output
103 %12 = OpConstant %11 2
104 %13 = OpTypeArray %10 %12
105 %14 = OpTypeStruct %13
106 %15 = OpTypePointer Uniform %14
107 %16 = OpVariable %15 Uniform
108 %17 = OpConstant %10 0
109 %18 = OpTypePointer Uniform %10
110 %22 = OpConstant %10 1
111 %33 = OpTypePointer Function %6
112 %35 = OpConstant %6 -0x1.8p+128
113 %36 = OpTypeArray %6 %12
114 %37 = OpTypeStruct %36
115 %38 = OpTypePointer Uniform %37
116 %39 = OpVariable %38 Uniform
117 %40 = OpTypePointer Uniform %6
119 %53 = OpConstant %11 1
120 %54 = OpTypePointer Output %6
121 %4 = OpFunction %2 None %3
123 %34 = OpVariable %33 Function
124 %19 = OpAccessChain %18 %16 %17 %17
126 %21 = OpConvertSToF %6 %20
127 %23 = OpAccessChain %18 %16 %17 %22
129 %25 = OpConvertSToF %6 %24
130 %26 = OpAccessChain %18 %16 %17 %22
132 %28 = OpConvertSToF %6 %27
133 %29 = OpAccessChain %18 %16 %17 %17
135 %31 = OpConvertSToF %6 %30
136 %32 = OpCompositeConstruct %7 %21 %25 %28 %31
138 %41 = OpAccessChain %40 %39 %17 %22
140 %43 = OpFMod %6 %35 %42
143 %45 = OpAccessChain %40 %39 %17 %17
145 %48 = OpFOrdNotEqual %47 %44 %46
146 OpSelectionMerge %50 None
147 OpBranchConditional %48 %49 %50
149 %51 = OpAccessChain %40 %39 %17 %17
151 %55 = OpAccessChain %54 %9 %53
159 # uniforms for variant
161 # _GLF_uniform_float_values
162 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
165 # _GLF_uniform_int_values
166 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
170 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
172 PIPELINE 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_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
178 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
180 CLEAR_COLOR variant_pipeline 0 0 0 255
182 CLEAR variant_pipeline
183 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
185 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255