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