Running a game using 3D acceleration in separate virtual terminal slow unless running as root

1

I put together a simple script for running Neverwinter Nights from a separate virtual terminal:

#!/bin/bash
read -r -d '' myrcfile <<'EOF'
#!/bin/bash
cd /path/to/game
./nwn
EOF

XINITRC=<(echo "${myrcfile}") xinit -- :1 vt8

While this works, gameplay is rather choppy. For reference, it runs fine from the initial / default X instance.

I fiddled around with schedtool to see if I could make it any better, and at first it seemed I'd succeeded, but in reality the improvement wasn't because of schedtool but rather because I had [naively] done this:

sudo schedtool ${parms} -e ./nwn
^^^^

... because some of schedtool's parameters require root (note: ${parms} is various combinations of schedtool parameters). schedtool wasn't responsible for the improvement in speed -- sudo was. To ensure that was the case I replaced the final line of the inner script with gnome-terminal -c 'sudo ./nwn' and sure enough it runs flawlessly.

Does anyone have a good suggestion for how to do this?

Here's some of the things I've tried:

  • Run X under sudo, then put su -c ./nwn myusername in the script
  • Ran the game & X as my user, then ran schedtool from a separate virtual terminal w/sudo to alter the settings for the currently running process but nothing changed
    • This seems to indicate schedtool isn't going to do any good

Brian Vandenberg

Posted 2014-11-30T05:56:39.040

Reputation: 504

This is a decent question. I edited for a bit of clarity and formatting. – JakeGould – 2014-11-30T06:10:18.203

I'll compromise. Some of the changes didn't reflect how I wanted it to read. – Brian Vandenberg – 2014-11-30T06:16:17.710

Answers

0

I just figured it out. I added myself to the video and games group. I'm not sure which one did it, but it worked.

One oddity I ran into while messing with this: before making the group change I ran glxgears instead; as root it was getting about the same FPS as if I'd ran it from the default session, but as my user it was reporting around 500fps.

Brian Vandenberg

Posted 2014-11-30T05:56:39.040

Reputation: 504