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

[dxgi] Implement and use GetWindowClientSize fuction

This new function provides a cleaner way to retrieve a
window's client size and can be used outside the swap
chain functions.
This commit is contained in:
Philip Rebohle 2018-12-21 15:14:07 +01:00
parent 1e393bf24d
commit 15078357dc
4 changed files with 36 additions and 23 deletions

View File

@ -127,5 +127,20 @@ namespace dxvk {
return status == DISP_CHANGE_SUCCESSFUL ? S_OK : DXGI_ERROR_NOT_CURRENTLY_AVAILABLE;;
}
void GetWindowClientSize(
HWND hWnd,
UINT* pWidth,
UINT* pHeight) {
RECT rect = { };
::GetClientRect(hWnd, &rect);
if (pWidth)
*pWidth = rect.right - rect.left;
if (pHeight)
*pHeight = rect.bottom - rect.top;
}
}

View File

@ -85,5 +85,17 @@ namespace dxvk {
HRESULT SetMonitorDisplayMode(
HMONITOR hMonitor,
const DXGI_MODE_DESC* pMode);
/**
* \brief Queries window client size
*
* \param [in] hWnd Window to query
* \param [out] pWidth Client width
* \param [out] pHeight Client height
*/
void GetWindowClientSize(
HWND hWnd,
UINT* pWidth,
UINT* pHeight);
}

View File

@ -24,10 +24,9 @@ namespace dxvk {
// Adjust initial back buffer size. If zero, these
// shall be set to the current window size.
const VkExtent2D windowSize = GetWindowSize();
if (m_desc.Width == 0) m_desc.Width = windowSize.width;
if (m_desc.Height == 0) m_desc.Height = windowSize.height;
GetWindowClientSize(m_window,
m_desc.Width ? nullptr : &m_desc.Width,
m_desc.Height ? nullptr : &m_desc.Height);
// Create presenter, which also serves as an interface to the device
if (FAILED(CreatePresenter(pDevice, &m_presenter)))
@ -287,11 +286,13 @@ namespace dxvk {
if (!IsWindow(m_window))
return DXGI_ERROR_INVALID_CALL;
const VkExtent2D windowSize = GetWindowSize();
std::lock_guard<std::mutex> lock(m_lockBuffer);
m_desc.Width = Width != 0 ? Width : windowSize.width;
m_desc.Height = Height != 0 ? Height : windowSize.height;
m_desc.Width = Width;
m_desc.Height = Height;
GetWindowClientSize(m_window,
m_desc.Width ? nullptr : &m_desc.Width,
m_desc.Height ? nullptr : &m_desc.Height);
if (BufferCount != 0)
m_desc.BufferCount = BufferCount;
@ -491,19 +492,6 @@ namespace dxvk {
}
VkExtent2D DxgiSwapChain::GetWindowSize() const {
RECT windowRect;
if (!::GetClientRect(m_window, &windowRect))
windowRect = RECT();
VkExtent2D result;
result.width = windowRect.right;
result.height = windowRect.bottom;
return result;
}
HRESULT DxgiSwapChain::EnterFullscreenMode(IDXGIOutput* pTarget) {
Com<IDXGIOutput> output = static_cast<DxgiOutput*>(pTarget);

View File

@ -183,8 +183,6 @@ namespace dxvk {
HMONITOR m_monitor;
WindowState m_windowState;
VkExtent2D GetWindowSize() const;
HRESULT EnterFullscreenMode(
IDXGIOutput *pTarget);