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 #include "VulkanHandleMapping.h"
16 
17 #include <vulkan/vulkan.h>
18 
19 namespace gfxstream {
20 namespace vk {
21 
22 #define DEFAULT_HANDLE_MAP_DEFINE(type)                                                            \
23     void DefaultHandleMapping::mapHandles_##type(type*, size_t) { return; }                        \
24     void DefaultHandleMapping::mapHandles_##type##_u64(const type* handles, uint64_t* handle_u64s, \
25                                                        size_t count) {                             \
26         for (size_t i = 0; i < count; ++i) {                                                       \
27             handle_u64s[i] = (uint64_t)(uintptr_t)handles[i];                                      \
28         }                                                                                          \
29     }                                                                                              \
30     void DefaultHandleMapping::mapHandles_u64_##type(const uint64_t* handle_u64s, type* handles,   \
31                                                      size_t count) {                               \
32         for (size_t i = 0; i < count; ++i) {                                                       \
33             handles[i] = (type)(uintptr_t)handle_u64s[i];                                          \
34         }                                                                                          \
35     }
36 
37 GOLDFISH_VK_LIST_HANDLE_TYPES(DEFAULT_HANDLE_MAP_DEFINE)
38 
39 }  // namespace vk
40 }  // namespace gfxstream
41