From 8a71039475212fb1e1a6dd2fd2911d02769637ef Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 8 Apr 2021 21:10:30 -0700 Subject: Improve robustness of gfx lifetime management. (#1788) * Improve robustness of gfx lifetime management. * fix clang error * fix clang error * Fix clang warning --- tools/gfx/d3d/d3d-swapchain.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'tools/gfx/d3d') diff --git a/tools/gfx/d3d/d3d-swapchain.h b/tools/gfx/d3d/d3d-swapchain.h index 5a9ead876..11914cca8 100644 --- a/tools/gfx/d3d/d3d-swapchain.h +++ b/tools/gfx/d3d/d3d-swapchain.h @@ -10,10 +10,10 @@ namespace gfx { class D3DSwapchainBase : public ISwapchain - , public Slang::RefObject + , public Slang::ComObject { public: - SLANG_REF_OBJECT_IUNKNOWN_ALL + SLANG_COM_OBJECT_IUNKNOWN_ALL ISwapchain* getInterface(const Slang::Guid& guid) { if (guid == GfxGUID::IID_ISlangUnknown || guid == GfxGUID::IID_ISwapchain) @@ -82,8 +82,7 @@ public: virtual SLANG_NO_THROW Result SLANG_MCALL getImage(uint32_t index, ITextureResource** outResource) override { - m_images[index]->addRef(); - *outResource = m_images[index].get(); + returnComPtr(outResource, m_images[index]); return SLANG_OK; } virtual SLANG_NO_THROW Result SLANG_MCALL present() override @@ -148,7 +147,7 @@ public: ISwapchain::Desc m_desc; HANDLE m_swapChainWaitableObject = nullptr; ComPtr m_swapChain; - Slang::ShortList> m_images; + Slang::ShortList> m_images; }; } -- cgit v1.2.3