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