| #!amber |
| # Copyright 2019 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. |
| |
| SHADER compute my_shader OPENCL-C |
| kernel void line(global int* in, global int* out, int slope, int offset) { |
| *out = *in * slope + offset; |
| } |
| END |
| |
| BUFFER in_buf DATA_TYPE uint32 DATA 3 END |
| BUFFER out_buf1 DATA_TYPE uint32 DATA 0 END |
| BUFFER out_buf2 DATA_TYPE uint32 DATA 0 END |
| BUFFER out_buf3 DATA_TYPE uint32 DATA 0 END |
| BUFFER out_buf4 DATA_TYPE uint32 DATA 0 END |
| |
| PIPELINE compute p1 |
| ATTACH my_shader ENTRY_POINT line |
| BIND BUFFER in_buf KERNEL ARG_NAME in |
| BIND BUFFER out_buf1 KERNEL ARG_NAME out |
| SET KERNEL ARG_NAME offset AS uint32 1 |
| SET KERNEL ARG_NAME slope AS int32 2 |
| END |
| |
| DERIVE_PIPELINE p2 FROM p1 |
| BIND BUFFER out_buf2 KERNEL ARG_NAME out |
| COMPILE_OPTIONS my_shader |
| -pod-ubo |
| END |
| END |
| |
| DERIVE_PIPELINE p3 FROM p1 |
| BIND BUFFER out_buf3 KERNEL ARG_NAME out |
| COMPILE_OPTIONS my_shader |
| -cluster-pod-kernel-args |
| END |
| END |
| |
| DERIVE_PIPELINE p4 FROM p1 |
| BIND BUFFER out_buf4 KERNEL ARG_NAME out |
| SET KERNEL ARG_NAME slope AS int32 3 |
| COMPILE_OPTIONS my_shader |
| -cluster-pod-kernel-args |
| -pod-ubo |
| END |
| END |
| |
| RUN p1 1 1 1 |
| RUN p2 1 1 1 |
| RUN p3 1 1 1 |
| RUN p4 1 1 1 |
| |
| EXPECT out_buf1 IDX 0 EQ 7 |
| EXPECT out_buf2 IDX 0 EQ 7 |
| EXPECT out_buf3 IDX 0 EQ 7 |
| EXPECT out_buf4 IDX 0 EQ 10 |