1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-05 01:24:14 +01:00

[d3d11] Implement IDXGIVkSwapChain1 interface for D3D11 swap chain

This commit is contained in:
Philip Rebohle 2023-06-16 15:56:06 +02:00
parent d7fa39c4eb
commit e02a800c33
2 changed files with 35 additions and 6 deletions

View File

@ -98,7 +98,8 @@ namespace dxvk {
InitReturnPtr(ppvObject); InitReturnPtr(ppvObject);
if (riid == __uuidof(IUnknown) if (riid == __uuidof(IUnknown)
|| riid == __uuidof(IDXGIVkSwapChain)) { || riid == __uuidof(IDXGIVkSwapChain)
|| riid == __uuidof(IDXGIVkSwapChain1)) {
*ppvObject = ref(this); *ppvObject = ref(this);
return S_OK; return S_OK;
} }
@ -340,6 +341,19 @@ namespace dxvk {
} }
void STDMETHODCALLTYPE D3D11SwapChain::GetLastPresentCount(
UINT64* pLastPresentCount) {
*pLastPresentCount = UINT64(m_frameId - DXGI_MAX_SWAP_CHAIN_BUFFERS);
}
void STDMETHODCALLTYPE D3D11SwapChain::GetFrameStatistics(
DXGI_VK_FRAME_STATISTICS* pFrameStatistics) {
std::lock_guard<dxvk::mutex> lock(m_frameStatisticsLock);
*pFrameStatistics = m_frameStatistics;
}
HRESULT D3D11SwapChain::PresentImage(UINT SyncInterval) { HRESULT D3D11SwapChain::PresentImage(UINT SyncInterval) {
// Flush pending rendering commands before // Flush pending rendering commands before
auto immediateContext = m_parent->GetContext(); auto immediateContext = m_parent->GetContext();
@ -645,11 +659,17 @@ namespace dxvk {
// Wait for the sync event so that we respect the maximum frame latency // Wait for the sync event so that we respect the maximum frame latency
m_frameLatencySignal->wait(m_frameId - GetActualFrameLatency()); m_frameLatencySignal->wait(m_frameId - GetActualFrameLatency());
if (m_frameLatencyEvent) { m_frameLatencySignal->setCallback(m_frameId, [this,
m_frameLatencySignal->setCallback(m_frameId, [cFrameLatencyEvent = m_frameLatencyEvent] () { cFrameId = m_frameId,
cFrameLatencyEvent = m_frameLatencyEvent
] () {
if (cFrameLatencyEvent)
ReleaseSemaphore(cFrameLatencyEvent, 1, nullptr); ReleaseSemaphore(cFrameLatencyEvent, 1, nullptr);
});
} std::lock_guard<dxvk::mutex> lock(m_frameStatisticsLock);
m_frameStatistics.PresentCount = cFrameId - DXGI_MAX_SWAP_CHAIN_BUFFERS;
m_frameStatistics.PresentQPCTime = dxvk::high_resolution_clock::get_counter();
});
} }

View File

@ -13,7 +13,7 @@ namespace dxvk {
class D3D11Device; class D3D11Device;
class D3D11DXGIDevice; class D3D11DXGIDevice;
class D3D11SwapChain : public ComObject<IDXGIVkSwapChain> { class D3D11SwapChain : public ComObject<IDXGIVkSwapChain1> {
constexpr static uint32_t DefaultFrameLatency = 1; constexpr static uint32_t DefaultFrameLatency = 1;
public: public:
@ -80,6 +80,12 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE SetHDRMetaData( HRESULT STDMETHODCALLTYPE SetHDRMetaData(
const DXGI_VK_HDR_METADATA* pMetaData); const DXGI_VK_HDR_METADATA* pMetaData);
void STDMETHODCALLTYPE GetLastPresentCount(
UINT64* pLastPresentCount);
void STDMETHODCALLTYPE GetFrameStatistics(
DXGI_VK_FRAME_STATISTICS* pFrameStatistics);
private: private:
enum BindingIds : uint32_t { enum BindingIds : uint32_t {
@ -125,6 +131,9 @@ namespace dxvk {
std::optional<VkHdrMetadataEXT> m_hdrMetadata; std::optional<VkHdrMetadataEXT> m_hdrMetadata;
bool m_dirtyHdrMetadata = true; bool m_dirtyHdrMetadata = true;
dxvk::mutex m_frameStatisticsLock;
DXGI_VK_FRAME_STATISTICS m_frameStatistics = { };
HRESULT PresentImage(UINT SyncInterval); HRESULT PresentImage(UINT SyncInterval);
void SubmitPresent( void SubmitPresent(