Improving performance of rendering text in DirectWrite.

Category: windows metro apps games


MiXenXd on Wed, 18 Feb 2015 13:27:34


I have a problem with rendering text in DirectWrite. I know, that using drawtext and drawtextlayout per frame really slows the game, but I want to create geometry of the text, that I can store and refresh, when my text change. Previously I use a FW1FontWrapper librabry, but it doesn't support Windows Phone, so I must change it. I try to save rendertarget to bitmap and later draw it, but it is so slow and for ~400 line of text, fps counter down quicly. So maybe anybody help me, what can I do with my text?


IssueKiller on Thu, 19 Feb 2015 06:13:25

Check suggestions in this document:

MiXenXd on Thu, 19 Feb 2015 11:48:03

I have read it before posting and there is no new ideas to improve my application, any other ideas?

Chuck Walbourn - MSFT on Thu, 19 Feb 2015 19:16:02

Have you looked at SpriteFont in DirectX Tool Kit?

Tarh ik on Thu, 19 Feb 2015 21:34:43

     Hi MixEnXD,

     Well, now that you have contemplated on changing your text to a bitmap, maybe you could upload the font as an image and then use DrawIndexedInstanced() to draw the 400 lines of text. That's what I did, and it really, really, really improved performance.

     I hope it helps!!

     Tarh Ik

PS: This posting has been posted "AS IS"

Tarh ik on Thu, 19 Feb 2015 22:04:19

     Hi MixEnXD,

     Before you scratch my suggestion, think of this: on all those 400 lines of text, you could have like 50 "e"s. With DrawIndexedInstanced(), you could draw all those 50 "e"s in one single Draw call. Same goes for "s", "t" and all the alphabet. So, no matter how many lines of text you have, worst case scenarion we're talking about 28 Draw calls (up to 58 if you're mixing upper and lower cases), which beats 400 by a lot. Better yet, if you have all your letters in a single buffer (kind of what you see in the Font Applet in your Control Panel), you only have to upload it once, and you could be drawing your entire text using one single Draw call. This last option is what I did on my game.

     I hope it helps!!!

     Tarh Ik

PS: This posting has been posted AS IS.