0
\$\begingroup\$

I'm learning godot with a laptop that has AMD discrete GPU. My OS is Arch Linux so if I want to use discrete GPU I have to set system environment variable DRI_PRIME=1 temporarily. This can be easily done with pygame, just add following code:

import os

os.environ['DRI_PRIME'] = '1'

The game will launch using discrete GPU.

But if I want to do that in godot, I have to run it fully in discrete GPU, which means I have to use command DRI_PRIME=1 godot to launch it. It's now using discrete GPU to run game, but it takes 4-5 seconds to react to my input when I switch back from tutorial webpage from browser. That's because the discrete GPU will hang when switching out of godot, and I have to wait for it to respond. It will waste a lot of time if I frequently switch between godot and browser.

Is there any configuration to temporarily set system environment variable only in 'play' mode inside godot editor?

\$\endgroup\$
1
  • \$\begingroup\$ I don't think what you want is possible because you likely need to set that variable before Godot starts rendering (before it creates a window). Works in pygame because you do it before the pygame loop. You need the env variable to be set early enough that the rendering system can read it when creating the window. \$\endgroup\$
    – idbrii
    Jul 30 at 21:22

1 Answer 1

2
\$\begingroup\$

Seems the solution that works so far is to write my own shell script.

Here's the script:

#!/bin/sh

export DRI_PRIME=1

if [[ $# -ge 1 ]]; then
    if [[ -f 'Scenes/'$1'.tscn' ]]; then
        godot -d Scenes/$1.tscn --position 400,300;
    else
        echo 'File doesn'\''t exist!';
    fi;
else
    echo 'Please specify main scene!';
fi

I wish godot team to provide cmdline feature inside editor ( / __ \ )

\$\endgroup\$
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .