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