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 shifts 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]
30 # #define _float_1_0 _GLF_uniform_float_values[0]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_int_values: [1, 0]
36 # layout(set = 0, binding = 1) uniform buf1
38 # int _GLF_uniform_int_values[2];
41 # layout(location = 0) out vec4 _GLF_color;
45 # int idx = 1 << _int_0;
47 # int a = int[2](_int_0, _int_1)[idx];
50 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
54 # _GLF_color = vec4(_int_0);
57 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
60 ; Generator: Khronos Glslang Reference Front End; 10
64 %1 = OpExtInstImport "GLSL.std.450"
65 OpMemoryModel Logical GLSL450
66 OpEntryPoint Fragment %4 "main" %42
67 OpExecutionMode %4 OriginUpperLeft
72 OpMemberName %13 0 "_GLF_uniform_int_values"
75 OpName %29 "indexable"
76 OpName %42 "_GLF_color"
77 OpDecorate %12 ArrayStride 16
78 OpMemberDecorate %13 0 Offset 0
80 OpDecorate %15 DescriptorSet 0
81 OpDecorate %15 Binding 1
82 OpDecorate %42 Location 0
84 %3 = OpTypeFunction %2
86 %7 = OpTypePointer Function %6
89 %11 = OpConstant %10 2
90 %12 = OpTypeArray %6 %11
91 %13 = OpTypeStruct %12
92 %14 = OpTypePointer Uniform %13
93 %15 = OpVariable %14 Uniform
95 %17 = OpTypePointer Uniform %6
96 %28 = OpTypePointer Function %12
99 %40 = OpTypeVector %39 4
100 %41 = OpTypePointer Output %40
101 %42 = OpVariable %41 Output
102 %4 = OpFunction %2 None %3
104 %8 = OpVariable %7 Function
105 %21 = OpVariable %7 Function
106 %29 = OpVariable %28 Function
107 %18 = OpAccessChain %17 %15 %16 %9
109 %20 = OpShiftLeftLogical %6 %9 %19
111 %22 = OpAccessChain %17 %15 %16 %9
113 %24 = OpAccessChain %17 %15 %16 %16
115 %26 = OpCompositeConstruct %12 %23 %25
118 %30 = OpAccessChain %7 %29 %27
122 %33 = OpAccessChain %17 %15 %16 %16
124 %36 = OpIEqual %35 %32 %34
125 OpSelectionMerge %38 None
126 OpBranchConditional %36 %37 %56
128 %43 = OpAccessChain %17 %15 %16 %16
130 %45 = OpConvertSToF %39 %44
131 %46 = OpAccessChain %17 %15 %16 %9
133 %48 = OpConvertSToF %39 %47
134 %49 = OpAccessChain %17 %15 %16 %9
136 %51 = OpConvertSToF %39 %50
137 %52 = OpAccessChain %17 %15 %16 %16
139 %54 = OpConvertSToF %39 %53
140 %55 = OpCompositeConstruct %40 %45 %48 %51 %54
144 %57 = OpAccessChain %17 %15 %16 %9
146 %59 = OpConvertSToF %39 %58
147 %60 = OpCompositeConstruct %40 %59 %59 %59 %59
155 # uniforms for variant
157 # _GLF_uniform_int_values
158 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
162 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
164 PIPELINE graphics variant_pipeline
165 ATTACH variant_vertex_shader
166 ATTACH variant_fragment_shader
167 FRAMEBUFFER_SIZE 256 256
168 BIND BUFFER variant_framebuffer AS color LOCATION 0
169 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
171 CLEAR_COLOR variant_pipeline 0 0 0 255
173 CLEAR variant_pipeline
174 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
176 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255