From f3585570fc62815446ecf85995f2724ee3f56cb3 Mon Sep 17 00:00:00 2001 From: Jaebaek Seo Date: Wed, 12 Dec 2018 12:35:18 -0500 Subject: Vulkan: fix discontinuous descriptor set error (#159) Without this commit, Amber supports descriptors with consecutive descriptor sets from `[0, N]`, but it does not support discontinuous descriptor sets e.g., `1, 3, 5`. To support discontinuous descriptor sets, this commit creates empty descriptor set layouts and puts them on pipeline layout. Fixes #158 --- tests/cases/compute_nothing_with_ssbo.amber | 37 +++++++ ...sparse_descriptor_set_in_compute_pipeline.amber | 116 +++++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 tests/cases/compute_nothing_with_ssbo.amber create mode 100644 tests/cases/multiple_ssbo_with_sparse_descriptor_set_in_compute_pipeline.amber (limited to 'tests') diff --git a/tests/cases/compute_nothing_with_ssbo.amber b/tests/cases/compute_nothing_with_ssbo.amber new file mode 100644 index 0000000..050cc00 --- /dev/null +++ b/tests/cases/compute_nothing_with_ssbo.amber @@ -0,0 +1,37 @@ +# Copyright 2018 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. + +[compute shader] +#version 430 + +layout(set = 1, binding = 2) buffer block1 { + float data_set1_binding2[11]; +}; + +void main() { +} + +[test] +ssbo 1:2 subdata vec4 0 0.1 0.2 0.3 0.4 +compute 4 1 1 +probe ssbo float 1:2 0 ~= 0.1 0.2 0.3 0.4 + + +ssbo 1:2 subdata float 0 0.57 0.56 0.55 0.54 \ + 0.53 0.52 0.51 0.50 \ + 0.49 0.48 0.47 +compute 4 1 1 +probe ssbo float 1:2 0 ~= 0.57 0.56 0.55 0.54 \ + 0.53 0.52 0.51 0.50 \ + 0.49 0.48 0.47 diff --git a/tests/cases/multiple_ssbo_with_sparse_descriptor_set_in_compute_pipeline.amber b/tests/cases/multiple_ssbo_with_sparse_descriptor_set_in_compute_pipeline.amber new file mode 100644 index 0000000..d5f15cf --- /dev/null +++ b/tests/cases/multiple_ssbo_with_sparse_descriptor_set_in_compute_pipeline.amber @@ -0,0 +1,116 @@ +# Copyright 2018 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. + +[compute shader] +#version 430 + +layout(set = 1, binding = 0) buffer block1 { + float data_set1_binding0[11]; + float data_set1_binding0_result[11]; +}; + +layout(set = 1, binding = 2) buffer block2 { + float data_set1_binding2[11]; + float data_set1_binding2_result[11]; +}; + +layout(set = 3, binding = 1) buffer block3 { + float data_set3_binding1[11]; + float data_set3_binding1_result[11]; +}; + +layout(set = 5, binding = 3) buffer block4 { + float data_set5_binding3[11]; + float data_set5_binding3_result[11]; +}; + +void main() { + for (int i = 0; i < 11; ++i) { + data_set1_binding0_result[i] = data_set1_binding2[i]; + data_set1_binding2_result[i] = data_set3_binding1[i]; + data_set3_binding1_result[i] = data_set5_binding3[i]; + data_set5_binding3_result[i] = data_set1_binding0[i]; + } +} + +[test] +ssbo 1:0 subdata vec4 0 0.1 0.2 0.3 0.4 +ssbo 1:2 subdata vec4 0 0.1 0.2 0.3 0.4 +ssbo 3:1 subdata vec4 0 0.1 0.2 0.3 0.4 +ssbo 5:3 subdata vec4 0 0.1 0.2 0.3 0.4 + +compute 4 1 1 + +probe ssbo float 1:0 0 ~= 0.1 0.2 0.3 0.4 +probe ssbo float 1:2 0 ~= 0.1 0.2 0.3 0.4 +probe ssbo float 3:1 0 ~= 0.1 0.2 0.3 0.4 +probe ssbo float 5:3 0 ~= 0.1 0.2 0.3 0.4 + +ssbo 1:0 subdata float 0 0.1 0.2 0.3 0.4 \ + 0.5 0.6 0.7 0.8 \ + 0.9 0.10 0.11 \ + 0.1 0.2 0.3 0.4 \ + 0.5 0.6 0.7 0.8 \ + 0.9 0.10 0.11 + +ssbo 1:2 subdata float 0 0.57 0.56 0.55 0.54 \ + 0.53 0.52 0.51 0.50 \ + 0.49 0.48 0.47 \ + 0.57 0.56 0.55 0.54 \ + 0.53 0.52 0.51 0.50 \ + 0.49 0.48 0.47 + +ssbo 3:1 subdata float 0 0.21 0.22 0.23 0.24 \ + 0.25 0.26 0.27 0.28 \ + 0.29 0.30 0.31 \ + 0.21 0.22 0.23 0.24 \ + 0.25 0.26 0.27 0.28 \ + 0.29 0.30 0.31 + +ssbo 5:3 subdata float 0 0.23 0.229 0.228 0.227 \ + 0.226 0.225 0.224 0.223 \ + 0.222 0.221 0.22 \ + 0.23 0.229 0.228 0.227 \ + 0.226 0.225 0.224 0.223 \ + 0.222 0.221 0.22 + +compute 4 1 1 + +probe ssbo float 1:0 0 ~= 0.1 0.2 0.3 0.4 \ + 0.5 0.6 0.7 0.8 \ + 0.9 0.10 0.11 +probe ssbo float 1:0 44 ~= 0.57 0.56 0.55 0.54 \ + 0.53 0.52 0.51 0.50 \ + 0.49 0.48 0.47 + +probe ssbo float 1:2 0 ~= 0.57 0.56 0.55 0.54 \ + 0.53 0.52 0.51 0.50 \ + 0.49 0.48 0.47 +probe ssbo float 1:2 44 ~= 0.21 0.22 0.23 0.24 \ + 0.25 0.26 0.27 0.28 \ + 0.29 0.30 0.31 + +probe ssbo float 3:1 0 ~= 0.21 0.22 0.23 0.24 \ + 0.25 0.26 0.27 0.28 \ + 0.29 0.30 0.31 +probe ssbo float 3:1 44 ~= 0.23 0.229 0.228 0.227 \ + 0.226 0.225 0.224 0.223 \ + 0.222 0.221 0.22 + +probe ssbo float 5:3 0 ~= 0.23 0.229 0.228 0.227 \ + 0.226 0.225 0.224 0.223 \ + 0.222 0.221 0.22 +probe ssbo float 5:3 44 ~= 0.1 0.2 0.3 0.4 \ + 0.5 0.6 0.7 0.8 \ + 0.9 0.10 0.11 -- cgit v1.2.3