Skip to content

Commit

Permalink
util: Allow overriding GPU Architecture using environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Saancreed committed Jun 16, 2024
1 parent f86f56b commit 31bf655
Showing 1 changed file with 42 additions and 5 deletions.
47 changes: 42 additions & 5 deletions src/nvapi_gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,50 @@ extern "C" {
if (pGpuArchInfo->version != NV_GPU_ARCH_INFO_VER_1 && pGpuArchInfo->version != NV_GPU_ARCH_INFO_VER_2)
return IncompatibleStructVersion(n);

auto architectureId = adapter->GetArchitectureId();
NV_GPU_ARCHITECTURE_ID architectureId = {};

if (auto archOverride = env::getEnvVariable("DXVK_NVAPI_GPU_ARCH"); !archOverride.empty()) {
#define CHECK_ARCH(arch) \
if (archOverride == #arch) \
architectureId = NV_GPU_ARCHITECTURE_##arch;
CHECK_ARCH(T2X)
CHECK_ARCH(T3X)
CHECK_ARCH(T4X)
CHECK_ARCH(T12X)
CHECK_ARCH(NV40)
CHECK_ARCH(NV50)
CHECK_ARCH(G78)
CHECK_ARCH(G80)
CHECK_ARCH(G90)
CHECK_ARCH(GT200)
CHECK_ARCH(GF100)
CHECK_ARCH(GF110)
CHECK_ARCH(GK100)
CHECK_ARCH(GK110)
CHECK_ARCH(GK200)
CHECK_ARCH(GM000)
CHECK_ARCH(GM200)
CHECK_ARCH(GP100)
CHECK_ARCH(GV100)
CHECK_ARCH(GV110)
CHECK_ARCH(TU100)
CHECK_ARCH(GA100)
CHECK_ARCH(AD100)
#undef CHECK_ARCH

if (architectureId)
log::info(str::format(n, ": GPU Architecture overriden to ", archOverride));
}

if (env::needsAmpereSpoofing(architectureId, returnAddress))
architectureId = NV_GPU_ARCHITECTURE_GA100;
if (!architectureId) {
architectureId = adapter->GetArchitectureId();

if (env::needsPascalSpoofing(architectureId))
architectureId = NV_GPU_ARCHITECTURE_GP100;
if (env::needsAmpereSpoofing(architectureId, returnAddress))
architectureId = NV_GPU_ARCHITECTURE_GA100;

if (env::needsPascalSpoofing(architectureId))
architectureId = NV_GPU_ARCHITECTURE_GP100;
}

// Assume the implementation ID from the architecture ID. No simple way
// to do a more fine-grained query at this time. Would need wine-nvml
Expand Down

0 comments on commit 31bf655

Please sign in to comment.