diff --git a/source-code/dependencies/GPUModel/GPUModel.h b/source-code/dependencies/GPUModel/GPUModel.h index 6a70623..c91cebc 100644 --- a/source-code/dependencies/GPUModel/GPUModel.h +++ b/source-code/dependencies/GPUModel/GPUModel.h @@ -30,6 +30,8 @@ namespace GPUModel int(*NvAPI_EnumPhysicalGPUs)(int64_t** handle, int* count) = NULL; int(*NvAPI_GPU_GetShortName)(int64_t* handle, char* name) = NULL; + // returns the nvidia GPU die/chip name if one is installed, else "AMD" if an AMD driver is found, else "Unknown" + // note that the used GL context may differ std::string getGpuName() { // detected model can be overridden -- 0: Kepler, 1: Maxwell, 2: Turing @@ -54,15 +56,26 @@ namespace GPUModel return arch; } + std::string non_nv_name = "Unknown"; + + // detect installed AMD driver + //DWORD dwAttrib = GetFileAttributesW(L"amdgfxinfo64.dll"); + //if (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) + struct stat buffer; // for some reason winapi version wasn't working + if (stat("amdgfxinfo64.dll", &buffer) == 0); + { + non_nv_name = "AMD"; + } + printf("[GPUModel] Checking GPU model\n"); HMODULE hdlNvapi = LoadLibraryW(L"nvapi64.dll"); - if (hdlNvapi == NULL) return - std::string("Other"); + if (hdlNvapi == NULL) + return non_nv_name; NvAPI_QueryInterface = (void* (*)(unsigned int offset))GetProcAddress(hdlNvapi, "nvapi_QueryInterface"); if (NvAPI_QueryInterface == nullptr) - return std::string("Other"); + return non_nv_name; NvAPI_Initialize = (int(*)())NvAPI_QueryInterface(0x0150E828); NvAPI_Unload = (int(*)()) NvAPI_QueryInterface(0xD22BDD7E); @@ -73,7 +86,7 @@ namespace GPUModel NvAPI_Unload == nullptr || NvAPI_EnumPhysicalGPUs == nullptr || NvAPI_GPU_GetShortName == nullptr) - return std::string("Unknown"); + return non_nv_name; int64_t* hdlGpu[64] = { 0 }; int nGpu = 0; @@ -85,7 +98,7 @@ namespace GPUModel if (nGpu < 1) { NvAPI_Unload(); - return std::string("Unknown"); + return non_nv_name; } char nameBuf[64]; diff --git a/source-code/source/plugins/Novidia/src/dllmain.cpp b/source-code/source/plugins/Novidia/src/dllmain.cpp index b15ef0e..5a60b7b 100644 --- a/source-code/source/plugins/Novidia/src/dllmain.cpp +++ b/source-code/source/plugins/Novidia/src/dllmain.cpp @@ -382,13 +382,13 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv { loadConfig(); - if (!disable_nvidia_check) + if (!disable_amd_check) { std::string gpuName = GPUModel::getGpuName(); - if (gpuName != "Other" && gpuName != "Unknown") + if (gpuName != "AMD") { // detected Nvidia GPU - printf("[Novidia] Detected Nvidia GPU! Quitting!\n"); + printf("[Novidia] Detected Non-AMD GPU! Quitting!\n"); return TRUE; } } @@ -444,7 +444,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv using namespace PluginConfig; PluginConfigOption config[] = { - { CONFIG_BOOLEAN, new PluginConfigBooleanData{ L"disable_nvidia_check", L"general", CONFIG_FILE, L"Disable Nvidia Check", L"On systems with both AMD and Nvidia graphics, the plugin may disable functionality due to detecting the Nvidia GPU. Set this to forcefully enable functionality.", false, false } }, + { CONFIG_BOOLEAN, new PluginConfigBooleanData{ L"disable_amd_check", L"general", CONFIG_FILE, L"Disable AMD Check", L"On systems with both AMD and Nvidia graphics, the plugin may disable functionality due to detecting a non-AMD GPU.\nSet this to forcefully enable functionality.", false, false } }, { CONFIG_BOOLEAN, new PluginConfigBooleanData{ L"enable_chara_skinning", L"general", CONFIG_FILE, L"Enable Chara Skinning", L"If you really need to get extra performance, you can disable uploading skinning data. (character models will disappear)", true, false } }, { CONFIG_BOOLEAN, new PluginConfigBooleanData{ L"use_TexSubImage", L"general", CONFIG_FILE, L"Use glTexSubImage", L"glTexSubImage should offer higher performance, but stuttering has been reported when it is used.\nTry disabling this if you have issues.", true, false } }, { CONFIG_BOOLEAN, new PluginConfigBooleanData{ L"force_BGRA_upload", L"general", CONFIG_FILE, L"Force BGRA Texture Uploads", L"BGRA format uploads seem to run faster (on some hardware), but drivers may suggest RGBA instead.\nUsing this forces uploads to use the BGRA format.\n\nDisabling this may decrease or improve performance.", true, false } }, diff --git a/source-code/source/plugins/Novidia/src/framework.h b/source-code/source/plugins/Novidia/src/framework.h index 54b1289..6162c90 100644 --- a/source-code/source/plugins/Novidia/src/framework.h +++ b/source-code/source/plugins/Novidia/src/framework.h @@ -24,7 +24,7 @@ bool checkBufferTargetOk(GLenum target) int __stdcall stub() { return 1; } -bool disable_nvidia_check; +bool disable_amd_check; bool enable_chara_skinning; bool use_TexSubImage; bool force_BGRA_upload; @@ -90,7 +90,7 @@ LPCWSTR CONFIG_FILE = CONFIG_FILE_STRING.c_str(); void loadConfig() { - disable_nvidia_check = GetPrivateProfileIntW(L"general", L"disable_nvidia_check", 0, CONFIG_FILE) > 0 ? true : false; + disable_amd_check = GetPrivateProfileIntW(L"general", L"disable_amd_check", 0, CONFIG_FILE) > 0 ? true : false; enable_chara_skinning = GetPrivateProfileIntW(L"general", L"enable_chara_skinning", 1, CONFIG_FILE) > 0 ? true : false; use_TexSubImage = GetPrivateProfileIntW(L"general", L"use_TexSubImage", 1, CONFIG_FILE) > 0 ? true : false; force_BGRA_upload = GetPrivateProfileIntW(L"general", L"force_BGRA_upload", 1, CONFIG_FILE) > 0 ? true : false;