mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxvk] Implement asynchronous presentation option in the backend
This commit is contained in:
parent
77fde83479
commit
a558f82b5f
13
dxvk.conf
13
dxvk.conf
@ -183,6 +183,19 @@
|
|||||||
# dxvk.numCompilerThreads = 0
|
# dxvk.numCompilerThreads = 0
|
||||||
|
|
||||||
|
|
||||||
|
# Toggles asynchronous present.
|
||||||
|
#
|
||||||
|
# Off-loads presentation to the queue submission thread in
|
||||||
|
# order to reduce stalling on the main rendering thread and
|
||||||
|
# improve performance.
|
||||||
|
#
|
||||||
|
# Supported values:
|
||||||
|
# - Auto: Enable on certain drivers
|
||||||
|
# - True / False: Always enable / disable
|
||||||
|
|
||||||
|
# dxvk.asyncPresent = Auto
|
||||||
|
|
||||||
|
|
||||||
# Toggles raw SSBO usage.
|
# Toggles raw SSBO usage.
|
||||||
#
|
#
|
||||||
# Uses storage buffers to implement raw and structured buffer
|
# Uses storage buffers to implement raw and structured buffer
|
||||||
|
@ -6,6 +6,7 @@ namespace dxvk {
|
|||||||
enableStateCache = config.getOption<bool> ("dxvk.enableStateCache", true);
|
enableStateCache = config.getOption<bool> ("dxvk.enableStateCache", true);
|
||||||
enableTransferQueue = config.getOption<bool> ("dxvk.enableTransferQueue", true);
|
enableTransferQueue = config.getOption<bool> ("dxvk.enableTransferQueue", true);
|
||||||
numCompilerThreads = config.getOption<int32_t> ("dxvk.numCompilerThreads", 0);
|
numCompilerThreads = config.getOption<int32_t> ("dxvk.numCompilerThreads", 0);
|
||||||
|
asyncPresent = config.getOption<Tristate>("dxvk.asyncPresent", Tristate::Auto);
|
||||||
useRawSsbo = config.getOption<Tristate>("dxvk.useRawSsbo", Tristate::Auto);
|
useRawSsbo = config.getOption<Tristate>("dxvk.useRawSsbo", Tristate::Auto);
|
||||||
useEarlyDiscard = config.getOption<Tristate>("dxvk.useEarlyDiscard", Tristate::Auto);
|
useEarlyDiscard = config.getOption<Tristate>("dxvk.useEarlyDiscard", Tristate::Auto);
|
||||||
hud = config.getOption<std::string>("dxvk.hud", "");
|
hud = config.getOption<std::string>("dxvk.hud", "");
|
||||||
|
@ -18,6 +18,9 @@ namespace dxvk {
|
|||||||
/// when using the state cache
|
/// when using the state cache
|
||||||
int32_t numCompilerThreads;
|
int32_t numCompilerThreads;
|
||||||
|
|
||||||
|
/// Asynchronous presentation
|
||||||
|
Tristate asyncPresent;
|
||||||
|
|
||||||
/// Shader-related options
|
/// Shader-related options
|
||||||
Tristate useRawSsbo;
|
Tristate useRawSsbo;
|
||||||
Tristate useEarlyDiscard;
|
Tristate useEarlyDiscard;
|
||||||
|
@ -7,7 +7,12 @@ namespace dxvk {
|
|||||||
: m_device(device),
|
: m_device(device),
|
||||||
m_submitThread([this] () { submitCmdLists(); }),
|
m_submitThread([this] () { submitCmdLists(); }),
|
||||||
m_finishThread([this] () { finishCmdLists(); }) {
|
m_finishThread([this] () { finishCmdLists(); }) {
|
||||||
|
// Asynchronous presentation seems to increase the
|
||||||
|
// likelyhood of hangs on Nvidia for some reason.
|
||||||
|
m_asyncPresent = !m_device->adapter()->matchesDriver(
|
||||||
|
DxvkGpuVendor::Nvidia, VK_DRIVER_ID_NVIDIA_PROPRIETARY_KHR, 0, 0);
|
||||||
|
|
||||||
|
applyTristate(m_asyncPresent, m_device->config().asyncPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -43,12 +48,21 @@ namespace dxvk {
|
|||||||
void DxvkSubmissionQueue::present(DxvkPresentInfo presentInfo, DxvkSubmitStatus* status) {
|
void DxvkSubmissionQueue::present(DxvkPresentInfo presentInfo, DxvkSubmitStatus* status) {
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
|
||||||
DxvkSubmitEntry entry = { };
|
if (m_asyncPresent) {
|
||||||
entry.status = status;
|
DxvkSubmitEntry entry = { };
|
||||||
entry.present = std::move(presentInfo);
|
entry.status = status;
|
||||||
|
entry.present = std::move(presentInfo);
|
||||||
|
|
||||||
m_submitQueue.push(std::move(entry));
|
m_submitQueue.push(std::move(entry));
|
||||||
m_appendCond.notify_all();
|
m_appendCond.notify_all();
|
||||||
|
} else {
|
||||||
|
m_submitCond.wait(lock, [this] {
|
||||||
|
return m_submitQueue.empty();
|
||||||
|
});
|
||||||
|
|
||||||
|
VkResult result = presentInfo.presenter->presentImage(presentInfo.waitSync);
|
||||||
|
status->result.store(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,6 +156,7 @@ namespace dxvk {
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
DxvkDevice* m_device;
|
DxvkDevice* m_device;
|
||||||
|
bool m_asyncPresent;
|
||||||
|
|
||||||
std::atomic<bool> m_stopped = { false };
|
std::atomic<bool> m_stopped = { false };
|
||||||
std::atomic<uint32_t> m_pending = { 0u };
|
std::atomic<uint32_t> m_pending = { 0u };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user