For better performance, set all your monitors to the same color format

Pplu wonders why programs run more slowly when the system is running with multiple monitors.

Well, for one thing, of course, when you have more than one monitor, there's more stuff on the screen for the system to keep track of. It's the same reason that programs run more slowly on a large monitor than on a small monitor.

And if there's only one monitor, then functions like MonitorFromPoint become trivial if the flag is something like MONITOR_DEFAULTTONEAREST, because when there's only one monitor, answering questions like "What monitor is closest to this point"? becomes very easy.

If your two monitors are not the same dimensions, then the union of the two monitors will not be rectangular, which makes clipping against the union of all monitors more complicated.

But I suspect the big penalty for multiple monitors kicks in if you make the mistake of setting your monitors to different color formats, for example, if you set one monitor to 565 format and set another to 24bpp.

If the two monitors do not use the same color format, then programs will be forced to use DIBs instead of DDBs for screen bitmaps, in case a window is moved to a window with a different color format (or worse, is positioned so it straddles two monitors with different color formats). In principle, programs need only use the "worst-case" DIB; for example, if one monitor is 555 and the other is 565, then a 565 DIB will suffice. In practice, however, most programs just fall back to a 24bpp or 32bpp DIB when faced with monitors with different color formats.

(You query whether all monitors have the same color format by calling GetSystemMetrics(SM_SAMEDISPLAYFORMAT).)

Since a format conversion takes place when a DIB is blitted to a device with a different color format, forcing a program to retain its bitmaps as DIBs means that for at least one of the monitors (and probably both), you're going to undergo a format conversion when that DIB is drawn to the screen. There are also a few miscellaneous optimizations which are disabled when not all your monitors use the same color format because the cost of using DIBs outweighs the savings from the optimization.

So if you haven't already, go into your display settings and check that you set all your monitors to the same color depth. If you don't do this, then a large class of graphics optimizations is lost.

