Files
gamemode/common/common-gpu.h
mangobiche e5b0a2bf3e feat(gamemode): Add support for new GPU cards via nv_per_profile_editable in gamemode.ini
- Added a new configuration variable `nv_per_profile_editable` to the `gamemode.ini` file.
  - If set to 1 (default behavior), the code will use per-profile offset behavior.
  - If set to 0, the code will use the AllPerformanceLevels API, which is compatible with newer cards like the GTX5060ti.

- Updated the `gpuclockctl` utility to accept the `nv_per_profile_editable` parameter.
  - If the parameter is not provided, it defaults to 1 and uses the previous API for backward compatibility.

This change allows `gamemode` to support a wider range of GPU cards by providing flexibility in how GPU performance levels are managed.

**Notes:**
- Ensure that the `gamemode.ini` file includes the new `nv_per_profile_editable` setting.
- Verify that the updated `gpuclockctl` utility functions as expected with both default and specified values for `nv_per_profile_editable`.

Tested on: RTX 5060 ti (driver 575.64.05) on Ubuntu 25.04
2025-08-27 16:39:44 -05:00

61 lines
2.4 KiB
C

/*
Copyright (c) 2017-2025, Feral Interactive and the GameMode contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Feral Interactive nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#define GPU_VALUE_MAX 256
/* Enums for GPU vendors */
enum GPUVendor {
Vendor_Invalid = 0,
Vendor_NVIDIA = 0x10de,
Vendor_AMD = 0x1002,
Vendor_Intel = 0x8086
};
#define GPUVendorValid(vendor) \
(vendor == Vendor_NVIDIA || vendor == Vendor_AMD || vendor == Vendor_Intel)
/* Storage for GPU info*/
struct GameModeGPUInfo {
long vendor;
long device; /* path to device, ie. /sys/class/drm/card#/ */
long nv_core; /* Nvidia core clock */
long nv_mem; /* Nvidia mem clock */
long nv_powermizer_mode; /* NV Powermizer Mode */
long nv_per_profile_editable; /* Allows per profile editable offsets */
char amd_performance_level[GPU_VALUE_MAX]; /* The AMD performance level set to */
};
/* Get the vendor for a device */
enum GPUVendor gamemode_get_gpu_vendor(long device);