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 instruction emitter code 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 _int_1 _GLF_uniform_int_values[0] 29# #define _int_0 _GLF_uniform_int_values[1] 30# #define _float_0_01 _GLF_uniform_float_values[0] 31# #define _float_3_0 _GLF_uniform_float_values[1] 32# #define _float_2_63 _GLF_uniform_float_values[2] 33# #define _float_1_0 _GLF_uniform_float_values[3] 34# 35# precision highp float; 36# 37# // Contents of _GLF_uniform_int_values: [1, 0] 38# layout(set = 0, binding = 0) uniform buf0 39# { 40# int _GLF_uniform_int_values[2]; 41# }; 42# 43# // Contents of _GLF_uniform_float_values: [0.01, 3.0, 2.63, 1.0] 44# layout(set = 0, binding = 1) uniform buf1 45# { 46# float _GLF_uniform_float_values[4]; 47# }; 48# 49# layout(location = 0) out vec4 _GLF_color; 50# 51# void main() 52# { 53# float f = pow(_float_3_0, asinh(_float_1_0)); 54# if (abs(f - _float_2_63) < _float_0_01) 55# { 56# _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1); 57# } 58# else 59# { 60# _GLF_color = vec4(abs(f - _float_2_63)); 61# } 62# } 63SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 64; SPIR-V 65; Version: 1.0 66; Generator: Khronos Glslang Reference Front End; 8 67; Bound: 67 68; Schema: 0 69 OpCapability Shader 70 %1 = OpExtInstImport "GLSL.std.450" 71 OpMemoryModel Logical GLSL450 72 OpEntryPoint Fragment %4 "main" %40 73 OpExecutionMode %4 OriginUpperLeft 74 OpSource ESSL 310 75 OpName %4 "main" 76 OpName %8 "f" 77 OpName %12 "buf1" 78 OpMemberName %12 0 "_GLF_uniform_float_values" 79 OpName %14 "" 80 OpName %40 "_GLF_color" 81 OpName %43 "buf0" 82 OpMemberName %43 0 "_GLF_uniform_int_values" 83 OpName %45 "" 84 OpDecorate %11 ArrayStride 16 85 OpMemberDecorate %12 0 Offset 0 86 OpDecorate %12 Block 87 OpDecorate %14 DescriptorSet 0 88 OpDecorate %14 Binding 1 89 OpDecorate %40 Location 0 90 OpDecorate %42 ArrayStride 16 91 OpMemberDecorate %43 0 RelaxedPrecision 92 OpMemberDecorate %43 0 Offset 0 93 OpDecorate %43 Block 94 OpDecorate %45 DescriptorSet 0 95 OpDecorate %45 Binding 0 96 OpDecorate %48 RelaxedPrecision 97 OpDecorate %51 RelaxedPrecision 98 OpDecorate %54 RelaxedPrecision 99 OpDecorate %57 RelaxedPrecision 100 %2 = OpTypeVoid 101 %3 = OpTypeFunction %2 102 %6 = OpTypeFloat 32 103 %7 = OpTypePointer Function %6 104 %9 = OpTypeInt 32 0 105 %10 = OpConstant %9 4 106 %11 = OpTypeArray %6 %10 107 %12 = OpTypeStruct %11 108 %13 = OpTypePointer Uniform %12 109 %14 = OpVariable %13 Uniform 110 %15 = OpTypeInt 32 1 111 %16 = OpConstant %15 0 112 %17 = OpConstant %15 1 113 %18 = OpTypePointer Uniform %6 114 %21 = OpConstant %15 3 115 %27 = OpConstant %15 2 116 %34 = OpTypeBool 117 %38 = OpTypeVector %6 4 118 %39 = OpTypePointer Output %38 119 %40 = OpVariable %39 Output 120 %41 = OpConstant %9 2 121 %42 = OpTypeArray %15 %41 122 %43 = OpTypeStruct %42 123 %44 = OpTypePointer Uniform %43 124 %45 = OpVariable %44 Uniform 125 %46 = OpTypePointer Uniform %15 126 %4 = OpFunction %2 None %3 127 %5 = OpLabel 128 %8 = OpVariable %7 Function 129 %19 = OpAccessChain %18 %14 %16 %17 130 %20 = OpLoad %6 %19 131 %22 = OpAccessChain %18 %14 %16 %21 132 %23 = OpLoad %6 %22 133 %24 = OpExtInst %6 %1 Asinh %23 134 %25 = OpExtInst %6 %1 Pow %20 %24 135 OpStore %8 %25 136 %26 = OpLoad %6 %8 137 %28 = OpAccessChain %18 %14 %16 %27 138 %29 = OpLoad %6 %28 139 %30 = OpFSub %6 %26 %29 140 %31 = OpExtInst %6 %1 FAbs %30 141 %32 = OpAccessChain %18 %14 %16 %16 142 %33 = OpLoad %6 %32 143 %35 = OpFOrdLessThan %34 %31 %33 144 OpSelectionMerge %37 None 145 OpBranchConditional %35 %36 %60 146 %36 = OpLabel 147 %47 = OpAccessChain %46 %45 %16 %16 148 %48 = OpLoad %15 %47 149 %49 = OpConvertSToF %6 %48 150 %50 = OpAccessChain %46 %45 %16 %17 151 %51 = OpLoad %15 %50 152 %52 = OpConvertSToF %6 %51 153 %53 = OpAccessChain %46 %45 %16 %17 154 %54 = OpLoad %15 %53 155 %55 = OpConvertSToF %6 %54 156 %56 = OpAccessChain %46 %45 %16 %16 157 %57 = OpLoad %15 %56 158 %58 = OpConvertSToF %6 %57 159 %59 = OpCompositeConstruct %38 %49 %52 %55 %58 160 OpStore %40 %59 161 OpBranch %37 162 %60 = OpLabel 163 %61 = OpLoad %6 %8 164 %62 = OpAccessChain %18 %14 %16 %27 165 %63 = OpLoad %6 %62 166 %64 = OpFSub %6 %61 %63 167 %65 = OpExtInst %6 %1 FAbs %64 168 %66 = OpCompositeConstruct %38 %65 %65 %65 %65 169 OpStore %40 %66 170 OpBranch %37 171 %37 = 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 0.01 3.0 2.63 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