4

I face one critical Performance problem in my Direct2D application. I make use of Direct2D to draw my graph using PathGeometry to get better performance and to achieve the clean rendering in Windows 8.1.

While creating the DeviceResources, i create the PathGeometry using the Factory interface. Then i set the Graph points to draw my graph in the output surface. Finally rendered ImageSource will be used as the source for my Image element in the XAML.

I just followed the below sample link to achieve my scenario.

http://code.msdn.microsoft.com/windowsapps/XAML-SurfaceImageSource-58f7e4d5

The above sample helped me a lot to get the ImageSource output from the Direct2D and finally used across the XAML/C# app.

Lets come to my problem. I use more than 24 graphs in the single Page of my Windows Store application. This graph allows the user to manipulate in Left and Right position and also allows to scale to the particular zoom level.

Hence whenever user tries to manipulate the graph , i just set the Translation and Scaling matrix to the TransformedPathGeometry instead of creating the new one for each and every time.

ID2D1TransformedGeometry *m_pTransformedGeometry;

pFactory->CreateTransformedGeometry(graphgeometry, combinedMatrix, &m_pTransformedGeometry);

Finally i draw the TransformedGeometry using the DrawGeometry method.

I checked my application using the Performance analysis tool in the VisualStudio2013. I could see that in the particular peek level, It takes more than 80% of running time to call the m_d2deviceContext->EndDraw() method. I attached the below screen shot to get more idea in this performance output.

Is there any way to increase this performance considerably ?

enter image description here

Could you please anyone help me in this ?

Regards, David C

David Bekham
  • 2,175
  • 3
  • 27
  • 56
  • 4
    This is normal. At the EndDraw() call, DirectX will actually get the job done of rendering to the screen. The problem here is not that drawing is slow, it is that the rest of your code simply doesn't take a lot of time. So the percentage is large. – Hans Passant Sep 02 '13 at 15:19
  • @HansPassant : I guess this is the problem for my performance leak. So cant we reduce the % externally ? . If yes what are the factors we need to consider ? – David Bekham Sep 02 '13 at 15:24
  • 3
    Write more code and the number automatically gets smaller. You have not demonstrated a performance problem at all. You only presented a number and did not indicate that the app actually has a responsiveness problem. Since there isn't anything you can do to change DirectX and make it faster, you are *done*. It is already as fast as it is ever going to run. Only simplifying what you draw could make it faster. – Hans Passant Sep 02 '13 at 15:30

2 Answers2

3

THere is a difference between slow performance and time spend.

If your draw method does more work than other parts, can mean that this method is slow but it also can mean that your other parts don't need a lot of cpu.

88.2% tells you only that you spend more time drawing that stuff than doing other stuff.

Use an timer to determine if your draw is slow.

sigi
  • 99
  • 11
  • I just call the EndDraw method from the framework. But it takes more percentage when we compare to other methods. What may be reason to reduce this amount of percentage to increase the performance. – David Bekham Sep 02 '13 at 15:19
  • 1
    @DavidBekham it is still not a valid way to compare it to other methods. When in the EndDraw every drawing happens or the hardest stuff, it is fine that this method useses 88.2%. – sigi Sep 02 '13 at 15:21
  • I actually mean in the performance way that my performance is too slow when i test my application in the ARM device. How to increase my app performance ? – David Bekham Sep 02 '13 at 15:29
  • @DavidBekham do you have any screenshots? Can you reduce the number of elements you draw? – sigi Sep 02 '13 at 15:40
  • can you post your mail id?> I will send all the screenshots to your mail. – David Bekham Sep 02 '13 at 15:47
  • 1
    @DavidBekham you should upload it here for all of us to determine your problem better. – sigi Sep 03 '13 at 11:51
0

"i just set the Translation and Scaling matrix to the TransformedPathGeometry instead of creating the new one for each and every time."

I hope you use world transform? Else you overwrite the pointer without releasing it before, providing a memory leak. You cannot change the matrix of a geometry directly, you have to recreate it each time, or if you can, you apply the transform to the entire world.

paulus
  • 11
  • 2