FSX:SE D2D vs. GDI+: Can anyone tell me if there are advantages between one over the other?

#1
Hi everyone,

Is 2D2 gauge (written for FSX) taking advantage of graphics acceleration hardware?

I've done a lot of GDI+ custom gauge programming, and all in all, I'm quite happy with it. However, lately I've noticed some major bottlenecks and FPS losses, and I was wondering if anyone has any experience with what NOT to do. In particular, a bitmap stretching is a huge no-no, as the rescaling of bitmaps in GDI+ is a very resource intensive process. In general, I've been trying to get away from using bitmaps for simple MFD-type line art. However, I've noticed also that a serious bottleneck can be a RotateTransform() call, especially in a container consisting of text.

Case in point: I tried moving away from bitmap-type compass wheel with a mask "window" (HSI) to a code-generated HSI "card" set consisting of a circle, 36 tick marks and 36 10-degree labels. Creating this in GDI+ requires 36 RotateTransform() calls on the label containers, and this seems to draw a rather large FPS penalty.

So, I was wondering if a move to D2D would speed things up? Does anyone have any experience or benchmarks with this?
 
#2
I think going to D2D would be a step backwards. If you are having GDI+ performance issues, it's going to be about how you have written your rendering code. GDI+ is a pretty decent rendering engine.
 
#3
Hmmm - okay, thanks! I was sure that someone stated that D2D was preferred over GDI+ because it takes advantage of hardware acceleration, but I'm not sure if that applies to the context of FSX gauges.

Perhaps I'll do some benchmarking myself and see how they compare.
 
#4
If you're going to benchmark the manipulation of bitmaps... then you're looking in the wrong direction to begin with. With GDI+ you don't typically render bitmaps at all, you render everything by drawing it all. If a compass rose is killing your frame rates, it's not GDI+ that's the issue... it's your code for drawing the compass rose. Also, GDI+ gauges tend to use separate threads these days to get their rendering done. There is an example here on how to create a threaded gauge for GDI+ rendering. My first foray in to GDI+ was Eaglesoft's Citation X. It has 10 or 11 GDI+ rendered screens in it's VC.
 

JB3DG

Resource contributor
#5
@Misho I was the one who first tried out D2D and posted the examples here in the forum and resources section. While it does in some respects work faster than GDI+, it is a pain to work with (D3D11 is actually nicer) and some operations for dynamic complex shapes can slow things down. As such, I turned my back on it very quickly. As Ed says, multi threaded GDI+ is much better, but be careful about using Raster images with it as they will eat processing resources.

That said, I have abandoned both D2D and GDI+ now. I wrote my own 2D vector rendering library that uses D3D11 so I can use it with P3D's PDK. I mimicked the GDI+ function call structure but also added many other features that I have long wanted. Can't share though, as it is proprietary to MV.
 
#7
@Misho I was the one who first tried out D2D and posted the examples here in the forum and resources section. While it does in some respects work faster than GDI+, it is a pain to work with (D3D11 is actually nicer) and some operations for dynamic complex shapes can slow things down. As such, I turned my back on it very quickly. As Ed says, multi threaded GDI+ is much better, but be careful about using Raster images with it as they will eat processing resources.

That said, I have abandoned both D2D and GDI+ now. I wrote my own 2D vector rendering library that uses D3D11 so I can use it with P3D's PDK. I mimicked the GDI+ function call structure but also added many other features that I have long wanted. Can't share though, as it is proprietary to MV.
Yes, sir, and I thank you, it got me going with the D2D setup, plus, I also have a GDI+ template that MS's ESP provided from way back, when Microsoft evolved FSX to ESP (which I understand, is the predecessor to P3D.) Now, I have no idea if the ESP's GDI+ template is multi-threaded... how can I tell?

Incidentally - You made the D2D template freely available in FSDeveloper's resources (wiki) section, but I don't see ESP GDI+ template. If allowed, I'd gladly provide it, just let me know how.
 
Last edited:

JB3DG

Resource contributor
#8
https://www.fsdeveloper.com/forum/resources/gdi-gauges-drawing-msdn-example.162/

The ESP version (link above) isn't multi threaded. The DrawThread.cpp in the D2D example however shows how to implement a separate thread and sync it with the gauge callback. I think you may have to have 3 different flag states, one signalling when the gauge callback refreshes (telling the drawthread to run), the next which is set by the draw thread (telling the gauge callback to call SET_OFF_SCREEN), and the last indicating that SET_OFF_SCREEN has been called so the gauge callback can refresh it on the next call. That way you can avoid some nasty flashing I have encountered when using GDI+ in a separate thread.
 
#9
Oh, there it is! I am still trying to figure out difference between wiki and resources on this site ;) Ok great, I'll check it out and see if it's worth implementing. I've never had any nasty flashing - I just ran into some performance issues that I'm trying to nail down.
 
Top