BsWin32RenderWindow.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "Win32/BsWin32RenderWindow.h"
  4. #include "Win32/BsWin32Platform.h"
  5. #include "Win32/BsWin32Window.h"
  6. #include "Win32/BsWin32VideoModeInfo.h"
  7. #include "Corethread/BsCoreThread.h"
  8. #include "Profiling/BsRenderStats.h"
  9. #include "Managers/BsRenderWindowManager.h"
  10. #include "BsVulkanRenderAPI.h"
  11. #include "BsVulkanDevice.h"
  12. #include "BsVulkanSwapChain.h"
  13. #include "BsVulkanDevice.h"
  14. #include "BsVulkanCommandBuffer.h"
  15. #include "Managers/BsVulkanCommandBufferManager.h"
  16. #include "BsVulkanQueue.h"
  17. #include "Math/BsMath.h"
  18. namespace bs
  19. {
  20. Win32RenderWindow::Win32RenderWindow(const RENDER_WINDOW_DESC& desc, UINT32 windowId)
  21. : RenderWindow(desc, windowId), mProperties(desc)
  22. { }
  23. void Win32RenderWindow::getCustomAttribute(const String& name, void* pData) const
  24. {
  25. if (name == "WINDOW")
  26. {
  27. UINT64 *pHwnd = (UINT64*)pData;
  28. *pHwnd = (UINT64)getHWnd();
  29. return;
  30. }
  31. }
  32. Vector2I Win32RenderWindow::screenToWindowPos(const Vector2I& screenPos) const
  33. {
  34. POINT pos;
  35. pos.x = screenPos.x;
  36. pos.y = screenPos.y;
  37. ScreenToClient(getHWnd(), &pos);
  38. return Vector2I(pos.x, pos.y);
  39. }
  40. Vector2I Win32RenderWindow::windowToScreenPos(const Vector2I& windowPos) const
  41. {
  42. POINT pos;
  43. pos.x = windowPos.x;
  44. pos.y = windowPos.y;
  45. ClientToScreen(getHWnd(), &pos);
  46. return Vector2I(pos.x, pos.y);
  47. }
  48. SPtr<ct::Win32RenderWindow> Win32RenderWindow::getCore() const
  49. {
  50. return std::static_pointer_cast<ct::Win32RenderWindow>(mCoreSpecific);
  51. }
  52. HWND Win32RenderWindow::getHWnd() const
  53. {
  54. blockUntilCoreInitialized();
  55. return getCore()->_getWindowHandle();
  56. }
  57. void Win32RenderWindow::syncProperties()
  58. {
  59. ScopedSpinLock lock(getCore()->mLock);
  60. mProperties = getCore()->mSyncedProperties;
  61. }
  62. namespace ct
  63. {
  64. Win32RenderWindow::Win32RenderWindow(const RENDER_WINDOW_DESC& desc, UINT32 windowId, VulkanRenderAPI& renderAPI)
  65. : RenderWindow(desc, windowId), mProperties(desc), mSyncedProperties(desc), mWindow(nullptr), mIsChild(false)
  66. , mShowOnSwap(false), mDisplayFrequency(0), mRenderAPI(renderAPI), mRequiresNewBackBuffer(true)
  67. { }
  68. Win32RenderWindow::~Win32RenderWindow()
  69. {
  70. SPtr<VulkanDevice> presentDevice = mRenderAPI._getPresentDevice();
  71. presentDevice->waitIdle();
  72. if (mWindow != nullptr)
  73. {
  74. bs_delete(mWindow);
  75. mWindow = nullptr;
  76. }
  77. mSwapChain = nullptr;
  78. vkDestroySurfaceKHR(mRenderAPI._getInstance(), mSurface, gVulkanAllocator);
  79. Platform::resetNonClientAreas(*this);
  80. }
  81. void Win32RenderWindow::initialize()
  82. {
  83. RenderWindowProperties& props = mProperties;
  84. // Create a window
  85. WINDOW_DESC windowDesc;
  86. windowDesc.showTitleBar = mDesc.showTitleBar;
  87. windowDesc.showBorder = mDesc.showBorder;
  88. windowDesc.allowResize = mDesc.allowResize;
  89. windowDesc.enableDoubleClick = true;
  90. windowDesc.fullscreen = mDesc.fullscreen;
  91. windowDesc.width = mDesc.videoMode.getWidth();
  92. windowDesc.height = mDesc.videoMode.getHeight();
  93. windowDesc.hidden = mDesc.hidden || mDesc.hideUntilSwap;
  94. windowDesc.left = mDesc.left;
  95. windowDesc.top = mDesc.top;
  96. windowDesc.outerDimensions = false;
  97. windowDesc.title = mDesc.title;
  98. windowDesc.toolWindow = mDesc.toolWindow;
  99. windowDesc.creationParams = this;
  100. windowDesc.modal = mDesc.modal;
  101. windowDesc.wndProc = &Win32Platform::_win32WndProc;
  102. #ifdef BS_STATIC_LIB
  103. windowDesc.module = GetModuleHandle(NULL);
  104. #else
  105. windowDesc.module = GetModuleHandle("BansheeVulkanRenderAPI.dll");
  106. #endif
  107. NameValuePairList::const_iterator opt;
  108. opt = mDesc.platformSpecific.find("parentWindowHandle");
  109. if (opt != mDesc.platformSpecific.end())
  110. windowDesc.parent = (HWND)parseUINT64(opt->second);
  111. opt = mDesc.platformSpecific.find("externalWindowHandle");
  112. if (opt != mDesc.platformSpecific.end())
  113. windowDesc.external = (HWND)parseUINT64(opt->second);
  114. const Win32VideoModeInfo& videoModeInfo = static_cast<const Win32VideoModeInfo&>(RenderAPI::instance().getVideoModeInfo());
  115. UINT32 numOutputs = videoModeInfo.getNumOutputs();
  116. if (numOutputs > 0)
  117. {
  118. UINT32 actualMonitorIdx = std::min(mDesc.videoMode.getOutputIdx(), numOutputs - 1);
  119. const Win32VideoOutputInfo& outputInfo = static_cast<const Win32VideoOutputInfo&>(videoModeInfo.getOutputInfo(actualMonitorIdx));
  120. windowDesc.monitor = outputInfo.getMonitorHandle();
  121. }
  122. // Must be set before creating a window, since wndProc will call ShowWindow if needed after creation
  123. if (!windowDesc.external)
  124. {
  125. mShowOnSwap = mDesc.hideUntilSwap;
  126. props.isHidden = mDesc.hideUntilSwap || mDesc.hidden;
  127. }
  128. mWindow = bs_new<Win32Window>(windowDesc);
  129. mIsChild = windowDesc.parent != nullptr;
  130. mDisplayFrequency = Math::roundToInt(mDesc.videoMode.getRefreshRate());
  131. // Update local properties
  132. props.isFullScreen = mDesc.fullscreen && !mIsChild;
  133. props.width = mWindow->getWidth();
  134. props.height = mWindow->getHeight();
  135. props.top = mWindow->getTop();
  136. props.left = mWindow->getLeft();
  137. props.hwGamma = mDesc.gamma;
  138. props.multisampleCount = 1;
  139. // Create Vulkan surface
  140. VkWin32SurfaceCreateInfoKHR surfaceCreateInfo;
  141. surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
  142. surfaceCreateInfo.pNext = nullptr;
  143. surfaceCreateInfo.flags = 0;
  144. surfaceCreateInfo.hwnd = mWindow->getHWnd();
  145. surfaceCreateInfo.hinstance = windowDesc.module;
  146. VkInstance instance = mRenderAPI._getInstance();
  147. VkResult result = vkCreateWin32SurfaceKHR(instance, &surfaceCreateInfo, gVulkanAllocator, &mSurface);
  148. assert(result == VK_SUCCESS);
  149. SPtr<VulkanDevice> presentDevice = mRenderAPI._getPresentDevice();
  150. VkPhysicalDevice physicalDevice = presentDevice->getPhysical();
  151. mPresentQueueFamily = presentDevice->getQueueFamily(GQT_GRAPHICS);
  152. VkBool32 supportsPresent;
  153. vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, mPresentQueueFamily, mSurface, &supportsPresent);
  154. if(!supportsPresent)
  155. {
  156. // Note: Not supporting present only queues at the moment
  157. // Note: Also present device can only return one family of graphics queue, while there could be more (some of
  158. // which support present)
  159. BS_EXCEPT(RenderingAPIException, "Cannot find a graphics queue that also supports present operations.");
  160. }
  161. SurfaceFormat format = presentDevice->getSurfaceFormat(mSurface, mDesc.gamma);
  162. mColorFormat = format.colorFormat;
  163. mColorSpace = format.colorSpace;
  164. mDepthFormat = format.depthFormat;
  165. // Create swap chain
  166. mSwapChain = bs_shared_ptr_new<VulkanSwapChain>();
  167. mSwapChain->rebuild(presentDevice, mSurface, props.width, props.height, props.vsync, mColorFormat, mColorSpace,
  168. mDesc.depthBuffer, mDepthFormat);
  169. // Make the window full screen if required
  170. if (!windowDesc.external)
  171. {
  172. if (props.isFullScreen)
  173. {
  174. DEVMODE displayDeviceMode;
  175. memset(&displayDeviceMode, 0, sizeof(displayDeviceMode));
  176. displayDeviceMode.dmSize = sizeof(DEVMODE);
  177. displayDeviceMode.dmBitsPerPel = 32;
  178. displayDeviceMode.dmPelsWidth = props.width;
  179. displayDeviceMode.dmPelsHeight = props.height;
  180. displayDeviceMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
  181. if (mDisplayFrequency)
  182. {
  183. displayDeviceMode.dmDisplayFrequency = mDisplayFrequency;
  184. displayDeviceMode.dmFields |= DM_DISPLAYFREQUENCY;
  185. if (ChangeDisplaySettingsEx(NULL, &displayDeviceMode, NULL, CDS_FULLSCREEN | CDS_TEST, NULL) != DISP_CHANGE_SUCCESSFUL)
  186. {
  187. BS_EXCEPT(RenderingAPIException, "ChangeDisplaySettings with user display frequency failed.");
  188. }
  189. }
  190. if (ChangeDisplaySettingsEx(NULL, &displayDeviceMode, NULL, CDS_FULLSCREEN, NULL) != DISP_CHANGE_SUCCESSFUL)
  191. {
  192. BS_EXCEPT(RenderingAPIException, "ChangeDisplaySettings failed.");
  193. }
  194. }
  195. }
  196. {
  197. ScopedSpinLock lock(mLock);
  198. mSyncedProperties = props;
  199. }
  200. bs::RenderWindowManager::instance().notifySyncDataDirty(this);
  201. RenderWindow::initialize();
  202. }
  203. void Win32RenderWindow::acquireBackBuffer()
  204. {
  205. // We haven't presented the current back buffer yet, so just use that one
  206. if (!mRequiresNewBackBuffer)
  207. return;
  208. mSwapChain->acquireBackBuffer();
  209. mRequiresNewBackBuffer = false;
  210. }
  211. void Win32RenderWindow::swapBuffers(UINT32 syncMask)
  212. {
  213. THROW_IF_NOT_CORE_THREAD;
  214. if (mShowOnSwap)
  215. setHidden(false);
  216. // Get a command buffer on which we'll submit
  217. SPtr<VulkanDevice> presentDevice = mRenderAPI._getPresentDevice();
  218. // Assuming present queue is always graphics
  219. assert(presentDevice->getQueueFamily(GQT_GRAPHICS) == mPresentQueueFamily);
  220. // Find an appropriate queue to execute on
  221. VulkanQueue* queue = presentDevice->getQueue(GQT_GRAPHICS, 0);
  222. UINT32 queueMask = presentDevice->getQueueMask(GQT_GRAPHICS, 0);
  223. // Ignore myself
  224. syncMask &= ~queueMask;
  225. UINT32 deviceIdx = presentDevice->getIndex();
  226. VulkanCommandBufferManager& cbm = static_cast<VulkanCommandBufferManager&>(CommandBufferManager::instance());
  227. UINT32 numSemaphores;
  228. cbm.getSyncSemaphores(deviceIdx, syncMask, mSemaphoresTemp, numSemaphores);
  229. // Wait on present (i.e. until the back buffer becomes available), if we haven't already done so
  230. const SwapChainSurface& surface = mSwapChain->getBackBuffer();
  231. if(surface.needsWait)
  232. {
  233. mSemaphoresTemp[numSemaphores] = mSwapChain->getBackBuffer().sync;
  234. numSemaphores++;
  235. mSwapChain->notifyBackBufferWaitIssued();
  236. }
  237. queue->present(mSwapChain.get(), mSemaphoresTemp, numSemaphores);
  238. mRequiresNewBackBuffer = true;
  239. }
  240. void Win32RenderWindow::move(INT32 left, INT32 top)
  241. {
  242. THROW_IF_NOT_CORE_THREAD;
  243. RenderWindowProperties& props = mProperties;
  244. if (!props.isFullScreen)
  245. {
  246. mWindow->move(left, top);
  247. props.top = mWindow->getTop();
  248. props.left = mWindow->getLeft();
  249. {
  250. ScopedSpinLock lock(mLock);
  251. mSyncedProperties.top = props.top;
  252. mSyncedProperties.left = props.left;
  253. }
  254. bs::RenderWindowManager::instance().notifySyncDataDirty(this);
  255. }
  256. }
  257. void Win32RenderWindow::resize(UINT32 width, UINT32 height)
  258. {
  259. THROW_IF_NOT_CORE_THREAD;
  260. RenderWindowProperties& props = mProperties;
  261. if (!props.isFullScreen)
  262. {
  263. mWindow->resize(width, height);
  264. props.width = mWindow->getWidth();
  265. props.height = mWindow->getHeight();
  266. {
  267. ScopedSpinLock lock(mLock);
  268. mSyncedProperties.width = props.width;
  269. mSyncedProperties.height = props.height;
  270. }
  271. bs::RenderWindowManager::instance().notifySyncDataDirty(this);
  272. }
  273. }
  274. void Win32RenderWindow::setActive(bool state)
  275. {
  276. THROW_IF_NOT_CORE_THREAD;
  277. mWindow->setActive(state);
  278. RenderWindow::setActive(state);
  279. }
  280. void Win32RenderWindow::setHidden(bool hidden)
  281. {
  282. THROW_IF_NOT_CORE_THREAD;
  283. mShowOnSwap = false;
  284. mWindow->setHidden(hidden);
  285. RenderWindow::setHidden(hidden);
  286. }
  287. void Win32RenderWindow::minimize()
  288. {
  289. THROW_IF_NOT_CORE_THREAD;
  290. mWindow->minimize();
  291. }
  292. void Win32RenderWindow::maximize()
  293. {
  294. THROW_IF_NOT_CORE_THREAD;
  295. mWindow->maximize();
  296. }
  297. void Win32RenderWindow::restore()
  298. {
  299. THROW_IF_NOT_CORE_THREAD;
  300. mWindow->restore();
  301. }
  302. void Win32RenderWindow::setFullscreen(UINT32 width, UINT32 height, float refreshRate, UINT32 monitorIdx)
  303. {
  304. THROW_IF_NOT_CORE_THREAD;
  305. if (mIsChild)
  306. return;
  307. const Win32VideoModeInfo& videoModeInfo = static_cast<const Win32VideoModeInfo&>(RenderAPI::instance().getVideoModeInfo());
  308. UINT32 numOutputs = videoModeInfo.getNumOutputs();
  309. if (numOutputs == 0)
  310. return;
  311. RenderWindowProperties& props = mProperties;
  312. UINT32 actualMonitorIdx = std::min(monitorIdx, numOutputs - 1);
  313. const Win32VideoOutputInfo& outputInfo = static_cast<const Win32VideoOutputInfo&>(videoModeInfo.getOutputInfo(actualMonitorIdx));
  314. mDisplayFrequency = Math::roundToInt(refreshRate);
  315. props.isFullScreen = true;
  316. DEVMODE displayDeviceMode;
  317. memset(&displayDeviceMode, 0, sizeof(displayDeviceMode));
  318. displayDeviceMode.dmSize = sizeof(DEVMODE);
  319. displayDeviceMode.dmBitsPerPel = 32;
  320. displayDeviceMode.dmPelsWidth = width;
  321. displayDeviceMode.dmPelsHeight = height;
  322. displayDeviceMode.dmDisplayFrequency = mDisplayFrequency;
  323. displayDeviceMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
  324. HMONITOR hMonitor = outputInfo.getMonitorHandle();
  325. MONITORINFOEX monitorInfo;
  326. memset(&monitorInfo, 0, sizeof(MONITORINFOEX));
  327. monitorInfo.cbSize = sizeof(MONITORINFOEX);
  328. GetMonitorInfo(hMonitor, &monitorInfo);
  329. if (ChangeDisplaySettingsEx(monitorInfo.szDevice, &displayDeviceMode, NULL, CDS_FULLSCREEN, NULL) != DISP_CHANGE_SUCCESSFUL)
  330. {
  331. BS_EXCEPT(RenderingAPIException, "ChangeDisplaySettings failed");
  332. }
  333. props.top = monitorInfo.rcMonitor.top;
  334. props.left = monitorInfo.rcMonitor.left;
  335. props.width = width;
  336. props.height = height;
  337. SetWindowLong(mWindow->getHWnd(), GWL_STYLE, WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
  338. SetWindowLong(mWindow->getHWnd(), GWL_EXSTYLE, 0);
  339. SetWindowPos(mWindow->getHWnd(), HWND_TOP, props.left, props.top, width, height, SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
  340. }
  341. void Win32RenderWindow::setFullscreen(const VideoMode& mode)
  342. {
  343. THROW_IF_NOT_CORE_THREAD;
  344. setFullscreen(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getOutputIdx());
  345. }
  346. void Win32RenderWindow::setWindowed(UINT32 width, UINT32 height)
  347. {
  348. THROW_IF_NOT_CORE_THREAD;
  349. RenderWindowProperties& props = mProperties;
  350. if (!props.isFullScreen)
  351. return;
  352. props.isFullScreen = false;
  353. props.width = width;
  354. props.height = height;
  355. // Drop out of fullscreen
  356. ChangeDisplaySettingsEx(NULL, NULL, NULL, 0, NULL);
  357. UINT32 winWidth = width;
  358. UINT32 winHeight = height;
  359. RECT rect;
  360. SetRect(&rect, 0, 0, winWidth, winHeight);
  361. AdjustWindowRect(&rect, mWindow->getStyle(), false);
  362. winWidth = rect.right - rect.left;
  363. winHeight = rect.bottom - rect.top;
  364. // Deal with centering when switching down to smaller resolution
  365. HMONITOR hMonitor = MonitorFromWindow(mWindow->getHWnd(), MONITOR_DEFAULTTONEAREST);
  366. MONITORINFO monitorInfo;
  367. memset(&monitorInfo, 0, sizeof(MONITORINFO));
  368. monitorInfo.cbSize = sizeof(MONITORINFO);
  369. GetMonitorInfo(hMonitor, &monitorInfo);
  370. LONG screenw = monitorInfo.rcWork.right - monitorInfo.rcWork.left;
  371. LONG screenh = monitorInfo.rcWork.bottom - monitorInfo.rcWork.top;
  372. INT32 left = screenw > INT32(winWidth) ? ((screenw - INT32(winWidth)) / 2) : 0;
  373. INT32 top = screenh > INT32(winHeight) ? ((screenh - INT32(winHeight)) / 2) : 0;
  374. SetWindowLong(mWindow->getHWnd(), GWL_STYLE, mWindow->getStyle() | WS_VISIBLE);
  375. SetWindowLong(mWindow->getHWnd(), GWL_EXSTYLE, mWindow->getStyleEx());
  376. SetWindowPos(mWindow->getHWnd(), HWND_NOTOPMOST, left, top, winWidth, winHeight,
  377. SWP_DRAWFRAME | SWP_FRAMECHANGED | SWP_NOACTIVATE);
  378. {
  379. ScopedSpinLock lock(mLock);
  380. mSyncedProperties.width = props.width;
  381. mSyncedProperties.height = props.height;
  382. }
  383. bs::RenderWindowManager::instance().notifySyncDataDirty(this);
  384. }
  385. void Win32RenderWindow::setVSync(bool enabled, UINT32 interval)
  386. {
  387. // Rebuild swap chain
  388. //// Need to make sure nothing is using the swap buffer before we re-create it
  389. // Note: Optionally I can detect exactly on which queues (if any) are the swap chain images used on, and only wait
  390. // on those
  391. SPtr<VulkanDevice> presentDevice = mRenderAPI._getPresentDevice();
  392. presentDevice->waitIdle();
  393. mSwapChain->rebuild(presentDevice, mSurface, mProperties.width, mProperties.height, enabled, mColorFormat, mColorSpace,
  394. mDesc.depthBuffer, mDepthFormat);
  395. mProperties.vsync = enabled;
  396. mProperties.vsyncInterval = interval;
  397. {
  398. ScopedSpinLock lock(mLock);
  399. mSyncedProperties.vsync = enabled;
  400. mSyncedProperties.vsyncInterval = interval;
  401. }
  402. bs::RenderWindowManager::instance().notifySyncDataDirty(this);
  403. }
  404. HWND Win32RenderWindow::_getWindowHandle() const
  405. {
  406. return mWindow->getHWnd();
  407. }
  408. void Win32RenderWindow::getCustomAttribute(const String& name, void* data) const
  409. {
  410. if (name == "FB")
  411. {
  412. VulkanFramebuffer** fb = (VulkanFramebuffer**)data;
  413. *fb = mSwapChain->getBackBuffer().framebuffer;
  414. return;
  415. }
  416. if(name == "SC")
  417. {
  418. VulkanSwapChain** sc = (VulkanSwapChain**)data;
  419. *sc = mSwapChain.get();
  420. return;
  421. }
  422. if(name == "WINDOW")
  423. {
  424. UINT64 *pWnd = (UINT64*)data;
  425. *pWnd = (UINT64)mWindow->getHWnd();
  426. return;
  427. }
  428. RenderWindow::getCustomAttribute(name, data);
  429. }
  430. void Win32RenderWindow::_windowMovedOrResized()
  431. {
  432. THROW_IF_NOT_CORE_THREAD;
  433. if (!mWindow)
  434. return;
  435. mWindow->_windowMovedOrResized();
  436. RenderWindowProperties& props = mProperties;
  437. if (!props.isFullScreen) // Fullscreen is handled directly by this object
  438. {
  439. props.top = mWindow->getTop();
  440. props.left = mWindow->getLeft();
  441. props.width = mWindow->getWidth();
  442. props.height = mWindow->getHeight();
  443. }
  444. // Resize swap chain
  445. //// Need to make sure nothing is using the swap buffer before we re-create it
  446. // Note: Optionally I can detect exactly on which queues (if any) are the swap chain images used on, and only wait
  447. // on those
  448. SPtr<VulkanDevice> presentDevice = mRenderAPI._getPresentDevice();
  449. presentDevice->waitIdle();
  450. mSwapChain->rebuild(presentDevice, mSurface, props.width, props.height, props.vsync, mColorFormat, mColorSpace,
  451. mDesc.depthBuffer, mDepthFormat);
  452. RenderWindow::_windowMovedOrResized();
  453. }
  454. void Win32RenderWindow::syncProperties()
  455. {
  456. ScopedSpinLock lock(mLock);
  457. mProperties = mSyncedProperties;
  458. }
  459. }
  460. }