aboutsummaryrefslogtreecommitdiff
path: root/tests/cases/opencl_generated_push_constants.amber
blob: e479f5cef458584ee84504f373e492a8a2102ba6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!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