• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2# Copyright 2020 The Amber Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     https:#www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16SET ENGINE_DATA fence_timeout_ms 1000000
17
18# #version 450
19# layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
20# layout(binding = 0, std430) buffer InBuffer
21# {
22#     int Data[];
23# } In;
24# layout(binding = 1, std430) buffer OutBuffer
25# {
26#     int Data[];
27# } Out;
28# void main()
29# {
30#     Out.Data[gl_GlobalInvocationID.x] = In.Data[gl_GlobalInvocationID.x];
31# }
32SHADER compute mah_shader SPIRV-ASM
33      OpCapability Shader
34      OpMemoryModel Logical GLSL450
35      OpEntryPoint GLCompute %1 "main" %2
36      OpExecutionMode %1 LocalSize 4 1 1
37      OpDecorate %3 ArrayStride 4
38      OpMemberDecorate %4 0 Offset 0
39      OpDecorate %4 BufferBlock
40      OpDecorate %5 DescriptorSet 0
41      OpDecorate %5 Binding 1
42      OpDecorate %2 BuiltIn GlobalInvocationId
43      OpDecorate %6 DescriptorSet 0
44      OpDecorate %6 Binding 0
45 %7 = OpTypeVoid
46 %8 = OpTypeFunction %7
47 %9 = OpTypeInt 32 1
48%10 = OpTypeInt 32 0
49 %3 = OpTypeRuntimeArray %9
50 %4 = OpTypeStruct %3
51%11 = OpTypePointer Uniform %4
52 %5 = OpVariable %11 Uniform
53%12 = OpConstant %9 0
54%13 = OpConstant %10 0
55%14 = OpTypeVector %10 3
56%15 = OpTypePointer Input %14
57 %2 = OpVariable %15 Input
58%16 = OpTypePointer Input %10
59 %6 = OpVariable %11 Uniform
60%17 = OpTypePointer Uniform %9
61 %1 = OpFunction %7 None %8
62%18 = OpLabel
63%19 = OpAccessChain %16 %2 %13
64%20 = OpLoad %10 %19
65%21 = OpAccessChain %17 %6 %12 %20
66%22 = OpLoad %9 %21
67%23 = OpAccessChain %17 %5 %12 %20
68      OpStore %23 %22
69      OpReturn
70      OpFunctionEnd
71END
72
73BUFFER buf_in DATA_TYPE uint32 DATA
74    20 30 40 50 60
75END
76
77BUFFER buf_out DATA_TYPE uint32 DATA
78    99 99 99 99 99
79END
80
81PIPELINE compute pipeline
82  ATTACH mah_shader
83
84  BIND BUFFER buf_in  AS storage DESCRIPTOR_SET 0 BINDING 0
85  BIND BUFFER buf_out AS storage DESCRIPTOR_SET 0 BINDING 1
86END
87
88# Only one workgroup.  Having only one invocation execute ensures
89# there are no race conditions.
90DEBUG pipeline 1 1 1
91    THREAD GLOBAL_INVOCATION_ID 2 0 0
92        EXPECT CALLSTACK
93            "SPIR-V" "ComputeShader0.spvasm" 20
94        END
95        EXPECT LOCATION "ComputeShader0.spvasm" 20 "%5 = OpVariable %11 Uniform"
96        STEP_IN
97        EXPECT LOCATION "ComputeShader0.spvasm" 25 "%2 = OpVariable %15 Input"
98        STEP_IN
99        EXPECT LOCATION "ComputeShader0.spvasm" 27 "%6 = OpVariable %11 Uniform"
100        STEP_IN
101        EXPECT LOCATION "ComputeShader0.spvasm" 31 "%19 = OpAccessChain %16 %2 %13"
102        STEP_IN
103        EXPECT LOCATION "ComputeShader0.spvasm" 32 "%20 = OpLoad %10 %19"
104        STEP_IN
105        EXPECT LOCAL "%20" EQ 2
106        EXPECT LOCATION "ComputeShader0.spvasm" 33 "%21 = OpAccessChain %17 %6 %12 %20"
107        STEP_IN
108        EXPECT LOCATION "ComputeShader0.spvasm" 34 "%22 = OpLoad %9 %21"
109        STEP_IN
110        EXPECT LOCAL "%22" EQ 40
111        EXPECT LOCATION "ComputeShader0.spvasm" 35 "%23 = OpAccessChain %17 %5 %12 %20"
112        STEP_IN
113        EXPECT LOCATION "ComputeShader0.spvasm" 36 "OpStore %23 %22"
114        STEP_IN
115        EXPECT CALLSTACK
116            "SPIR-V" "ComputeShader0.spvasm" 37
117        END
118        EXPECT LOCATION "ComputeShader0.spvasm" 37 "OpReturn"
119        CONTINUE
120    END
121END
122
123EXPECT buf_in  IDX 0 EQ 20 30 40 50 60
124EXPECT buf_out IDX 0 EQ 20 30 40 50 99
125
126