aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJames Price <jrprice@google.com>2020-03-18 11:19:21 -0400
committerGitHub <noreply@github.com>2020-03-18 11:19:21 -0400
commitc360eb6162d55cc80b33d48c6e03313fb3f5b072 (patch)
tree00a9510ea7d152fe4edbe046faf3562a82421c6e /tests
parent32aa3b89754243dad223508bdb18cc771d927164 (diff)
downloadamber-c360eb6162d55cc80b33d48c6e03313fb3f5b072.tar.gz
Add support for push constants generated by Clspv (#812)
When the -work-dim or -global-offset flags are passed to Clspv, it will generate push constants. The sizes and offsets of the push constant values are provided in the descriptor map. Amber needs to add these to the pipeline layout and create a buffer for them.
Diffstat (limited to 'tests')
-rw-r--r--tests/cases/opencl_generated_push_constants.amber79
-rwxr-xr-xtests/run_tests.py1
2 files changed, 80 insertions, 0 deletions
diff --git a/tests/cases/opencl_generated_push_constants.amber b/tests/cases/opencl_generated_push_constants.amber
new file mode 100644
index 0000000..e479f5c
--- /dev/null
+++ b/tests/cases/opencl_generated_push_constants.amber
@@ -0,0 +1,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
diff --git a/tests/run_tests.py b/tests/run_tests.py
index 7d76050..b3903cd 100755
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -95,6 +95,7 @@ SUPPRESSIONS_SWIFTSHADER = [
OPENCL_CASES = [
"opencl_bind_buffer.amber",
"opencl_c_copy.amber",
+ "opencl_generated_push_constants.amber",
"opencl_read_and_write_image3d_rgba32i.amber",
"opencl_read_image.amber",
"opencl_read_image_literal_sampler.amber",