Slow Direct 2D performance


  • Hi.

    I am a c# developer looking at writing a game for W8. I have never touched C++ before but am slowly learning.

    I am trying to draw thousands of squares to the screen and animate them as a perf test, and its turning out terribly. With XNA on my phone I can do a similar thing with around 6000 squares before it starts lagging. On my core i5 with 4Gb ram, I cant even get double that. Im sure I am drawing it wrong or something

    Here is my code, I would appreciate help

    	for (int i = 0; i < 10000; i++)
    		Pixel p = pixels[i];
    		pixels[i].YPos += 1;
    		m_d2dContext->DrawRectangle(D2D1::RectF(p.XPos, p.YPos, p.XPos + 3, p.YPos +3),m_solidBrush.Get());


    Saturday, March 03, 2012 10:17 PM


  • Hi ruguemat,

    difficult for me to see a issue with only those lines of code. Where are your BeginDraw & EndDraw methods? Can you paste you main loop here? Direct2D is optimized to send a lot of geometry at once to the GPU - maybe you can optimize for that.

    Did you already have a look here: http://msdn.microsoft.com/en-us/library/windows/desktop/dd372260%28v=vs.85%29.aspx

    - Paul

    Monday, March 05, 2012 11:57 AM