| #!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. |
| |
| SHADER compute work_dim_shader OPENCL-C |
| kernel void foo(global int* out) { |
| *out = get_work_dim(); |
| } |
| END |
| |
| SHADER compute global_offset_shader OPENCL-C |
| kernel void foo(global int* out) { |
| out[0] = get_global_offset(0); |
| out[1] = get_global_offset(1); |
| out[2] = get_global_offset(2); |
| } |
| END |
| |
| SHADER compute all_constants_shader OPENCL-C |
| kernel void foo(global int* out) { |
| out[0] = get_global_offset(0); |
| out[1] = get_global_offset(1); |
| out[2] = get_global_offset(2); |
| out[3] = get_work_dim(); |
| } |
| END |
| |
| BUFFER work_dim_buf DATA_TYPE uint32 SIZE 1 FILL -1 |
| BUFFER global_offset_buf DATA_TYPE uint32 SIZE 3 FILL -1 |
| BUFFER all_constants_buf DATA_TYPE uint32 SIZE 4 FILL -1 |
| |
| PIPELINE compute work_dim_pipeline |
| ATTACH work_dim_shader ENTRY_POINT foo |
| COMPILE_OPTIONS work_dim_shader |
| -work-dim |
| END |
| BIND BUFFER work_dim_buf AS storage DESCRIPTOR_SET 0 BINDING 0 |
| END |
| |
| PIPELINE compute global_offset_pipeline |
| ATTACH global_offset_shader ENTRY_POINT foo |
| COMPILE_OPTIONS global_offset_shader |
| -global-offset |
| END |
| BIND BUFFER global_offset_buf AS storage DESCRIPTOR_SET 0 BINDING 0 |
| END |
| |
| PIPELINE compute all_constants_pipeline |
| ATTACH all_constants_shader ENTRY_POINT foo |
| COMPILE_OPTIONS all_constants_shader |
| -work-dim -global-offset |
| END |
| BIND BUFFER all_constants_buf AS storage DESCRIPTOR_SET 0 BINDING 0 |
| END |
| |
| RUN work_dim_pipeline 1 1 1 |
| EXPECT work_dim_buf IDX 0 EQ 3 |
| |
| RUN global_offset_pipeline 1 1 1 |
| EXPECT global_offset_buf IDX 0 EQ 0 |
| EXPECT global_offset_buf IDX 4 EQ 0 |
| EXPECT global_offset_buf IDX 8 EQ 0 |
| |
| RUN all_constants_pipeline 1 1 1 |
| EXPECT all_constants_buf IDX 0 EQ 0 |
| EXPECT all_constants_buf IDX 4 EQ 0 |
| EXPECT all_constants_buf IDX 8 EQ 0 |
| EXPECT all_constants_buf IDX 12 EQ 3 |