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 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_0 _GLF_uniform_int_values[0]
29 # #define _int_1 _GLF_uniform_int_values[1]
31 # precision highp float;
32 # precision highp int;
34 # // Contents of _GLF_uniform_int_values: [0, 1]
35 # layout(set = 0, binding = 0) uniform buf0
37 # int _GLF_uniform_int_values[2];
40 # layout(location = 0) out vec4 _GLF_color;
45 # int i = bitfieldExtract(_int_0, bitCount(0), _int_1);
49 # _GLF_color = vec4(_int_1, i, i, _int_1);
53 # _GLF_color = vec4(i);
56 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
59 ; Generator: Khronos Glslang Reference Front End; 8
63 %1 = OpExtInstImport "GLSL.std.450"
64 OpMemoryModel Logical GLSL450
65 OpEntryPoint Fragment %4 "main" %34
66 OpExecutionMode %4 OriginUpperLeft
71 OpMemberName %12 0 "_GLF_uniform_int_values"
73 OpName %34 "_GLF_color"
74 OpDecorate %11 ArrayStride 16
75 OpMemberDecorate %12 0 Offset 0
77 OpDecorate %14 DescriptorSet 0
78 OpDecorate %14 Binding 0
79 OpDecorate %19 RelaxedPrecision
80 OpDecorate %34 Location 0
82 %3 = OpTypeFunction %2
84 %7 = OpTypePointer Function %6
87 %11 = OpTypeArray %6 %10
88 %12 = OpTypeStruct %11
89 %13 = OpTypePointer Uniform %12
90 %14 = OpVariable %13 Uniform
92 %16 = OpTypePointer Uniform %6
96 %32 = OpTypeVector %31 4
97 %33 = OpTypePointer Output %32
98 %34 = OpVariable %33 Output
99 %4 = OpFunction %2 None %3
101 %8 = OpVariable %7 Function
102 %17 = OpAccessChain %16 %14 %15 %15
104 %19 = OpBitCount %6 %15
105 %21 = OpAccessChain %16 %14 %15 %20
107 %23 = OpBitFieldSExtract %6 %18 %19 %22
110 %25 = OpAccessChain %16 %14 %15 %15
112 %28 = OpIEqual %27 %24 %26
113 OpSelectionMerge %30 None
114 OpBranchConditional %28 %29 %46
116 %35 = OpAccessChain %16 %14 %15 %20
118 %37 = OpConvertSToF %31 %36
120 %39 = OpConvertSToF %31 %38
122 %41 = OpConvertSToF %31 %40
123 %42 = OpAccessChain %16 %14 %15 %20
125 %44 = OpConvertSToF %31 %43
126 %45 = OpCompositeConstruct %32 %37 %39 %41 %44
131 %48 = OpConvertSToF %31 %47
132 %49 = OpCompositeConstruct %32 %48 %48 %48 %48
140 # uniforms for variant
142 # _GLF_uniform_int_values
143 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
147 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
149 PIPELINE graphics variant_pipeline
150 ATTACH variant_vertex_shader
151 ATTACH variant_fragment_shader
152 FRAMEBUFFER_SIZE 256 256
153 BIND BUFFER variant_framebuffer AS color LOCATION 0
154 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
156 CLEAR_COLOR variant_pipeline 0 0 0 255
158 CLEAR variant_pipeline
159 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
161 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255