mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 06:48:06 +02:00
vulkan: Move vk_device to its own file
Things are going to start getting more complicated so let's avoid the single mega-file approach. Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
This commit is contained in:
parent
b283965427
commit
8ee88948e3
12 changed files with 127 additions and 59 deletions
|
|
@ -55,7 +55,7 @@
|
||||||
#include "util/xmlconfig.h"
|
#include "util/xmlconfig.h"
|
||||||
#include "vk_alloc.h"
|
#include "vk_alloc.h"
|
||||||
#include "vk_debug_report.h"
|
#include "vk_debug_report.h"
|
||||||
#include "vk_object.h"
|
#include "vk_device.h"
|
||||||
#include "vk_format.h"
|
#include "vk_format.h"
|
||||||
|
|
||||||
#include "radv_radeon_winsys.h"
|
#include "radv_radeon_winsys.h"
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
#include <vulkan/vk_icd.h>
|
#include <vulkan/vk_icd.h>
|
||||||
#include <vk_enum_to_str.h>
|
#include <vk_enum_to_str.h>
|
||||||
|
|
||||||
#include "vk_object.h"
|
#include "vk_device.h"
|
||||||
|
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,8 @@
|
||||||
#include "util/macros.h"
|
#include "util/macros.h"
|
||||||
#include "util/u_atomic.h"
|
#include "util/u_atomic.h"
|
||||||
#include "vk_alloc.h"
|
#include "vk_alloc.h"
|
||||||
#include "vk_object.h"
|
|
||||||
#include "vk_debug_report.h"
|
#include "vk_debug_report.h"
|
||||||
|
#include "vk_device.h"
|
||||||
#include "wsi_common.h"
|
#include "wsi_common.h"
|
||||||
|
|
||||||
#include "ir3/ir3_compiler.h"
|
#include "ir3/ir3_compiler.h"
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ typedef uint32_t xcb_window_t;
|
||||||
|
|
||||||
#include "lvp_extensions.h"
|
#include "lvp_extensions.h"
|
||||||
#include "lvp_entrypoints.h"
|
#include "lvp_entrypoints.h"
|
||||||
#include "vk_object.h"
|
#include "vk_device.h"
|
||||||
|
|
||||||
#include "wsi_common.h"
|
#include "wsi_common.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@
|
||||||
#include "util/xmlconfig.h"
|
#include "util/xmlconfig.h"
|
||||||
#include "vk_alloc.h"
|
#include "vk_alloc.h"
|
||||||
#include "vk_debug_report.h"
|
#include "vk_debug_report.h"
|
||||||
#include "vk_object.h"
|
#include "vk_device.h"
|
||||||
|
|
||||||
/* Pre-declarations needed for WSI entrypoints */
|
/* Pre-declarations needed for WSI entrypoints */
|
||||||
struct wl_surface;
|
struct wl_surface;
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ VULKAN_UTIL_FILES := \
|
||||||
util/vk_debug_report.h \
|
util/vk_debug_report.h \
|
||||||
util/vk_deferred_operation.c \
|
util/vk_deferred_operation.c \
|
||||||
util/vk_deferred_operation.h \
|
util/vk_deferred_operation.h \
|
||||||
|
util/vk_device.c \
|
||||||
|
util/vk_device.h \
|
||||||
util/vk_format.c \
|
util/vk_format.c \
|
||||||
util/vk_object.c \
|
util/vk_object.c \
|
||||||
util/vk_object.h \
|
util/vk_object.h \
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ files_vulkan_util = files(
|
||||||
'vk_debug_report.h',
|
'vk_debug_report.h',
|
||||||
'vk_deferred_operation.c',
|
'vk_deferred_operation.c',
|
||||||
'vk_deferred_operation.h',
|
'vk_deferred_operation.h',
|
||||||
|
'vk_device.c',
|
||||||
|
'vk_device.h',
|
||||||
'vk_format.c',
|
'vk_format.c',
|
||||||
'vk_object.c',
|
'vk_object.c',
|
||||||
'vk_object.h',
|
'vk_object.h',
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include "vk_deferred_operation.h"
|
#include "vk_deferred_operation.h"
|
||||||
|
|
||||||
#include "vk_alloc.h"
|
#include "vk_alloc.h"
|
||||||
|
#include "vk_device.h"
|
||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
vk_create_deferred_operation(struct vk_device *device,
|
vk_create_deferred_operation(struct vk_device *device,
|
||||||
|
|
|
||||||
61
src/vulkan/util/vk_device.c
Normal file
61
src/vulkan/util/vk_device.c
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2020 Intel Corporation
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice (including the next
|
||||||
|
* paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
* Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "vk_device.h"
|
||||||
|
|
||||||
|
#include "util/hash_table.h"
|
||||||
|
#include "util/ralloc.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
vk_device_init(struct vk_device *device,
|
||||||
|
UNUSED const VkDeviceCreateInfo *pCreateInfo,
|
||||||
|
const VkAllocationCallbacks *instance_alloc,
|
||||||
|
const VkAllocationCallbacks *device_alloc)
|
||||||
|
{
|
||||||
|
vk_object_base_init(device, &device->base, VK_OBJECT_TYPE_DEVICE);
|
||||||
|
if (device_alloc)
|
||||||
|
device->alloc = *device_alloc;
|
||||||
|
else
|
||||||
|
device->alloc = *instance_alloc;
|
||||||
|
|
||||||
|
p_atomic_set(&device->private_data_next_index, 0);
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
mtx_init(&device->swapchain_private_mtx, mtx_plain);
|
||||||
|
device->swapchain_private = NULL;
|
||||||
|
#endif /* ANDROID */
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vk_device_finish(UNUSED struct vk_device *device)
|
||||||
|
{
|
||||||
|
#ifdef ANDROID
|
||||||
|
if (device->swapchain_private) {
|
||||||
|
hash_table_foreach(device->swapchain_private, entry)
|
||||||
|
util_sparse_array_finish(entry->data);
|
||||||
|
ralloc_free(device->swapchain_private);
|
||||||
|
}
|
||||||
|
#endif /* ANDROID */
|
||||||
|
|
||||||
|
vk_object_base_finish(&device->base);
|
||||||
|
}
|
||||||
55
src/vulkan/util/vk_device.h
Normal file
55
src/vulkan/util/vk_device.h
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2020 Intel Corporation
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice (including the next
|
||||||
|
* paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
* Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
#ifndef VK_DEVICE_H
|
||||||
|
#define VK_DEVICE_H
|
||||||
|
|
||||||
|
#include "vk_object.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct vk_device {
|
||||||
|
struct vk_object_base base;
|
||||||
|
VkAllocationCallbacks alloc;
|
||||||
|
|
||||||
|
/* For VK_EXT_private_data */
|
||||||
|
uint32_t private_data_next_index;
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
mtx_t swapchain_private_mtx;
|
||||||
|
struct hash_table *swapchain_private;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
void vk_device_init(struct vk_device *device,
|
||||||
|
const VkDeviceCreateInfo *pCreateInfo,
|
||||||
|
const VkAllocationCallbacks *instance_alloc,
|
||||||
|
const VkAllocationCallbacks *device_alloc);
|
||||||
|
void vk_device_finish(struct vk_device *device);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* VK_DEVICE_H */
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include "vk_object.h"
|
#include "vk_object.h"
|
||||||
|
|
||||||
#include "vk_alloc.h"
|
#include "vk_alloc.h"
|
||||||
|
#include "vk_device.h"
|
||||||
#include "util/hash_table.h"
|
#include "util/hash_table.h"
|
||||||
#include "util/ralloc.h"
|
#include "util/ralloc.h"
|
||||||
|
|
||||||
|
|
@ -43,40 +44,6 @@ vk_object_base_finish(struct vk_object_base *base)
|
||||||
util_sparse_array_finish(&base->private_data);
|
util_sparse_array_finish(&base->private_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
vk_device_init(struct vk_device *device,
|
|
||||||
UNUSED const VkDeviceCreateInfo *pCreateInfo,
|
|
||||||
const VkAllocationCallbacks *instance_alloc,
|
|
||||||
const VkAllocationCallbacks *device_alloc)
|
|
||||||
{
|
|
||||||
vk_object_base_init(device, &device->base, VK_OBJECT_TYPE_DEVICE);
|
|
||||||
if (device_alloc)
|
|
||||||
device->alloc = *device_alloc;
|
|
||||||
else
|
|
||||||
device->alloc = *instance_alloc;
|
|
||||||
|
|
||||||
p_atomic_set(&device->private_data_next_index, 0);
|
|
||||||
|
|
||||||
#ifdef ANDROID
|
|
||||||
mtx_init(&device->swapchain_private_mtx, mtx_plain);
|
|
||||||
device->swapchain_private = NULL;
|
|
||||||
#endif /* ANDROID */
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
vk_device_finish(UNUSED struct vk_device *device)
|
|
||||||
{
|
|
||||||
#ifdef ANDROID
|
|
||||||
if (device->swapchain_private) {
|
|
||||||
hash_table_foreach(device->swapchain_private, entry)
|
|
||||||
util_sparse_array_finish(entry->data);
|
|
||||||
ralloc_free(device->swapchain_private);
|
|
||||||
}
|
|
||||||
#endif /* ANDROID */
|
|
||||||
|
|
||||||
vk_object_base_finish(&device->base);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
void *
|
||||||
vk_object_alloc(struct vk_device *device,
|
vk_object_alloc(struct vk_device *device,
|
||||||
const VkAllocationCallbacks *alloc,
|
const VkAllocationCallbacks *alloc,
|
||||||
|
|
|
||||||
|
|
@ -66,26 +66,6 @@ vk_object_base_from_u64_handle(uint64_t handle, VkObjectType obj_type)
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct vk_device {
|
|
||||||
struct vk_object_base base;
|
|
||||||
VkAllocationCallbacks alloc;
|
|
||||||
|
|
||||||
/* For VK_EXT_private_data */
|
|
||||||
uint32_t private_data_next_index;
|
|
||||||
|
|
||||||
#ifdef ANDROID
|
|
||||||
mtx_t swapchain_private_mtx;
|
|
||||||
struct hash_table *swapchain_private;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
void vk_device_init(struct vk_device *device,
|
|
||||||
const VkDeviceCreateInfo *pCreateInfo,
|
|
||||||
const VkAllocationCallbacks *instance_alloc,
|
|
||||||
const VkAllocationCallbacks *device_alloc);
|
|
||||||
void vk_device_finish(struct vk_device *device);
|
|
||||||
|
|
||||||
#define VK_DEFINE_HANDLE_CASTS(__driver_type, __base, __VkType, __VK_TYPE) \
|
#define VK_DEFINE_HANDLE_CASTS(__driver_type, __base, __VkType, __VK_TYPE) \
|
||||||
static inline struct __driver_type * \
|
static inline struct __driver_type * \
|
||||||
__driver_type ## _from_handle(__VkType _handle) \
|
__driver_type ## _from_handle(__VkType _handle) \
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue