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