One computer, two GPUs, three screens.

I know that nowadays this doesn’t seem anything special, but long ago I started to work on a project, which I deemed impossible, not worth to try, and I could have bet against its success. It wasn’t that long ago, but instead of just simply giving you the year it will be more fun to remember some facts, so let’s see if you can set your time machine correctly.

  • Robert Downey Jr escaped from a cave in an Iron Suit
  • We came out of Vault 101, got scared walking on USG Ishimura, and explored the universe on a ship called Normandy.
  • People were jamming in their cars singing “Pa Pa Poker Face …”
  • Smartphones just started to become a thing
  • You still had a chance to buy something called “Zune”
  • We were slowly moving to 16:9 screens from 4:3
  • Facebook celebrated its 100 million active users
  • Michael Jackson was still bla…, just kidding just kidding he wasn’t
  • We learned that the burst of some bubbles are not fun for anybody

See what I mean? It feels very long ago doesn’t it?

The project was about a heads up poker table. It had three screens, two small touchscreens like the ones in an ATM, tilted towards the players, and a central screen for community cards and chips. Since all of this had to work on a single computer my initial thoughts were pessimistic at best. To be honest I called it Impossible, and even if I saw some models from competitors at trade shows, my explanation was that they were using two computers and network communication between them.

We needed to overcome the following issues,

  • Our dedicated graphics device had only two ports.
  • Differentiate the mouse clicks on the two touchscreens.

Whenever you need to figure something out, it is a good idea to start with a set of Proof of Concept projects. This allows you to do trial and error really fast, and enables you to concentrate on one issue at the time.

About the ports, we had an on-board GPU too which is deactivated once a dedicated GPU is detected. So we had three physical connections from which only two worked. I researched a lot (remember the era, the internet wasn’t that full of info as it is now) and it turns out you can enable the on-board GPU too in tandem with your dedicated one. After exchanging some mails with our motherboard supplier, they told me what to change in the bios so we had three screens show up in windows, yaaay! One down one more to go, I said in my head.

It didn’t take long until it dawned on me that, I have two GPUs but can I write a game that uses both of them? Shit … One down two more to go. I wrote the game engine and user interface for all of our games, but I never actually tried that out. I was working in Managed DirectX at that time which was a wrapper around DirectX. The first parameter in the constructor of the Device (the main component trough which you were giving rendering commands) was setting the graphics adapter, every tutorial on the internet used the value 0 there (the default device). Putting 1 there allowed me to render with the on-board graphics device, Kewl! Now I knew, if I write another engine for this game, load the correct textures, meshes, on the correct device, I will be able to run two separate game loops, even support different refresh rate per screen. I quickly created the proof of concept and it worked. Everything after that was a blur since we started to celebrate by drinking :).

Next week I concentrated my work around the input issue, even if you connect two pointing devices (using mice as a plural just felt awkward) Windows treats them as one and they move the same pointer. Hours later I was exploring the cool but huge realm of the WinAPI. It turns out by capturing the Raw HID messages (Human Interface Device) and handling them instead of traditional clicks you are able to differentiate the origin of the click. I will definitely write about this later. Since at this point we didn’t see any other blocking issues, we proceeded with the project and it was one of my most fulfilling endeavor.

At this point you are very entitled to ask “why should something that happened to you a decade ago be relevant for me today?” Well the moral of the story still holds strong in my everyday work life and the very fact that I’m telling you this story, means that I still think about it from time to time.

I didn’t invent anything here but moving past my initial fear of tackling something I deemed impossible for me to do, breaking down the problem into smaller pieces, solving them individually, really showed me that, sometimes you just need to put in the effort, you need to sweat, you need to grind in order to move forward.

In today’s world we are so in the habit of having the answers at our fingertips that when they are not there, or they are not as easy to find, we don’t even try, we give up early. History proved us that things seem impossible, until somebody actually tries hard enough.