Reputation: 81
I have a single graphics card in a remote headless ubuntu server. I have set nvidia-xconfig to make a virtual display. I need virtual x server, but not xvfb, to run a unity game headless, yet record a video of rendering of the game. Xvfb does work fine, but it does not use graphics card, which makes rendering very slow.
This works fine with xinit if I run a single game.
xinit ./game.x86_64
Starts game and renders game play without any problem.
However, when I try to start multiple games simultaneously with different x-servers:
xinit ./game1.x86_64 -- :0
xinit ./game2.x86_64 -- :1
This does not render properly. One of the game (the one that started first) does not render. (Checked with the recorded video) As far as I know, this is because a single graphics card can only have a single x-server running.
Then, I set multiple screens by tweaking xorg.conf and tried
xinit ./game1.x86_64 -- :0.0
xinit ./game2.x86_64 -- :0.1
However, since xinit tries to start a new server, the latter one does not work, telling there's already an x-server running at X:0
If I search for multiple monitor x-server setting, what I can find is real monitor setup only, yet what I need is virtual monitor setup.
Is there a way to start multiple applications that need a screen in a headless server?
What I think I need to know is
A way to start a x-server with multiple screens and tell the application to use which screen OR
A way to use windows manager remotely on console
If there's any better solutions, or if I have missed something, it would be really helpful too.
Upvotes: 1
Views: 2057
Reputation: 81
I was misunderstanding how xinit works. I figured this out by running xinit without any clients in the background (like tmux)
xinit
or xinit -- :0
and then, specifying which display to use. Of course, multiple monitors are set in xorg.conf. For unity, it was enough to just exporting display environment variable.
export DISPLAY=:0.0
for game1
export DISPLAY=:0.1
for game2
The log says unity recognizes both display, but game1 says
:0.0 display is 'display 0 (Primary display)'
while game2 says
:0.1 display is 'display 0 (Primary display)'
My misunderstanding was that I thought xinit is only used with client application, although xinit can run without any client application and just running in the background.
Upvotes: 0