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: A fragment shader that uses an uninitialized variable
22 # The test passes because the shader always writes the color red.
23 # The update to _GLF_color.x has no effect on visible pixels.
25 SHADER vertex variant_vertex_shader PASSTHROUGH
27 # variant_fragment_shader is derived from the following GLSL:
29 # precision highp float;
31 # layout(location = 0) out vec4 _GLF_color;
35 # _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
39 # // For visible pixels, this is equivalent to: _GLF_color.x = _GLF_color.x;
40 # _GLF_color.x = gl_FragCoord.x > -1.0 ? _GLF_color.x : float(178493u + (--foo));
42 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
45 ; Generator: Khronos Glslang Reference Front End; 7
49 %1 = OpExtInstImport "GLSL.std.450"
50 OpMemoryModel Logical GLSL450
51 OpEntryPoint Fragment %4 "main" %9 %14
52 OpExecutionMode %4 OriginUpperLeft
55 OpName %9 "_GLF_color"
56 OpName %14 "gl_FragCoord"
58 OpDecorate %9 Location 0
59 OpDecorate %14 BuiltIn FragCoord
60 OpDecorate %33 RelaxedPrecision
61 OpDecorate %34 RelaxedPrecision
62 OpDecorate %37 RelaxedPrecision
63 OpDecorate %38 RelaxedPrecision
65 %3 = OpTypeFunction %2
67 %7 = OpTypeVector %6 4
68 %8 = OpTypePointer Output %7
69 %9 = OpVariable %8 Output
72 %12 = OpConstantComposite %7 %10 %11 %11 %10
73 %13 = OpTypePointer Input %7
74 %14 = OpVariable %13 Input
76 %16 = OpConstant %15 0
77 %17 = OpTypePointer Input %6
78 %20 = OpConstant %6 -1
80 %23 = OpTypePointer Function %6
81 %27 = OpTypePointer Output %6
82 %31 = OpConstant %15 178493
83 %32 = OpTypePointer Function %15
85 %36 = OpConstant %35 1
86 %4 = OpFunction %2 None %3
88 %24 = OpVariable %23 Function
89 %33 = OpVariable %32 Function
91 %18 = OpAccessChain %17 %14 %16
93 %22 = OpFOrdGreaterThan %21 %19 %20
94 OpSelectionMerge %26 None
95 OpBranchConditional %22 %25 %30
97 %28 = OpAccessChain %27 %9 %16
103 %37 = OpISub %15 %34 %36
105 %38 = OpIAdd %15 %31 %37
106 %39 = OpConvertUToF %6 %38
111 %41 = OpAccessChain %27 %9 %16
117 # uniforms for variant
120 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
122 PIPELINE graphics variant_pipeline
123 ATTACH variant_vertex_shader
124 ATTACH variant_fragment_shader
125 FRAMEBUFFER_SIZE 256 256
126 BIND BUFFER variant_framebuffer AS color LOCATION 0
128 CLEAR_COLOR variant_pipeline 0 0 0 255
130 CLEAR variant_pipeline
131 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
133 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255