Comments (29)
  1. Anonymous says:

    So if a window that crosses two monitors has to be repainted, do I actually get two WM_PAINT, one for each monitor?

    [Hey, wow, there’s a whole MSDN chapter on multi-monitor programming, including one which describes paint messages. And you wonder why I don’t cover advanced topics any more. -Raymond]
  2. Anonymous says:

    People still use 16-bit? What’s wrong with this world??

  3. Anonymous says:

    I know we’re all nerds here and knew what you meant, but I think you should clarify that it is the larger resolution of the monitor that slows things down (as opposed to the larger physical size).  A physically larger monitor does not necessarily have a larger resolution.

  4. Anonymous says:

    @John – If someone could not infer that from the article, then you pointing it out won’t help either.

  5. Anonymous says:


    I actually had a (supposedly) technical customer once ask me why when he set his 32" monitor to 800×600 (and this particular monitor would stretch the resolution to fit the screen dimensions), his application appeared bigger than running on his old 15" monitor at 800×600.

    No matter how I tried to explain, he would always respond "But the resolution is the same!" -_-

  6. Anonymous says:

    Yeah, Raymond, and while you’re at it, you might as well point out that taller monitors slows things down too. </sarcasm>

  7. Anonymous says:

    I notice Windows 7 hides the color depth in the Advanced dialog.  As well it should.  I didn’t miss it until I specifically looked for it.

  8. Anonymous says:

    I always kind of wondered how my non-rectangular monitor setup at home affected performance. (Not enough to actually benchmark it, though…) In my case, though, the beefy gaming video card is probably negating any difference. Would be interesting to see what happened if I switched to the Intel built-in video.

    I have a 1680×1050 next to a 1280×1024.

  9. Anonymous says:

    Color management gets fun as well.

    Some apps always use the primary monitor’s profile regardless of which monitor their windows are one.

    Very few apps will do the right thing with a window that straddles two monitors (where half the window DC is in one color profile and the other half in another).

    Of course, few apps support color management in the first place. Few need to, IMO. But if you’re going to support it, remember that each monitor might have a different profile.

  10. barrkel says:

    Another performance killer: Windows 7 color calibration. Even though graphics cards can usually control the mappings of the RGB tuples, you need to go through the graphics card driver’s utility to do so.

    If you use Windows 7’s color calibration, it will do all the conversions in software. That means horrific screen flashing as you move an image from one monitor to the next, and multi-second delays when stepping through pictures using Windows Photo Viewer – even though e.g. my machine has a Core i7 @ 3.6GHz, 12GB of memory and 1GB Radeon 5870 GPU. Yes, multiple seconds to scroll between large pictures, on a machine capable of tens of billions of CPU operations per second, never mind the GPU.

  11. Anonymous says:

    James Strain:

    Perhaps your customer had a different understanding of "resolution", and thought it in strictly a "dots per inch" sense rather than the "total pixel count" sense. (Size of pixels versus size in pixels.)

  12. Anonymous says:

    I’m trying to recall memories here… The laptop that I was using at the time is long gone :)

    I rember learning that when using two different color formats the sudden screen glitches would happen less often, and that the computer fealt faster (+1 to Raymonds psychic debugging skills)

    Now I have another laptop and more multi-monitor "problems". When the computer wakes up from a hibernation, and has a second monitor enabled, the color pallete on the second monitor  "shifts"… (I like to say that the computer is on LSD :D).

    I have the feeling that manufacuters and driver makers don’t test too much in multi-monitor mode. I’ve been through 4 or 5 multi-monitor setups… and none ran with zero problems (all solvable, or with a work around, but still problems).

    And that’s only drivers / hardware! I always have liked programs that try to be "smarter" than others, and then have strange behaviours in multi-monitor setups. Take for example a program that saves the screen position in which the user last closed it, so that it can open in the same position you left it when you execute again. If you closed it on the second monitor, and you disable the monitor: The application positions it’s window off the screen. Not that you can’t Alt+Space yourself out of the situation…

    All that said: The advantages outweigh by far the disadvantages, and I can’t revert back to one monitor. Thanks for supporting multi-monitor out of the box!

    Happy multi-monitoring to all!


  13. Anonymous says:

    The case that annoyed me the most was an overly-helpful graphics driver — on resume from screensaver/login etc it would automatically disable my second monitor if it wasn’t plugged in.  Unfortunately, my second monitor was on a KVM switch, and I quite often had it switched over to a second PC while working on both.  So unless I remembered to switch back at the right time it would helpfully rearrange all the windows and I’d have to manually go back into the control panel to re-enable the monitor and then move windows back over there.

    Multi-monitor is very useful, but apps do all sorts of weird things when faced with it, sadly.

  14. Yuhong Bao says:

    "No matter how I tried to explain, he would always respond "But the resolution is the same!""

    Yep, DPI is the key word here.

  15. Anonymous says:

    "if you make the mistake of setting your monitors to different color formats"

    Wait… you can do that? Seriously, why does it let you do that?

    @James Strain – I once had a teacher in high school who insisted that lowering the resolution made this annoying custom slider control in one of the apps we did physics problems in (think like a certain movie player’s volume control, only smaller) a bigger target for the mouse to hit.

    I got detention for refusing to back down from my "ridiculous" claim that lowering the resolution just makes each pixel bigger (rather than increasing the number of pixels the controls take up)

  16. Anonymous says:

    Random832: Why not let you have different color formats for different monitors? What if the different video cards didn’t even support the same color formats?

    As for "too helpful" graphics drivers, I agree that they are overly annoying. Trying to keep a computer connected to monitors that aren’t always on has become a near-impossible task. And don’t get me started on video cards that won’t recognize monitors without proper EDID information!

  17. Anonymous says:

    And another annoyance: Programs that assume the leftmost monitor is always the primary.

    I often move the secondary monitor to the top left, since there’s the least likely place my pointer will end (at the bottom are the start menu and the taskbar, top right are window controls), but MANY programs are confused by this. :(

  18. Anonymous says:

    @Niels, @yuhong2

    At first I mistook his query as one about DPI differences, but that just confused him further.

    It’s a bit off-topic to go into further, but he finally caught on once I changed the comparison from running it on a monitor to running it on a projector :)

  19. Anonymous says:

    Another software mini-annoyance: FireFox and <SELECT> tags. If you unroll the list of a select box on the primary monitor, and the list overflows the bottom of the screen, it gets rendered in the opposite direction (from the bottom to the top of the screen, so it won’t overflow). This doesn’t happen when you unroll on the secondary screen. The list will just overflow through the bottom :(

    Good luck this doesn’t happen with IE (I understand they reimplemented all the windows controls to make them feel like native windows controls), nor native controls.

  20. Anonymous says:

    @Pplu: actually Firefox also reimplemented all controls, so that it could apply arbitrary CSS to them. Rather than whining here, you should consult Mozilla’s public bug database, and raise a new report if necessary.

  21. Anonymous says:

    @too helpful graphics driver: a common problem when hardware manufacturers try to do UI. It’s like hardware engineers don’t have the part of the brain required (disclaimer: I acknowledge that I don’t have the part of the brain required for building hardware of any kind). No gadget I’ve ever owned has been anything other than pathetic when it came to UI, software or not.

    My current gripe is with my two-monitor KVM switch. It "helpfully" replies "1024×768" when asked for screen resolution by e.g. a booting computer on the offline channel, which screws up desktops etc. nicely. Why not just say "Nuffin’ here guv" or "Undefined, carry on as you were" and let the OS do whatever it would do if the monitor was unplugged (which in my experience is to go with Last Known Good)? As it is I can’t boot both computers at the same time but have to wait until one shows signs of intelligent life before I can change channel and press the button on the other. A royal pain. Bad design.

  22. Anonymous says:

    Pplu: In IE 6 they reimplemented all controls except the combo box. One could assume that this is so they get the proper multimon behavior. And the reason to reimplement them is not to apply arbitrary CSS styles (owner-drawn controls could support that), but because natively they’re separate windows. That means you can’t change their Z-order and you can’t make a page that shows thousands of them.

    Morten: I’ve found that hardware companies pretty universally can’t write software. I won’t name names, but I don’t have to because good software from hardware companies is few and far between.

  23. Anonymous says:

    @Neil: I’m not whining. I’m just exposing curiosities I’ve found when working in multimonitor mode. That’s all. I really do know that whining in the comments of this blog will not get my bugs fixed. When I found out about the bug (long ago) I took the time to search the mozilla bug database and saw that the issue was already reported. Actually I’m the kind of guy that gets a kick out of catching a bug (blush), and reporting enough info to get it fixed correctly (blush*2) :D

    @Neil and @Gabe: The resume would be:

    • IE got the multimon behaviour right using the OS’s control (I think that out of pure luck) although broke they broke Z-order, and ¿CSS?).
    • Firefox reimplemented the control and got multimon support quircks, but on my understading got z-order and CSS right.

    You can never make everybody happy XD

  24. Anonymous says:

    Just for laughs: my computer after waking up from hibernation with two monitors:

  25. Anonymous says:

    James: actually, I find your customer quite sensible. The first thing I did on my laptop was to turn off the screen stretching. So 800×600 *is* taking less of my LCD. Maybe he had worked on a computer with that settting on and was used to that behavior. Or maybe he simply expected it.

    Personally, I find that stretching on LCD is one of those bane I have to endure. I really hate going to watch TV with my parents because they want the picture to take the whole screen even though it looks horrible on old 4:3 channels.

  26. Anonymous says:

    If you closed it on the second monitor, and you disable the monitor: The application positions it’s window off the screen.

    This bug can ofcouse also happen when using a single monitor and lowering the resolution.

    Some dumb apps try to compensate for this and bounce the window against the egde… of the first screen!

  27. Syllopsium says:

    I have a number of odd things that are possible in my monitor setup – it consists of one 17" rotatable TFT, one 19" 3D (Zalman Trimon) monitor and two 22" IBM CRT monitors using DVI-A (yes A, not D) and HD15 connectors respectively.

    I would like my primary monitor to be the CRT monitor, as that has the highest resolution, unfortunately this is not possible.

    1) Install rotation software for 17" TFT. Rotate 17" TFT, image on 22" CRT is rotated.. (Have not tried in Vista or Windows 7; this was an XP/2003 issue).

    2) Install Forceware and Nvidia 3DVision drivers. Run 3D setup and find the 3D capabilities cannot be used unless it is the primary monitor..

    I’ve also seen some KVM weirdness, but need to investigate how that’s happening.

    On the bright side, I’m firmly of the opinion that each new Windows release is considerably moving multimonitor forward. It’s also substantially better than any other PC OS; Nvidia’s binary drivers on Unix aren’t bad, but Windows Just Works.

  28. Anonymous says:

    @PPlu: works for me (Firefox 3.5.7, nVidia display drivers, WinXP with all updates except yesterdays).

    Is your secondary monitor on a lower vertical resolution than your primary?  If so, I could understand the problem (Firefox may be using the bounding rectangle of all monitors to clip the box to, without realising there’s a hole in that rectangle that isn’t visible).

  29. Anonymous says:

    Of course, what I always wonder about my multimonitor setup is why playing videos on the secondary display always stutters and fails to keep up with the correct timings, but they work flawlessly on the primary.  A colleague with identical hardware doesn’t have the problem, and a brief examination of settings failed to turn up anything relevant that was set differently…

Comments are closed.