3 # Copyright 2021 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 specific BRW code paths
22 # The test passes because the shader always writes red.
24 # Optimized using spirv-opt with the following arguments:
26 # spirv-opt commit hash: a0370efd589be33d5d9a85cfde2f85841b3755af
30 SHADER vertex variant_vertex_shader PASSTHROUGH
32 # variant_fragment_shader is derived from the following GLSL:
34 # #define _int_0 _GLF_uniform_int_values[0]
35 # #define _int_1 _GLF_uniform_int_values[1]
37 # precision highp float;
38 # precision highp int;
40 # // Contents of _GLF_uniform_int_values: [0, 1]
41 # layout(set = 0, binding = 0) uniform buf0
43 # int _GLF_uniform_int_values[2];
46 # const int _GLF_global_loop_bound = 100;
47 # int _GLF_global_loop_count = 0;
49 # layout(location = 0) out vec4 _GLF_color;
55 # while (_GLF_global_loop_count < _GLF_global_loop_bound - _int_1)
57 # _GLF_global_loop_count++;
64 # while (_GLF_global_loop_count < _GLF_global_loop_bound)
66 # _GLF_global_loop_count++;
75 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
79 # _GLF_color = vec4(_int_0);
82 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
85 ; Generator: Khronos Glslang Reference Front End; 10
89 %1 = OpExtInstImport "GLSL.std.450"
90 OpMemoryModel Logical GLSL450
91 OpEntryPoint Fragment %4 "main" %61
92 OpExecutionMode %4 OriginUpperLeft
96 OpMemberName %23 0 "_GLF_uniform_int_values"
98 OpName %61 "_GLF_color"
99 OpDecorate %22 ArrayStride 16
100 OpMemberDecorate %23 0 Offset 0
102 OpDecorate %25 DescriptorSet 0
103 OpDecorate %25 Binding 0
104 OpDecorate %61 Location 0
106 %3 = OpTypeFunction %2
109 %12 = OpConstant %6 1
110 %19 = OpConstant %6 100
112 %21 = OpConstant %20 2
113 %22 = OpTypeArray %6 %21
114 %23 = OpTypeStruct %22
115 %24 = OpTypePointer Uniform %23
116 %25 = OpVariable %24 Uniform
117 %26 = OpTypePointer Uniform %6
120 %59 = OpTypeVector %58 4
121 %60 = OpTypePointer Output %59
122 %61 = OpVariable %60 Output
123 %4 = OpFunction %2 None %3
127 %80 = OpPhi %6 %9 %5 %33 %14
128 %27 = OpAccessChain %26 %25 %9 %12
130 %29 = OpISub %6 %19 %28
131 %31 = OpSLessThan %30 %80 %29
132 OpLoopMerge %15 %14 None
133 OpBranchConditional %31 %14 %15
135 %33 = OpIAdd %6 %80 %12
138 %34 = OpAccessChain %26 %25 %9 %9
140 %36 = OpIEqual %30 %35 %9
141 OpSelectionMerge %38 None
142 OpBranchConditional %36 %37 %38
146 %84 = OpPhi %6 %12 %37 %51 %40
147 %81 = OpPhi %6 %80 %37 %47 %40
148 %45 = OpSLessThan %30 %81 %19
149 OpLoopMerge %41 %40 None
150 OpBranchConditional %45 %40 %41
152 %47 = OpIAdd %6 %81 %12
153 %49 = OpISub %6 %12 %84
154 %51 = OpIMul %6 %84 %49
159 %82 = OpPhi %6 %12 %15 %84 %41
160 %55 = OpIEqual %30 %82 %35
161 OpSelectionMerge %57 None
162 OpBranchConditional %55 %56 %75
164 %64 = OpConvertSToF %58 %28
165 %67 = OpConvertSToF %58 %35
166 %74 = OpCompositeConstruct %59 %64 %67 %67 %64
170 %78 = OpConvertSToF %58 %35
171 %79 = OpCompositeConstruct %59 %78 %78 %78 %78
179 # uniforms for variant
181 # _GLF_uniform_int_values
182 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
186 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
188 PIPELINE graphics variant_pipeline
189 ATTACH variant_vertex_shader
190 ATTACH variant_fragment_shader
191 FRAMEBUFFER_SIZE 256 256
192 BIND BUFFER variant_framebuffer AS color LOCATION 0
193 BIND BUFFER variant__GLF_uniform_int_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