2018-10-22 22:41:25 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "d3d11_texture.h"
|
|
|
|
|
|
|
|
#include "../dxvk/hud/dxvk_hud.h"
|
|
|
|
|
2021-02-27 14:50:07 +01:00
|
|
|
#include "../dxvk/dxvk_swapchain_blitter.h"
|
|
|
|
|
2019-11-26 00:24:33 +01:00
|
|
|
#include "../util/sync/sync_signal_win32.h"
|
|
|
|
|
2018-10-22 22:41:25 +02:00
|
|
|
namespace dxvk {
|
|
|
|
|
|
|
|
class D3D11Device;
|
2018-12-03 19:26:29 +01:00
|
|
|
class D3D11DXGIDevice;
|
2018-10-22 22:41:25 +02:00
|
|
|
|
|
|
|
class D3D11SwapChain : public ComObject<IDXGIVkSwapChain> {
|
2019-11-25 17:45:28 +01:00
|
|
|
constexpr static uint32_t DefaultFrameLatency = 1;
|
2018-10-22 22:41:25 +02:00
|
|
|
public:
|
|
|
|
|
|
|
|
D3D11SwapChain(
|
2018-12-03 19:26:29 +01:00
|
|
|
D3D11DXGIDevice* pContainer,
|
|
|
|
D3D11Device* pDevice,
|
|
|
|
HWND hWnd,
|
|
|
|
const DXGI_SWAP_CHAIN_DESC1* pDesc);
|
2018-10-22 22:41:25 +02:00
|
|
|
|
|
|
|
~D3D11SwapChain();
|
|
|
|
|
|
|
|
HRESULT STDMETHODCALLTYPE QueryInterface(
|
2018-12-03 19:26:29 +01:00
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject);
|
2018-10-22 22:41:25 +02:00
|
|
|
|
|
|
|
HRESULT STDMETHODCALLTYPE GetDesc(
|
|
|
|
DXGI_SWAP_CHAIN_DESC1* pDesc);
|
|
|
|
|
2018-11-12 11:20:27 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE GetAdapter(
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject);
|
|
|
|
|
2018-10-24 15:52:09 +02:00
|
|
|
HRESULT STDMETHODCALLTYPE GetDevice(
|
|
|
|
REFIID riid,
|
|
|
|
void** ppDevice);
|
|
|
|
|
2018-10-22 22:41:25 +02:00
|
|
|
HRESULT STDMETHODCALLTYPE GetImage(
|
|
|
|
UINT BufferId,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppBuffer);
|
|
|
|
|
|
|
|
UINT STDMETHODCALLTYPE GetImageIndex();
|
|
|
|
|
2019-11-25 18:05:58 +01:00
|
|
|
UINT STDMETHODCALLTYPE GetFrameLatency();
|
|
|
|
|
2019-11-26 01:17:22 +01:00
|
|
|
HANDLE STDMETHODCALLTYPE GetFrameLatencyEvent();
|
|
|
|
|
2018-10-22 22:41:25 +02:00
|
|
|
HRESULT STDMETHODCALLTYPE ChangeProperties(
|
|
|
|
const DXGI_SWAP_CHAIN_DESC1* pDesc);
|
|
|
|
|
|
|
|
HRESULT STDMETHODCALLTYPE SetPresentRegion(
|
|
|
|
const RECT* pRegion);
|
|
|
|
|
|
|
|
HRESULT STDMETHODCALLTYPE SetGammaControl(
|
|
|
|
UINT NumControlPoints,
|
|
|
|
const DXGI_RGB* pControlPoints);
|
|
|
|
|
2019-11-25 18:05:58 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE SetFrameLatency(
|
|
|
|
UINT MaxLatency);
|
|
|
|
|
2018-10-22 22:41:25 +02:00
|
|
|
HRESULT STDMETHODCALLTYPE Present(
|
|
|
|
UINT SyncInterval,
|
|
|
|
UINT PresentFlags,
|
|
|
|
const DXGI_PRESENT_PARAMETERS* pPresentParameters);
|
2019-11-25 17:45:28 +01:00
|
|
|
|
2018-10-22 22:41:25 +02:00
|
|
|
private:
|
|
|
|
|
|
|
|
enum BindingIds : uint32_t {
|
2019-04-03 17:39:13 +02:00
|
|
|
Image = 0,
|
|
|
|
Gamma = 1,
|
2018-10-22 22:41:25 +02:00
|
|
|
};
|
|
|
|
|
2019-10-01 22:26:07 +02:00
|
|
|
Com<D3D11DXGIDevice, false> m_dxgiDevice;
|
2018-10-22 22:41:25 +02:00
|
|
|
|
2021-02-27 14:50:07 +01:00
|
|
|
D3D11Device* m_parent;
|
|
|
|
HWND m_window;
|
2018-10-22 22:41:25 +02:00
|
|
|
|
2021-02-27 14:50:07 +01:00
|
|
|
DXGI_SWAP_CHAIN_DESC1 m_desc;
|
2018-10-22 22:41:25 +02:00
|
|
|
|
2021-02-27 14:50:07 +01:00
|
|
|
Rc<DxvkDevice> m_device;
|
|
|
|
Rc<DxvkContext> m_context;
|
2018-10-22 22:41:25 +02:00
|
|
|
|
2021-02-27 14:50:07 +01:00
|
|
|
Rc<vk::Presenter> m_presenter;
|
2018-10-22 22:41:25 +02:00
|
|
|
|
2021-02-27 14:50:07 +01:00
|
|
|
Rc<DxvkImage> m_swapImage;
|
|
|
|
Rc<DxvkImageView> m_swapImageView;
|
|
|
|
Rc<DxvkSwapchainBlitter> m_blitter;
|
2018-10-22 22:41:25 +02:00
|
|
|
|
2021-02-27 14:50:07 +01:00
|
|
|
Rc<hud::Hud> m_hud;
|
2018-10-22 22:41:25 +02:00
|
|
|
|
2021-02-27 14:50:07 +01:00
|
|
|
D3D11Texture2D* m_backBuffer = nullptr;
|
|
|
|
DxvkSubmitStatus m_presentStatus;
|
2019-07-05 14:27:45 +02:00
|
|
|
|
2018-11-28 12:27:24 +01:00
|
|
|
std::vector<Rc<DxvkImageView>> m_imageViews;
|
|
|
|
|
2019-11-25 18:05:58 +01:00
|
|
|
uint64_t m_frameId = DXGI_MAX_SWAP_CHAIN_BUFFERS;
|
|
|
|
uint32_t m_frameLatency = DefaultFrameLatency;
|
2019-11-25 17:37:16 +01:00
|
|
|
uint32_t m_frameLatencyCap = 0;
|
2019-11-26 00:24:33 +01:00
|
|
|
HANDLE m_frameLatencyEvent = nullptr;
|
|
|
|
Rc<sync::Win32Fence> m_frameLatencySignal;
|
2019-11-25 17:45:28 +01:00
|
|
|
|
2018-10-22 22:41:25 +02:00
|
|
|
bool m_dirty = true;
|
|
|
|
bool m_vsync = true;
|
|
|
|
|
2019-12-15 11:33:17 +01:00
|
|
|
HRESULT PresentImage(UINT SyncInterval);
|
2018-10-22 22:41:25 +02:00
|
|
|
|
2019-11-02 16:32:55 +01:00
|
|
|
void SubmitPresent(
|
|
|
|
D3D11ImmediateContext* pContext,
|
2019-12-13 15:02:45 +01:00
|
|
|
const vk::PresenterSync& Sync,
|
|
|
|
uint32_t FrameId);
|
2019-11-02 16:32:55 +01:00
|
|
|
|
2019-07-05 14:59:24 +02:00
|
|
|
void SynchronizePresent();
|
|
|
|
|
2018-11-28 12:27:24 +01:00
|
|
|
void RecreateSwapChain(
|
|
|
|
BOOL Vsync);
|
|
|
|
|
2019-11-26 00:24:33 +01:00
|
|
|
void CreateFrameLatencyEvent();
|
2019-11-25 17:45:28 +01:00
|
|
|
|
2018-11-28 12:27:24 +01:00
|
|
|
void CreatePresenter();
|
|
|
|
|
|
|
|
void CreateRenderTargetViews();
|
2018-10-22 22:41:25 +02:00
|
|
|
|
|
|
|
void CreateBackBuffer();
|
|
|
|
|
2021-02-27 14:50:07 +01:00
|
|
|
void CreateBlitter();
|
2019-11-26 00:24:33 +01:00
|
|
|
|
2018-10-22 22:41:25 +02:00
|
|
|
void CreateHud();
|
|
|
|
|
2021-02-27 14:50:07 +01:00
|
|
|
void DestroyFrameLatencyEvent();
|
2019-11-25 17:45:28 +01:00
|
|
|
|
2019-11-26 00:24:33 +01:00
|
|
|
void SignalFrameLatencyEvent();
|
|
|
|
|
2019-11-25 17:45:28 +01:00
|
|
|
uint32_t GetActualFrameLatency();
|
2018-10-22 22:41:25 +02:00
|
|
|
|
2018-11-28 12:27:24 +01:00
|
|
|
uint32_t PickFormats(
|
|
|
|
DXGI_FORMAT Format,
|
|
|
|
VkSurfaceFormatKHR* pDstFormats);
|
|
|
|
|
|
|
|
uint32_t PickPresentModes(
|
|
|
|
BOOL Vsync,
|
|
|
|
VkPresentModeKHR* pDstModes);
|
2018-10-22 22:41:25 +02:00
|
|
|
|
2018-12-14 14:58:36 +01:00
|
|
|
uint32_t PickImageCount(
|
|
|
|
UINT Preferred);
|
|
|
|
|
2019-12-05 13:08:35 +01:00
|
|
|
VkFullScreenExclusiveEXT PickFullscreenMode();
|
|
|
|
|
2020-01-28 13:45:15 +01:00
|
|
|
std::string GetApiName() const;
|
|
|
|
|
2018-10-22 22:41:25 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|