1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-22 16:54:27 +01:00

[d3d11] Ignore explicit flush if there are unresolved render targets

Cursed perf hack for some Unity Engine games.
This commit is contained in:
Philip Rebohle 2025-02-10 22:27:37 +01:00
parent e31c84640d
commit 10ca8d3ef5
4 changed files with 30 additions and 2 deletions

View File

@ -156,6 +156,7 @@ namespace dxvk {
void STDMETHODCALLTYPE D3D11ImmediateContext::Flush() {
D3D10DeviceLock lock = LockContext();
if (!IgnoreExplicitFlush())
ExecuteFlush(GpuFlushType::ExplicitFlush, nullptr, true);
}
@ -165,6 +166,7 @@ namespace dxvk {
HANDLE hEvent) {
D3D10DeviceLock lock = LockContext();
if (!IgnoreExplicitFlush())
ExecuteFlush(GpuFlushType::ExplicitFlush, hEvent, true);
}
@ -1078,6 +1080,22 @@ namespace dxvk {
}
bool D3D11ImmediateContext::IgnoreExplicitFlush() {
// This is sketchy in general since not respecting an explicit flush can
// keep resources alive indefinitely when they shouldn't be. Only do this
// in tiler mode if flushing would prevent resolve optimizations, and if
// we don't break submission order w.r.t. other D3D devices.
if (!m_device->perfHints().preferRenderPassOps)
return false;
if (m_parent->Is11on12Device()
|| m_parent->HasSharedResources())
return false;
return m_hasPendingMsaaResolve;
}
GpuFlushType D3D11ImmediateContext::GetMaxFlushType(
D3D11Device* pParent,
const Rc<DxvkDevice>& Device) {

View File

@ -210,6 +210,8 @@ namespace dxvk {
DxvkStagingBufferStats GetStagingMemoryStatistics();
bool IgnoreExplicitFlush();
static GpuFlushType GetMaxFlushType(
D3D11Device* pParent,
const Rc<DxvkDevice>& Device);

View File

@ -2375,6 +2375,8 @@ namespace dxvk {
Logger::err(e.message());
return E_INVALIDARG;
}
m_hasSharedResources.store(true, std::memory_order_release);
#else
Logger::warn("D3D11Device::OpenSharedResourceGeneric: Not supported on this platform.");
return E_INVALIDARG;

View File

@ -464,6 +464,10 @@ namespace dxvk {
bool Is11on12Device() const;
bool HasSharedResources() const {
return m_hasSharedResources.load(std::memory_order_acquire);
}
static D3D_FEATURE_LEVEL GetMaxFeatureLevel(
const Rc<DxvkInstance>& Instance,
const Rc<DxvkAdapter>& Adapter);
@ -512,6 +516,8 @@ namespace dxvk {
D3D_FEATURE_LEVEL m_maxFeatureLevel;
D3D11DeviceFeatures m_deviceFeatures;
std::atomic<bool> m_hasSharedResources = { false };
HRESULT CreateShaderModule(
D3D11CommonShader* pShaderModule,
DxvkShaderKey ShaderKey,