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 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 _float_4_0 _GLF_uniform_float_values[0]
31 # #define _float_0_25 _GLF_uniform_float_values[1]
33 # precision highp int;
34 # precision highp float;
36 # // Contents of _GLF_uniform_int_values: [0, 1]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[2];
42 # // Contents of _GLF_uniform_float_values: [4.0, 0.25]
43 # layout(set = 0, binding = 1) uniform buf1
45 # float _GLF_uniform_float_values[2];
48 # layout(location = 0) out vec4 _GLF_color;
53 # float b = clamp(_float_0_25, false ? a : 0.0, 1.0);
56 # if(b == _float_0_25)
58 # _GLF_color = vec4(b * _float_4_0, _int_0, _int_0, _int_1);
62 # _GLF_color = vec4(_int_0);
65 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
68 ; Generator: Khronos Glslang Reference Front End; 10
72 %1 = OpExtInstImport "GLSL.std.450"
73 OpMemoryModel Logical GLSL450
74 OpEntryPoint Fragment %4 "main" %37
75 OpExecutionMode %4 OriginUpperLeft
81 OpMemberName %14 0 "_GLF_uniform_float_values"
83 OpName %37 "_GLF_color"
85 OpMemberName %43 0 "_GLF_uniform_int_values"
87 OpDecorate %13 ArrayStride 16
88 OpMemberDecorate %14 0 Offset 0
90 OpDecorate %16 DescriptorSet 0
91 OpDecorate %16 Binding 1
92 OpDecorate %37 Location 0
93 OpDecorate %42 ArrayStride 16
94 OpMemberDecorate %43 0 Offset 0
96 OpDecorate %45 DescriptorSet 0
97 OpDecorate %45 Binding 0
99 %3 = OpTypeFunction %2
101 %7 = OpTypePointer Function %6
104 %12 = OpConstant %11 2
105 %13 = OpTypeArray %6 %12
106 %14 = OpTypeStruct %13
107 %15 = OpTypePointer Uniform %14
108 %16 = OpVariable %15 Uniform
110 %18 = OpConstant %17 0
111 %19 = OpConstant %17 1
112 %20 = OpTypePointer Uniform %6
114 %24 = OpConstantFalse %23
115 %26 = OpConstant %6 0
116 %35 = OpTypeVector %6 4
117 %36 = OpTypePointer Output %35
118 %37 = OpVariable %36 Output
119 %42 = OpTypeArray %17 %12
120 %43 = OpTypeStruct %42
121 %44 = OpTypePointer Uniform %43
122 %45 = OpVariable %44 Uniform
123 %46 = OpTypePointer Uniform %17
124 %4 = OpFunction %2 None %3
126 %8 = OpVariable %7 Function
127 %10 = OpVariable %7 Function
129 %21 = OpAccessChain %20 %16 %18 %19
132 %27 = OpSelect %6 %24 %25 %26
133 %28 = OpExtInst %6 %1 FClamp %22 %27 %9
136 %30 = OpAccessChain %20 %16 %18 %19
138 %32 = OpFOrdEqual %23 %29 %31
139 OpSelectionMerge %34 None
140 OpBranchConditional %32 %33 %57
143 %39 = OpAccessChain %20 %16 %18 %18
145 %41 = OpFMul %6 %38 %40
146 %47 = OpAccessChain %46 %45 %18 %18
148 %49 = OpConvertSToF %6 %48
149 %50 = OpAccessChain %46 %45 %18 %18
151 %52 = OpConvertSToF %6 %51
152 %53 = OpAccessChain %46 %45 %18 %19
154 %55 = OpConvertSToF %6 %54
155 %56 = OpCompositeConstruct %35 %41 %49 %52 %55
159 %58 = OpAccessChain %46 %45 %18 %18
161 %60 = OpConvertSToF %6 %59
162 %61 = OpCompositeConstruct %35 %60 %60 %60 %60
170 # uniforms for variant
172 # _GLF_uniform_float_values
173 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
176 # _GLF_uniform_int_values
177 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
181 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
183 PIPELINE graphics variant_pipeline
184 ATTACH variant_vertex_shader
185 ATTACH variant_fragment_shader
186 FRAMEBUFFER_SIZE 256 256
187 BIND BUFFER variant_framebuffer AS color LOCATION 0
188 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
189 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
191 CLEAR_COLOR variant_pipeline 0 0 0 255
193 CLEAR variant_pipeline
194 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
196 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255