diff --git a/src/virtio/vulkan/vn_common.c b/src/virtio/vulkan/vn_common.c index ec48f72a2a0..9977160101d 100644 --- a/src/virtio/vulkan/vn_common.c +++ b/src/virtio/vulkan/vn_common.c @@ -35,6 +35,7 @@ static const struct debug_control vn_perf_options[] = { { "no_async_buffer_create", VN_PERF_NO_ASYNC_BUFFER_CREATE }, { "no_async_queue_submit", VN_PERF_NO_ASYNC_QUEUE_SUBMIT }, { "no_event_feedback", VN_PERF_NO_EVENT_FEEDBACK }, + { "no_fence_feedback", VN_PERF_NO_FENCE_FEEDBACK }, { NULL, 0 }, }; diff --git a/src/virtio/vulkan/vn_common.h b/src/virtio/vulkan/vn_common.h index 47505e7e805..d8a68721697 100644 --- a/src/virtio/vulkan/vn_common.h +++ b/src/virtio/vulkan/vn_common.h @@ -147,6 +147,7 @@ enum vn_perf { VN_PERF_NO_ASYNC_BUFFER_CREATE = 1ull << 1, VN_PERF_NO_ASYNC_QUEUE_SUBMIT = 1ull << 2, VN_PERF_NO_EVENT_FEEDBACK = 1ull << 3, + VN_PERF_NO_FENCE_FEEDBACK = 1ull << 4, }; typedef uint64_t vn_object_id; diff --git a/src/virtio/vulkan/vn_physical_device.c b/src/virtio/vulkan/vn_physical_device.c index 1ba46ad9664..5fa1a3ee47e 100644 --- a/src/virtio/vulkan/vn_physical_device.c +++ b/src/virtio/vulkan/vn_physical_device.c @@ -164,6 +164,30 @@ vn_physical_device_init_features(struct vn_physical_device *physical_dev) feats->vulkan_1_0 = features2.features; + /* TODO allow sparse resource along with sync feedback + * + * vkQueueBindSparse relies on explicit sync primitives. To intercept the + * timeline semaphores within each bind info to write the feedback buffer, + * we have to split the call into bindInfoCount number of calls while + * inserting vkQueueSubmit to wait on the signal timeline semaphores before + * filling the feedback buffer. To intercept the fence to be signaled, we + * have to relocate the fence to another vkQueueSubmit call and potentially + * have to use an internal timeline semaphore to synchronize between them. + * Those would make the code overly complex, so we disable sparse binding + * for simplicity. + */ + if (!VN_PERF(NO_FENCE_FEEDBACK)) { + feats->vulkan_1_0.sparseBinding = false; + feats->vulkan_1_0.sparseResidencyBuffer = false; + feats->vulkan_1_0.sparseResidencyImage2D = false; + feats->vulkan_1_0.sparseResidencyImage3D = false; + feats->vulkan_1_0.sparseResidency2Samples = false; + feats->vulkan_1_0.sparseResidency4Samples = false; + feats->vulkan_1_0.sparseResidency8Samples = false; + feats->vulkan_1_0.sparseResidency16Samples = false; + feats->vulkan_1_0.sparseResidencyAliased = false; + } + struct VkPhysicalDeviceVulkan11Features *vk11_feats = &feats->vulkan_1_1; struct VkPhysicalDeviceVulkan12Features *vk12_feats = &feats->vulkan_1_2; @@ -466,6 +490,13 @@ vn_physical_device_init_properties(struct vn_physical_device *physical_dev) props->vulkan_1_0 = properties2.properties; + /* TODO allow sparse resource along with sync feedback */ + if (!VN_PERF(NO_FENCE_FEEDBACK)) { + props->vulkan_1_0.limits.sparseAddressSpaceSize = 0; + props->vulkan_1_0.sparseProperties = + (VkPhysicalDeviceSparseProperties){ 0 }; + } + struct VkPhysicalDeviceProperties *vk10_props = &props->vulkan_1_0; struct VkPhysicalDeviceVulkan11Properties *vk11_props = &props->vulkan_1_1; struct VkPhysicalDeviceVulkan12Properties *vk12_props = &props->vulkan_1_2; diff --git a/src/virtio/vulkan/vn_queue.c b/src/virtio/vulkan/vn_queue.c index 37f8ebe1f71..e50d28b2eaf 100644 --- a/src/virtio/vulkan/vn_queue.c +++ b/src/virtio/vulkan/vn_queue.c @@ -392,6 +392,9 @@ vn_QueueBindSparse(VkQueue _queue, struct vn_queue *queue = vn_queue_from_handle(_queue); struct vn_device *dev = queue->device; + /* TODO allow sparse resource along with sync feedback */ + assert(VN_PERF(NO_FENCE_FEEDBACK)); + struct vn_queue_submission submit; VkResult result = vn_queue_submission_prepare_bind_sparse( &submit, _queue, bindInfoCount, pBindInfo, fence);