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