From 21adb804fa0c9e12eb5c35ffab9df3c53f6d01b8 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Thu, 18 Aug 2022 13:38:40 +0200 Subject: [PATCH] AtlasEngine: Fix debugGlyphGenerationPerformance (#13757) `debugGlyphGenerationPerformance` used to only test the performance of text segmentation/parsing, so I renamed it to `debugTextParsingPerformance`. The new `debugGlyphGenerationPerformance` actually clears the glyph atlas now. Additionally this fixes a bug with `debugGeneralPerformance`: If a `DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT` is requested, it needs to be used. Since `debugGeneralPerformance` is for testing without V-Sync, we need to ensure that the waitable object is properly disabled. --- src/renderer/atlas/AtlasEngine.cpp | 8 +++++++- src/renderer/atlas/AtlasEngine.h | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/renderer/atlas/AtlasEngine.cpp b/src/renderer/atlas/AtlasEngine.cpp index ffe24158c64..c6fad7ca09b 100644 --- a/src/renderer/atlas/AtlasEngine.cpp +++ b/src/renderer/atlas/AtlasEngine.cpp @@ -233,6 +233,11 @@ try } if constexpr (debugGlyphGenerationPerformance) + { + _r.glyphs = {}; + _r.tileAllocator = TileAllocator{ _api.fontMetrics.cellSize, _api.sizeInPixel }; + } + if constexpr (debugTextParsingPerformance) { _api.dirtyRect = til::rect{ 0, 0, _api.cellCount.x, _api.cellCount.y }; } @@ -686,7 +691,7 @@ void AtlasEngine::_createSwapChain() // * If our background is opaque we can enable "independent" flips by setting DXGI_SWAP_EFFECT_FLIP_DISCARD and DXGI_ALPHA_MODE_IGNORE. // As our swap chain won't have to compose with DWM anymore it reduces the display latency dramatically. desc.AlphaMode = _api.hwnd || _api.backgroundOpaqueMixin ? DXGI_ALPHA_MODE_IGNORE : DXGI_ALPHA_MODE_PREMULTIPLIED; - desc.Flags = DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT; + desc.Flags = debugGeneralPerformance ? 0 : DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT; wil::com_ptr dxgiFactory; THROW_IF_FAILED(CreateDXGIFactory1(IID_PPV_ARGS(dxgiFactory.addressof()))); @@ -708,6 +713,7 @@ void AtlasEngine::_createSwapChain() THROW_IF_FAILED(dxgiFactory.query()->CreateSwapChainForCompositionSurfaceHandle(_r.device.get(), _api.swapChainHandle.get(), &desc, nullptr, _r.swapChain.put())); } + if constexpr (!debugGeneralPerformance) { const auto swapChain2 = _r.swapChain.query(); _r.frameLatencyWaitableObject.reset(swapChain2->GetFrameLatencyWaitableObject()); diff --git a/src/renderer/atlas/AtlasEngine.h b/src/renderer/atlas/AtlasEngine.h index 08a388ed1d4..78c3a02df4a 100644 --- a/src/renderer/atlas/AtlasEngine.h +++ b/src/renderer/atlas/AtlasEngine.h @@ -903,7 +903,8 @@ namespace Microsoft::Console::Render void _drawCursor(); static constexpr bool debugGlyphGenerationPerformance = false; - static constexpr bool debugGeneralPerformance = false || debugGlyphGenerationPerformance; + static constexpr bool debugTextParsingPerformance = false || debugGlyphGenerationPerformance; + static constexpr bool debugGeneralPerformance = false || debugTextParsingPerformance; static constexpr u16 u16min = 0x0000; static constexpr u16 u16max = 0xffff;