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 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # #define _int_0 _GLF_uniform_int_values[0]
29 # #define _int_1 _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 # precision highp int;
37 # // Contents of _GLF_uniform_int_values: [0, 1]
38 # layout(set = 0, binding = 0) uniform buf0
40 # int _GLF_uniform_int_values[2];
43 # // Contents of _GLF_uniform_float_values: [0.0, 1.0]
44 # layout(set = 0, binding = 1) uniform buf1
46 # float _GLF_uniform_float_values[2];
49 # layout(location = 0) out vec4 _GLF_color;
54 # data[_int_0] = _float_0_0;
55 # data[_int_1] = _float_1_0;
56 # float a = data[(1 ^ (_int_1 & 2))];
57 # if (a == _float_1_0)
59 # _GLF_color = vec4(_float_1_0, _float_0_0, _float_0_0, _float_1_0);
63 # _GLF_color = vec4(_float_0_0);
66 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
69 ; Generator: Khronos Glslang Reference Front End; 8
73 %1 = OpExtInstImport "GLSL.std.450"
74 OpMemoryModel Logical GLSL450
75 OpEntryPoint Fragment %4 "main" %53
76 OpExecutionMode %4 OriginUpperLeft
81 OpMemberName %14 0 "_GLF_uniform_int_values"
84 OpMemberName %22 0 "_GLF_uniform_float_values"
87 OpName %53 "_GLF_color"
88 OpDecorate %13 ArrayStride 16
89 OpMemberDecorate %14 0 Offset 0
91 OpDecorate %16 DescriptorSet 0
92 OpDecorate %16 Binding 0
93 OpDecorate %21 ArrayStride 16
94 OpMemberDecorate %22 0 Offset 0
96 OpDecorate %24 DescriptorSet 0
97 OpDecorate %24 Binding 1
98 OpDecorate %53 Location 0
100 %3 = OpTypeFunction %2
104 %9 = OpTypeArray %6 %8
105 %10 = OpTypePointer Function %9
107 %13 = OpTypeArray %12 %8
108 %14 = OpTypeStruct %13
109 %15 = OpTypePointer Uniform %14
110 %16 = OpVariable %15 Uniform
111 %17 = OpConstant %12 0
112 %18 = OpTypePointer Uniform %12
113 %21 = OpTypeArray %6 %8
114 %22 = OpTypeStruct %21
115 %23 = OpTypePointer Uniform %22
116 %24 = OpVariable %23 Uniform
117 %25 = OpTypePointer Uniform %6
118 %28 = OpTypePointer Function %6
119 %30 = OpConstant %12 1
120 %39 = OpConstant %12 2
122 %51 = OpTypeVector %6 4
123 %52 = OpTypePointer Output %51
124 %53 = OpVariable %52 Output
125 %4 = OpFunction %2 None %3
127 %11 = OpVariable %10 Function
128 %36 = OpVariable %28 Function
129 %19 = OpAccessChain %18 %16 %17 %17
131 %26 = OpAccessChain %25 %24 %17 %17
133 %29 = OpAccessChain %28 %11 %20
135 %31 = OpAccessChain %18 %16 %17 %30
137 %33 = OpAccessChain %25 %24 %17 %30
139 %35 = OpAccessChain %28 %11 %32
141 %37 = OpAccessChain %18 %16 %17 %30
143 %40 = OpBitwiseAnd %12 %38 %39
144 %41 = OpBitwiseXor %12 %30 %40
145 %42 = OpAccessChain %28 %11 %41
149 %45 = OpAccessChain %25 %24 %17 %30
151 %48 = OpFOrdEqual %47 %44 %46
152 OpSelectionMerge %50 None
153 OpBranchConditional %48 %49 %63
155 %54 = OpAccessChain %25 %24 %17 %30
157 %56 = OpAccessChain %25 %24 %17 %17
159 %58 = OpAccessChain %25 %24 %17 %17
161 %60 = OpAccessChain %25 %24 %17 %30
163 %62 = OpCompositeConstruct %51 %55 %57 %59 %61
167 %64 = OpAccessChain %25 %24 %17 %17
169 %66 = OpCompositeConstruct %51 %65 %65 %65 %65
177 # uniforms for variant
179 # _GLF_uniform_float_values
180 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
183 # _GLF_uniform_int_values
184 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
188 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
190 PIPELINE graphics variant_pipeline
191 ATTACH variant_vertex_shader
192 ATTACH variant_fragment_shader
193 FRAMEBUFFER_SIZE 256 256
194 BIND BUFFER variant_framebuffer AS color LOCATION 0
195 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
196 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
198 CLEAR_COLOR variant_pipeline 0 0 0 255
200 CLEAR variant_pipeline
201 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
203 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255