Hello,
I need to disable shader caching for a specific application (not the whole system).
First I tried to disable shader caching globally. Using the documentation provided by NVidia (http://developer.download.nvidia.com/NVAPI/PG-5116-001_v01_public.pdf) and various ressources found on the Internet, I ended with something similar to :
//
// Create a window
//
//...
//
// Configure NVidia driver
//
NvAPI_Status Status;
// Initialize NVAPI
Status = NvAPI_Initialize();
CHECK_NVAPI_STATUS(Status);
// Create a new session
NvDRSSessionHandle hSession;
Status = NvAPI_DRS_CreateSession(&hSession);
CHECK_NVAPI_STATUS(Status);
Status = NvAPI_DRS_LoadSettings(hSession);
CHECK_NVAPI_STATUS(Status);
// Affect whole system profile
Status = NvAPI_DRS_GetBaseProfile(hSession, &hProfile);
CHECK_NVAPI_STATUS(Status);
// Current shader cache setting
NVDRS_SETTING drsSetting = {0};
drsSetting.version = NVDRS_SETTING_VER;
drsSetting.settingId = PS_SHADERDISKCACHE_ID;
drsSetting.settingType = NVDRS_DWORD_TYPE;
Status = NvAPI_DRS_GetSetting(hSession, hProfile, PS_SHADERDISKCACHE_ID, &drsSetting);
CHECK_NVAPI_STATUS(Status);
// Disable shader cache
drsSetting.u32CurrentValue = PS_SHADERDISKCACHE_OFF;
Status = NvAPI_DRS_SetSetting(hSession, hProfile, &drsSetting);
CHECK_NVAPI_STATUS(Status);
// nvogl64.dll isn't loaded here
//
// Initialize OpenGL
//
// ...
// nvogl64.dll is loaded here
//
// Do something with OpenGL
//
// ...
//
// Release NVAPI
//
// Save settings (following whiteparer best practices)
NvAPI_DRS_SaveSettings(hSession);
NvAPI_DRS_DestroySession(hSession);
NvAPI_Unload();
//
// Release OpenGL
//
// ...
//
// Release Window
//
// ...
System :
Drivers 344.75
NVAPI r343
Geforce 770 GTX
Windows 7 SP1 64bit
The PS_SHADERDISKCACHE_ID value is actually saved by NvAPI_DRS_SaveSettings but %APPDATA%/Roaming/NVidia/GLCache is always filled when I launch the application.
Any advices ? The best is a working sample compiling with Visual Studio 2010.
Best regards
Sylvain