Prof-Butts / xwa_ddraw_d3d11

Direct3D 11 implementation of DDraw.dll for XWA with VR support and New Shaders
MIT License
6 stars 4 forks source link

Release 1 1 4 #27

Closed MamiyaOtaru closed 4 years ago

MamiyaOtaru commented 4 years ago

instead of having drawText compute a layout for each and every char every frame, cache layouts for each char and use them in calling drawTextLayout. This doubles my FPS in text heavy views.

MamiyaOtaru commented 4 years ago

I tried using cached brushes for the radar too, and it made no discernible difference. Using them for the font is likewise a tiny tiny difference if it makes one at all. The real savings is caching the layouts. So omitting the last commit should bring all of the performance improvements, while being a smaller change. On the other hand, the last one (caching the brushes) doesn't really hurt anything.

JeremyAnsel commented 4 years ago

Hello, Thanks for the idea.

I've run a benchmark to compare the performance. I use the text in the Pilot Proving Ground for the test. Original method takes around 20.7597 ms to render. Layout caching takes around 7.1108 ms to render.

When there are a lot of text, there is a FPS drop with the DrawText method, and there is a FPS gain with the DrawTextLayout method.