diff options
| author | lucy96chen <47800040+lucy96chen@users.noreply.github.com> | 2022-08-04 16:59:28 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-04 16:59:28 -0700 |
| commit | 12a846e8facf090aaeb68fcabf55867f5eaed747 (patch) | |
| tree | cc7c70c447200c1b45f20efc47e43e17828ec84d /tools/gfx/debug-layer/debug-swap-chain.cpp | |
| parent | 11b29eff99910d55a54658b8a1d053cc4ec076fc (diff) | |
Split debug-layer into smaller files (#2344)
* checkpoint commit
* debug-layer split, does not compile
* Almost compiles, rebasing before making any further changes
* everything compiles and passes tests locally
* Added tools/gfx/debug-layer to premake and ran premake
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tools/gfx/debug-layer/debug-swap-chain.cpp')
| -rw-r--r-- | tools/gfx/debug-layer/debug-swap-chain.cpp | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/tools/gfx/debug-layer/debug-swap-chain.cpp b/tools/gfx/debug-layer/debug-swap-chain.cpp new file mode 100644 index 000000000..3c8058b5c --- /dev/null +++ b/tools/gfx/debug-layer/debug-swap-chain.cpp @@ -0,0 +1,93 @@ +// debug-swap-chain.cpp +#include "debug-swap-chain.h" + +#include "debug-command-queue.h" +#include "debug-texture.h" + +#include "debug-helper-functions.h" + +namespace gfx +{ +using namespace Slang; + +namespace debug +{ + +const ISwapchain::Desc& DebugSwapchain::getDesc() +{ + SLANG_GFX_API_FUNC; + desc = baseObject->getDesc(); + desc.queue = queue.Ptr(); + return desc; +} + +Result DebugSwapchain::getImage(GfxIndex index, ITextureResource** outResource) +{ + SLANG_GFX_API_FUNC; + maybeRebuildImageList(); + if (index > (GfxCount)m_images.getCount()) + { + GFX_DIAGNOSE_ERROR_FORMAT( + "`index`(%d) must not exceed total number of images (%d) in the swapchain.", + index, + (uint32_t)m_images.getCount()); + } + returnComPtr(outResource, m_images[index]); + return SLANG_OK; +} + +Result DebugSwapchain::present() +{ + SLANG_GFX_API_FUNC; + return baseObject->present(); +} + +int DebugSwapchain::acquireNextImage() +{ + SLANG_GFX_API_FUNC; + return baseObject->acquireNextImage(); +} + +Result DebugSwapchain::resize(GfxCount width, GfxCount height) +{ + SLANG_GFX_API_FUNC; + for (auto& image : m_images) + { + if (image->debugGetReferenceCount() != 1) + { + GFX_DIAGNOSE_ERROR("all swapchain images must be released before calling resize()."); + return SLANG_FAIL; + } + } + m_images.clearAndDeallocate(); + 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; + if (m_images.getCount() != 0) + return; + m_images.clearAndDeallocate(); + for (GfxIndex i = 0; i < baseObject->getDesc().imageCount; i++) + { + RefPtr<DebugTextureResource> image = new DebugTextureResource(); + baseObject->getImage(i, image->baseObject.writeRef()); + m_images.add(image); + } +} + +} // namespace debug +} // namespace gfx |
