2018-01-13 18:56:15 +01:00
|
|
|
#include "dxgi_device.h"
|
2017-10-11 16:22:13 +02:00
|
|
|
#include "dxgi_factory.h"
|
|
|
|
#include "dxgi_swapchain.h"
|
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
|
|
|
DxgiSwapChain::DxgiSwapChain(
|
|
|
|
DxgiFactory* factory,
|
|
|
|
IUnknown* pDevice,
|
2017-11-26 14:02:08 +01:00
|
|
|
DXGI_SWAP_CHAIN_DESC* pDesc)
|
|
|
|
: m_factory (factory),
|
|
|
|
m_desc (*pDesc) {
|
|
|
|
|
2017-11-26 15:29:57 +01:00
|
|
|
// Retrieve a device pointer that allows us to
|
|
|
|
// communicate with the underlying D3D device
|
2017-11-29 16:23:33 +01:00
|
|
|
if (FAILED(pDevice->QueryInterface(__uuidof(IDXGIPresentDevicePrivate),
|
2017-12-04 11:33:04 +01:00
|
|
|
reinterpret_cast<void**>(&m_presentDevice))))
|
2017-11-26 14:02:08 +01:00
|
|
|
throw DxvkError("DxgiSwapChain::DxgiSwapChain: Invalid device");
|
|
|
|
|
2017-11-29 07:55:44 +01:00
|
|
|
// Retrieve the adapter, which is going
|
|
|
|
// to be used to enumerate displays.
|
2018-01-13 18:56:15 +01:00
|
|
|
Com<IDXGIDevice> device;
|
2017-12-04 11:33:04 +01:00
|
|
|
Com<IDXGIAdapter> adapter;
|
2017-11-29 07:55:44 +01:00
|
|
|
|
2018-01-13 18:56:15 +01:00
|
|
|
if (FAILED(pDevice->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(&device))))
|
2017-11-29 07:55:44 +01:00
|
|
|
throw DxvkError("DxgiSwapChain::DxgiSwapChain: Invalid device");
|
|
|
|
|
2018-01-13 18:56:15 +01:00
|
|
|
if (FAILED(device->GetAdapter(&adapter)))
|
2017-11-29 07:55:44 +01:00
|
|
|
throw DxvkError("DxgiSwapChain::DxgiSwapChain: Failed to retrieve adapter");
|
|
|
|
|
2018-01-13 18:56:15 +01:00
|
|
|
m_device = static_cast<DxgiDevice*>(device.ptr());
|
|
|
|
m_adapter = static_cast<DxgiAdapter*>(adapter.ptr());
|
|
|
|
|
2017-11-26 15:29:57 +01:00
|
|
|
// Initialize frame statistics
|
|
|
|
m_stats.PresentCount = 0;
|
|
|
|
m_stats.PresentRefreshCount = 0;
|
|
|
|
m_stats.SyncRefreshCount = 0;
|
|
|
|
m_stats.SyncQPCTime.QuadPart = 0;
|
|
|
|
m_stats.SyncGPUTime.QuadPart = 0;
|
|
|
|
|
2017-12-04 22:21:02 +01:00
|
|
|
// Adjust initial back buffer size. If zero, these
|
|
|
|
// shall be set to the current window size.
|
2017-12-31 00:23:34 +01:00
|
|
|
const VkExtent2D windowSize = GetWindowSize();
|
2017-12-04 22:21:02 +01:00
|
|
|
|
|
|
|
if (m_desc.BufferDesc.Width == 0) m_desc.BufferDesc.Width = windowSize.width;
|
|
|
|
if (m_desc.BufferDesc.Height == 0) m_desc.BufferDesc.Height = windowSize.height;
|
|
|
|
|
2017-11-26 15:29:57 +01:00
|
|
|
// Set initial window mode and fullscreen state
|
2018-01-13 18:56:15 +01:00
|
|
|
if (!pDesc->Windowed && FAILED(EnterFullscreenMode(nullptr)))
|
|
|
|
throw DxvkError("DxgiSwapChain: Failed to set initial fullscreen state");
|
2017-11-26 18:38:50 +01:00
|
|
|
|
2017-12-31 00:23:34 +01:00
|
|
|
if (FAILED(CreatePresenter()) || FAILED(CreateBackBuffer()))
|
|
|
|
throw DxvkError("DxgiSwapChain: Failed to create presenter or back buffer");
|
2017-10-11 16:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DxgiSwapChain::~DxgiSwapChain() {
|
2017-12-31 00:23:34 +01:00
|
|
|
|
2017-10-11 16:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiSwapChain::QueryInterface(REFIID riid, void** ppvObject) {
|
2017-10-15 21:50:45 +02:00
|
|
|
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
|
|
|
|
COM_QUERY_IFACE(riid, ppvObject, IDXGIObject);
|
2017-11-26 14:02:08 +01:00
|
|
|
COM_QUERY_IFACE(riid, ppvObject, IDXGIDeviceSubObject);
|
2017-10-11 16:22:13 +02:00
|
|
|
COM_QUERY_IFACE(riid, ppvObject, IDXGISwapChain);
|
|
|
|
|
|
|
|
Logger::warn("DxgiSwapChain::QueryInterface: Unknown interface query");
|
2018-03-12 14:05:43 +03:00
|
|
|
Logger::warn(str::format(riid));
|
2017-10-11 16:22:13 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiSwapChain::GetParent(REFIID riid, void** ppParent) {
|
2017-11-26 14:02:08 +01:00
|
|
|
return m_factory->QueryInterface(riid, ppParent);
|
2017-10-11 16:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiSwapChain::GetDevice(REFIID riid, void** ppDevice) {
|
2017-11-26 14:02:08 +01:00
|
|
|
return m_device->QueryInterface(riid, ppDevice);
|
2017-10-11 16:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiSwapChain::GetBuffer(UINT Buffer, REFIID riid, void** ppSurface) {
|
2018-02-14 13:11:59 +01:00
|
|
|
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
2017-11-26 15:29:57 +01:00
|
|
|
|
2017-11-26 18:38:50 +01:00
|
|
|
if (Buffer > 0) {
|
|
|
|
Logger::err("DxgiSwapChain::GetBuffer: Buffer > 0 not supported");
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
}
|
|
|
|
|
2017-12-19 16:01:50 +01:00
|
|
|
return m_backBuffer->QueryInterface(riid, ppSurface);
|
2017-10-11 16:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiSwapChain::GetContainingOutput(IDXGIOutput** ppOutput) {
|
2018-01-13 18:56:15 +01:00
|
|
|
if (ppOutput == nullptr)
|
2017-11-26 15:29:57 +01:00
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
|
2018-01-13 18:56:15 +01:00
|
|
|
RECT windowRect = { 0, 0, 0, 0 };
|
|
|
|
::GetWindowRect(m_desc.OutputWindow, &windowRect);
|
|
|
|
|
|
|
|
HMONITOR monitor = ::MonitorFromPoint(
|
|
|
|
{ (windowRect.left + windowRect.right) / 2,
|
|
|
|
(windowRect.top + windowRect.bottom) / 2 },
|
|
|
|
MONITOR_DEFAULTTOPRIMARY);
|
|
|
|
|
|
|
|
return m_adapter->GetOutputFromMonitor(monitor, ppOutput);
|
2017-10-11 16:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiSwapChain::GetDesc(DXGI_SWAP_CHAIN_DESC* pDesc) {
|
2017-11-26 15:29:57 +01:00
|
|
|
if (pDesc == nullptr)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
|
2018-02-14 13:11:59 +01:00
|
|
|
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
2017-11-26 15:29:57 +01:00
|
|
|
*pDesc = m_desc;
|
|
|
|
return S_OK;
|
2017-10-11 16:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiSwapChain::GetFrameStatistics(DXGI_FRAME_STATISTICS* pStats) {
|
2017-11-26 15:29:57 +01:00
|
|
|
if (pStats == nullptr)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
|
2018-02-14 13:11:59 +01:00
|
|
|
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
2017-11-26 15:29:57 +01:00
|
|
|
*pStats = m_stats;
|
|
|
|
return S_OK;
|
2017-10-11 16:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiSwapChain::GetFullscreenState(
|
2017-10-11 16:22:13 +02:00
|
|
|
BOOL* pFullscreen,
|
|
|
|
IDXGIOutput** ppTarget) {
|
2018-02-14 13:11:59 +01:00
|
|
|
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
2017-11-26 15:29:57 +01:00
|
|
|
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
if (pFullscreen != nullptr)
|
|
|
|
*pFullscreen = !m_desc.Windowed;
|
|
|
|
|
2018-03-27 02:58:33 +03:00
|
|
|
if (ppTarget != nullptr) {
|
|
|
|
*ppTarget = nullptr;
|
|
|
|
if (!m_desc.Windowed)
|
|
|
|
hr = this->GetContainingOutput(ppTarget);
|
|
|
|
}
|
2017-11-26 15:29:57 +01:00
|
|
|
|
|
|
|
return hr;
|
2017-10-11 16:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiSwapChain::GetLastPresentCount(UINT* pLastPresentCount) {
|
2017-11-26 15:29:57 +01:00
|
|
|
if (pLastPresentCount == nullptr)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
|
2018-02-14 13:11:59 +01:00
|
|
|
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
2017-11-26 15:29:57 +01:00
|
|
|
*pLastPresentCount = m_stats.PresentCount;
|
|
|
|
return S_OK;
|
2017-10-11 16:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiSwapChain::Present(UINT SyncInterval, UINT Flags) {
|
2018-02-14 13:11:59 +01:00
|
|
|
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
2017-11-26 15:29:57 +01:00
|
|
|
|
2018-02-18 23:49:00 +01:00
|
|
|
if (Flags & DXGI_PRESENT_TEST)
|
|
|
|
return S_OK;
|
|
|
|
|
2017-11-29 07:55:44 +01:00
|
|
|
try {
|
|
|
|
// Submit pending rendering commands
|
|
|
|
// before recording the present code.
|
2017-12-04 11:33:04 +01:00
|
|
|
m_presentDevice->FlushRenderingCommands();
|
2017-12-31 00:23:34 +01:00
|
|
|
|
|
|
|
// Update swap chain properties. This will not only set
|
|
|
|
// up vertical synchronization properly, but also apply
|
|
|
|
// changes that were made to the window size even if the
|
|
|
|
// Vulkan swap chain itself remains valid.
|
|
|
|
DxvkSwapchainProperties swapchainProps;
|
|
|
|
swapchainProps.preferredSurfaceFormat
|
|
|
|
= m_presenter->pickSurfaceFormat(m_desc.BufferDesc.Format);
|
|
|
|
swapchainProps.preferredPresentMode = SyncInterval == 0
|
|
|
|
? m_presenter->pickPresentMode(VK_PRESENT_MODE_IMMEDIATE_KHR)
|
2018-01-30 08:53:00 +01:00
|
|
|
: m_presenter->pickPresentMode(VK_PRESENT_MODE_FIFO_KHR);
|
2017-12-31 00:23:34 +01:00
|
|
|
swapchainProps.preferredBufferSize = GetWindowSize();
|
|
|
|
|
|
|
|
m_presenter->recreateSwapchain(swapchainProps);
|
2018-01-30 08:45:50 +01:00
|
|
|
m_presenter->presentImage();
|
2017-11-29 07:55:44 +01:00
|
|
|
return S_OK;
|
|
|
|
} catch (const DxvkError& err) {
|
|
|
|
Logger::err(err.message());
|
|
|
|
return DXGI_ERROR_DRIVER_INTERNAL_ERROR;
|
|
|
|
}
|
2017-10-11 16:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiSwapChain::ResizeBuffers(
|
2017-10-11 16:22:13 +02:00
|
|
|
UINT BufferCount,
|
|
|
|
UINT Width,
|
|
|
|
UINT Height,
|
|
|
|
DXGI_FORMAT NewFormat,
|
|
|
|
UINT SwapChainFlags) {
|
2018-02-14 13:11:59 +01:00
|
|
|
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
2017-11-26 15:29:57 +01:00
|
|
|
|
2017-12-31 00:23:34 +01:00
|
|
|
const VkExtent2D windowSize = GetWindowSize();
|
2017-12-04 22:21:02 +01:00
|
|
|
|
2017-12-31 00:23:34 +01:00
|
|
|
m_desc.BufferDesc.Width = Width != 0 ? Width : windowSize.width;
|
2017-12-04 22:21:02 +01:00
|
|
|
m_desc.BufferDesc.Height = Height != 0 ? Height : windowSize.height;
|
|
|
|
|
|
|
|
m_desc.Flags = SwapChainFlags;
|
2017-11-26 18:38:50 +01:00
|
|
|
|
2017-11-29 07:55:44 +01:00
|
|
|
if (BufferCount != 0)
|
2017-12-04 22:21:02 +01:00
|
|
|
m_desc.BufferCount = BufferCount;
|
|
|
|
|
|
|
|
if (NewFormat != DXGI_FORMAT_UNKNOWN)
|
|
|
|
m_desc.BufferDesc.Format = NewFormat;
|
2017-11-29 07:55:44 +01:00
|
|
|
|
2017-12-31 00:23:34 +01:00
|
|
|
return CreateBackBuffer();
|
2017-10-11 16:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiSwapChain::ResizeTarget(const DXGI_MODE_DESC* pNewTargetParameters) {
|
2017-11-26 15:29:57 +01:00
|
|
|
if (pNewTargetParameters == nullptr)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
|
2018-02-14 13:11:59 +01:00
|
|
|
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
2017-11-26 15:29:57 +01:00
|
|
|
|
2017-12-31 00:23:34 +01:00
|
|
|
// TODO support fullscreen mode
|
|
|
|
RECT newRect = { 0, 0, 0, 0 };
|
|
|
|
RECT oldRect = { 0, 0, 0, 0 };
|
2017-12-05 15:20:03 +01:00
|
|
|
|
2017-12-31 00:23:34 +01:00
|
|
|
::GetWindowRect(m_desc.OutputWindow, &oldRect);
|
|
|
|
::SetRect(&newRect, 0, 0, pNewTargetParameters->Width, pNewTargetParameters->Height);
|
|
|
|
::AdjustWindowRectEx(&newRect,
|
|
|
|
::GetWindowLongW(m_desc.OutputWindow, GWL_STYLE), FALSE,
|
|
|
|
::GetWindowLongW(m_desc.OutputWindow, GWL_EXSTYLE));
|
|
|
|
::SetRect(&newRect, 0, 0, newRect.right - newRect.left, newRect.bottom - newRect.top);
|
|
|
|
::OffsetRect(&newRect, oldRect.left, oldRect.top);
|
|
|
|
::MoveWindow(m_desc.OutputWindow, newRect.left, newRect.top,
|
|
|
|
newRect.right - newRect.left, newRect.bottom - newRect.top, TRUE);
|
|
|
|
|
|
|
|
return S_OK;
|
2017-10-11 16:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiSwapChain::SetFullscreenState(
|
2017-10-11 16:22:13 +02:00
|
|
|
BOOL Fullscreen,
|
|
|
|
IDXGIOutput* pTarget) {
|
2018-02-14 13:11:59 +01:00
|
|
|
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
2017-11-26 15:29:57 +01:00
|
|
|
|
2018-01-13 18:56:15 +01:00
|
|
|
if (Fullscreen)
|
|
|
|
Logger::warn("DxgiSwapChain: Display mode changes not implemented");
|
|
|
|
|
|
|
|
if (m_desc.Windowed && Fullscreen)
|
|
|
|
return this->EnterFullscreenMode(pTarget);
|
|
|
|
else if (!m_desc.Windowed && !Fullscreen)
|
|
|
|
return this->LeaveFullscreenMode();
|
|
|
|
|
|
|
|
return S_OK;
|
2017-10-11 16:22:13 +02:00
|
|
|
}
|
|
|
|
|
2017-11-29 07:55:44 +01:00
|
|
|
|
2017-12-31 00:23:34 +01:00
|
|
|
HRESULT DxgiSwapChain::CreatePresenter() {
|
|
|
|
try {
|
|
|
|
m_presenter = new DxgiPresenter(
|
|
|
|
m_device->GetDXVKDevice(),
|
|
|
|
m_desc.OutputWindow);
|
|
|
|
return S_OK;
|
|
|
|
} catch (const DxvkError& e) {
|
|
|
|
Logger::err(e.message());
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2017-11-29 21:46:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-31 00:23:34 +01:00
|
|
|
HRESULT DxgiSwapChain::CreateBackBuffer() {
|
2018-03-18 20:39:14 +01:00
|
|
|
// Figure out sample count based on swap chain description
|
2017-12-12 00:27:49 +01:00
|
|
|
VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
|
2017-12-02 16:47:06 +01:00
|
|
|
|
2017-12-31 00:23:34 +01:00
|
|
|
if (FAILED(GetSampleCount(m_desc.SampleDesc.Count, &sampleCount))) {
|
|
|
|
Logger::err("DxgiSwapChain: Invalid sample count");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
2017-11-29 08:29:12 +01:00
|
|
|
|
2018-03-18 20:39:14 +01:00
|
|
|
// Destroy previous back buffer before creating a new one
|
|
|
|
m_backBuffer = nullptr;
|
|
|
|
|
2017-12-31 00:23:34 +01:00
|
|
|
if (FAILED(m_presentDevice->CreateSwapChainBackBuffer(&m_desc, &m_backBuffer))) {
|
|
|
|
Logger::err("DxgiSwapChain: Failed to create back buffer");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2017-11-29 08:29:12 +01:00
|
|
|
|
2017-12-31 00:23:34 +01:00
|
|
|
try {
|
|
|
|
m_presenter->updateBackBuffer(m_backBuffer->GetDXVKImage());
|
|
|
|
return S_OK;
|
|
|
|
} catch (const DxvkError& e) {
|
|
|
|
Logger::err(e.message());
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2017-11-29 07:55:44 +01:00
|
|
|
}
|
|
|
|
|
2017-12-04 22:21:02 +01:00
|
|
|
|
2017-12-31 00:23:34 +01:00
|
|
|
VkExtent2D DxgiSwapChain::GetWindowSize() const {
|
|
|
|
RECT windowRect;
|
|
|
|
::GetClientRect(m_desc.OutputWindow, &windowRect);
|
2017-12-04 22:21:02 +01:00
|
|
|
|
2017-12-05 15:20:03 +01:00
|
|
|
VkExtent2D result;
|
2017-12-31 00:23:34 +01:00
|
|
|
result.width = windowRect.right;
|
|
|
|
result.height = windowRect.bottom;
|
2017-12-05 15:20:03 +01:00
|
|
|
return result;
|
2017-12-04 22:21:02 +01:00
|
|
|
}
|
|
|
|
|
2017-12-12 00:27:49 +01:00
|
|
|
|
2018-01-13 18:56:15 +01:00
|
|
|
HRESULT DxgiSwapChain::EnterFullscreenMode(IDXGIOutput *pTarget) {
|
|
|
|
Com<IDXGIOutput> output = pTarget;
|
|
|
|
|
|
|
|
if (output == nullptr) {
|
|
|
|
if (FAILED(GetContainingOutput(&output))) {
|
|
|
|
Logger::err("DxgiSwapChain: Failed to enter fullscreen mode: Cannot query containing output");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-14 13:11:59 +01:00
|
|
|
// Update swap chain description
|
|
|
|
m_desc.Windowed = FALSE;
|
|
|
|
|
2018-01-13 18:56:15 +01:00
|
|
|
// Change the window flags to remove the decoration etc.
|
|
|
|
LONG style = ::GetWindowLongW(m_desc.OutputWindow, GWL_STYLE);
|
|
|
|
LONG exstyle = ::GetWindowLongW(m_desc.OutputWindow, GWL_EXSTYLE);
|
|
|
|
|
|
|
|
m_windowState.style = style;
|
|
|
|
m_windowState.exstyle = exstyle;
|
|
|
|
::GetWindowRect(m_desc.OutputWindow, &m_windowState.rect);
|
|
|
|
|
|
|
|
style |= WS_POPUP | WS_SYSMENU;
|
|
|
|
style &= ~(WS_CAPTION | WS_THICKFRAME);
|
|
|
|
|
|
|
|
exstyle &= ~(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE);
|
|
|
|
|
|
|
|
::SetWindowLongW(m_desc.OutputWindow, GWL_STYLE, style);
|
|
|
|
::SetWindowLongW(m_desc.OutputWindow, GWL_EXSTYLE, exstyle);
|
|
|
|
|
|
|
|
// Move the window so that it covers the entire output
|
|
|
|
DXGI_OUTPUT_DESC desc;
|
|
|
|
output->GetDesc(&desc);
|
|
|
|
|
|
|
|
const RECT rect = desc.DesktopCoordinates;
|
|
|
|
|
|
|
|
::SetWindowPos(m_desc.OutputWindow, HWND_TOPMOST,
|
|
|
|
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
|
|
|
|
SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOACTIVATE);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT DxgiSwapChain::LeaveFullscreenMode() {
|
2018-02-14 13:11:59 +01:00
|
|
|
m_desc.Windowed = TRUE;
|
|
|
|
|
2018-01-13 18:56:15 +01:00
|
|
|
// FIXME wine only restores window flags if the application
|
|
|
|
// has not modified them in the meantime. Some applications
|
|
|
|
// may rely on that behaviour.
|
|
|
|
const RECT rect = m_windowState.rect;
|
|
|
|
|
|
|
|
::SetWindowLongW(m_desc.OutputWindow, GWL_STYLE, m_windowState.style);
|
|
|
|
::SetWindowLongW(m_desc.OutputWindow, GWL_EXSTYLE, m_windowState.exstyle);
|
|
|
|
|
|
|
|
::SetWindowPos(m_desc.OutputWindow, 0,
|
|
|
|
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
|
|
|
|
SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 00:27:49 +01:00
|
|
|
HRESULT DxgiSwapChain::GetSampleCount(UINT Count, VkSampleCountFlagBits* pCount) const {
|
|
|
|
switch (Count) {
|
|
|
|
case 1: *pCount = VK_SAMPLE_COUNT_1_BIT; return S_OK;
|
|
|
|
case 2: *pCount = VK_SAMPLE_COUNT_2_BIT; return S_OK;
|
|
|
|
case 4: *pCount = VK_SAMPLE_COUNT_4_BIT; return S_OK;
|
|
|
|
case 8: *pCount = VK_SAMPLE_COUNT_8_BIT; return S_OK;
|
|
|
|
case 16: *pCount = VK_SAMPLE_COUNT_16_BIT; return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2017-10-11 16:22:13 +02:00
|
|
|
}
|