1#!amber 2 3# Copyright 2019 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 GraphicsFuzz. 19 20# Short description: A fragment shader that covers a specific propagate array copy path. 21 22# The test passes because 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# precision highp float; 29# 30# layout(location = 0) out vec4 _GLF_color; 31# 32# layout(set = 0, binding = 0) uniform buf0 33# { 34# int zero; 35# }; 36# 37# struct Array { 38# int values[2]; 39# }; 40# 41# void main() 42# { 43# Array a; 44# a.values[zero] = 1; 45# Array b = a; 46# float one = 0.0; 47# // If condition is always true 48# if(b.values[zero] == 1) 49# one = 1.0; 50# _GLF_color = vec4(one, 0, 0, 1); 51# } 52SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 53; SPIR-V 54; Version: 1.0 55; Generator: Khronos Glslang Reference Front End; 8 56; Bound: 43 57; Schema: 0 58 OpCapability Shader 59 %1 = OpExtInstImport "GLSL.std.450" 60 OpMemoryModel Logical GLSL450 61 OpEntryPoint Fragment %4 "main" %40 62 OpExecutionMode %4 OriginUpperLeft 63 OpSource ESSL 310 64 OpName %4 "main" 65 OpName %10 "Array" 66 OpMemberName %10 0 "values" 67 OpName %12 "a" 68 OpName %14 "buf0" 69 OpMemberName %14 0 "zero" 70 OpName %16 "" 71 OpName %23 "b" 72 OpName %27 "one" 73 OpName %40 "_GLF_color" 74 OpMemberDecorate %10 0 RelaxedPrecision 75 OpMemberDecorate %14 0 RelaxedPrecision 76 OpMemberDecorate %14 0 Offset 0 77 OpDecorate %14 Block 78 OpDecorate %16 DescriptorSet 0 79 OpDecorate %16 Binding 0 80 OpDecorate %19 RelaxedPrecision 81 OpDecorate %30 RelaxedPrecision 82 OpDecorate %32 RelaxedPrecision 83 OpDecorate %40 Location 0 84 %2 = OpTypeVoid 85 %3 = OpTypeFunction %2 86 %6 = OpTypeInt 32 1 87 %7 = OpTypeInt 32 0 88 %8 = OpConstant %7 2 89 %9 = OpTypeArray %6 %8 90 %10 = OpTypeStruct %9 91 %11 = OpTypePointer Function %10 92 %13 = OpConstant %6 0 93 %14 = OpTypeStruct %6 94 %15 = OpTypePointer Uniform %14 95 %16 = OpVariable %15 Uniform 96 %17 = OpTypePointer Uniform %6 97 %20 = OpConstant %6 1 98 %21 = OpTypePointer Function %6 99 %25 = OpTypeFloat 32 100 %26 = OpTypePointer Function %25 101 %28 = OpConstant %25 0 102 %33 = OpTypeBool 103 %37 = OpConstant %25 1 104 %38 = OpTypeVector %25 4 105 %39 = OpTypePointer Output %38 106 %40 = OpVariable %39 Output 107 %4 = OpFunction %2 None %3 108 %5 = OpLabel 109 %12 = OpVariable %11 Function 110 %23 = OpVariable %11 Function 111 %27 = OpVariable %26 Function 112 %18 = OpAccessChain %17 %16 %13 113 %19 = OpLoad %6 %18 114 %22 = OpAccessChain %21 %12 %13 %19 115 OpStore %22 %20 116 %24 = OpLoad %10 %12 117 OpStore %23 %24 118 OpStore %27 %28 119 %29 = OpAccessChain %17 %16 %13 120 %30 = OpLoad %6 %29 121 %31 = OpAccessChain %21 %23 %13 %30 122 %32 = OpLoad %6 %31 123 %34 = OpIEqual %33 %32 %20 124 OpSelectionMerge %36 None 125 OpBranchConditional %34 %35 %36 126 %35 = OpLabel 127 OpStore %27 %37 128 OpBranch %36 129 %36 = OpLabel 130 %41 = OpLoad %25 %27 131 %42 = OpCompositeConstruct %38 %41 %28 %28 %37 132 OpStore %40 %42 133 OpReturn 134 OpFunctionEnd 135END 136 137# uniforms for variant 138 139# zero 140BUFFER variant_zero DATA_TYPE int32 DATA 141 0 142END 143 144BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 145 146PIPELINE graphics variant_pipeline 147 ATTACH variant_vertex_shader 148 ATTACH variant_fragment_shader 149 FRAMEBUFFER_SIZE 256 256 150 BIND BUFFER variant_framebuffer AS color LOCATION 0 151 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 0 152END 153CLEAR_COLOR variant_pipeline 0 0 0 255 154 155CLEAR variant_pipeline 156RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 157 158EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 159