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 16SHADER compute work_dim_shader OPENCL-C 17kernel void foo(global int* out) { 18 *out = get_work_dim(); 19} 20END 21 22SHADER compute global_offset_shader OPENCL-C 23kernel void foo(global int* out) { 24 out[0] = get_global_offset(0); 25 out[1] = get_global_offset(1); 26 out[2] = get_global_offset(2); 27} 28END 29 30SHADER compute all_constants_shader OPENCL-C 31kernel void foo(global int* out) { 32 out[0] = get_global_offset(0); 33 out[1] = get_global_offset(1); 34 out[2] = get_global_offset(2); 35 out[3] = get_work_dim(); 36} 37END 38 39BUFFER work_dim_buf DATA_TYPE uint32 SIZE 1 FILL -1 40BUFFER global_offset_buf DATA_TYPE uint32 SIZE 3 FILL -1 41BUFFER all_constants_buf DATA_TYPE uint32 SIZE 4 FILL -1 42 43PIPELINE compute work_dim_pipeline 44 ATTACH work_dim_shader ENTRY_POINT foo 45 COMPILE_OPTIONS work_dim_shader 46 -work-dim 47 END 48 BIND BUFFER work_dim_buf AS storage DESCRIPTOR_SET 0 BINDING 0 49END 50 51PIPELINE compute global_offset_pipeline 52 ATTACH global_offset_shader ENTRY_POINT foo 53 COMPILE_OPTIONS global_offset_shader 54 -global-offset 55 END 56 BIND BUFFER global_offset_buf AS storage DESCRIPTOR_SET 0 BINDING 0 57END 58 59PIPELINE compute all_constants_pipeline 60 ATTACH all_constants_shader ENTRY_POINT foo 61 COMPILE_OPTIONS all_constants_shader 62 -work-dim -global-offset 63 END 64 BIND BUFFER all_constants_buf AS storage DESCRIPTOR_SET 0 BINDING 0 65END 66 67RUN work_dim_pipeline 1 1 1 68EXPECT work_dim_buf IDX 0 EQ 3 69 70RUN global_offset_pipeline 1 1 1 71EXPECT global_offset_buf IDX 0 EQ 0 72EXPECT global_offset_buf IDX 4 EQ 0 73EXPECT global_offset_buf IDX 8 EQ 0 74 75RUN all_constants_pipeline 1 1 1 76EXPECT all_constants_buf IDX 0 EQ 0 77EXPECT all_constants_buf IDX 4 EQ 0 78EXPECT all_constants_buf IDX 8 EQ 0 79EXPECT all_constants_buf IDX 12 EQ 3 80