Lingfeng Yang | c023a19 | 2018-11-08 09:22:31 -0800 | [diff] [blame] | 1 | // Copyright (C) 2018 The Android Open Source Project |
| 2 | // Copyright (C) 2018 Google Inc. |
| 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 | // http://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 | #pragma once |
| 16 | |
| 17 | #include <vulkan/vulkan.h> |
| 18 | |
Lingfeng Yang | 2285df1 | 2018-11-17 16:25:11 -0800 | [diff] [blame] | 19 | #include "VulkanHandles.h" |
| 20 | |
Jason Macnak | 3d66400 | 2023-03-30 16:00:50 -0700 | [diff] [blame] | 21 | namespace gfxstream { |
| 22 | namespace vk { |
Lingfeng Yang | c023a19 | 2018-11-08 09:22:31 -0800 | [diff] [blame] | 23 | |
| 24 | class VulkanHandleMapping { |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 25 | public: |
Lingfeng Yang | c023a19 | 2018-11-08 09:22:31 -0800 | [diff] [blame] | 26 | VulkanHandleMapping() = default; |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 27 | virtual ~VulkanHandleMapping() {} |
Lingfeng Yang | c023a19 | 2018-11-08 09:22:31 -0800 | [diff] [blame] | 28 | |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 29 | #define DECLARE_HANDLE_MAP_PURE_VIRTUAL_METHOD(type) \ |
| 30 | virtual void mapHandles_##type(type* handles, size_t count = 1) = 0; \ |
| 31 | virtual void mapHandles_##type##_u64(const type* handles, uint64_t* handle_u64s, \ |
| 32 | size_t count = 1) = 0; \ |
| 33 | virtual void mapHandles_u64_##type(const uint64_t* handle_u64s, type* handles, \ |
| 34 | size_t count = 1) = 0; |
Lingfeng Yang | c023a19 | 2018-11-08 09:22:31 -0800 | [diff] [blame] | 35 | |
Lingfeng Yang | 2285df1 | 2018-11-17 16:25:11 -0800 | [diff] [blame] | 36 | GOLDFISH_VK_LIST_HANDLE_TYPES(DECLARE_HANDLE_MAP_PURE_VIRTUAL_METHOD) |
Lingfeng Yang | c023a19 | 2018-11-08 09:22:31 -0800 | [diff] [blame] | 37 | }; |
| 38 | |
Lingfeng Yang | 2285df1 | 2018-11-17 16:25:11 -0800 | [diff] [blame] | 39 | class DefaultHandleMapping : public VulkanHandleMapping { |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 40 | public: |
| 41 | virtual ~DefaultHandleMapping() {} |
Lingfeng Yang | 2285df1 | 2018-11-17 16:25:11 -0800 | [diff] [blame] | 42 | |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 43 | #define DECLARE_HANDLE_MAP_OVERRIDE(type) \ |
| 44 | void mapHandles_##type(type* handles, size_t count) override; \ |
| 45 | void mapHandles_##type##_u64(const type* handles, uint64_t* handle_u64s, size_t count) \ |
| 46 | override; \ |
| 47 | void mapHandles_u64_##type(const uint64_t* handle_u64s, type* handles, size_t count) override; |
Lingfeng Yang | 2285df1 | 2018-11-17 16:25:11 -0800 | [diff] [blame] | 48 | |
| 49 | GOLDFISH_VK_LIST_HANDLE_TYPES(DECLARE_HANDLE_MAP_OVERRIDE) |
| 50 | }; |
| 51 | |
Jason Macnak | 3d66400 | 2023-03-30 16:00:50 -0700 | [diff] [blame] | 52 | } // namespace vk |
| 53 | } // namespace gfxstream |