diff options
| author | lucy96chen <47800040+lucy96chen@users.noreply.github.com> | 2022-02-25 02:58:42 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-25 02:58:42 -0800 |
| commit | 8990d270e3a0c01b1f7abbf4f79556c5ef82a096 (patch) | |
| tree | 5056131c8b0f5e838447120ae9b44f602e06e64b | |
| parent | 97ee917b5be4544db0f29eeb095eb55e360619c6 (diff) | |
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
| -rw-r--r-- | slang-gfx.h | 6 | ||||
| -rw-r--r-- | tools/gfx/d3d11/render-d3d11.cpp | 8 | ||||
| -rw-r--r-- | tools/gfx/d3d12/render-d3d12.cpp | 8 | ||||
| -rw-r--r-- | tools/gfx/debug-layer.cpp | 12 | ||||
| -rw-r--r-- | tools/gfx/debug-layer.h | 2 | ||||
| -rw-r--r-- | tools/gfx/open-gl/render-gl.cpp | 9 | ||||
| -rw-r--r-- | tools/gfx/vulkan/render-vk.cpp | 8 |
7 files changed, 53 insertions, 0 deletions
diff --git a/slang-gfx.h b/slang-gfx.h index 9971b81fe..d36892b31 100644 --- a/slang-gfx.h +++ b/slang-gfx.h @@ -1955,6 +1955,12 @@ public: /// Resizes the back buffers of this swapchain. All render target views and framebuffers /// referencing the back buffer images must be freed before calling this method. virtual SLANG_NO_THROW Result SLANG_MCALL resize(uint32_t width, uint32_t height) = 0; + + // Check if the window is occluded. + virtual SLANG_NO_THROW bool SLANG_MCALL isOccluded() = 0; + + // Toggle full screen mode. + virtual SLANG_NO_THROW Result SLANG_MCALL setFullScreenMode(bool mode) = 0; }; #define SLANG_UUID_ISwapchain \ { \ 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<DebugCommandQueue> 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<WeakSink<GLDevice>> 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, |
