blob: b672d6f05cdb1b03a365ccd69a76919ed47c674a [file] [log] [blame]
#!amber
# Copyright 2020 The Amber Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https:#www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
SET ENGINE_DATA fence_timeout_ms 1000000
# #version 450
# layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
# layout(binding = 0, std430) buffer InBuffer
# {
# int Data[];
# } In;
# layout(binding = 1, std430) buffer OutBuffer
# {
# int Data[];
# } Out;
# void main()
# {
# Out.Data[gl_GlobalInvocationID.x] = In.Data[gl_GlobalInvocationID.x];
# }
SHADER compute mah_shader SPIRV-ASM
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %1 "main" %2
OpExecutionMode %1 LocalSize 4 1 1
OpDecorate %3 ArrayStride 4
OpMemberDecorate %4 0 Offset 0
OpDecorate %4 BufferBlock
OpDecorate %5 DescriptorSet 0
OpDecorate %5 Binding 1
OpDecorate %2 BuiltIn GlobalInvocationId
OpDecorate %6 DescriptorSet 0
OpDecorate %6 Binding 0
%7 = OpTypeVoid
%8 = OpTypeFunction %7
%9 = OpTypeInt 32 1
%10 = OpTypeInt 32 0
%3 = OpTypeRuntimeArray %9
%4 = OpTypeStruct %3
%11 = OpTypePointer Uniform %4
%5 = OpVariable %11 Uniform
%12 = OpConstant %9 0
%13 = OpConstant %10 0
%14 = OpTypeVector %10 3
%15 = OpTypePointer Input %14
%2 = OpVariable %15 Input
%16 = OpTypePointer Input %10
%6 = OpVariable %11 Uniform
%17 = OpTypePointer Uniform %9
%1 = OpFunction %7 None %8
%18 = OpLabel
%19 = OpAccessChain %16 %2 %13
%20 = OpLoad %10 %19
%21 = OpAccessChain %17 %6 %12 %20
%22 = OpLoad %9 %21
%23 = OpAccessChain %17 %5 %12 %20
OpStore %23 %22
OpReturn
OpFunctionEnd
END
BUFFER buf_in DATA_TYPE uint32 DATA
20 30 40 50 60
END
BUFFER buf_out DATA_TYPE uint32 DATA
99 99 99 99 99
END
PIPELINE compute pipeline
ATTACH mah_shader
BIND BUFFER buf_in AS storage DESCRIPTOR_SET 0 BINDING 0
BIND BUFFER buf_out AS storage DESCRIPTOR_SET 0 BINDING 1
END
# Only one workgroup. Having only one invocation execute ensures
# there are no race conditions.
DEBUG pipeline 1 1 1
THREAD GLOBAL_INVOCATION_ID 2 0 0
EXPECT CALLSTACK
"ComputeShader" "ComputeShader0.spvasm" 20
END
EXPECT LOCATION "ComputeShader0.spvasm" 20 "%5 = OpVariable %11 Uniform"
STEP_IN
EXPECT LOCATION "ComputeShader0.spvasm" 25 "%2 = OpVariable %15 Input"
STEP_IN
EXPECT LOCATION "ComputeShader0.spvasm" 27 "%6 = OpVariable %11 Uniform"
STEP_IN
EXPECT LOCATION "ComputeShader0.spvasm" 31 "%19 = OpAccessChain %16 %2 %13"
STEP_IN
EXPECT LOCATION "ComputeShader0.spvasm" 32 "%20 = OpLoad %10 %19"
STEP_IN
EXPECT LOCAL "%20" EQ 2
EXPECT LOCATION "ComputeShader0.spvasm" 33 "%21 = OpAccessChain %17 %6 %12 %20"
STEP_IN
EXPECT LOCATION "ComputeShader0.spvasm" 34 "%22 = OpLoad %9 %21"
STEP_IN
EXPECT LOCAL "%22" EQ 40
EXPECT LOCATION "ComputeShader0.spvasm" 35 "%23 = OpAccessChain %17 %5 %12 %20"
STEP_IN
EXPECT LOCATION "ComputeShader0.spvasm" 36 "OpStore %23 %22"
STEP_IN
EXPECT CALLSTACK
"ComputeShader" "ComputeShader0.spvasm" 37
END
EXPECT LOCATION "ComputeShader0.spvasm" 37 "OpReturn"
CONTINUE
END
END
EXPECT buf_in IDX 0 EQ 20 30 40 50 60
EXPECT buf_out IDX 0 EQ 20 30 40 50 99