mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 05:52:11 +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());
|
||||
immediateContext->Flush();
|
||||
|
||||
if (!m_device->hasAsyncPresent())
|
||||
immediateContext->SynchronizeCsThread();
|
||||
|
||||
// Wait for the sync event so that we respect the maximum frame latency
|
||||
auto syncEvent = m_dxgiDevice->GetFrameSyncEvent(m_desc.BufferCount);
|
||||
syncEvent->wait();
|
||||
@ -321,34 +318,22 @@ namespace dxvk {
|
||||
void D3D11SwapChain::SubmitPresent(
|
||||
D3D11ImmediateContext* pContext,
|
||||
const vk::PresenterSync& Sync) {
|
||||
if (m_device->hasAsyncPresent()) {
|
||||
// Present from CS thread so that we don't
|
||||
// have to synchronize with it first.
|
||||
m_presentStatus.result = VK_NOT_READY;
|
||||
// Present from CS thread so that we don't
|
||||
// have to synchronize with it first.
|
||||
m_presentStatus.result = VK_NOT_READY;
|
||||
|
||||
pContext->EmitCs([this,
|
||||
cSync = Sync,
|
||||
cCommandList = m_context->endRecording()
|
||||
] (DxvkContext* ctx) {
|
||||
m_device->submitCommandList(cCommandList,
|
||||
cSync.acquire, cSync.present);
|
||||
pContext->EmitCs([this,
|
||||
cSync = Sync,
|
||||
cCommandList = m_context->endRecording()
|
||||
] (DxvkContext* ctx) {
|
||||
m_device->submitCommandList(cCommandList,
|
||||
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,
|
||||
Sync.present, &m_presentStatus);
|
||||
cSync.present, &m_presentStatus);
|
||||
});
|
||||
|
||||
SynchronizePresent();
|
||||
}
|
||||
pContext->FlushCsChunk();
|
||||
}
|
||||
|
||||
|
||||
|
@ -401,17 +401,6 @@ namespace dxvk {
|
||||
VkSemaphore waitSync,
|
||||
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
|
||||
*
|
||||
|
@ -6,7 +6,6 @@ namespace dxvk {
|
||||
enableStateCache = config.getOption<bool> ("dxvk.enableStateCache", true);
|
||||
enableOpenVR = config.getOption<bool> ("dxvk.enableOpenVR", true);
|
||||
numCompilerThreads = config.getOption<int32_t> ("dxvk.numCompilerThreads", 0);
|
||||
asyncPresent = config.getOption<Tristate>("dxvk.asyncPresent", Tristate::Auto);
|
||||
useRawSsbo = config.getOption<Tristate>("dxvk.useRawSsbo", Tristate::Auto);
|
||||
useEarlyDiscard = config.getOption<Tristate>("dxvk.useEarlyDiscard", Tristate::Auto);
|
||||
hud = config.getOption<std::string>("dxvk.hud", "");
|
||||
|
@ -18,9 +18,6 @@ namespace dxvk {
|
||||
/// when using the state cache
|
||||
int32_t numCompilerThreads;
|
||||
|
||||
/// Asynchronous presentation
|
||||
Tristate asyncPresent;
|
||||
|
||||
/// Shader-related options
|
||||
Tristate useRawSsbo;
|
||||
Tristate useEarlyDiscard;
|
||||
|
@ -7,12 +7,7 @@ namespace dxvk {
|
||||
: m_device(device),
|
||||
m_submitThread([this] () { submitCmdLists(); }),
|
||||
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) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
|
||||
if (m_asyncPresent) {
|
||||
DxvkSubmitEntry entry = { };
|
||||
entry.status = status;
|
||||
entry.present = std::move(presentInfo);
|
||||
DxvkSubmitEntry entry = { };
|
||||
entry.status = status;
|
||||
entry.present = std::move(presentInfo);
|
||||
|
||||
m_submitQueue.push(std::move(entry));
|
||||
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);
|
||||
}
|
||||
m_submitQueue.push(std::move(entry));
|
||||
m_appendCond.notify_all();
|
||||
}
|
||||
|
||||
|
||||
|
@ -104,14 +104,6 @@ namespace dxvk {
|
||||
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
|
||||
*
|
||||
@ -175,7 +167,6 @@ namespace dxvk {
|
||||
private:
|
||||
|
||||
DxvkDevice* m_device;
|
||||
bool m_asyncPresent;
|
||||
|
||||
std::atomic<VkResult> m_lastError = { VK_SUCCESS };
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user