How to force Discrete GPU in electron.js?

后端 未结 2 648
日久生厌
日久生厌 2021-01-25 17:01

Update: I also saw documentation and discussions that it must always use discrete GPU but it is not, it always use internal one at the moment.

I need to use discrete GPU

相关标签:
2条回答
  • 2021-01-25 17:21

    With current Electron.js/WebGL, there is no mechanism to enforce this. However, you shouldn't need to, because running on the discrete GPU is the default.

    0 讨论(0)
  • 2021-01-25 17:29

    I figured out, you can silently restart the app with setting the the special windows env variable, which forces the process to use the dedicated GPU.

    const { spawn } = require('child_process');
    
    // Restart with force using the dedicated GPU
    if (process.env.GPUSET !== 'true') {
      spawn(process.execPath, process.argv, {
        env: {
          ...process.env,
          SHIM_MCCOMPAT: '0x800000001', // this forces windows to use the dedicated GPU for the process
          GPUSET: 'true'
        },
        detached: true,
      });
      process.exit(0);
    }
    
    0 讨论(0)
提交回复
热议问题