locked
Improving performance of rendering text in DirectWrite.

    Question

  • Hello,

    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?

    Wednesday, February 18, 2015 1:27 PM

All replies

  • Check suggestions in this document: https://msdn.microsoft.com/en-us/library/windows/desktop/dd372260(v=vs.85).aspx#text

    Best Regards,
    Please remember to mark the replies as answers if they help

    Thursday, February 19, 2015 6:13 AM
  • I have read it before posting and there is no new ideas to improve my application, any other ideas?
    Thursday, February 19, 2015 11:48 AM
  • Have you looked at SpriteFont in DirectX Tool Kit?
    Thursday, February 19, 2015 7:16 PM
  •      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

    Thursday, February 19, 2015 9:34 PM
  •      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.


    Tarh ik

    Thursday, February 19, 2015 10:04 PM