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