Created
April 28, 2017 03:03
-
-
Save nlguillemot/390024aec8a2038c949a52f038c31361 to your computer and use it in GitHub Desktop.
stable opengl timestamps with D3D12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: you need to enable developer mode to call SetStablePowerState().