mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-12 13:08:50 +01:00
[d3d11] Consider flushing after each CS chunk
This way we will never end up with overly long command lists.
This commit is contained in:
parent
2a3d7ee7dc
commit
591e2df701
@ -4918,8 +4918,10 @@ namespace dxvk {
|
||||
if (needsUpdate) {
|
||||
BindFramebuffer();
|
||||
|
||||
if constexpr (!IsDeferred)
|
||||
if constexpr (!IsDeferred) {
|
||||
// Doing this makes it less likely to flush during render passes
|
||||
GetTypedContext()->ConsiderFlush(GpuFlushType::ImplicitWeakHint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include "../d3d10/d3d10_multithread.h"
|
||||
|
||||
#include "../util/util_flush.h"
|
||||
|
||||
#include "d3d11_annotation.h"
|
||||
#include "d3d11_buffer.h"
|
||||
#include "d3d11_cmd.h"
|
||||
@ -1064,27 +1066,35 @@ namespace dxvk {
|
||||
DxvkMultisampleState* pMsState,
|
||||
UINT SampleMask);
|
||||
|
||||
template<typename Cmd>
|
||||
template<bool AllowFlush = !IsDeferred, typename Cmd>
|
||||
void EmitCs(Cmd&& command) {
|
||||
m_cmdData = nullptr;
|
||||
|
||||
if (unlikely(!m_csChunk->push(command))) {
|
||||
GetTypedContext()->EmitCsChunk(std::move(m_csChunk));
|
||||
|
||||
m_csChunk = AllocCsChunk();
|
||||
|
||||
if constexpr (AllowFlush)
|
||||
GetTypedContext()->ConsiderFlush(GpuFlushType::ImplicitWeakHint);
|
||||
|
||||
m_csChunk->push(command);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename M, typename Cmd, typename... Args>
|
||||
template<typename M, bool AllowFlush = !IsDeferred, typename Cmd, typename... Args>
|
||||
M* EmitCsCmd(Cmd&& command, Args&&... args) {
|
||||
M* data = m_csChunk->pushCmd<M, Cmd, Args...>(
|
||||
command, std::forward<Args>(args)...);
|
||||
|
||||
if (unlikely(!data)) {
|
||||
GetTypedContext()->EmitCsChunk(std::move(m_csChunk));
|
||||
|
||||
m_csChunk = AllocCsChunk();
|
||||
|
||||
if constexpr (AllowFlush)
|
||||
GetTypedContext()->ConsiderFlush(GpuFlushType::ImplicitWeakHint);
|
||||
|
||||
// We must record this command after the potential
|
||||
// flush since the caller may still access the data
|
||||
data = m_csChunk->pushCmd<M, Cmd, Args...>(
|
||||
command, std::forward<Args>(args)...);
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ namespace dxvk {
|
||||
// As an optimization, flush everything if the
|
||||
// number of pending draw calls is high enough.
|
||||
ConsiderFlush(GpuFlushType::ImplicitWeakHint);
|
||||
|
||||
|
||||
// Dispatch command list to the CS thread and
|
||||
// restore the immediate context's state
|
||||
uint64_t csSeqNum = commandList->EmitToCsThread(&m_csThread);
|
||||
@ -247,7 +247,7 @@ namespace dxvk {
|
||||
else
|
||||
ResetContextState();
|
||||
|
||||
// Flush after if the command list was sufficiently long
|
||||
// Flush again if the command list was sufficiently long
|
||||
ConsiderFlush(GpuFlushType::ImplicitWeakHint);
|
||||
}
|
||||
|
||||
@ -378,8 +378,6 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
if (doInvalidatePreserve) {
|
||||
ConsiderFlush(GpuFlushType::ImplicitWeakHint);
|
||||
|
||||
auto prevSlice = pResource->GetMappedSlice();
|
||||
auto physSlice = pResource->DiscardSlice();
|
||||
|
||||
@ -525,8 +523,6 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
if (doFlags & DoInvalidate) {
|
||||
ConsiderFlush(GpuFlushType::ImplicitWeakHint);
|
||||
|
||||
DxvkBufferSliceHandle prevSlice = pResource->GetMappedSlice(Subresource);
|
||||
DxvkBufferSliceHandle physSlice = pResource->DiscardSlice(Subresource);
|
||||
|
||||
@ -770,7 +766,7 @@ namespace dxvk {
|
||||
void D3D11ImmediateContext::EndFrame() {
|
||||
D3D10DeviceLock lock = LockContext();
|
||||
|
||||
EmitCs([] (DxvkContext* ctx) {
|
||||
EmitCs<false>([] (DxvkContext* ctx) {
|
||||
ctx->endFrame();
|
||||
});
|
||||
}
|
||||
@ -887,7 +883,7 @@ namespace dxvk {
|
||||
});
|
||||
}
|
||||
|
||||
EmitCs([
|
||||
EmitCs<false>([
|
||||
cSubmissionFence = m_submissionFence,
|
||||
cSubmissionId = submissionId
|
||||
] (DxvkContext* ctx) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "../util/util_flush.h"
|
||||
#include "../util/util_time.h"
|
||||
|
||||
#include "../util/sync/sync_signal.h"
|
||||
|
Loading…
Reference in New Issue
Block a user