xref: /aosp_15_r20/external/mesa3d/src/gfxstream/guest/vulkan_enc/VulkanHandleMapping.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright 2018 Google LLC
3  * SPDX-License-Identifier: MIT
4  */
5 #pragma once
6 
7 #include <vulkan/vulkan.h>
8 
9 #include "VulkanHandles.h"
10 
11 namespace gfxstream {
12 namespace vk {
13 
14 class VulkanHandleMapping {
15    public:
16     VulkanHandleMapping() = default;
~VulkanHandleMapping()17     virtual ~VulkanHandleMapping() {}
18 
19 #define DECLARE_HANDLE_MAP_PURE_VIRTUAL_METHOD(type)                                 \
20     virtual void mapHandles_##type(type* handles, size_t count = 1) = 0;             \
21     virtual void mapHandles_##type##_u64(const type* handles, uint64_t* handle_u64s, \
22                                          size_t count = 1) = 0;                      \
23     virtual void mapHandles_u64_##type(const uint64_t* handle_u64s, type* handles,   \
24                                        size_t count = 1) = 0;
25 
26     GOLDFISH_VK_LIST_HANDLE_TYPES(DECLARE_HANDLE_MAP_PURE_VIRTUAL_METHOD)
27 };
28 
29 class DefaultHandleMapping : public VulkanHandleMapping {
30    public:
~DefaultHandleMapping()31     virtual ~DefaultHandleMapping() {}
32 
33 #define DECLARE_HANDLE_MAP_OVERRIDE(type)                                                  \
34     void mapHandles_##type(type* handles, size_t count) override;                          \
35     void mapHandles_##type##_u64(const type* handles, uint64_t* handle_u64s, size_t count) \
36         override;                                                                          \
37     void mapHandles_u64_##type(const uint64_t* handle_u64s, type* handles, size_t count) override;
38 
39     GOLDFISH_VK_LIST_HANDLE_TYPES(DECLARE_HANDLE_MAP_OVERRIDE)
40 };
41 
42 }  // namespace vk
43 }  // namespace gfxstream
44