1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-29 10:24:10 +01:00

[dxgi] Implement IDXGISwapChain2::SetFrameLatency

This commit is contained in:
Philip Rebohle 2019-11-25 18:05:58 +01:00
parent 2d1fb52b2f
commit ef37b5fed6
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 42 additions and 7 deletions

View File

@ -108,6 +108,11 @@ namespace dxvk {
}
UINT STDMETHODCALLTYPE D3D11SwapChain::GetFrameLatency() {
return m_frameLatency;
}
HRESULT STDMETHODCALLTYPE D3D11SwapChain::ChangeProperties(
const DXGI_SWAP_CHAIN_DESC1* pDesc) {
@ -164,6 +169,16 @@ namespace dxvk {
}
HRESULT STDMETHODCALLTYPE D3D11SwapChain::SetFrameLatency(
UINT MaxLatency) {
if (MaxLatency == 0 || MaxLatency > DXGI_MAX_SWAP_CHAIN_BUFFERS)
return DXGI_ERROR_INVALID_CALL;
m_frameLatency = MaxLatency;
return S_OK;
}
HRESULT STDMETHODCALLTYPE D3D11SwapChain::Present(
UINT SyncInterval,
UINT PresentFlags,
@ -718,8 +733,10 @@ namespace dxvk {
uint32_t D3D11SwapChain::GetActualFrameLatency() {
uint32_t maxFrameLatency = DefaultFrameLatency;
m_dxgiDevice->GetMaximumFrameLatency(&maxFrameLatency);
uint32_t maxFrameLatency = m_frameLatency;
if (!(m_desc.Flags & DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT))
m_dxgiDevice->GetMaximumFrameLatency(&maxFrameLatency);
if (m_frameLatencyCap)
maxFrameLatency = std::min(maxFrameLatency, m_frameLatencyCap);

View File

@ -54,6 +54,8 @@ namespace dxvk {
UINT STDMETHODCALLTYPE GetImageIndex();
UINT STDMETHODCALLTYPE GetFrameLatency();
HRESULT STDMETHODCALLTYPE ChangeProperties(
const DXGI_SWAP_CHAIN_DESC1* pDesc);
@ -64,6 +66,9 @@ namespace dxvk {
UINT NumControlPoints,
const DXGI_RGB* pControlPoints);
HRESULT STDMETHODCALLTYPE SetFrameLatency(
UINT MaxLatency);
HRESULT STDMETHODCALLTYPE Present(
UINT SyncInterval,
UINT PresentFlags,
@ -117,7 +122,8 @@ namespace dxvk {
std::vector<Rc<DxvkImageView>> m_imageViews;
uint64_t m_frameId = DXGI_MAX_SWAP_CHAIN_BUFFERS;
uint64_t m_frameId = DXGI_MAX_SWAP_CHAIN_BUFFERS;
uint32_t m_frameLatency = DefaultFrameLatency;
uint32_t m_frameLatencyCap = 0;
Rc<sync::Signal> m_frameLatencySignal;

View File

@ -56,6 +56,8 @@ IDXGIVkSwapChain : public IUnknown {
virtual UINT STDMETHODCALLTYPE GetImageIndex() = 0;
virtual UINT STDMETHODCALLTYPE GetFrameLatency() = 0;
virtual HRESULT STDMETHODCALLTYPE ChangeProperties(
const DXGI_SWAP_CHAIN_DESC1* pDesc) = 0;
@ -66,6 +68,9 @@ IDXGIVkSwapChain : public IUnknown {
UINT NumControlPoints,
const DXGI_RGB* pControlPoints) = 0;
virtual HRESULT STDMETHODCALLTYPE SetFrameLatency(
UINT MaxLatency) = 0;
virtual HRESULT STDMETHODCALLTYPE Present(
UINT SyncInterval,
UINT PresentFlags,

View File

@ -421,8 +421,12 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE DxgiSwapChain::GetMaximumFrameLatency(
UINT* pMaxLatency) {
Logger::err("DxgiSwapChain::GetMaximumFrameLatency: Not implemented");
return DXGI_ERROR_INVALID_CALL;
if (!(m_desc.Flags & DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT))
return DXGI_ERROR_INVALID_CALL;
std::lock_guard<std::recursive_mutex> lock(m_lockWindow);
*pMaxLatency = m_presenter->GetFrameLatency();
return S_OK;
}
@ -446,8 +450,11 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE DxgiSwapChain::SetMaximumFrameLatency(
UINT MaxLatency) {
Logger::err("DxgiSwapChain::SetMaximumFrameLatency: Not implemented");
return DXGI_ERROR_INVALID_CALL;
if (!(m_desc.Flags & DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT))
return DXGI_ERROR_INVALID_CALL;
std::lock_guard<std::recursive_mutex> lock(m_lockWindow);
return m_presenter->SetFrameLatency(MaxLatency);
}