From 8990d270e3a0c01b1f7abbf4f79556c5ef82a096 Mon Sep 17 00:00:00 2001 From: lucy96chen <47800040+lucy96chen@users.noreply.github.com> Date: Fri, 25 Feb 2022 02:58:42 -0800 Subject: Add isOccluded() and setFullScreenMode() to ISwapchain (#2145) * Added isOccluded() and setFullScreenMode() to ISwapchain and provided implementations for D3D12 (all others currently return false) * Removed isWindowOccluded variable and directly return the result of m_swapchain3->Present * Restart CI --- tools/gfx/d3d11/render-d3d11.cpp | 8 ++++++++ tools/gfx/d3d12/render-d3d12.cpp | 8 ++++++++ tools/gfx/debug-layer.cpp | 12 ++++++++++++ tools/gfx/debug-layer.h | 2 ++ tools/gfx/open-gl/render-gl.cpp | 9 +++++++++ tools/gfx/vulkan/render-vk.cpp | 8 ++++++++ 6 files changed, 47 insertions(+) (limited to 'tools') diff --git a/tools/gfx/d3d11/render-d3d11.cpp b/tools/gfx/d3d11/render-d3d11.cpp index 04399700e..d7a918a3b 100644 --- a/tools/gfx/d3d11/render-d3d11.cpp +++ b/tools/gfx/d3d11/render-d3d11.cpp @@ -370,6 +370,14 @@ protected: m_renderer->m_immediateContext->ClearState(); return D3DSwapchainBase::resize(width, height); } + virtual SLANG_NO_THROW bool SLANG_MCALL isOccluded() override + { + return false; + } + virtual SLANG_NO_THROW Result SLANG_MCALL setFullScreenMode(bool mode) override + { + return SLANG_FAIL; + } }; class InputLayoutImpl: public InputLayoutBase diff --git a/tools/gfx/d3d12/render-d3d12.cpp b/tools/gfx/d3d12/render-d3d12.cpp index 826475f43..c45ba2751 100644 --- a/tools/gfx/d3d12/render-d3d12.cpp +++ b/tools/gfx/d3d12/render-d3d12.cpp @@ -5436,6 +5436,14 @@ public: return SLANG_OK; } + virtual SLANG_NO_THROW bool SLANG_MCALL isOccluded() override + { + return (m_swapChain3->Present(0, DXGI_PRESENT_TEST) == DXGI_STATUS_OCCLUDED); + } + virtual SLANG_NO_THROW Result SLANG_MCALL setFullScreenMode(bool mode) override + { + return m_swapChain3->SetFullscreenState(mode, nullptr); + } }; static PROC loadProc(HMODULE module, char const* name); diff --git a/tools/gfx/debug-layer.cpp b/tools/gfx/debug-layer.cpp index 9cd8d216c..0926c5273 100644 --- a/tools/gfx/debug-layer.cpp +++ b/tools/gfx/debug-layer.cpp @@ -1638,6 +1638,18 @@ Result DebugSwapchain::resize(uint32_t width, uint32_t height) return baseObject->resize(width, height); } +bool DebugSwapchain::isOccluded() +{ + SLANG_GFX_API_FUNC; + return baseObject->isOccluded(); +} + +Result DebugSwapchain::setFullScreenMode(bool mode) +{ + SLANG_GFX_API_FUNC; + return baseObject->setFullScreenMode(mode); +} + void DebugSwapchain::maybeRebuildImageList() { SLANG_GFX_API_FUNC; diff --git a/tools/gfx/debug-layer.h b/tools/gfx/debug-layer.h index c141ce24a..a8cb0e849 100644 --- a/tools/gfx/debug-layer.h +++ b/tools/gfx/debug-layer.h @@ -735,6 +735,8 @@ public: virtual SLANG_NO_THROW Result SLANG_MCALL present() override; virtual SLANG_NO_THROW int SLANG_MCALL acquireNextImage() override; virtual SLANG_NO_THROW Result SLANG_MCALL resize(uint32_t width, uint32_t height) override; + virtual SLANG_NO_THROW bool SLANG_MCALL isOccluded() override; + virtual SLANG_NO_THROW Result SLANG_MCALL setFullScreenMode(bool mode) override; public: Slang::RefPtr queue; diff --git a/tools/gfx/open-gl/render-gl.cpp b/tools/gfx/open-gl/render-gl.cpp index b407fa000..934510fb2 100644 --- a/tools/gfx/open-gl/render-gl.cpp +++ b/tools/gfx/open-gl/render-gl.cpp @@ -582,6 +582,15 @@ public: return SLANG_OK; } + virtual SLANG_NO_THROW bool SLANG_MCALL isOccluded() override + { + return false; + } + virtual SLANG_NO_THROW Result SLANG_MCALL setFullScreenMode(bool mode) override + { + return SLANG_FAIL; + } + public: RefPtr> m_renderer = nullptr; GLuint m_framebuffer; diff --git a/tools/gfx/vulkan/render-vk.cpp b/tools/gfx/vulkan/render-vk.cpp index a1544ebc0..abe5a3b4d 100644 --- a/tools/gfx/vulkan/render-vk.cpp +++ b/tools/gfx/vulkan/render-vk.cpp @@ -6449,6 +6449,14 @@ public: m_queue->m_pendingWaitSemaphores[1] = m_nextImageSemaphore; return m_currentImageIndex; } + virtual SLANG_NO_THROW bool SLANG_MCALL isOccluded() override + { + return false; + } + virtual SLANG_NO_THROW Result SLANG_MCALL setFullScreenMode(bool mode) override + { + return SLANG_FAIL; + } }; VkBool32 handleDebugMessage(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objType, uint64_t srcObject, -- cgit v1.2.3