• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2020 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 the GraphicsFuzz project.
19
20# Short description: A fragment shader with vec2 in modulus fraction function
21
22# The test passes because the shader always writes the color red.
23
24SHADER vertex variant_vertex_shader PASSTHROUGH
25
26# variant_fragment_shader is derived from the following GLSL:
27# #version 320 es
28# precision highp float;
29#
30# precision highp int;
31#
32# layout(location = 0) out vec4 _GLF_color;
33#
34# void main()
35# {
36#     vec2 uv = vec2(1.0, 1.0);
37#     uv.x = (modf(1.0, uv.y));
38#     // uv.y == 1.0, uv.x == 0.0
39#     if (uv.y > 0.0 && uv.x < 1.0)
40#     {
41#         _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
42#     }
43#     else
44#     {
45#         _GLF_color = vec4(1.0);
46#     }
47# }
48SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
49; SPIR-V
50; Version: 1.0
51; Generator: Khronos Glslang Reference Front End; 10
52; Bound: 38
53; Schema: 0
54               OpCapability Shader
55          %1 = OpExtInstImport "GLSL.std.450"
56               OpMemoryModel Logical GLSL450
57               OpEntryPoint Fragment %4 "main" %34
58               OpExecutionMode %4 OriginUpperLeft
59               OpSource ESSL 320
60               OpName %4 "main"
61               OpName %9 "uv"
62               OpName %34 "_GLF_color"
63               OpDecorate %34 Location 0
64          %2 = OpTypeVoid
65          %3 = OpTypeFunction %2
66          %6 = OpTypeFloat 32
67          %7 = OpTypeVector %6 2
68          %8 = OpTypePointer Function %7
69         %10 = OpConstant %6 1
70         %11 = OpConstantComposite %7 %10 %10
71         %12 = OpTypeInt 32 0
72         %13 = OpConstant %12 1
73         %14 = OpTypePointer Function %6
74         %17 = OpConstant %12 0
75         %19 = OpTypeBool
76         %22 = OpConstant %6 0
77         %32 = OpTypeVector %6 4
78         %33 = OpTypePointer Output %32
79         %34 = OpVariable %33 Output
80         %35 = OpConstantComposite %32 %10 %22 %22 %10
81         %37 = OpConstantComposite %32 %10 %10 %10 %10
82          %4 = OpFunction %2 None %3
83          %5 = OpLabel
84          %9 = OpVariable %8 Function
85               OpStore %9 %11
86         %15 = OpAccessChain %14 %9 %13
87         %16 = OpExtInst %6 %1 Modf %10 %15
88         %18 = OpAccessChain %14 %9 %17
89               OpStore %18 %16
90         %20 = OpAccessChain %14 %9 %13
91         %21 = OpLoad %6 %20
92         %23 = OpFOrdGreaterThan %19 %21 %22
93               OpSelectionMerge %25 None
94               OpBranchConditional %23 %24 %25
95         %24 = OpLabel
96         %26 = OpAccessChain %14 %9 %17
97         %27 = OpLoad %6 %26
98         %28 = OpFOrdLessThan %19 %27 %10
99               OpBranch %25
100         %25 = OpLabel
101         %29 = OpPhi %19 %23 %5 %28 %24
102               OpSelectionMerge %31 None
103               OpBranchConditional %29 %30 %36
104         %30 = OpLabel
105               OpStore %34 %35
106               OpBranch %31
107         %36 = OpLabel
108               OpStore %34 %37
109               OpBranch %31
110         %31 = OpLabel
111               OpReturn
112               OpFunctionEnd
113END
114
115
116BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
117
118PIPELINE graphics variant_pipeline
119  ATTACH variant_vertex_shader
120  ATTACH variant_fragment_shader
121  FRAMEBUFFER_SIZE 256 256
122  BIND BUFFER variant_framebuffer AS color LOCATION 0
123END
124CLEAR_COLOR variant_pipeline 0 0 0 255
125
126CLEAR variant_pipeline
127RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
128
129EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
130