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