diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index 70898ebe5a..5a17e90ece 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -71,8 +71,34 @@ FRenderer *gl_CreateInterface(); void I_RestartRenderer(); int currentrenderer = -1; int currentcanvas = -1; +int currentgpuswitch = -1; bool changerenderer; +// Optimus/Hybrid switcher +CUSTOM_CVAR(Int, vid_gpuswitch, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (self != currentgpuswitch) + { + switch (self) + { + case 0: + Printf("Selecting default GPU...\n"); + break; + case 1: + Printf("Selecting high-performance dedicated GPU...\n"); + break; + case 2: + Printf("Selecting power-saving integrated GPU...\n"); + break; + default: + Printf("Unknown option (%d) - falling back to 'default'\n", *vid_gpuswitch); + self = 0; + break; + } + Printf("You must restart " GAMENAME " for this change to take effect.\n"); + } +} + // Software OpenGL canvas CUSTOM_CVAR(Bool, vid_used3d, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { @@ -128,6 +154,13 @@ void I_InitGraphics () { UCVarValue val; + // todo: implement ATI version of this. this only works for nvidia notebooks, for now. + currentgpuswitch = vid_gpuswitch; + if (currentgpuswitch == 1) + putenv("SHIM_MCCOMPAT=0x800000001"); // discrete + else if (currentgpuswitch == 2) + putenv("SHIM_MCCOMPAT=0x800000000"); // integrated + // If the focus window is destroyed, it doesn't go back to the active window. // (e.g. because the net pane was up, and a button on it had focus) if (GetFocus() == NULL && GetActiveWindow() == Window) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 75ef5eb512..85f7ee830d 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1832,6 +1832,7 @@ DSPLYMNU_DIMCOLOR = "Dim color"; DSPLYMNU_MOVEBOB = "View bob amount while moving"; DSPLYMNU_STILLBOB = "View bob amount while not moving"; DSPLYMNU_BOBSPEED = "Weapon bob speed"; +DSPLYMNU_GPUSWITCH = "Notebook Switchable GPU"; // HUD Options HUDMNU_TITLE = "HUD Options"; @@ -2359,6 +2360,8 @@ OPTVAL_GL = "OpenGL"; OPTVAL_D3D = "Direct3D"; OPTVAL_HWPOLY = "OpenGL-Accelerated"; OPTVAL_SWDOOM = "Doom Software Renderer"; +OPTVAL_DEDICATED = "High-Performance"; +OPTVAL_INTEGRATED = "Power-Saving"; // Colors C_BRICK = "\cabrick"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index ef20322417..2f5bd0d71c 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -683,6 +683,13 @@ OptionValue Fuzziness 2.0, "$OPTVAL_SHADOW" } +OptionValue GPUSwitch +{ + 0.0, "$OPTVAL_DEFAULT" + 1.0, "$OPTVAL_DEDICATED" + 2.0, "$OPTVAL_INTEGRATED" +} + OptionMenu "OpenGLOptions" { Title "$GLMNU_TITLE" @@ -755,7 +762,11 @@ OptionMenu "VideoOptions" Slider "$DSPLYMNU_MOVEBOB", "movebob", 0, 1.0, 0.05, 2 Slider "$DSPLYMNU_STILLBOB", "stillbob", 0, 1.0, 0.05, 2 Slider "$DSPLYMNU_BOBSPEED", "wbobspeed", 0, 2.0, 0.1 - + IfOption(Windows) + { + StaticText " " + Option "$DSPLYMNU_GPUSWITCH", vid_gpuswitch, "GPUSwitch" + } } //-------------------------------------------------------------------------------------------