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]
31 # precision highp int;
32 # precision highp float;
34 # // Contents of _GLF_uniform_int_values: [1, 0]
35 # layout(set = 0, binding = 0) uniform buf0
37 # int _GLF_uniform_int_values[2];
40 # layout(location = 0) out vec4 _GLF_color;
44 # mat2 m = transpose(transpose(mat2x2(_int_1)));
46 # if(m == mat2x2(_int_1))
48 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
52 # _GLF_color = vec4(_int_0);
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" %52
65 OpExecutionMode %4 OriginUpperLeft
70 OpMemberName %15 0 "_GLF_uniform_int_values"
72 OpName %52 "_GLF_color"
73 OpDecorate %14 ArrayStride 16
74 OpMemberDecorate %15 0 Offset 0
76 OpDecorate %17 DescriptorSet 0
77 OpDecorate %17 Binding 0
78 OpDecorate %52 Location 0
80 %3 = OpTypeFunction %2
82 %7 = OpTypeVector %6 2
83 %8 = OpTypeMatrix %7 2
84 %9 = OpTypePointer Function %8
87 %13 = OpConstant %12 2
88 %14 = OpTypeArray %11 %13
89 %15 = OpTypeStruct %14
90 %16 = OpTypePointer Uniform %15
91 %17 = OpVariable %16 Uniform
92 %18 = OpConstant %11 0
93 %19 = OpTypePointer Uniform %11
97 %40 = OpTypeVector %37 2
98 %50 = OpTypeVector %6 4
99 %51 = OpTypePointer Output %50
100 %52 = OpVariable %51 Output
101 %56 = OpConstant %11 1
102 %4 = OpFunction %2 None %3
104 %10 = OpVariable %9 Function
105 %20 = OpAccessChain %19 %17 %18 %18
107 %22 = OpConvertSToF %6 %21
108 %25 = OpCompositeConstruct %7 %22 %24
109 %26 = OpCompositeConstruct %7 %24 %22
110 %27 = OpCompositeConstruct %8 %25 %26
111 %28 = OpTranspose %8 %27
112 %29 = OpTranspose %8 %28
115 %31 = OpAccessChain %19 %17 %18 %18
117 %33 = OpConvertSToF %6 %32
118 %34 = OpCompositeConstruct %7 %33 %24
119 %35 = OpCompositeConstruct %7 %24 %33
120 %36 = OpCompositeConstruct %8 %34 %35
121 %38 = OpCompositeExtract %7 %30 0
122 %39 = OpCompositeExtract %7 %36 0
123 %41 = OpFOrdEqual %40 %38 %39
125 %43 = OpCompositeExtract %7 %30 1
126 %44 = OpCompositeExtract %7 %36 1
127 %45 = OpFOrdEqual %40 %43 %44
129 %47 = OpLogicalAnd %37 %42 %46
130 OpSelectionMerge %49 None
131 OpBranchConditional %47 %48 %67
133 %53 = OpAccessChain %19 %17 %18 %18
135 %55 = OpConvertSToF %6 %54
136 %57 = OpAccessChain %19 %17 %18 %56
138 %59 = OpConvertSToF %6 %58
139 %60 = OpAccessChain %19 %17 %18 %56
141 %62 = OpConvertSToF %6 %61
142 %63 = OpAccessChain %19 %17 %18 %18
144 %65 = OpConvertSToF %6 %64
145 %66 = OpCompositeConstruct %50 %55 %59 %62 %65
149 %68 = OpAccessChain %19 %17 %18 %56
151 %70 = OpConvertSToF %6 %69
152 %71 = OpCompositeConstruct %50 %70 %70 %70 %70
160 # uniforms for variant
162 # _GLF_uniform_int_values
163 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
167 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
169 PIPELINE graphics variant_pipeline
170 ATTACH variant_vertex_shader
171 ATTACH variant_fragment_shader
172 FRAMEBUFFER_SIZE 256 256
173 BIND BUFFER variant_framebuffer AS color LOCATION 0
174 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
176 CLEAR_COLOR variant_pipeline 0 0 0 255
178 CLEAR variant_pipeline
179 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
181 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255