Skip to content

Commit

Permalink
nvapi: Allow switching ShowDlssIndicator registry setting
Browse files Browse the repository at this point in the history
  • Loading branch information
jp7677 committed Feb 7, 2025
1 parent 3967375 commit 7b25b38
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/nvapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "util/util_string.h"
#include "util/util_env.h"
#include "util/util_log.h"
#include "util/util_dlss.h"
#include "../version.h"
#include "../config.h"

Expand Down Expand Up @@ -384,6 +385,8 @@ extern "C" {
nvapiD3dInstance = std::make_unique<NvapiD3dInstance>(*resourceFactory);
nvapiD3dInstance->Initialize();

setDlssIndicator();

return Ok(n);
}
}
38 changes: 38 additions & 0 deletions src/util/util_dlss.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#pragma once

#include "../nvapi_private.h"
#include "util_log.h"
#include "util_env.h"

namespace dxvk {
inline void setDlssIndicator() {
constexpr static auto showDLSSIndicatorEnvName = "DXVK_NVAPI_SET_DLSS_INDICATOR";
const static auto showDLSSIndicator = env::getEnvVariable(showDLSSIndicatorEnvName);

if (showDLSSIndicator.empty())
return;

NvU32 showDLSSIndicatorValue;
if (!str::parsedword(std::string_view(showDLSSIndicator), showDLSSIndicatorValue)) {
log::info(str::format(showDLSSIndicatorEnvName, " is set to '", showDLSSIndicator, "', but this value is invalid, please set a number"));
return;
}

if (showDLSSIndicatorValue != 0)
log::info(str::format(showDLSSIndicatorEnvName, " is set, enable ShowDlssIndicator in registry"));
else
log::info(str::format(showDLSSIndicatorEnvName, " is set to 0, disable ShowDlssIndicator in registry"));

HKEY key{};
auto status = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\NVIDIA Corporation\\Global\\NGXCore", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, &key);
if (status != NO_ERROR || !key) {
log::info(str::format(R"(Failed to open SOFTWARE\NVIDIA Corporation\Global\NGXCore registry key: )", status));
return;
}

if (RegSetValueExW(key, L"ShowDlssIndicator", 0, REG_DWORD, reinterpret_cast<const BYTE*>(&showDLSSIndicatorValue), sizeof(DWORD)) != NO_ERROR)
log::info(str::format("Failed to set ShowDlssIndicator registry key"));

RegCloseKey(key);
}
}

0 comments on commit 7b25b38

Please sign in to comment.