• 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# A test for a bug reduced by GraphicsFuzz.
18
19# Short description: A fragment shader that uses a temporary struct variable
20
21# The test passes because the fragment shader is provided with a red vec4
22# as input, and copies this through to the output (via a struct)
23
24# The following GLSL, produced by SPIRV-Cross (and then manually edited for
25# readability) shows what the shader does.
26
27# Fragment shader GLSL:
28# #version 310 es
29# precision mediump float;
30# precision highp int;
31#
32# struct S
33# {
34#     highp vec4 v;
35# };
36#
37# layout(binding = 0, std140) uniform somename
38# {
39#     highp vec4 v;
40# } buf;
41#
42# layout(location = 0) out highp vec4 color;
43#
44# S undef;
45#
46# void main()
47# {
48#     S temp = undef;
49#     temp.v = buf.v;
50#     color = temp.v;
51# }
52
53SHADER vertex gfz_vert PASSTHROUGH
54
55SHADER fragment gfz_frag SPIRV-ASM TARGET_ENV spv1.3
56; SPIR-V
57; Version: 1.3
58; Generator: Khronos SPIR-V Tools Assembler; 0
59; Bound: 22
60; Schema: 0
61               OpCapability Shader
62          %1 = OpExtInstImport "GLSL.std.450"
63               OpMemoryModel Logical GLSL450
64               OpEntryPoint Fragment %4 "main" %9
65               OpExecutionMode %4 OriginUpperLeft
66               OpSource ESSL 310
67               OpDecorate %9 Location 0
68               OpMemberDecorate %10 0 Offset 0
69               OpDecorate %10 Block
70               OpDecorate %12 DescriptorSet 0
71               OpDecorate %12 Binding 0
72               OpDecorate %21 RelaxedPrecision
73          %2 = OpTypeVoid
74          %3 = OpTypeFunction %2
75          %6 = OpTypeFloat 32
76          %7 = OpTypeVector %6 4
77          %8 = OpTypePointer Output %7
78          %9 = OpVariable %8 Output
79         %10 = OpTypeStruct %7
80         %11 = OpTypePointer Uniform %10
81         %12 = OpVariable %11 Uniform
82         %13 = OpTypeInt 32 1
83         %14 = OpConstant %13 0
84         %15 = OpTypePointer Uniform %7
85         %18 = OpTypeStruct %7
86         %19 = OpUndef %18
87          %4 = OpFunction %2 None %3
88          %5 = OpLabel
89         %16 = OpAccessChain %15 %12 %14
90         %17 = OpLoad %7 %16
91         %20 = OpCompositeInsert %18 %17 %19 0
92         %21 = OpCompositeExtract %7 %20 0
93               OpStore %9 %21
94               OpReturn
95               OpFunctionEnd
96END
97
98BUFFER framebuffer FORMAT B8G8R8A8_UNORM
99
100# f
101BUFFER f DATA_TYPE vec4<float> DATA
102 1.0 0.0 0.0 1.0
103END
104
105PIPELINE graphics gfz_pipeline
106  ATTACH gfz_vert
107  ATTACH gfz_frag
108  FRAMEBUFFER_SIZE 256 256
109  BIND BUFFER framebuffer AS color LOCATION 0
110BIND BUFFER f AS uniform DESCRIPTOR_SET 0 BINDING 0
111END
112
113CLEAR_COLOR gfz_pipeline 0 0 0 255
114CLEAR gfz_pipeline
115RUN gfz_pipeline DRAW_RECT POS 0 0 SIZE 256 256
116
117EXPECT framebuffer IDX 0 0 SIZE 256 256 EQ_RGB 255 0 0
118