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 DAG 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: a187dd58a0485988841d325a85c8e6063f53500a
30 SHADER vertex variant_vertex_shader PASSTHROUGH
32 # variant_fragment_shader is derived from the following GLSL:
34 # #define _float_1_0 _GLF_uniform_float_values[0]
35 # #define _float_0_0 _GLF_uniform_float_values[1]
36 # #define _float_0_1 _GLF_uniform_float_values[2]
37 # #define _float_0_3 _GLF_uniform_float_values[3]
38 # #define _float_0_2 _GLF_uniform_float_values[4]
40 # precision highp float;
42 # precision highp int;
44 # // Contents of _GLF_uniform_float_values: [1.0, 0.0, 0.1, 0.3, 0.2]
45 # layout(set = 0, binding = 0) uniform buf0
47 # float _GLF_uniform_float_values[5];
50 # layout(location = 0) out vec4 _GLF_color;
54 # // These conditions don't matter since the color
55 # // gets overwritten right after.
56 # if(gl_FragCoord.x > _float_1_0)
58 # _GLF_color = vec4(_float_0_1);
59 # if(gl_FragCoord.y > _float_1_0)
61 # _GLF_color = vec4(_float_0_2);
63 # _GLF_color = vec4(_float_0_3);
66 # _GLF_color = vec4(_float_1_0, _float_0_0, _float_0_0, 10.0);
67 # // Multiplying by an identity matrix doesn't change the vector value.
68 # _GLF_color = mat4(_float_1_0) * _GLF_color;
70 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
73 ; Generator: Khronos Glslang Reference Front End; 10
77 %1 = OpExtInstImport "GLSL.std.450"
78 OpMemoryModel Logical GLSL450
79 OpEntryPoint Fragment %4 "main" %9 %30
80 OpExecutionMode %4 OriginUpperLeft
83 OpName %9 "gl_FragCoord"
85 OpMemberName %17 0 "_GLF_uniform_float_values"
87 OpName %30 "_GLF_color"
88 OpDecorate %9 BuiltIn FragCoord
89 OpDecorate %16 ArrayStride 16
90 OpMemberDecorate %17 0 Offset 0
92 OpDecorate %19 DescriptorSet 0
93 OpDecorate %19 Binding 0
94 OpDecorate %30 Location 0
96 %3 = OpTypeFunction %2
98 %7 = OpTypeVector %6 4
99 %8 = OpTypePointer Input %7
100 %9 = OpVariable %8 Input
102 %11 = OpConstant %10 0
103 %12 = OpTypePointer Input %6
104 %15 = OpConstant %10 5
105 %16 = OpTypeArray %6 %15
106 %17 = OpTypeStruct %16
107 %18 = OpTypePointer Uniform %17
108 %19 = OpVariable %18 Uniform
110 %21 = OpConstant %20 0
111 %22 = OpTypePointer Uniform %6
113 %29 = OpTypePointer Output %7
114 %30 = OpVariable %29 Output
115 %31 = OpConstant %20 2
116 %35 = OpConstant %10 1
117 %43 = OpConstant %20 4
118 %47 = OpConstant %20 3
119 %53 = OpConstant %20 1
120 %58 = OpConstant %6 10
121 %62 = OpTypeMatrix %7 4
122 %64 = OpConstant %6 0
123 %4 = OpFunction %2 None %3
125 %13 = OpAccessChain %12 %9 %11
127 %23 = OpAccessChain %22 %19 %21 %21
129 %26 = OpFOrdGreaterThan %25 %14 %24
130 OpSelectionMerge %28 None
131 OpBranchConditional %26 %27 %28
133 %32 = OpAccessChain %22 %19 %21 %31
135 %34 = OpCompositeConstruct %7 %33 %33 %33 %33
137 %36 = OpAccessChain %12 %9 %35
139 %40 = OpFOrdGreaterThan %25 %37 %24
140 OpSelectionMerge %42 None
141 OpBranchConditional %40 %41 %42
143 %44 = OpAccessChain %22 %19 %21 %43
145 %46 = OpCompositeConstruct %7 %45 %45 %45 %45
149 %48 = OpAccessChain %22 %19 %21 %47
151 %50 = OpCompositeConstruct %7 %49 %49 %49 %49
155 %54 = OpAccessChain %22 %19 %21 %53
157 %59 = OpCompositeConstruct %7 %24 %55 %55 %58
159 %65 = OpCompositeConstruct %7 %24 %64 %64 %64
160 %66 = OpCompositeConstruct %7 %64 %24 %64 %64
161 %67 = OpCompositeConstruct %7 %64 %64 %24 %64
162 %68 = OpCompositeConstruct %7 %64 %64 %64 %24
163 %69 = OpCompositeConstruct %62 %65 %66 %67 %68
165 %71 = OpMatrixTimesVector %7 %69 %70
171 # uniforms for variant
173 # _GLF_uniform_float_values
174 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
178 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
180 PIPELINE graphics variant_pipeline
181 ATTACH variant_vertex_shader
182 ATTACH variant_fragment_shader
183 FRAMEBUFFER_SIZE 16 16
184 BIND BUFFER variant_framebuffer AS color LOCATION 0
185 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
187 CLEAR_COLOR variant_pipeline 0 0 0 255
189 CLEAR variant_pipeline
190 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
192 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255