3 # Copyright 2019 Google LLC
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # A test for a bug found by GraphicsFuzz.
20 # Short description: Fragment shader that writes red despite unreachable loops
22 # The test passes because red is written, and the loops inside the if (one of
23 # which would be infinite) are dynamically unreachable due to the runtime content
26 SHADER vertex variant_vertex_shader PASSTHROUGH
28 # variant_fragment_shader is derived from the following GLSL:
30 # precision highp float;
32 # layout(location = 0) out vec4 _GLF_color;
34 # layout(set = 0, binding = 0) uniform buf0 {
40 # _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
41 # if (injected.x > injected.y) {
53 # _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
58 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
61 ; Generator: Khronos Glslang Reference Front End; 7
65 %1 = OpExtInstImport "GLSL.std.450"
66 OpMemoryModel Logical GLSL450
67 OpEntryPoint Fragment %4 "main" %9
68 OpExecutionMode %4 OriginUpperLeft
71 OpName %9 "_GLF_color"
73 OpMemberName %14 0 "injected"
76 OpDecorate %9 Location 0
77 OpMemberDecorate %14 0 Offset 0
79 OpDecorate %16 DescriptorSet 0
80 OpDecorate %16 Binding 0
81 OpDecorate %37 RelaxedPrecision
83 %3 = OpTypeFunction %2
85 %7 = OpTypeVector %6 4
86 %8 = OpTypePointer Output %7
87 %9 = OpVariable %8 Output
90 %12 = OpConstantComposite %7 %10 %11 %11 %10
91 %13 = OpTypeVector %6 2
92 %14 = OpTypeStruct %13
93 %15 = OpTypePointer Uniform %14
94 %16 = OpVariable %15 Uniform
96 %18 = OpConstant %17 0
98 %20 = OpConstant %19 0
99 %21 = OpTypePointer Uniform %6
100 %24 = OpConstant %19 1
102 %35 = OpConstantFalse %27
103 %36 = OpTypePointer Function %17
104 %38 = OpConstant %17 1
105 %44 = OpConstantTrue %27
106 %4 = OpFunction %2 None %3
108 %37 = OpVariable %36 Function
110 %22 = OpAccessChain %21 %16 %18 %20
112 %25 = OpAccessChain %21 %16 %18 %24
114 %28 = OpFOrdGreaterThan %27 %23 %26
115 OpSelectionMerge %30 None
116 OpBranchConditional %28 %29 %30
120 OpLoopMerge %33 %34 None
125 OpBranchConditional %35 %31 %33
130 OpLoopMerge %41 %42 None
133 OpBranchConditional %44 %40 %41
146 # uniforms for variant
149 BUFFER variant_resolution DATA_TYPE vec2<float> DATA
153 BUFFER framebuffer FORMAT B8G8R8A8_UNORM
155 PIPELINE graphics gfz_pipeline
156 ATTACH variant_vertex_shader
157 ATTACH variant_fragment_shader
158 FRAMEBUFFER_SIZE 256 256
159 BIND BUFFER framebuffer AS color LOCATION 0
160 BIND BUFFER variant_resolution AS uniform DESCRIPTOR_SET 0 BINDING 0
162 CLEAR_COLOR gfz_pipeline 0 0 0 255
165 RUN gfz_pipeline DRAW_RECT POS 0 0 SIZE 256 256
166 EXPECT framebuffer IDX 0 0 SIZE 256 256 EQ_RGB 255 0 0