1#!amber 2 3# Copyright 2021 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 specific LLVM code paths 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 320 es 28# #define _int_0 _GLF_uniform_int_values[0] 29# #define _float_1_0 _GLF_uniform_float_values[0] 30# #define _float_0_0 _GLF_uniform_float_values[1] 31# 32# precision highp float; 33# precision highp int; 34# 35# // Contents of _GLF_uniform_float_values: [1.0, 0.0] 36# layout(set = 0, binding = 0) uniform buf0 37# { 38# float _GLF_uniform_float_values[2]; 39# }; 40# 41# // Contents of _GLF_uniform_int_values: 0 42# layout(set = 0, binding = 1) uniform buf1 43# { 44# int _GLF_uniform_int_values[1]; 45# }; 46# 47# layout(location = 0) out vec4 _GLF_color; 48# 49# // Contents of resolution: [256.0, 256.0] 50# layout(set = 0, binding = 2) uniform buf2 51# { 52# vec2 resolution; 53# }; 54# 55# void main() 56# { 57# // v becomes (0, 0). 58# vec2 v = (mat3(_float_0_0) * vec3(resolution, 1)).xy; 59# 60# // Always true. 61# if(v == vec2(_int_0)) 62# { 63# _GLF_color = vec4(_float_1_0, v, _float_1_0); 64# } 65# else 66# { 67# _GLF_color = vec4(_int_0); 68# } 69# } 70SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 71; SPIR-V 72; Version: 1.0 73; Generator: Khronos Glslang Reference Front End; 10 74; Bound: 74 75; Schema: 0 76 OpCapability Shader 77 %1 = OpExtInstImport "GLSL.std.450" 78 OpMemoryModel Logical GLSL450 79 OpEntryPoint Fragment %4 "main" %60 80 OpExecutionMode %4 OriginUpperLeft 81 OpSource ESSL 320 82 OpName %4 "main" 83 OpName %9 "v" 84 OpName %13 "buf0" 85 OpMemberName %13 0 "_GLF_uniform_float_values" 86 OpName %15 "" 87 OpName %30 "buf2" 88 OpMemberName %30 0 "resolution" 89 OpName %32 "" 90 OpName %44 "buf1" 91 OpMemberName %44 0 "_GLF_uniform_int_values" 92 OpName %46 "" 93 OpName %60 "_GLF_color" 94 OpDecorate %12 ArrayStride 16 95 OpMemberDecorate %13 0 Offset 0 96 OpDecorate %13 Block 97 OpDecorate %15 DescriptorSet 0 98 OpDecorate %15 Binding 0 99 OpMemberDecorate %30 0 Offset 0 100 OpDecorate %30 Block 101 OpDecorate %32 DescriptorSet 0 102 OpDecorate %32 Binding 2 103 OpDecorate %43 ArrayStride 16 104 OpMemberDecorate %44 0 Offset 0 105 OpDecorate %44 Block 106 OpDecorate %46 DescriptorSet 0 107 OpDecorate %46 Binding 1 108 OpDecorate %60 Location 0 109 %2 = OpTypeVoid 110 %3 = OpTypeFunction %2 111 %6 = OpTypeFloat 32 112 %7 = OpTypeVector %6 2 113 %8 = OpTypePointer Function %7 114 %10 = OpTypeInt 32 0 115 %11 = OpConstant %10 2 116 %12 = OpTypeArray %6 %11 117 %13 = OpTypeStruct %12 118 %14 = OpTypePointer Uniform %13 119 %15 = OpVariable %14 Uniform 120 %16 = OpTypeInt 32 1 121 %17 = OpConstant %16 0 122 %18 = OpConstant %16 1 123 %19 = OpTypePointer Uniform %6 124 %22 = OpTypeVector %6 3 125 %23 = OpTypeMatrix %22 3 126 %24 = OpConstant %6 1 127 %25 = OpConstant %6 0 128 %30 = OpTypeStruct %7 129 %31 = OpTypePointer Uniform %30 130 %32 = OpVariable %31 Uniform 131 %33 = OpTypePointer Uniform %7 132 %42 = OpConstant %10 1 133 %43 = OpTypeArray %16 %42 134 %44 = OpTypeStruct %43 135 %45 = OpTypePointer Uniform %44 136 %46 = OpVariable %45 Uniform 137 %47 = OpTypePointer Uniform %16 138 %52 = OpTypeBool 139 %53 = OpTypeVector %52 2 140 %58 = OpTypeVector %6 4 141 %59 = OpTypePointer Output %58 142 %60 = OpVariable %59 Output 143 %4 = OpFunction %2 None %3 144 %5 = OpLabel 145 %9 = OpVariable %8 Function 146 %20 = OpAccessChain %19 %15 %17 %18 147 %21 = OpLoad %6 %20 148 %26 = OpCompositeConstruct %22 %21 %25 %25 149 %27 = OpCompositeConstruct %22 %25 %21 %25 150 %28 = OpCompositeConstruct %22 %25 %25 %21 151 %29 = OpCompositeConstruct %23 %26 %27 %28 152 %34 = OpAccessChain %33 %32 %17 153 %35 = OpLoad %7 %34 154 %36 = OpCompositeExtract %6 %35 0 155 %37 = OpCompositeExtract %6 %35 1 156 %38 = OpCompositeConstruct %22 %36 %37 %24 157 %39 = OpMatrixTimesVector %22 %29 %38 158 %40 = OpVectorShuffle %7 %39 %39 0 1 159 OpStore %9 %40 160 %41 = OpLoad %7 %9 161 %48 = OpAccessChain %47 %46 %17 %17 162 %49 = OpLoad %16 %48 163 %50 = OpConvertSToF %6 %49 164 %51 = OpCompositeConstruct %7 %50 %50 165 %54 = OpFOrdEqual %53 %41 %51 166 %55 = OpAll %52 %54 167 OpSelectionMerge %57 None 168 OpBranchConditional %55 %56 %69 169 %56 = OpLabel 170 %61 = OpAccessChain %19 %15 %17 %17 171 %62 = OpLoad %6 %61 172 %63 = OpLoad %7 %9 173 %64 = OpAccessChain %19 %15 %17 %17 174 %65 = OpLoad %6 %64 175 %66 = OpCompositeExtract %6 %63 0 176 %67 = OpCompositeExtract %6 %63 1 177 %68 = OpCompositeConstruct %58 %62 %66 %67 %65 178 OpStore %60 %68 179 OpBranch %57 180 %69 = OpLabel 181 %70 = OpAccessChain %47 %46 %17 %17 182 %71 = OpLoad %16 %70 183 %72 = OpConvertSToF %6 %71 184 %73 = OpCompositeConstruct %58 %72 %72 %72 %72 185 OpStore %60 %73 186 OpBranch %57 187 %57 = OpLabel 188 OpReturn 189 OpFunctionEnd 190END 191 192# uniforms for variant 193 194# resolution 195BUFFER variant_resolution DATA_TYPE vec2<float> STD140 DATA 196 256.0 256.0 197END 198# _GLF_uniform_int_values 199BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 200 0 201END 202# _GLF_uniform_float_values 203BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA 204 1.0 0.0 205END 206 207BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 208 209PIPELINE graphics variant_pipeline 210 ATTACH variant_vertex_shader 211 ATTACH variant_fragment_shader 212 FRAMEBUFFER_SIZE 256 256 213 BIND BUFFER variant_framebuffer AS color LOCATION 0 214 BIND BUFFER variant_resolution AS uniform DESCRIPTOR_SET 0 BINDING 2 215 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1 216 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0 217END 218CLEAR_COLOR variant_pipeline 0 0 0 255 219 220CLEAR variant_pipeline 221RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 222 223EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 224