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 inst combine compares 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]
30 # #define _int_10 _GLF_uniform_int_values[2]
31 # #define _float_1_0 _GLF_uniform_float_values[0]
33 # precision highp float;
35 # precision highp int;
37 # // Contents of _GLF_uniform_float_values: 1.0
38 # layout(set = 0, binding = 0) uniform buf0
40 # float _GLF_uniform_float_values[1];
43 # // Contents of _GLF_uniform_int_values: [0, 1, 10]
44 # layout(set = 0, binding = 1) uniform buf1
46 # int _GLF_uniform_int_values[3];
48 # layout(location = 0) out vec4 _GLF_color;
57 # _GLF_color = vec4(1, _int_0, _int_0, _int_1);
61 # _GLF_color = vec4(_float_1_0);
66 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
69 ; Generator: Khronos Glslang Reference Front End; 8
73 %1 = OpExtInstImport "GLSL.std.450"
74 OpMemoryModel Logical GLSL450
75 OpEntryPoint Fragment %4 "main" %36
76 OpExecutionMode %4 OriginUpperLeft
81 OpMemberName %12 0 "_GLF_uniform_int_values"
83 OpName %36 "_GLF_color"
85 OpMemberName %52 0 "_GLF_uniform_float_values"
87 OpDecorate %11 ArrayStride 16
88 OpMemberDecorate %12 0 Offset 0
90 OpDecorate %14 DescriptorSet 0
91 OpDecorate %14 Binding 1
92 OpDecorate %36 Location 0
93 OpDecorate %51 ArrayStride 16
94 OpMemberDecorate %52 0 Offset 0
96 OpDecorate %54 DescriptorSet 0
97 OpDecorate %54 Binding 0
99 %3 = OpTypeFunction %2
101 %7 = OpTypePointer Function %6
103 %10 = OpConstant %9 3
104 %11 = OpTypeArray %6 %10
105 %12 = OpTypeStruct %11
106 %13 = OpTypePointer Uniform %12
107 %14 = OpVariable %13 Uniform
108 %15 = OpConstant %6 0
109 %16 = OpConstant %6 2
110 %17 = OpTypePointer Uniform %6
113 %34 = OpTypeVector %33 4
114 %35 = OpTypePointer Output %34
115 %36 = OpVariable %35 Output
116 %37 = OpConstant %33 1
117 %44 = OpConstant %6 1
118 %50 = OpConstant %9 1
119 %51 = OpTypeArray %33 %50
120 %52 = OpTypeStruct %51
121 %53 = OpTypePointer Uniform %52
122 %54 = OpVariable %53 Uniform
123 %55 = OpTypePointer Uniform %33
124 %4 = OpFunction %2 None %3
126 %8 = OpVariable %7 Function
127 %18 = OpAccessChain %17 %14 %15 %16
132 OpLoopMerge %22 %23 None
136 %27 = OpSGreaterThanEqual %26 %25 %15
137 OpBranchConditional %27 %21 %22
140 %29 = OpSMod %6 %28 %16
141 %30 = OpIEqual %26 %29 %15
142 OpSelectionMerge %32 None
143 OpBranchConditional %30 %31 %49
145 %38 = OpAccessChain %17 %14 %15 %15
147 %40 = OpConvertSToF %33 %39
148 %41 = OpAccessChain %17 %14 %15 %15
150 %43 = OpConvertSToF %33 %42
151 %45 = OpAccessChain %17 %14 %15 %44
153 %47 = OpConvertSToF %33 %46
154 %48 = OpCompositeConstruct %34 %37 %40 %43 %47
158 %56 = OpAccessChain %55 %54 %15 %15
160 %58 = OpCompositeConstruct %34 %57 %57 %57 %57
165 %60 = OpISub %6 %59 %44
175 # uniforms for variant
177 # _GLF_uniform_int_values
178 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
181 # _GLF_uniform_float_values
182 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] 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 1
194 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
196 CLEAR_COLOR variant_pipeline 0 0 0 255
198 CLEAR variant_pipeline
199 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
201 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255