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: Covers specific inst combine simplify demanded and inst combine shifts 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_256_0 _GLF_uniform_float_values[0]
39 # precision highp float;
40 # precision highp int;
42 # // Contents of _GLF_uniform_float_values: [0.0, 256.0]
43 # layout(set = 0, binding = 0) uniform buf0
45 # float _GLF_uniform_float_values[2];
48 # // Contents of _GLF_uniform_int_values: [1, 0]
49 # layout(set = 0, binding = 1) uniform buf1
51 # int _GLF_uniform_int_values[2];
54 # layout(location = 0) out vec4 _GLF_color;
58 # vec2 v1 = vec2(_float_256_0);
60 # // v1.y becomes undefined. This results in an undefined value, but not in undefined behavior.
61 # v1[_int_1] = ldexp(v1.y, -256);
63 # vec2 v2 = v1 * mat2(_float_0_0);
65 # if (v2.x == _float_0_0)
66 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
68 # _GLF_color = vec4(_int_0);
70 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
73 ; Generator: Khronos Glslang Reference Front End; 10
77 %1 = OpExtInstImport "GLSL.std.450"
78 OpMemoryModel Logical GLSL450
79 OpEntryPoint Fragment %4 "main" %58
80 OpExecutionMode %4 OriginUpperLeft
85 OpMemberName %13 0 "_GLF_uniform_float_values"
88 OpMemberName %23 0 "_GLF_uniform_int_values"
90 OpName %58 "_GLF_color"
91 OpDecorate %12 ArrayStride 16
92 OpMemberDecorate %13 0 Offset 0
94 OpDecorate %15 DescriptorSet 0
95 OpDecorate %15 Binding 0
96 OpDecorate %22 ArrayStride 16
97 OpMemberDecorate %23 0 Offset 0
99 OpDecorate %25 DescriptorSet 0
100 OpDecorate %25 Binding 1
101 OpDecorate %58 Location 0
103 %3 = OpTypeFunction %2
105 %7 = OpTypeVector %6 2
106 %8 = OpTypePointer Function %7
108 %11 = OpConstant %10 2
109 %12 = OpTypeArray %6 %11
110 %13 = OpTypeStruct %12
111 %14 = OpTypePointer Uniform %13
112 %15 = OpVariable %14 Uniform
114 %17 = OpConstant %16 0
115 %18 = OpTypePointer Uniform %6
116 %22 = OpTypeArray %16 %11
117 %23 = OpTypeStruct %22
118 %24 = OpTypePointer Uniform %23
119 %25 = OpVariable %24 Uniform
120 %26 = OpTypePointer Uniform %16
121 %29 = OpConstant %10 1
122 %30 = OpTypePointer Function %6
123 %33 = OpConstant %16 -256
124 %40 = OpTypeMatrix %7 2
125 %42 = OpConstant %6 0
127 %56 = OpTypeVector %6 4
128 %57 = OpTypePointer Output %56
129 %58 = OpVariable %57 Output
130 %62 = OpConstant %16 1
131 %4 = OpFunction %2 None %3
133 %9 = OpVariable %8 Function
134 %19 = OpAccessChain %18 %15 %17 %17
136 %21 = OpCompositeConstruct %7 %20 %20
138 %27 = OpAccessChain %26 %25 %17 %17
140 %31 = OpAccessChain %30 %9 %29
142 %34 = OpExtInst %6 %1 Ldexp %32 %33
143 %35 = OpAccessChain %30 %9 %28
146 %43 = OpCompositeConstruct %7 %20 %42
147 %44 = OpCompositeConstruct %7 %42 %20
148 %45 = OpCompositeConstruct %40 %43 %44
149 %46 = OpVectorTimesMatrix %7 %37 %45
150 %49 = OpCompositeExtract %6 %46 0
151 %53 = OpFOrdEqual %52 %49 %20
152 OpSelectionMerge %55 None
153 OpBranchConditional %53 %54 %73
155 %61 = OpConvertSToF %6 %28
156 %63 = OpAccessChain %26 %25 %17 %62
158 %65 = OpConvertSToF %6 %64
159 %72 = OpCompositeConstruct %56 %61 %65 %65 %61
163 %74 = OpAccessChain %26 %25 %17 %62
165 %76 = OpConvertSToF %6 %75
166 %77 = OpCompositeConstruct %56 %76 %76 %76 %76
174 # uniforms for variant
176 # _GLF_uniform_int_values
177 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
180 # _GLF_uniform_float_values
181 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
185 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
187 PIPELINE graphics variant_pipeline
188 ATTACH variant_vertex_shader
189 ATTACH variant_fragment_shader
190 FRAMEBUFFER_SIZE 256 256
191 BIND BUFFER variant_framebuffer AS color LOCATION 0
192 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
193 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
195 CLEAR_COLOR variant_pipeline 0 0 0 255
197 CLEAR variant_pipeline
198 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
200 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255