From 63a431b81c8c4e295118b1cf320bf68b578e57c4 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 22 Jun 2020 11:57:32 -0500 Subject: [PATCH] anv: Add a trivial implementation of VK_KHR_deferred_host_operation This isn't actually capable of deferring anything; it just trivially returns success. Acked-by: Lionel Landwerlin Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/intel/vulkan/anv_device.c | 44 ++++++++++++++ src/intel/vulkan/anv_extensions.py | 1 + src/vulkan/Makefile.sources | 2 + src/vulkan/util/meson.build | 2 + src/vulkan/util/vk_deferred_operation.c | 80 +++++++++++++++++++++++++ src/vulkan/util/vk_deferred_operation.h | 69 +++++++++++++++++++++ 6 files changed, 198 insertions(+) create mode 100644 src/vulkan/util/vk_deferred_operation.c create mode 100644 src/vulkan/util/vk_deferred_operation.h diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index bcc33923b2a..5638f30890c 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -43,6 +43,7 @@ #include "util/driconf.h" #include "git_sha1.h" #include "vk_util.h" +#include "vk_deferred_operation.h" #include "common/gen_aux_map.h" #include "common/gen_defines.h" #include "common/gen_uuid.h" @@ -4697,3 +4698,46 @@ void anv_GetPrivateDataEXT( objectType, objectHandle, privateDataSlot, pData); } + +VkResult anv_CreateDeferredOperationKHR( + VkDevice _device, + const VkAllocationCallbacks* pAllocator, + VkDeferredOperationKHR* pDeferredOperation) +{ + ANV_FROM_HANDLE(anv_device, device, _device); + return vk_create_deferred_operation(&device->vk, pAllocator, + pDeferredOperation); +} + +void anv_DestroyDeferredOperationKHR( + VkDevice _device, + VkDeferredOperationKHR operation, + const VkAllocationCallbacks* pAllocator) +{ + ANV_FROM_HANDLE(anv_device, device, _device); + vk_destroy_deferred_operation(&device->vk, operation, pAllocator); +} + +uint32_t anv_GetDeferredOperationMaxConcurrencyKHR( + VkDevice _device, + VkDeferredOperationKHR operation) +{ + ANV_FROM_HANDLE(anv_device, device, _device); + return vk_get_deferred_operation_max_concurrency(&device->vk, operation); +} + +VkResult anv_GetDeferredOperationResultKHR( + VkDevice _device, + VkDeferredOperationKHR operation) +{ + ANV_FROM_HANDLE(anv_device, device, _device); + return vk_get_deferred_operation_result(&device->vk, operation); +} + +VkResult anv_DeferredOperationJoinKHR( + VkDevice _device, + VkDeferredOperationKHR operation) +{ + ANV_FROM_HANDLE(anv_device, device, _device); + return vk_deferred_operation_join(&device->vk, operation); +} diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py index b19dfcf6b77..35744a4fd55 100644 --- a/src/intel/vulkan/anv_extensions.py +++ b/src/intel/vulkan/anv_extensions.py @@ -59,6 +59,7 @@ EXTENSIONS = [ Extension('VK_KHR_copy_commands2', 1, True), Extension('VK_KHR_create_renderpass2', 1, True), Extension('VK_KHR_dedicated_allocation', 3, True), + Extension('VK_KHR_deferred_host_operations', 1, True), Extension('VK_KHR_depth_stencil_resolve', 1, True), Extension('VK_KHR_descriptor_update_template', 1, True), Extension('VK_KHR_device_group', 4, True), diff --git a/src/vulkan/Makefile.sources b/src/vulkan/Makefile.sources index 640c36eff22..e979d1a2450 100644 --- a/src/vulkan/Makefile.sources +++ b/src/vulkan/Makefile.sources @@ -27,6 +27,8 @@ VULKAN_UTIL_FILES := \ util/vk_alloc.h \ util/vk_debug_report.c \ util/vk_debug_report.h \ + util/vk_deferred_operation.c \ + util/vk_deferred_operation.h \ util/vk_format.c \ util/vk_object.c \ util/vk_object.h \ diff --git a/src/vulkan/util/meson.build b/src/vulkan/util/meson.build index 687a7d48d10..f7d8a3df502 100644 --- a/src/vulkan/util/meson.build +++ b/src/vulkan/util/meson.build @@ -22,6 +22,8 @@ files_vulkan_util = files( 'vk_alloc.h', 'vk_debug_report.c', 'vk_debug_report.h', + 'vk_deferred_operation.c', + 'vk_deferred_operation.h', 'vk_format.c', 'vk_object.c', 'vk_object.h', diff --git a/src/vulkan/util/vk_deferred_operation.c b/src/vulkan/util/vk_deferred_operation.c new file mode 100644 index 00000000000..765a8b3d4c2 --- /dev/null +++ b/src/vulkan/util/vk_deferred_operation.c @@ -0,0 +1,80 @@ +/* + * 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_deferred_operation.h" + +#include "vk_alloc.h" + +VkResult +vk_create_deferred_operation(struct vk_device *device, + const VkAllocationCallbacks *pAllocator, + VkDeferredOperationKHR *pDeferredOperation) +{ + struct vk_deferred_operation *op = + vk_alloc2(&device->alloc, pAllocator, sizeof(*op), 8, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + if (op == NULL) + return VK_ERROR_OUT_OF_HOST_MEMORY; + + vk_object_base_init(device, &op->base, + VK_OBJECT_TYPE_DEFERRED_OPERATION_KHR); + + *pDeferredOperation = vk_deferred_operation_to_handle(op); + + return VK_SUCCESS; +} + +void +vk_destroy_deferred_operation(struct vk_device *device, + VkDeferredOperationKHR operation, + const VkAllocationCallbacks *pAllocator) +{ + if (operation == VK_NULL_HANDLE) + return; + + VK_FROM_HANDLE(vk_deferred_operation, op, operation); + + vk_object_base_finish(&op->base); + vk_free2(&device->alloc, pAllocator, op); +} + +uint32_t +vk_get_deferred_operation_max_concurrency(UNUSED struct vk_device *device, + UNUSED VkDeferredOperationKHR operation) +{ + return 1; +} + +VkResult +vk_get_deferred_operation_result(UNUSED struct vk_device *device, + UNUSED VkDeferredOperationKHR operation) +{ + return VK_SUCCESS; +} + +VkResult +vk_deferred_operation_join(UNUSED struct vk_device *device, + UNUSED VkDeferredOperationKHR operation) +{ + return VK_SUCCESS; +} diff --git a/src/vulkan/util/vk_deferred_operation.h b/src/vulkan/util/vk_deferred_operation.h new file mode 100644 index 00000000000..78b1c450bbe --- /dev/null +++ b/src/vulkan/util/vk_deferred_operation.h @@ -0,0 +1,69 @@ +/* + * 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_DEFERRED_OPERATION_H +#define VK_DEFERRED_OPERATION_H + +#include "vk_object.h" + +#include "c11/threads.h" +#include "util/list.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct vk_deferred_operation { + struct vk_object_base base; +}; + +VK_DEFINE_NONDISP_HANDLE_CASTS(vk_deferred_operation, base, + VkDeferredOperationKHR, + VK_OBJECT_TYPE_DEFERRED_OPERATION_KHR) + +VkResult +vk_create_deferred_operation(struct vk_device *device, + const VkAllocationCallbacks *pAllocator, + VkDeferredOperationKHR *pDeferredOperation); + +void +vk_destroy_deferred_operation(struct vk_device *device, + VkDeferredOperationKHR operation, + const VkAllocationCallbacks *pAllocator); + +uint32_t +vk_get_deferred_operation_max_concurrency(struct vk_device *device, + VkDeferredOperationKHR operation); + +VkResult +vk_get_deferred_operation_result(struct vk_device *device, + VkDeferredOperationKHR operation); + +VkResult +vk_deferred_operation_join(struct vk_device *device, + VkDeferredOperationKHR operation); + +#ifdef __cplusplus +} +#endif + +#endif /* VK_DEFERRED_OPERATION_H */