stride3d / stride3d/stride

Graphics: a GPU preference API on GraphicsAdapter, and full screen on a hybrid laptop

Open
#3,428 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
7.8k
Forks
1.2k
Avg merge
2d 17h
Merged PRs (30d)
49

Description

Summary

Follow-up to #3388, from @xen2's review there. Stride has no way to choose which GPU a game runs on beyond GraphicsDeviceManager.RequiredAdapterUid. #3388 first proposed a GraphicsAdapterFactory.GpuPreference static (an enum plus Reset()), which was withdrawn from that PR: a mutable static that changes what GraphicsAdapterFactory.Adapters returns, and a Reset() that disposes adapters a live GraphicsDevice may still use, is not the right shape.

Proposed direction (xen2)

GraphicsAdapterFactory reports what the system has, untouched, with facts on each GraphicsAdapter:

public enum GraphicsAdapterType { Unknown, Integrated, Discrete, Virtual, Software }

public GraphicsAdapterType Type { get; }   // set by each backend
public int AdapterOrder { get; }           // system enumeration order; 0 is the system default
public bool IsDefaultAdapter => AdapterOrder == 0;
public int PerformanceRank { get; }        // platform's fastest-first order; 0 is the fastest
public int PowerEfficiencyRank { get; }    // platform's most-efficient-first order; 0 is the most efficient
  • Direct3D fills the ranks from DXGI EnumAdapterByGpuPreference (HighPerformance and MinimumPower orders).
  • Vulkan fills them from VkPhysicalDeviceType: Discrete > Integrated > Virtual > Cpu for performance, Integrated first for efficiency.
  • The preference itself lives with the other creation settings, in GameGraphicsParameters then GraphicsDeviceManager (e.g. PreferredGpu), and FindBestDevices sorts by the matching rank. Device creation stops depending on a mutable static.
Also to settle
  • Full screen on a hybrid laptop: an adapter with no output produces no full-screen candidate in FindBestDevices, so a game that starts full screen lands on the integrated GPU while the same game windowed lands on the discrete one. Exclusive full screen on an output-less adapter is not possible in DXGI, so the expected behaviour is probably borderless full screen on the chosen adapter rather than an output lookup.
Related
  • #3388 keeps only the bug fix: the discrete GPU of a hybrid laptop is no longer skipped, and Vulkan enumerates the discrete GPU first as Direct3D already did.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with GraphicsAdapterFactory and the GraphicsAdapter implementations, then trace GameGraphicsParameters, GraphicsDeviceManager, and FindBestDevices; review #3388 for the existing hybrid-laptop fix. Done means adapter facts and backend ranks are reported, GPU preference is carried through device creation without mutable global state, and hybrid-laptop full-screen behavior is settled.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
computer-graphics, game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.