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 NIR code paths
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 _int_2 _GLF_uniform_int_values[2]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_int_values: [1, 0, 2]
36 # layout(set = 0, binding = 0) uniform buf0
38 # int _GLF_uniform_int_values[3];
41 # layout(location = 0) out vec4 _GLF_color;
46 # _GLF_color = vec4(_int_0);
49 # while((_int_2 == a) ^^ true)
51 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
55 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
58 ; Generator: Khronos Glslang Reference Front End; 10
62 %1 = OpExtInstImport "GLSL.std.450"
63 OpMemoryModel Logical GLSL450
64 OpEntryPoint Fragment %4 "main" %22
65 OpExecutionMode %4 OriginUpperLeft
70 OpMemberName %12 0 "_GLF_uniform_int_values"
72 OpName %22 "_GLF_color"
73 OpDecorate %11 ArrayStride 16
74 OpMemberDecorate %12 0 Offset 0
76 OpDecorate %14 DescriptorSet 0
77 OpDecorate %14 Binding 0
78 OpDecorate %22 Location 0
80 %3 = OpTypeFunction %2
82 %7 = OpTypePointer Function %6
85 %11 = OpTypeArray %6 %10
86 %12 = OpTypeStruct %11
87 %13 = OpTypePointer Uniform %12
88 %14 = OpVariable %13 Uniform
90 %16 = OpTypePointer Uniform %6
92 %20 = OpTypeVector %19 4
93 %21 = OpTypePointer Output %20
94 %22 = OpVariable %21 Output
98 %39 = OpConstantTrue %37
99 %4 = OpFunction %2 None %3
101 %8 = OpVariable %7 Function
102 %17 = OpAccessChain %16 %14 %15 %15
105 %24 = OpAccessChain %16 %14 %15 %23
107 %26 = OpConvertSToF %19 %25
108 %27 = OpCompositeConstruct %20 %26 %26 %26 %26
112 OpLoopMerge %30 %31 None
115 %34 = OpAccessChain %16 %14 %15 %33
118 %38 = OpIEqual %37 %35 %36
119 %40 = OpLogicalNotEqual %37 %38 %39
120 OpBranchConditional %40 %29 %30
122 %41 = OpAccessChain %16 %14 %15 %15
124 %43 = OpConvertSToF %19 %42
125 %44 = OpAccessChain %16 %14 %15 %23
127 %46 = OpConvertSToF %19 %45
128 %47 = OpAccessChain %16 %14 %15 %23
130 %49 = OpConvertSToF %19 %48
131 %50 = OpAccessChain %16 %14 %15 %15
133 %52 = OpConvertSToF %19 %51
134 %53 = OpCompositeConstruct %20 %43 %46 %49 %52
144 # uniforms for variant
146 # _GLF_uniform_int_values
147 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
151 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
153 PIPELINE graphics variant_pipeline
154 ATTACH variant_vertex_shader
155 ATTACH variant_fragment_shader
156 FRAMEBUFFER_SIZE 256 256
157 BIND BUFFER variant_framebuffer AS color LOCATION 0
158 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
160 CLEAR_COLOR variant_pipeline 0 0 0 255
162 CLEAR variant_pipeline
163 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
165 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255