mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-03 04:24:11 +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
@ -2,6 +2,8 @@
|
||||
#include "dxgi_factory.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
constexpr uint32_t DxgiDevice::DefaultFrameLatency;
|
||||
|
||||
DxgiDevice::DxgiDevice(
|
||||
IDXGIObject* pContainer,
|
||||
@ -10,6 +12,9 @@ namespace dxvk {
|
||||
: m_container (pContainer),
|
||||
m_adapter (pAdapter) {
|
||||
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(
|
||||
UINT* pMaxLatency) {
|
||||
Logger::warn("DxgiDevice::GetMaximumFrameLatency: Stub");
|
||||
*pMaxLatency = 1;
|
||||
*pMaxLatency = m_frameLatency;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE DxgiDevice::SetMaximumFrameLatency(
|
||||
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;
|
||||
}
|
||||
|
||||
@ -149,4 +159,10 @@ namespace dxvk {
|
||||
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 DxgiDevice : public IDXGIVkDevice {
|
||||
|
||||
constexpr static uint32_t DefaultFrameLatency = 3;
|
||||
public:
|
||||
|
||||
DxgiDevice(
|
||||
@ -86,6 +86,8 @@ namespace dxvk {
|
||||
HANDLE hEvent) final;
|
||||
|
||||
Rc<DxvkDevice> STDMETHODCALLTYPE GetDXVKDevice() final;
|
||||
|
||||
Rc<DxvkEvent> STDMETHODCALLTYPE GetFrameSyncEvent();
|
||||
|
||||
private:
|
||||
|
||||
@ -93,6 +95,11 @@ namespace dxvk {
|
||||
|
||||
Com<IDXGIVkAdapter> m_adapter;
|
||||
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