From 34fba7b5e726136c6eee8a318ab9a75381399c00 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 20 Apr 2021 13:17:29 -0700 Subject: Various fixes to make `model-viewer` example almost working. (#1801) * Fixing `PseudoPtr` legalization and `gfx` lifetime issues. * Fixing `model-viewer` example. This change contains various fixes to bring `model-viewer` example to fully functional. These fixes include: 1. Add `spReflectionTypeLayout_getSubObjectRangeSpaceOffset` function to return the space index for a sub object referenced through a `ParameterBlock` binding. 2. Make sure `D3D12Device` specifies column major matrix order creating a Slang session. 3. Fix `platform::Window::close()` and `platform::Application::quit()`. 4. Fix memory leak during `model-viewer''s model loading. 5. Fix command buffer recording in `model-viewer`. With these changes, model viewer can now produce an image with a gray cube. The lighting is still incorrect becuase the `gfx` shader object implementation still does not handle "pending layout" resulting from global existential parameters. * Fix d3d12 root signature creation. * Use row-major matrix layout in model-viewer --- tools/platform/windows/win-window.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'tools/platform/windows/win-window.cpp') diff --git a/tools/platform/windows/win-window.cpp b/tools/platform/windows/win-window.cpp index 0d80eda7b..a0175a911 100644 --- a/tools/platform/windows/win-window.cpp +++ b/tools/platform/windows/win-window.cpp @@ -294,6 +294,8 @@ void Application::run(Window* mainWindow, bool waitForEvents) while (!Win32AppContext::isTerminated) { doEventsImpl(waitForEvents); + if (Win32AppContext::isTerminated) + break; if (mainWindow) { mainWindow->events.mainLoop(); @@ -343,14 +345,7 @@ public: Win32AppContext::windows[handle] = this; } - ~Win32PlatformWindow() - { - if (handle) - { - Win32AppContext::windows.Remove(handle); - } - DestroyWindow(handle); - } + ~Win32PlatformWindow() { close(); } virtual void setClientSize(uint32_t width, uint32_t height) override { @@ -401,7 +396,15 @@ public: MoveWindow(handle, left, top, width, height, FALSE); } - virtual void close() override {} + virtual void close() override + { + if (handle) + { + Win32AppContext::windows.Remove(handle); + } + DestroyWindow(handle); + handle = NULL; + } virtual bool getFocused() override { return GetFocus() == handle; } virtual bool getVisible() override { return visible; } virtual WindowHandle getNativeHandle() override -- cgit v1.2.3