mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-04 16:24:29 +01:00
[d3d11] Implement IDXGIVkSwapChain1 interface for D3D11 swap chain
This commit is contained in:
parent
d7fa39c4eb
commit
e02a800c33
@ -98,7 +98,8 @@ namespace dxvk {
|
||||
InitReturnPtr(ppvObject);
|
||||
|
||||
if (riid == __uuidof(IUnknown)
|
||||
|| riid == __uuidof(IDXGIVkSwapChain)) {
|
||||
|| riid == __uuidof(IDXGIVkSwapChain)
|
||||
|| riid == __uuidof(IDXGIVkSwapChain1)) {
|
||||
*ppvObject = ref(this);
|
||||
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) {
|
||||
// Flush pending rendering commands before
|
||||
auto immediateContext = m_parent->GetContext();
|
||||
@ -645,12 +659,18 @@ namespace dxvk {
|
||||
// Wait for the sync event so that we respect the maximum frame latency
|
||||
m_frameLatencySignal->wait(m_frameId - GetActualFrameLatency());
|
||||
|
||||
if (m_frameLatencyEvent) {
|
||||
m_frameLatencySignal->setCallback(m_frameId, [cFrameLatencyEvent = m_frameLatencyEvent] () {
|
||||
m_frameLatencySignal->setCallback(m_frameId, [this,
|
||||
cFrameId = m_frameId,
|
||||
cFrameLatencyEvent = m_frameLatencyEvent
|
||||
] () {
|
||||
if (cFrameLatencyEvent)
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint32_t D3D11SwapChain::GetActualFrameLatency() {
|
||||
|
@ -13,7 +13,7 @@ namespace dxvk {
|
||||
class D3D11Device;
|
||||
class D3D11DXGIDevice;
|
||||
|
||||
class D3D11SwapChain : public ComObject<IDXGIVkSwapChain> {
|
||||
class D3D11SwapChain : public ComObject<IDXGIVkSwapChain1> {
|
||||
constexpr static uint32_t DefaultFrameLatency = 1;
|
||||
public:
|
||||
|
||||
@ -80,6 +80,12 @@ namespace dxvk {
|
||||
HRESULT STDMETHODCALLTYPE SetHDRMetaData(
|
||||
const DXGI_VK_HDR_METADATA* pMetaData);
|
||||
|
||||
void STDMETHODCALLTYPE GetLastPresentCount(
|
||||
UINT64* pLastPresentCount);
|
||||
|
||||
void STDMETHODCALLTYPE GetFrameStatistics(
|
||||
DXGI_VK_FRAME_STATISTICS* pFrameStatistics);
|
||||
|
||||
private:
|
||||
|
||||
enum BindingIds : uint32_t {
|
||||
@ -125,6 +131,9 @@ namespace dxvk {
|
||||
std::optional<VkHdrMetadataEXT> m_hdrMetadata;
|
||||
bool m_dirtyHdrMetadata = true;
|
||||
|
||||
dxvk::mutex m_frameStatisticsLock;
|
||||
DXGI_VK_FRAME_STATISTICS m_frameStatistics = { };
|
||||
|
||||
HRESULT PresentImage(UINT SyncInterval);
|
||||
|
||||
void SubmitPresent(
|
||||
|
Loading…
Reference in New Issue
Block a user