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 APFloat 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 _float_1_0 _GLF_uniform_float_values[0] 29# #define _float_0_0 _GLF_uniform_float_values[1] 30# #define _float_0_01 _GLF_uniform_float_values[2] 31# 32# precision highp float; 33# precision highp int; 34# 35# // Contents of _GLF_uniform_float_values: 1.0 36# layout(set = 0, binding = 0) uniform buf0 37# { 38# float _GLF_uniform_float_values[3]; 39# }; 40# layout(location = 0) out vec4 _GLF_color; 41# 42# void main() 43# { 44# float a = mod(uintBitsToFloat(1u), 1.0); 45# 46# _GLF_color = vec4(_float_0_0); 47# if (a < _float_0_01) 48# _GLF_color = vec4(_float_1_0, _float_0_0, _float_0_0, _float_1_0); 49# } 50SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 51; SPIR-V 52; Version: 1.0 53; Generator: Khronos Glslang Reference Front End; 10 54; Bound: 46 55; Schema: 0 56 OpCapability Shader 57 %1 = OpExtInstImport "GLSL.std.450" 58 OpMemoryModel Logical GLSL450 59 OpEntryPoint Fragment %4 "main" %16 60 OpExecutionMode %4 OriginUpperLeft 61 OpSource ESSL 310 62 OpName %4 "main" 63 OpName %8 "a" 64 OpName %16 "_GLF_color" 65 OpName %19 "buf0" 66 OpMemberName %19 0 "_GLF_uniform_float_values" 67 OpName %21 "" 68 OpDecorate %16 Location 0 69 OpDecorate %18 ArrayStride 16 70 OpMemberDecorate %19 0 Offset 0 71 OpDecorate %19 Block 72 OpDecorate %21 DescriptorSet 0 73 OpDecorate %21 Binding 0 74 %2 = OpTypeVoid 75 %3 = OpTypeFunction %2 76 %6 = OpTypeFloat 32 77 %7 = OpTypePointer Function %6 78 %9 = OpTypeInt 32 0 79 %10 = OpConstant %9 1 80 %12 = OpConstant %6 1 81 %14 = OpTypeVector %6 4 82 %15 = OpTypePointer Output %14 83 %16 = OpVariable %15 Output 84 %17 = OpConstant %9 3 85 %18 = OpTypeArray %6 %17 86 %19 = OpTypeStruct %18 87 %20 = OpTypePointer Uniform %19 88 %21 = OpVariable %20 Uniform 89 %22 = OpTypeInt 32 1 90 %23 = OpConstant %22 0 91 %24 = OpConstant %22 1 92 %25 = OpTypePointer Uniform %6 93 %30 = OpConstant %22 2 94 %33 = OpTypeBool 95 %4 = OpFunction %2 None %3 96 %5 = OpLabel 97 %8 = OpVariable %7 Function 98 %11 = OpBitcast %6 %10 99 %13 = OpFMod %6 %11 %12 100 OpStore %8 %13 101 %26 = OpAccessChain %25 %21 %23 %24 102 %27 = OpLoad %6 %26 103 %28 = OpCompositeConstruct %14 %27 %27 %27 %27 104 OpStore %16 %28 105 %29 = OpLoad %6 %8 106 %31 = OpAccessChain %25 %21 %23 %30 107 %32 = OpLoad %6 %31 108 %34 = OpFOrdLessThan %33 %29 %32 109 OpSelectionMerge %36 None 110 OpBranchConditional %34 %35 %36 111 %35 = OpLabel 112 %37 = OpAccessChain %25 %21 %23 %23 113 %38 = OpLoad %6 %37 114 %39 = OpAccessChain %25 %21 %23 %24 115 %40 = OpLoad %6 %39 116 %41 = OpAccessChain %25 %21 %23 %24 117 %42 = OpLoad %6 %41 118 %43 = OpAccessChain %25 %21 %23 %23 119 %44 = OpLoad %6 %43 120 %45 = OpCompositeConstruct %14 %38 %40 %42 %44 121 OpStore %16 %45 122 OpBranch %36 123 %36 = OpLabel 124 OpReturn 125 OpFunctionEnd 126END 127 128# uniforms for variant 129 130# _GLF_uniform_float_values 131BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA 132 1.0 0.0 0.01 133END 134 135BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 136 137PIPELINE graphics variant_pipeline 138 ATTACH variant_vertex_shader 139 ATTACH variant_fragment_shader 140 FRAMEBUFFER_SIZE 256 256 141 BIND BUFFER variant_framebuffer AS color LOCATION 0 142 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0 143END 144CLEAR_COLOR variant_pipeline 0 0 0 255 145 146CLEAR variant_pipeline 147RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 148 149EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 150