• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 that uses an uninitialized variable
21
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.
24
25SHADER vertex variant_vertex_shader PASSTHROUGH
26
27# variant_fragment_shader is derived from the following GLSL:
28# #version 310 es
29# precision highp float;
30#
31# layout(location = 0) out vec4 _GLF_color;
32#
33# void main()
34# {
35#     _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
36#
37#     uint foo;
38#
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));
41# }
42SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
43; SPIR-V
44; Version: 1.0
45; Generator: Khronos Glslang Reference Front End; 7
46; Bound: 42
47; Schema: 0
48               OpCapability Shader
49          %1 = OpExtInstImport "GLSL.std.450"
50               OpMemoryModel Logical GLSL450
51               OpEntryPoint Fragment %4 "main" %9 %14
52               OpExecutionMode %4 OriginUpperLeft
53               OpSource ESSL 310
54               OpName %4 "main"
55               OpName %9 "_GLF_color"
56               OpName %14 "gl_FragCoord"
57               OpName %33 "foo"
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
64          %2 = OpTypeVoid
65          %3 = OpTypeFunction %2
66          %6 = OpTypeFloat 32
67          %7 = OpTypeVector %6 4
68          %8 = OpTypePointer Output %7
69          %9 = OpVariable %8 Output
70         %10 = OpConstant %6 1
71         %11 = OpConstant %6 0
72         %12 = OpConstantComposite %7 %10 %11 %11 %10
73         %13 = OpTypePointer Input %7
74         %14 = OpVariable %13 Input
75         %15 = OpTypeInt 32 0
76         %16 = OpConstant %15 0
77         %17 = OpTypePointer Input %6
78         %20 = OpConstant %6 -1
79         %21 = OpTypeBool
80         %23 = OpTypePointer Function %6
81         %27 = OpTypePointer Output %6
82         %31 = OpConstant %15 178493
83         %32 = OpTypePointer Function %15
84         %35 = OpTypeInt 32 1
85         %36 = OpConstant %35 1
86          %4 = OpFunction %2 None %3
87          %5 = OpLabel
88         %24 = OpVariable %23 Function
89         %33 = OpVariable %32 Function
90               OpStore %9 %12
91         %18 = OpAccessChain %17 %14 %16
92         %19 = OpLoad %6 %18
93         %22 = OpFOrdGreaterThan %21 %19 %20
94               OpSelectionMerge %26 None
95               OpBranchConditional %22 %25 %30
96         %25 = OpLabel
97         %28 = OpAccessChain %27 %9 %16
98         %29 = OpLoad %6 %28
99               OpStore %24 %29
100               OpBranch %26
101         %30 = OpLabel
102         %34 = OpLoad %15 %33
103         %37 = OpISub %15 %34 %36
104               OpStore %33 %37
105         %38 = OpIAdd %15 %31 %37
106         %39 = OpConvertUToF %6 %38
107               OpStore %24 %39
108               OpBranch %26
109         %26 = OpLabel
110         %40 = OpLoad %6 %24
111         %41 = OpAccessChain %27 %9 %16
112               OpStore %41 %40
113               OpReturn
114               OpFunctionEnd
115END
116
117# uniforms for variant
118
119
120BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
121
122PIPELINE 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
127END
128CLEAR_COLOR variant_pipeline 0 0 0 255
129
130CLEAR variant_pipeline
131RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
132
133EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
134