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