yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1// debug-swap-chain.cpp 2#include "debug-swap-chain.h" 3 4#include "debug-command-queue.h" 5#include "debug-helper-functions.h" 6#include "debug-texture.h" 7 8namespace gfx 9{ 10using namespace Slang ; 11 12namespace debug 13{ 14 15const ISwapchain ::Desc & DebugSwapchain ::getDesc () 16{ 17SLANG_GFX_API_FUNC ; 18desc = baseObject -> getDesc (); 19desc .queue = queue .Ptr (); 20return desc ; 21} 22 23Result DebugSwapchain ::getImage (GfxIndex index ,ITextureResource ** outResource ) 24{ 25SLANG_GFX_API_FUNC ; 26maybeRebuildImageList (); 27if (index > (GfxCount )m_images .getCount ()) 28 { 29GFX_DIAGNOSE_ERROR_FORMAT ( 30"`index`(%d) must not exceed total number of images (%d) in the swapchain." , 31index , 32 (uint32_t )m_images .getCount ()); 33 } 34returnComPtr (outResource ,m_images [index ]); 35return SLANG_OK ; 36} 37 38Result DebugSwapchain ::present () 39{ 40SLANG_GFX_API_FUNC ; 41return baseObject -> present (); 42} 43 44int DebugSwapchain ::acquireNextImage () 45{ 46SLANG_GFX_API_FUNC ; 47return baseObject -> acquireNextImage (); 48} 49 50Result DebugSwapchain ::resize (GfxCount width ,GfxCount height ) 51{ 52SLANG_GFX_API_FUNC ; 53for (auto & image :m_images ) 54 { 55if (image -> debugGetReferenceCount ()!= 1 ) 56 { 57// Only warn here because tools like NSight might keep 58// an additional reference to swapchain images. 59GFX_DIAGNOSE_WARNING ("all swapchain images must be released before calling resize()." ); 60break ; 61 } 62 } 63m_images .clearAndDeallocate (); 64return baseObject -> resize (width ,height ); 65} 66 67bool DebugSwapchain ::isOccluded () 68{ 69SLANG_GFX_API_FUNC ; 70return baseObject -> isOccluded (); 71} 72 73Result DebugSwapchain ::setFullScreenMode (bool mode ) 74{ 75SLANG_GFX_API_FUNC ; 76return baseObject -> setFullScreenMode (mode ); 77} 78 79void DebugSwapchain ::maybeRebuildImageList () 80{ 81SLANG_GFX_API_FUNC ; 82if (m_images .getCount ()!= 0 ) 83return ; 84m_images .clearAndDeallocate (); 85for (GfxIndex i = 0 ;i < baseObject -> getDesc ().imageCount ;i ++ ) 86 { 87RefPtr < DebugTextureResource > image = new DebugTextureResource (); 88baseObject -> getImage (i ,image -> baseObject .writeRef ()); 89m_images .add (image ); 90 } 91} 92 93}// namespace debug 94}// namespace gfx