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