Skip to content

Instantly share code, notes, and snippets.

@nlguillemot
Created April 28, 2017 03:03
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nlguillemot/390024aec8a2038c949a52f038c31361 to your computer and use it in GitHub Desktop.
Save nlguillemot/390024aec8a2038c949a52f038c31361 to your computer and use it in GitHub Desktop.
stable opengl timestamps with D3D12
#ifdef _WIN32
#include <d3d12.h>
#include <dxgi1_5.h>
#pragma comment(lib, "d3d12.lib")
#pragma comment(lib, "dxgi.lib")
#endif
#ifdef _WIN32
void SetStablePowerState()
{
IDXGIFactory4* pDXGIFactory;
CreateDXGIFactory1(IID_PPV_ARGS(&pDXGIFactory));
IDXGIAdapter1* pDXGIAdapter;
pDXGIFactory->EnumAdapters1(0, &pDXGIAdapter);
ID3D12Device* pDevice;
D3D12CreateDevice(pDXGIAdapter, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&pDevice));
pDevice->SetStablePowerState(TRUE);
}
#else
void SetStablePowerState()
{
// I don't know how to do this on other platforms.
}
#endif
int main()
{
SetStablePowerState();
// Rest of OpenGL program as usual...
}
@nlguillemot
Copy link
Author

Note: you need to enable developer mode to call SetStablePowerState().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment