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 
19 #include "VulkanHandles.h"
20 
21 namespace goldfish_vk {
22 
23 class VulkanHandleMapping {
24 public:
25     VulkanHandleMapping() = default;
~VulkanHandleMapping()26     virtual ~VulkanHandleMapping() { }
27 
28 #define DECLARE_HANDLE_MAP_PURE_VIRTUAL_METHOD(type) \
29     virtual void mapHandles_##type(type* handles, size_t count = 1) = 0; \
30     virtual void mapHandles_##type##_u64(const type* handles, uint64_t* handle_u64s, size_t count = 1) = 0; \
31     virtual void mapHandles_u64_##type(const uint64_t* handle_u64s, type* handles, size_t count = 1) = 0; \
32 
33     GOLDFISH_VK_LIST_HANDLE_TYPES(DECLARE_HANDLE_MAP_PURE_VIRTUAL_METHOD)
34 };
35 
36 class DefaultHandleMapping : public VulkanHandleMapping {
37 public:
~DefaultHandleMapping()38     virtual ~DefaultHandleMapping() { }
39 
40 #define DECLARE_HANDLE_MAP_OVERRIDE(type) \
41     void mapHandles_##type(type* handles, size_t count) override; \
42     void mapHandles_##type##_u64(const type* handles, uint64_t* handle_u64s, size_t count) override; \
43     void mapHandles_u64_##type(const uint64_t* handle_u64s, type* handles, size_t count) override; \
44 
45     GOLDFISH_VK_LIST_HANDLE_TYPES(DECLARE_HANDLE_MAP_OVERRIDE)
46 };
47 
48 } // namespace goldfish_vk