Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically selected the dedicated graphics card. #469

Open
pixtur opened this issue Sep 25, 2024 · 0 comments
Open

Automatically selected the dedicated graphics card. #469

pixtur opened this issue Sep 25, 2024 · 0 comments

Comments

@pixtur
Copy link
Collaborator

pixtur commented Sep 25, 2024

The choice of the graphics cards appears to be random and nontransparent:

https://uc7b04bcb73b8b6abddf797fedb7.dl.dropboxusercontent.com/cd/0/inline/CbNDCbYz6bQK-f7aenAYId7Pcr-KyAEznr0ZDcJ9atzjw-Hq_H_OhRwQFyk8mcprWNz1IQjQvV7S9Erpr1sxYJHutUJQ0cwXuLy3Xmzhn1qkvVcqbfZcFkwHiCWu_TZBjT8/file#

ChatGPT suggests these solutions:

To indicate that your SharpDX application prefers to use the dedicated graphics card (like an NVIDIA RTX) instead of the integrated graphics card, you can use a few methods:

1. Set Preferred Graphics Processor in the NVIDIA Control Panel (User Configuration):

  • Go to the NVIDIA Control Panel → "Manage 3D settings."
  • Under "Program Settings," add your SharpDX application and set it to use the "High-performance NVIDIA processor."

This allows users to choose their preferred GPU, but it doesn't enforce the choice programmatically from within the application.

2. Use DXGI to Specify High-Performance GPU in Code (Programmatic Approach):

Since Windows 10 (version 1803), Microsoft provides an API that allows applications to request the high-performance GPU.

Here’s how you can do it programmatically using the DXGI interface in SharpDX:

using SharpDX.DXGI;

// Create a factory to enumerate adapters
using (var factory = new Factory4())
{
    Adapter1 adapter = null;

    // Iterate through all adapters
    for (int i = 0; i < factory.Adapters1.Length; i++)
    {
        var tmpAdapter = factory.GetAdapter1(i);
        var desc = tmpAdapter.Description1;

        // Check if the adapter is the high-performance GPU
        if ((desc.Flags & AdapterFlags.Software) == 0 && tmpAdapter.Description1.DeviceId != 0)
        {
            adapter = tmpAdapter;
            break;
        }
    }

    // Create the device using the high-performance adapter
    if (adapter != null)
    {
        var device = new SharpDX.Direct3D11.Device(adapter);
    }
    else
    {
        throw new Exception("No high-performance GPU found.");
    }
}

3. Directly Specify GPU for Windows (DX12):

For more control, especially in DirectX 12, you can query available GPUs and select the high-performance one based on its hardware type (discrete vs. integrated). However, SharpDX mostly works with DirectX 11, and the method above works for DX11 applications.

4. High Performance GPU via app.manifest:

You can also indicate GPU preference at the manifest level for Windows:

<application xmlns="urn:schemas-microsoft-com:asm.v3">
  <windowsSettings>
    <useLegacyGraphicsPerformanceNotifications>false</useLegacyGraphicsPerformanceNotifications>
  </windowsSettings>
</application>

This will tell the system to prefer the high-performance GPU.

By combining these approaches, your application can better target dedicated GPUs without requiring manual user configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant