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 inst combine and or xor code path
22 # The test passes because the shader always writes red.
24 # Optimized using spirv-opt with the following arguments:
26 # spirv-opt commit hash: a187dd58a0485988841d325a85c8e6063f53500a
30 SHADER vertex variant_vertex_shader PASSTHROUGH
32 # variant_fragment_shader is derived from the following GLSL:
34 # #define _int_1 _GLF_uniform_int_values[0]
35 # #define _int_0 _GLF_uniform_int_values[1]
36 # #define _float_0_0 _GLF_uniform_float_values[0]
37 # #define _float_1_0 _GLF_uniform_float_values[1]
39 # precision highp int;
41 # precision highp float;
43 # // Contents of _GLF_uniform_float_values: [0.0, 1.0]
44 # layout(set = 0, binding = 0) uniform buf0
46 # float _GLF_uniform_float_values[2];
49 # // Contents of _GLF_uniform_int_values: [1, 0]
50 # layout(set = 0, binding = 1) uniform buf1
52 # int _GLF_uniform_int_values[2];
55 # layout(location = 0) out vec4 _GLF_color;
59 # _GLF_color = vec4(_float_1_0);
62 # if (gl_FragCoord.y >= _float_0_0)
68 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
73 # if (_int_0 == _int_1)
75 # _GLF_color = vec4(_float_0_0);
78 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
81 ; Generator: Khronos Glslang Reference Front End; 10
85 %1 = OpExtInstImport "GLSL.std.450"
86 OpMemoryModel Logical GLSL450
87 OpEntryPoint Fragment %4 "main" %9 %24
88 OpExecutionMode %4 OriginUpperLeft
91 OpName %9 "_GLF_color"
93 OpMemberName %13 0 "_GLF_uniform_float_values"
95 OpName %24 "gl_FragCoord"
97 OpMemberName %36 0 "_GLF_uniform_int_values"
99 OpDecorate %9 Location 0
100 OpDecorate %12 ArrayStride 16
101 OpMemberDecorate %13 0 Offset 0
103 OpDecorate %15 DescriptorSet 0
104 OpDecorate %15 Binding 0
105 OpDecorate %24 BuiltIn FragCoord
106 OpDecorate %35 ArrayStride 16
107 OpMemberDecorate %36 0 Offset 0
109 OpDecorate %38 DescriptorSet 0
110 OpDecorate %38 Binding 1
112 %3 = OpTypeFunction %2
114 %7 = OpTypeVector %6 4
115 %8 = OpTypePointer Output %7
116 %9 = OpVariable %8 Output
118 %11 = OpConstant %10 2
119 %12 = OpTypeArray %6 %11
120 %13 = OpTypeStruct %12
121 %14 = OpTypePointer Uniform %13
122 %15 = OpVariable %14 Uniform
124 %17 = OpConstant %16 0
125 %18 = OpConstant %16 1
126 %19 = OpTypePointer Uniform %6
127 %23 = OpTypePointer Input %7
128 %24 = OpVariable %23 Input
129 %25 = OpConstant %10 1
130 %26 = OpTypePointer Input %6
132 %35 = OpTypeArray %16 %11
133 %36 = OpTypeStruct %35
134 %37 = OpTypePointer Uniform %36
135 %38 = OpVariable %37 Uniform
136 %39 = OpTypePointer Uniform %16
137 %4 = OpFunction %2 None %3
139 %20 = OpAccessChain %19 %15 %17 %18
141 %22 = OpCompositeConstruct %7 %21 %21 %21 %21
143 %27 = OpAccessChain %26 %24 %25
145 %29 = OpAccessChain %19 %15 %17 %17
147 %32 = OpFOrdGreaterThanEqual %31 %28 %30
148 OpSelectionMerge %34 None
149 OpBranchConditional %32 %33 %34
151 %40 = OpAccessChain %39 %38 %17 %18
153 OpSelectionMerge %43 None
154 OpSwitch %41 %43 16 %42 0 %42
156 %44 = OpAccessChain %39 %38 %17 %17
158 %46 = OpConvertSToF %6 %45
159 %49 = OpConvertSToF %6 %41
160 %56 = OpCompositeConstruct %7 %46 %49 %49 %46
166 %58 = OpAccessChain %39 %38 %17 %18
168 %60 = OpAccessChain %39 %38 %17 %17
170 %62 = OpIEqual %31 %59 %61
171 OpSelectionMerge %64 None
172 OpBranchConditional %62 %63 %64
174 %67 = OpCompositeConstruct %7 %30 %30 %30 %30
182 # uniforms for variant
184 # _GLF_uniform_int_values
185 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
188 # _GLF_uniform_float_values
189 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
193 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
195 PIPELINE graphics variant_pipeline
196 ATTACH variant_vertex_shader
197 ATTACH variant_fragment_shader
198 FRAMEBUFFER_SIZE 256 256
199 BIND BUFFER variant_framebuffer AS color LOCATION 0
200 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
201 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
203 CLEAR_COLOR variant_pipeline 0 0 0 255
205 CLEAR variant_pipeline
206 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
208 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255