1#!amber 2 3# Copyright 2020 Google LLC 4# 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 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 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. 16 17 18# A test for a coverage-gap found by the GraphicsFuzz project. 19 20# Short description: A fragment shader that covers a specific inst combine mul div rem code path 21 22# The test passes because the shader always writes red. 23 24SHADER vertex variant_vertex_shader PASSTHROUGH 25 26# variant_fragment_shader is derived from the following GLSL: 27# #version 310 es 28# #define _int_1 _GLF_uniform_int_values[0] 29# #define _int_0 _GLF_uniform_int_values[1] 30# #define _float_1_0 _GLF_uniform_float_values[0] 31# #define _float_0_0 _GLF_uniform_float_values[1] 32# 33# precision highp float; 34# precision highp int; 35# 36# // Contents of _GLF_uniform_int_values: [1, 0] 37# layout(set = 0, binding = 0) uniform buf0 38# { 39# int _GLF_uniform_int_values[2]; 40# }; 41# 42# // Contents of _GLF_uniform_float_values: [1.0, 0.0] 43# layout(set = 0, binding = 1) uniform buf1 44# { 45# float _GLF_uniform_float_values[2]; 46# }; 47# 48# layout(location = 0) out vec4 _GLF_color; 49# 50# float f1(float a) 51# { 52# return dFdx(a); 53# } 54# 55# void main() 56# { 57# _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1); 58# 59# vec4 v2; 60# 61# // Always false. 62# if (gl_FragCoord.x < _float_0_0) 63# { 64# // v2 is undefined. Doesn't matter since this is never executed. 65# if (!(v2.x < 1.0)) 66# { 67# float a = _float_0_0 / ((_float_0_0 > _float_1_0) ? f1(_float_1_0) : _float_1_0); 68# _GLF_color = 69# vec4(mix(vec3(_float_1_0), vec3(_float_1_0), a), _float_0_0); 70# } 71# } 72# } 73SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 74; SPIR-V 75; Version: 1.0 76; Generator: Khronos Glslang Reference Front End; 10 77; Bound: 104 78; Schema: 0 79 OpCapability Shader 80 %1 = OpExtInstImport "GLSL.std.450" 81 OpMemoryModel Logical GLSL450 82 OpEntryPoint Fragment %4 "main" %18 %43 83 OpExecutionMode %4 OriginUpperLeft 84 OpSource ESSL 310 85 OpName %4 "main" 86 OpName %10 "f1(f1;" 87 OpName %9 "a" 88 OpName %18 "_GLF_color" 89 OpName %23 "buf0" 90 OpMemberName %23 0 "_GLF_uniform_int_values" 91 OpName %25 "" 92 OpName %43 "gl_FragCoord" 93 OpName %49 "buf1" 94 OpMemberName %49 0 "_GLF_uniform_float_values" 95 OpName %51 "" 96 OpName %60 "v2" 97 OpName %68 "a" 98 OpName %79 "param" 99 OpDecorate %18 Location 0 100 OpDecorate %22 ArrayStride 16 101 OpMemberDecorate %23 0 Offset 0 102 OpDecorate %23 Block 103 OpDecorate %25 DescriptorSet 0 104 OpDecorate %25 Binding 0 105 OpDecorate %43 BuiltIn FragCoord 106 OpDecorate %48 ArrayStride 16 107 OpMemberDecorate %49 0 Offset 0 108 OpDecorate %49 Block 109 OpDecorate %51 DescriptorSet 0 110 OpDecorate %51 Binding 1 111 %2 = OpTypeVoid 112 %3 = OpTypeFunction %2 113 %6 = OpTypeFloat 32 114 %7 = OpTypePointer Function %6 115 %8 = OpTypeFunction %6 %7 116 %16 = OpTypeVector %6 4 117 %17 = OpTypePointer Output %16 118 %18 = OpVariable %17 Output 119 %19 = OpTypeInt 32 1 120 %20 = OpTypeInt 32 0 121 %21 = OpConstant %20 2 122 %22 = OpTypeArray %19 %21 123 %23 = OpTypeStruct %22 124 %24 = OpTypePointer Uniform %23 125 %25 = OpVariable %24 Uniform 126 %26 = OpConstant %19 0 127 %27 = OpTypePointer Uniform %19 128 %31 = OpConstant %19 1 129 %42 = OpTypePointer Input %16 130 %43 = OpVariable %42 Input 131 %44 = OpConstant %20 0 132 %45 = OpTypePointer Input %6 133 %48 = OpTypeArray %6 %21 134 %49 = OpTypeStruct %48 135 %50 = OpTypePointer Uniform %49 136 %51 = OpVariable %50 Uniform 137 %52 = OpTypePointer Uniform %6 138 %55 = OpTypeBool 139 %59 = OpTypePointer Function %16 140 %63 = OpConstant %6 1 141 %90 = OpTypeVector %6 3 142 %4 = OpFunction %2 None %3 143 %5 = OpLabel 144 %60 = OpVariable %59 Function 145 %68 = OpVariable %7 Function 146 %76 = OpVariable %7 Function 147 %79 = OpVariable %7 Function 148 %28 = OpAccessChain %27 %25 %26 %26 149 %29 = OpLoad %19 %28 150 %30 = OpConvertSToF %6 %29 151 %32 = OpAccessChain %27 %25 %26 %31 152 %33 = OpLoad %19 %32 153 %34 = OpConvertSToF %6 %33 154 %35 = OpAccessChain %27 %25 %26 %31 155 %36 = OpLoad %19 %35 156 %37 = OpConvertSToF %6 %36 157 %38 = OpAccessChain %27 %25 %26 %26 158 %39 = OpLoad %19 %38 159 %40 = OpConvertSToF %6 %39 160 %41 = OpCompositeConstruct %16 %30 %34 %37 %40 161 OpStore %18 %41 162 %46 = OpAccessChain %45 %43 %44 163 %47 = OpLoad %6 %46 164 %53 = OpAccessChain %52 %51 %26 %31 165 %54 = OpLoad %6 %53 166 %56 = OpFOrdLessThan %55 %47 %54 167 OpSelectionMerge %58 None 168 OpBranchConditional %56 %57 %58 169 %57 = OpLabel 170 %61 = OpAccessChain %7 %60 %44 171 %62 = OpLoad %6 %61 172 %64 = OpFOrdLessThan %55 %62 %63 173 %65 = OpLogicalNot %55 %64 174 OpSelectionMerge %67 None 175 OpBranchConditional %65 %66 %67 176 %66 = OpLabel 177 %69 = OpAccessChain %52 %51 %26 %31 178 %70 = OpLoad %6 %69 179 %71 = OpAccessChain %52 %51 %26 %31 180 %72 = OpLoad %6 %71 181 %73 = OpAccessChain %52 %51 %26 %26 182 %74 = OpLoad %6 %73 183 %75 = OpFOrdGreaterThan %55 %72 %74 184 OpSelectionMerge %78 None 185 OpBranchConditional %75 %77 %83 186 %77 = OpLabel 187 %80 = OpAccessChain %52 %51 %26 %26 188 %81 = OpLoad %6 %80 189 OpStore %79 %81 190 %82 = OpFunctionCall %6 %10 %79 191 OpStore %76 %82 192 OpBranch %78 193 %83 = OpLabel 194 %84 = OpAccessChain %52 %51 %26 %26 195 %85 = OpLoad %6 %84 196 OpStore %76 %85 197 OpBranch %78 198 %78 = OpLabel 199 %86 = OpLoad %6 %76 200 %87 = OpFDiv %6 %70 %86 201 OpStore %68 %87 202 %88 = OpAccessChain %52 %51 %26 %26 203 %89 = OpLoad %6 %88 204 %91 = OpCompositeConstruct %90 %89 %89 %89 205 %92 = OpAccessChain %52 %51 %26 %26 206 %93 = OpLoad %6 %92 207 %94 = OpCompositeConstruct %90 %93 %93 %93 208 %95 = OpLoad %6 %68 209 %96 = OpCompositeConstruct %90 %95 %95 %95 210 %97 = OpExtInst %90 %1 FMix %91 %94 %96 211 %98 = OpAccessChain %52 %51 %26 %31 212 %99 = OpLoad %6 %98 213 %100 = OpCompositeExtract %6 %97 0 214 %101 = OpCompositeExtract %6 %97 1 215 %102 = OpCompositeExtract %6 %97 2 216 %103 = OpCompositeConstruct %16 %100 %101 %102 %99 217 OpStore %18 %103 218 OpBranch %67 219 %67 = OpLabel 220 OpBranch %58 221 %58 = OpLabel 222 OpReturn 223 OpFunctionEnd 224 %10 = OpFunction %6 None %8 225 %9 = OpFunctionParameter %7 226 %11 = OpLabel 227 %12 = OpLoad %6 %9 228 %13 = OpDPdx %6 %12 229 OpReturnValue %13 230 OpFunctionEnd 231END 232 233# uniforms for variant 234 235# injectionSwitch 236BUFFER variant_injectionSwitch DATA_TYPE vec2<float> STD140 DATA 237 0.0 1.0 238END 239# _GLF_uniform_float_values 240BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA 241 1.0 0.0 242END 243# _GLF_uniform_int_values 244BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 245 1 0 246END 247 248BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 249 250PIPELINE graphics variant_pipeline 251 ATTACH variant_vertex_shader 252 ATTACH variant_fragment_shader 253 FRAMEBUFFER_SIZE 16 16 254 BIND BUFFER variant_framebuffer AS color LOCATION 0 255 BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 2 256 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1 257 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0 258END 259CLEAR_COLOR variant_pipeline 0 0 0 255 260 261CLEAR variant_pipeline 262RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16 263 264EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255 265