Skip to content

Commit

Permalink
Fix Anti-Aliasing on Nvidia
Browse files Browse the repository at this point in the history
by disabling forced Anti-Aliasing Gamma Correction in the driver
  • Loading branch information
oomek committed Jan 12, 2024
1 parent c9b67ea commit 149af25
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
25 changes: 21 additions & 4 deletions extlibs/nvapi/nvapi.hpp
Expand Up @@ -32,10 +32,11 @@ namespace {

int nvapi_init()
{
const bool disableThreadedOptimizations = true;
const bool setMaximumPerformance = true;
const bool disableTripleBuffering = true;
const bool setPrerenderedFrames = true;
const bool disableThreadedOptimizations = true;
const bool setMaximumPerformance = true;
const bool disableTripleBuffering = true;
const bool setPrerenderedFrames = true;
const bool disableAntialiasingGammaCorrection = true;

const wchar_t* profileName = L"Attract Mode";
const wchar_t* appName = L"";
Expand Down Expand Up @@ -229,6 +230,22 @@ namespace {
FeDebug() << "NvAPI: GPU Maximum Performance ON: " << nvapi_get_error_msg( status );
}

// Set Antialiasing Gamma Correction
if ( disableAntialiasingGammaCorrection )
{
setting.version = NVDRS_SETTING_VER;
setting.settingId = AA_MODE_GAMMACORRECTION_ID;
setting.settingType = NVDRS_DWORD_TYPE;
setting.settingLocation = NVDRS_CURRENT_PROFILE_LOCATION;
setting.isCurrentPredefined = 0;
setting.isPredefinedValid = 0;
setting.u32CurrentValue = AA_MODE_GAMMACORRECTION_OFF;
setting.u32PredefinedValue = AA_MODE_GAMMACORRECTION_OFF;

status = NvAPI_DRS_SetSetting( hSession, hProfile, &setting );
FeDebug() << "NvAPI: Antialiasing Gamma Correction OFF: " << nvapi_get_error_msg( status );
}

// Save changes
status = NvAPI_DRS_SaveSettings( hSession );
FeDebug() << "NvAPI: Saving Nvidia profile: " << nvapi_get_error_msg( status );
Expand Down
15 changes: 14 additions & 1 deletion extlibs/nvapi/nvapi_definitions.hpp
Expand Up @@ -11,7 +11,8 @@ enum Esetting {
OGL_TRIPLE_BUFFER_ID = 0x20FDD1F9,
PREFERRED_PSTATE_ID = 0x1057EB71,
PRERENDERLIMIT_ID = 0x007BA09E,
OGL_MAX_FRAMES_ALLOWED_ID = 0x208E55E3
OGL_MAX_FRAMES_ALLOWED_ID = 0x208E55E3,
AA_MODE_GAMMACORRECTION_ID = 0x107D639D
};

enum EValues_OGL_THREAD_CONTROL {
Expand Down Expand Up @@ -49,6 +50,18 @@ enum EValues_PRERENDERLIMIT {
PRERENDERLIMIT_DEFAULT = PRERENDERLIMIT_APP_CONTROLLED
};

enum EValues_AA_MODE_GAMMACORRECTION {
AA_MODE_GAMMACORRECTION_MASK = 0x00000003,
AA_MODE_GAMMACORRECTION_OFF = 0x00000000,
AA_MODE_GAMMACORRECTION_ON_IF_FOS = 0x00000001,
AA_MODE_GAMMACORRECTION_ON_ALWAYS = 0x00000002,
AA_MODE_GAMMACORRECTION_MAX = 0x00000002,
AA_MODE_GAMMACORRECTION_DEFAULT = 0x00000000,
AA_MODE_GAMMACORRECTION_DEFAULT_TESLA = 0x00000002,
AA_MODE_GAMMACORRECTION_DEFAULT_FERMI = 0x00000002,
AA_MODE_GAMMACORRECTION_NUM_VALUES = 8,
};

typedef enum _NvAPI_Status
{
NVAPI_OK = 0, //!< Success. Request is completed.
Expand Down

0 comments on commit 149af25

Please sign in to comment.