[Vulkan] Sparse shared memory

This commit is contained in:
Triang3l
2020-10-07 21:03:50 +03:00
parent fee2189d39
commit 4d59f556a9
7 changed files with 298 additions and 68 deletions

View File

@@ -30,7 +30,7 @@ DEFINE_bool(
vulkan_validation, true,
"Enable Vulkan validation (VK_LAYER_KHRONOS_validation). Messages will be "
"written to the OS debug log.",
"GPU");
"Vulkan");
DEFINE_int32(
vulkan_device, -1,
"Index of the physical device to use, or -1 for any compatible device.",
@@ -587,6 +587,7 @@ bool VulkanProvider::Initialize() {
XE_VULKAN_LOAD_DFN(vkMapMemory);
XE_VULKAN_LOAD_DFN(vkResetCommandPool);
XE_VULKAN_LOAD_DFN(vkResetFences);
XE_VULKAN_LOAD_DFN(vkQueueBindSparse);
XE_VULKAN_LOAD_DFN(vkQueuePresentKHR);
XE_VULKAN_LOAD_DFN(vkQueueSubmit);
XE_VULKAN_LOAD_DFN(vkUnmapMemory);

View File

@@ -190,6 +190,7 @@ class VulkanProvider : public GraphicsProvider {
PFN_vkMapMemory vkMapMemory;
PFN_vkResetCommandPool vkResetCommandPool;
PFN_vkResetFences vkResetFences;
PFN_vkQueueBindSparse vkQueueBindSparse;
PFN_vkQueuePresentKHR vkQueuePresentKHR;
PFN_vkQueueSubmit vkQueueSubmit;
PFN_vkUnmapMemory vkUnmapMemory;
@@ -205,9 +206,21 @@ class VulkanProvider : public GraphicsProvider {
return dfn_.vkQueueSubmit(queue_graphics_compute_, submit_count, submits,
fence);
}
bool CanSubmitSparseBindings() const {
// Safer in Xenia context - in case a sparse binding queue was not obtained
// for some reason.
bool IsSparseBindingSupported() const {
return queue_sparse_binding_ != VK_NULL_HANDLE;
}
VkResult BindSparse(uint32_t bind_info_count,
const VkBindSparseInfo* bind_info, VkFence fence) {
assert_true(IsSparseBindingSupported());
std::mutex& mutex = queue_sparse_binding_ == queue_graphics_compute_
? queue_graphics_compute_mutex_
: queue_sparse_binding_separate_mutex_;
std::lock_guard<std::mutex> lock(mutex);
return dfn_.vkQueueBindSparse(queue_sparse_binding_, bind_info_count,
bind_info, fence);
}
VkResult Present(const VkPresentInfoKHR* present_info) {
// FIXME(Triang3l): Allow a separate queue for present - see
// vulkan_provider.cc for details.