mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-04 19:29:15 +01:00
[d3d9] Rework device reset detection
More robust.
This commit is contained in:
parent
f9c3dd1f5f
commit
3dbe8ad43c
@ -539,7 +539,7 @@ namespace dxvk {
|
||||
SynchronizeCsThread(DxvkCsThread::SynchronizeAll);
|
||||
|
||||
if (m_d3d9Options.deferSurfaceCreation)
|
||||
m_deviceHasBeenReset = true;
|
||||
m_resetCtr++;
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
@ -1143,12 +1143,12 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Returns whether the device has been reset and marks it as true.
|
||||
* \brief Queries current reset counter
|
||||
* Used for the deferred surface creation workaround.
|
||||
* (Device Reset detection for D3D9SwapChainEx::Present)
|
||||
*/
|
||||
bool IsDeviceReset() {
|
||||
return std::exchange(m_deviceHasBeenReset, false);
|
||||
uint32_t GetResetCounter() {
|
||||
return m_resetCtr;
|
||||
}
|
||||
|
||||
template <bool Synchronize9On12>
|
||||
@ -1513,7 +1513,7 @@ namespace dxvk {
|
||||
VkImageLayout m_hazardLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
|
||||
bool m_usingGraphicsPipelines = false;
|
||||
bool m_deviceHasBeenReset = false;
|
||||
uint32_t m_resetCtr = 0u;
|
||||
|
||||
DxvkDepthBiasRepresentation m_depthBiasRepresentation = { VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORMAT_EXT, false };
|
||||
float m_depthBiasScale = 0.0f;
|
||||
|
@ -151,7 +151,7 @@ namespace dxvk {
|
||||
if (!UpdateWindowCtx())
|
||||
return D3D_OK;
|
||||
|
||||
if (options->deferSurfaceCreation && m_parent->IsDeviceReset())
|
||||
if (options->deferSurfaceCreation && IsDeviceReset(m_wctx))
|
||||
m_wctx->presenter->invalidateSurface();
|
||||
|
||||
m_wctx->presenter->setSyncInterval(presentInterval);
|
||||
@ -1272,6 +1272,18 @@ namespace dxvk {
|
||||
return this->GetParent()->IsExtended() ? "D3D9Ex" : "D3D9";
|
||||
}
|
||||
|
||||
|
||||
bool D3D9SwapChainEx::IsDeviceReset(D3D9WindowContext* wctx) {
|
||||
uint32_t counter = m_parent->GetResetCounter();
|
||||
|
||||
if (counter == wctx->deviceResetCounter)
|
||||
return false;
|
||||
|
||||
wctx->deviceResetCounter = counter;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
D3D9VkExtSwapchain::D3D9VkExtSwapchain(D3D9SwapChainEx *pSwapChain)
|
||||
: m_swapchain(pSwapChain) {
|
||||
|
||||
|
@ -55,6 +55,8 @@ namespace dxvk {
|
||||
|
||||
uint64_t frameId = D3D9DeviceEx::MaxFrameLatency;
|
||||
Rc<sync::Fence> frameLatencySignal;
|
||||
|
||||
uint32_t deviceResetCounter = 0u;
|
||||
};
|
||||
|
||||
using D3D9SwapChainExBase = D3D9DeviceChild<IDirect3DSwapChain9Ex>;
|
||||
@ -228,6 +230,8 @@ namespace dxvk {
|
||||
|
||||
std::string GetApiName();
|
||||
|
||||
bool IsDeviceReset(D3D9WindowContext* wctx);
|
||||
|
||||
const Com<D3D9Surface, false>& GetFrontBuffer() const {
|
||||
return m_backBuffers.back();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user