mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-04 07:24:15 +01:00
[dxgi] Implement IDXGIDevice::SetMaximumFrameLatency
We'll be doing the CPU synchronization with DXVK events during presentation.
This commit is contained in:
parent
0fd8019a70
commit
fd55520301
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
|
constexpr uint32_t DxgiDevice::DefaultFrameLatency;
|
||||||
|
|
||||||
DxgiDevice::DxgiDevice(
|
DxgiDevice::DxgiDevice(
|
||||||
IDXGIObject* pContainer,
|
IDXGIObject* pContainer,
|
||||||
IDXGIVkAdapter* pAdapter,
|
IDXGIVkAdapter* pAdapter,
|
||||||
@ -10,6 +12,9 @@ namespace dxvk {
|
|||||||
: m_container (pContainer),
|
: m_container (pContainer),
|
||||||
m_adapter (pAdapter) {
|
m_adapter (pAdapter) {
|
||||||
m_device = m_adapter->GetDXVKAdapter()->createDevice(*pFeatures);
|
m_device = m_adapter->GetDXVKAdapter()->createDevice(*pFeatures);
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < m_frameEvents.size(); i++)
|
||||||
|
m_frameEvents[i] = new DxvkEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -107,15 +112,20 @@ namespace dxvk {
|
|||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE DxgiDevice::GetMaximumFrameLatency(
|
HRESULT STDMETHODCALLTYPE DxgiDevice::GetMaximumFrameLatency(
|
||||||
UINT* pMaxLatency) {
|
UINT* pMaxLatency) {
|
||||||
Logger::warn("DxgiDevice::GetMaximumFrameLatency: Stub");
|
*pMaxLatency = m_frameLatency;
|
||||||
*pMaxLatency = 1;
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE DxgiDevice::SetMaximumFrameLatency(
|
HRESULT STDMETHODCALLTYPE DxgiDevice::SetMaximumFrameLatency(
|
||||||
UINT MaxLatency) {
|
UINT MaxLatency) {
|
||||||
Logger::warn("DxgiDevice::SetMaximumFrameLatency: Stub");
|
if (MaxLatency == 0)
|
||||||
|
MaxLatency = DefaultFrameLatency;
|
||||||
|
|
||||||
|
if (MaxLatency > m_frameEvents.size())
|
||||||
|
MaxLatency = m_frameEvents.size();
|
||||||
|
|
||||||
|
m_frameLatency = MaxLatency;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,4 +159,10 @@ namespace dxvk {
|
|||||||
return m_device;
|
return m_device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Rc<DxvkEvent> STDMETHODCALLTYPE DxgiDevice::GetFrameSyncEvent() {
|
||||||
|
uint32_t frameId = m_frameId++ % m_frameLatency;
|
||||||
|
return m_frameEvents[frameId];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ namespace dxvk {
|
|||||||
class DxgiFactory;
|
class DxgiFactory;
|
||||||
|
|
||||||
class DxgiDevice : public IDXGIVkDevice {
|
class DxgiDevice : public IDXGIVkDevice {
|
||||||
|
constexpr static uint32_t DefaultFrameLatency = 3;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DxgiDevice(
|
DxgiDevice(
|
||||||
@ -87,6 +87,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
Rc<DxvkDevice> STDMETHODCALLTYPE GetDXVKDevice() final;
|
Rc<DxvkDevice> STDMETHODCALLTYPE GetDXVKDevice() final;
|
||||||
|
|
||||||
|
Rc<DxvkEvent> STDMETHODCALLTYPE GetFrameSyncEvent();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
IDXGIObject* m_container;
|
IDXGIObject* m_container;
|
||||||
@ -94,6 +96,11 @@ namespace dxvk {
|
|||||||
Com<IDXGIVkAdapter> m_adapter;
|
Com<IDXGIVkAdapter> m_adapter;
|
||||||
Rc<DxvkDevice> m_device;
|
Rc<DxvkDevice> m_device;
|
||||||
|
|
||||||
|
uint32_t m_frameLatency = DefaultFrameLatency;
|
||||||
|
uint32_t m_frameId = 0;
|
||||||
|
|
||||||
|
std::array<Rc<DxvkEvent>, 16> m_frameEvents;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user