mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-05 01:24:14 +01:00
[dxvk] Add callback to lock submission queue
Can be used to perform additional synchronization as necessary.
This commit is contained in:
parent
56a8fa2e6f
commit
35895ba05b
@ -543,7 +543,7 @@ namespace dxvk {
|
||||
queues.transfer = getDeviceQueue(vkd, queueFamilies.transfer, 0);
|
||||
queues.sparse = getDeviceQueue(vkd, queueFamilies.sparse, 0);
|
||||
|
||||
return new DxvkDevice(instance, this, vkd, enabledFeatures, queues);
|
||||
return new DxvkDevice(instance, this, vkd, enabledFeatures, queues, DxvkQueueCallback());
|
||||
}
|
||||
|
||||
|
||||
@ -655,7 +655,7 @@ namespace dxvk {
|
||||
queues.graphics = { args.queue, args.queueFamily };
|
||||
queues.transfer = queues.graphics;
|
||||
|
||||
return new DxvkDevice(instance, this, vkd, enabledFeatures, queues);
|
||||
return new DxvkDevice(instance, this, vkd, enabledFeatures, queues, args.queueCallback);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
|
||||
#include "dxvk_device_info.h"
|
||||
@ -12,6 +13,8 @@ namespace dxvk {
|
||||
class DxvkDevice;
|
||||
class DxvkInstance;
|
||||
|
||||
using DxvkQueueCallback = std::function<void (bool)>;
|
||||
|
||||
/**
|
||||
* \brief GPU vendors
|
||||
* Based on PCIe IDs.
|
||||
@ -65,6 +68,7 @@ namespace dxvk {
|
||||
uint32_t extensionCount;
|
||||
const char** extensionNames;
|
||||
const VkPhysicalDeviceFeatures2* features;
|
||||
DxvkQueueCallback queueCallback;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -8,7 +8,8 @@ namespace dxvk {
|
||||
const Rc<DxvkAdapter>& adapter,
|
||||
const Rc<vk::DeviceFn>& vkd,
|
||||
const DxvkDeviceFeatures& features,
|
||||
const DxvkDeviceQueueSet& queues)
|
||||
const DxvkDeviceQueueSet& queues,
|
||||
const DxvkQueueCallback& queueCallback)
|
||||
: m_options (instance->options()),
|
||||
m_instance (instance),
|
||||
m_adapter (adapter),
|
||||
@ -18,7 +19,7 @@ namespace dxvk {
|
||||
m_perfHints (getPerfHints()),
|
||||
m_objects (this),
|
||||
m_queues (queues),
|
||||
m_submissionQueue (this) {
|
||||
m_submissionQueue (this, queueCallback) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,8 @@ namespace dxvk {
|
||||
const Rc<DxvkAdapter>& adapter,
|
||||
const Rc<vk::DeviceFn>& vkd,
|
||||
const DxvkDeviceFeatures& features,
|
||||
const DxvkDeviceQueueSet& queues);
|
||||
const DxvkDeviceQueueSet& queues,
|
||||
const DxvkQueueCallback& queueCallback);
|
||||
|
||||
~DxvkDevice();
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
DxvkSubmissionQueue::DxvkSubmissionQueue(DxvkDevice* device)
|
||||
: m_device(device),
|
||||
DxvkSubmissionQueue::DxvkSubmissionQueue(DxvkDevice* device, const DxvkQueueCallback& callback)
|
||||
: m_device(device), m_callback(callback),
|
||||
m_submitThread([this] () { submitCmdLists(); }),
|
||||
m_finishThread([this] () { finishCmdLists(); }) {
|
||||
|
||||
@ -75,10 +75,16 @@ namespace dxvk {
|
||||
|
||||
void DxvkSubmissionQueue::lockDeviceQueue() {
|
||||
m_mutexQueue.lock();
|
||||
|
||||
if (m_callback)
|
||||
m_callback(true);
|
||||
}
|
||||
|
||||
|
||||
void DxvkSubmissionQueue::unlockDeviceQueue() {
|
||||
if (m_callback)
|
||||
m_callback(false);
|
||||
|
||||
m_mutexQueue.unlock();
|
||||
}
|
||||
|
||||
@ -105,10 +111,16 @@ namespace dxvk {
|
||||
if (m_lastError != VK_ERROR_DEVICE_LOST) {
|
||||
std::lock_guard<dxvk::mutex> lock(m_mutexQueue);
|
||||
|
||||
if (m_callback)
|
||||
m_callback(true);
|
||||
|
||||
if (entry.submit.cmdList != nullptr)
|
||||
status = entry.submit.cmdList->submit();
|
||||
else if (entry.present.presenter != nullptr)
|
||||
status = entry.present.presenter->presentImage();
|
||||
|
||||
if (m_callback)
|
||||
m_callback(false);
|
||||
} else {
|
||||
// Don't submit anything after device loss
|
||||
// so that drivers get a chance to recover
|
||||
|
@ -64,7 +64,10 @@ namespace dxvk {
|
||||
|
||||
public:
|
||||
|
||||
DxvkSubmissionQueue(DxvkDevice* device);
|
||||
DxvkSubmissionQueue(
|
||||
DxvkDevice* device,
|
||||
const DxvkQueueCallback& callback);
|
||||
|
||||
~DxvkSubmissionQueue();
|
||||
|
||||
/**
|
||||
@ -176,6 +179,7 @@ namespace dxvk {
|
||||
private:
|
||||
|
||||
DxvkDevice* m_device;
|
||||
DxvkQueueCallback m_callback;
|
||||
|
||||
std::atomic<VkResult> m_lastError = { VK_SUCCESS };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user