Skip to content

Commit

Permalink
(Minor) Added argument to set VROverlay GPU to index 1, Fixes issues …
Browse files Browse the repository at this point in the history
…when rendering SteamVR on a GPU that is not considered the main GPU, such as with an IGPU
  • Loading branch information
Myrkie committed Nov 11, 2022
1 parent d385279 commit 22ef667
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static class Program
public static string ConfigLocation;
public static string Version { get; private set; }
public static bool LaunchDebug;

public static bool GPUFix;
static Program()
{
BaseDirectory = AppDomain.CurrentDomain.BaseDirectory;
Expand Down
1 change: 1 addition & 0 deletions StartupArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static void ArgsCheck()

foreach (string arg in args)
{
if (arg.Contains("--gpufix")) Program.GPUFix = true;
if (arg.Length > 12 && arg.Substring(0, 12) == "/uri=vrcx://")
LaunchCommand = arg.Substring(12);

Expand Down
20 changes: 16 additions & 4 deletions VRCXVR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,23 @@ private void ThreadLoop()

// REMOVE THIS
// nextOverlay = DateTime.MaxValue;
// https://stackoverflow.com/questions/38312597/how-to-choose-a-specific-graphics-device-in-sharpdx-directx-11/38596725#38596725
SharpDX.DXGI.Factory f = new SharpDX.DXGI.Factory1();
SharpDX.DXGI.Adapter a = f.GetAdapter(1);
FeatureLevel[] levels = new FeatureLevel[]
{
#if DIRECTX11_1
FeatureLevel.Level_11_1,
#endif
FeatureLevel.Level_11_0,
FeatureLevel.Level_10_1,
FeatureLevel.Level_10_0,
FeatureLevel.Level_9_3
};
DeviceCreationFlags flags = DeviceCreationFlags.BgraSupport;
// _device = new Device(a, flags, levels);

_device = new Device(
DriverType.Hardware,
DeviceCreationFlags.SingleThreaded | DeviceCreationFlags.BgraSupport
);
_device = Program.GPUFix ? new Device(a, flags) : new Device(DriverType.Hardware, DeviceCreationFlags.SingleThreaded | DeviceCreationFlags.BgraSupport);

_texture1 = new Texture2D(
_device,
Expand Down

0 comments on commit 22ef667

Please sign in to comment.