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