mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxvk] Enable asynchronous presentation on all hardware
...and remove the dxvk.asyncPresent option.
This commit is contained in:
parent
ceddbaf7c4
commit
6b3d60ab25
@ -205,9 +205,6 @@ namespace dxvk {
|
|||||||
auto immediateContext = static_cast<D3D11ImmediateContext*>(deviceContext.ptr());
|
auto immediateContext = static_cast<D3D11ImmediateContext*>(deviceContext.ptr());
|
||||||
immediateContext->Flush();
|
immediateContext->Flush();
|
||||||
|
|
||||||
if (!m_device->hasAsyncPresent())
|
|
||||||
immediateContext->SynchronizeCsThread();
|
|
||||||
|
|
||||||
// Wait for the sync event so that we respect the maximum frame latency
|
// Wait for the sync event so that we respect the maximum frame latency
|
||||||
auto syncEvent = m_dxgiDevice->GetFrameSyncEvent(m_desc.BufferCount);
|
auto syncEvent = m_dxgiDevice->GetFrameSyncEvent(m_desc.BufferCount);
|
||||||
syncEvent->wait();
|
syncEvent->wait();
|
||||||
@ -321,34 +318,22 @@ namespace dxvk {
|
|||||||
void D3D11SwapChain::SubmitPresent(
|
void D3D11SwapChain::SubmitPresent(
|
||||||
D3D11ImmediateContext* pContext,
|
D3D11ImmediateContext* pContext,
|
||||||
const vk::PresenterSync& Sync) {
|
const vk::PresenterSync& Sync) {
|
||||||
if (m_device->hasAsyncPresent()) {
|
// Present from CS thread so that we don't
|
||||||
// Present from CS thread so that we don't
|
// have to synchronize with it first.
|
||||||
// have to synchronize with it first.
|
m_presentStatus.result = VK_NOT_READY;
|
||||||
m_presentStatus.result = VK_NOT_READY;
|
|
||||||
|
|
||||||
pContext->EmitCs([this,
|
pContext->EmitCs([this,
|
||||||
cSync = Sync,
|
cSync = Sync,
|
||||||
cCommandList = m_context->endRecording()
|
cCommandList = m_context->endRecording()
|
||||||
] (DxvkContext* ctx) {
|
] (DxvkContext* ctx) {
|
||||||
m_device->submitCommandList(cCommandList,
|
m_device->submitCommandList(cCommandList,
|
||||||
cSync.acquire, cSync.present);
|
cSync.acquire, cSync.present);
|
||||||
|
|
||||||
m_device->presentImage(m_presenter,
|
|
||||||
cSync.present, &m_presentStatus);
|
|
||||||
});
|
|
||||||
|
|
||||||
pContext->FlushCsChunk();
|
|
||||||
} else {
|
|
||||||
// Safe path, present from calling thread
|
|
||||||
m_device->submitCommandList(
|
|
||||||
m_context->endRecording(),
|
|
||||||
Sync.acquire, Sync.present);
|
|
||||||
|
|
||||||
m_device->presentImage(m_presenter,
|
m_device->presentImage(m_presenter,
|
||||||
Sync.present, &m_presentStatus);
|
cSync.present, &m_presentStatus);
|
||||||
|
});
|
||||||
|
|
||||||
SynchronizePresent();
|
pContext->FlushCsChunk();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -401,17 +401,6 @@ namespace dxvk {
|
|||||||
VkSemaphore waitSync,
|
VkSemaphore waitSync,
|
||||||
VkSemaphore wakeSync);
|
VkSemaphore wakeSync);
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Checks for async presentation support
|
|
||||||
*
|
|
||||||
* If this is \c false, synchronize with the
|
|
||||||
* present call immediately after submitting it.
|
|
||||||
* \returns \c true if async present is enabled
|
|
||||||
*/
|
|
||||||
bool hasAsyncPresent() const {
|
|
||||||
return m_submissionQueue.hasAsyncPresent();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Locks submission queue
|
* \brief Locks submission queue
|
||||||
*
|
*
|
||||||
|
@ -6,7 +6,6 @@ namespace dxvk {
|
|||||||
enableStateCache = config.getOption<bool> ("dxvk.enableStateCache", true);
|
enableStateCache = config.getOption<bool> ("dxvk.enableStateCache", true);
|
||||||
enableOpenVR = config.getOption<bool> ("dxvk.enableOpenVR", true);
|
enableOpenVR = config.getOption<bool> ("dxvk.enableOpenVR", 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,9 +18,6 @@ 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,12 +7,7 @@ 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -48,21 +43,12 @@ 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);
|
||||||
|
|
||||||
if (m_asyncPresent) {
|
DxvkSubmitEntry entry = { };
|
||||||
DxvkSubmitEntry entry = { };
|
entry.status = status;
|
||||||
entry.status = status;
|
entry.present = std::move(presentInfo);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,14 +104,6 @@ namespace dxvk {
|
|||||||
return m_lastError.load();
|
return m_lastError.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Checks whether asynchronous presentation is supported
|
|
||||||
* \returns \c true if presentation is asynchronous
|
|
||||||
*/
|
|
||||||
bool hasAsyncPresent() const {
|
|
||||||
return m_asyncPresent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Submits a command list asynchronously
|
* \brief Submits a command list asynchronously
|
||||||
*
|
*
|
||||||
@ -175,7 +167,6 @@ namespace dxvk {
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
DxvkDevice* m_device;
|
DxvkDevice* m_device;
|
||||||
bool m_asyncPresent;
|
|
||||||
|
|
||||||
std::atomic<VkResult> m_lastError = { VK_SUCCESS };
|
std::atomic<VkResult> m_lastError = { VK_SUCCESS };
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user