[Vulkan] Submissions
This commit is contained in:
@@ -737,10 +737,9 @@ void VulkanContext::EndSwap() {
|
||||
return;
|
||||
}
|
||||
|
||||
const VulkanProvider& provider = GetVulkanProvider();
|
||||
VulkanProvider& provider = GetVulkanProvider();
|
||||
const VulkanProvider::DeviceFunctions& dfn = provider.dfn();
|
||||
VkDevice device = provider.device();
|
||||
VkQueue queue_graphics_compute = provider.queue_graphics_compute();
|
||||
|
||||
const SwapSubmission& submission =
|
||||
swap_submissions_[swap_submission_current_ % kSwapchainMaxImageCount];
|
||||
@@ -771,8 +770,8 @@ void VulkanContext::EndSwap() {
|
||||
submit_info.pCommandBuffers = submit_command_buffers;
|
||||
submit_info.signalSemaphoreCount = 1;
|
||||
submit_info.pSignalSemaphores = &swap_render_completion_semaphore_;
|
||||
VkResult submit_result = dfn.vkQueueSubmit(queue_graphics_compute, 1,
|
||||
&submit_info, submission.fence);
|
||||
VkResult submit_result =
|
||||
provider.SubmitToGraphicsComputeQueue(1, &submit_info, submission.fence);
|
||||
if (submit_result != VK_SUCCESS) {
|
||||
// If failed, can't even return the swapchain image - so treat all errors as
|
||||
// context loss.
|
||||
@@ -790,10 +789,7 @@ void VulkanContext::EndSwap() {
|
||||
present_info.pSwapchains = &swap_swapchain_;
|
||||
present_info.pImageIndices = &swap_swapchain_image_current_;
|
||||
present_info.pResults = nullptr;
|
||||
// FIXME(Triang3l): Allow a separate queue for present - see
|
||||
// vulkan_provider.cc for details.
|
||||
VkResult present_result =
|
||||
dfn.vkQueuePresentKHR(queue_graphics_compute, &present_info);
|
||||
VkResult present_result = provider.Present(&present_info);
|
||||
swap_swapchain_image_current_ = UINT32_MAX;
|
||||
switch (present_result) {
|
||||
case VK_SUCCESS:
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "xenia/ui/vulkan/vulkan_immediate_drawer.h"
|
||||
#include "xenia/ui/vulkan/vulkan_provider.h"
|
||||
|
||||
#define FINE_GRAINED_DRAW_SCOPES 1
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
namespace vulkan {
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/platform.h"
|
||||
#include "xenia/ui/graphics_provider.h"
|
||||
|
||||
@@ -193,9 +195,22 @@ class VulkanProvider : public GraphicsProvider {
|
||||
};
|
||||
const DeviceFunctions& dfn() const { return dfn_; }
|
||||
|
||||
VkQueue queue_graphics_compute() const { return queue_graphics_compute_; }
|
||||
// May be VK_NULL_HANDLE if not available.
|
||||
VkQueue queue_sparse_binding() const { return queue_sparse_binding_; }
|
||||
VkResult SubmitToGraphicsComputeQueue(uint32_t submit_count,
|
||||
const VkSubmitInfo* submits,
|
||||
VkFence fence) {
|
||||
std::lock_guard<std::mutex> lock(queue_graphics_compute_mutex_);
|
||||
return dfn_.vkQueueSubmit(queue_graphics_compute_, submit_count, submits,
|
||||
fence);
|
||||
}
|
||||
bool CanSubmitSparseBindings() const {
|
||||
return queue_sparse_binding_ != VK_NULL_HANDLE;
|
||||
}
|
||||
VkResult Present(const VkPresentInfoKHR* present_info) {
|
||||
// FIXME(Triang3l): Allow a separate queue for present - see
|
||||
// vulkan_provider.cc for details.
|
||||
std::lock_guard<std::mutex> lock(queue_graphics_compute_mutex_);
|
||||
return dfn_.vkQueuePresentKHR(queue_graphics_compute_, present_info);
|
||||
}
|
||||
|
||||
// Samplers that may be useful for host needs. Only these samplers should be
|
||||
// used in host, non-emulation contexts, because the total number of samplers
|
||||
@@ -242,8 +257,14 @@ class VulkanProvider : public GraphicsProvider {
|
||||
VkDevice device_ = VK_NULL_HANDLE;
|
||||
DeviceFunctions dfn_ = {};
|
||||
VkQueue queue_graphics_compute_;
|
||||
// VkQueue access must be externally synchronized - must be locked when
|
||||
// submitting anything.
|
||||
std::mutex queue_graphics_compute_mutex_;
|
||||
// May be VK_NULL_HANDLE if not available.
|
||||
VkQueue queue_sparse_binding_;
|
||||
// If queue_sparse_binding_ == queue_graphics_compute_, lock
|
||||
// queue_graphics_compute_mutex_ instead when submitting sparse bindings.
|
||||
std::mutex queue_sparse_binding_separate_mutex_;
|
||||
|
||||
VkSampler host_samplers_[size_t(HostSampler::kCount)] = {};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user