Skip to content

Commit

Permalink
AtlasEngine: Fix debugGlyphGenerationPerformance (microsoft#13757)
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
lhecker authored Aug 18, 2022
1 parent 8ba43f9 commit 21adb80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/renderer/atlas/AtlasEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
Expand Down Expand Up @@ -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<IDXGIFactory2> dxgiFactory;
THROW_IF_FAILED(CreateDXGIFactory1(IID_PPV_ARGS(dxgiFactory.addressof())));
Expand All @@ -708,6 +713,7 @@ void AtlasEngine::_createSwapChain()
THROW_IF_FAILED(dxgiFactory.query<IDXGIFactoryMedia>()->CreateSwapChainForCompositionSurfaceHandle(_r.device.get(), _api.swapChainHandle.get(), &desc, nullptr, _r.swapChain.put()));
}

if constexpr (!debugGeneralPerformance)
{
const auto swapChain2 = _r.swapChain.query<IDXGISwapChain2>();
_r.frameLatencyWaitableObject.reset(swapChain2->GetFrameLatencyWaitableObject());
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/atlas/AtlasEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 21adb80

Please sign in to comment.