gsdx ogl: plug GL_NVX_gpu_memory_info and GL_ATI_meminfo

to query available memory on the GPU

Requirement
* dedicated GPU (ofc!)
* proprietary driver. Free driver supports r600, radeonsi
This commit is contained in:
Gregory Hainaut 2016-07-07 22:02:10 +02:00
parent 7e2b3da928
commit d8050634f6
3 changed files with 26 additions and 0 deletions

View File

@ -208,6 +208,9 @@ namespace GLLoader {
bool found_GL_ARB_gpu_shader5 = false; // Require IvyBridge
bool found_GL_ARB_shader_image_load_store = false; // Intel IB. Nvidia/AMD miss Mesa implementation.
bool found_GL_ARB_viewport_array = false; // Intel IB. AMD/NVIDIA DX10
// Bonus to monitor the VRAM
bool found_GL_NVX_gpu_memory_info = false;
bool found_GL_ATI_meminfo = false;
// Mandatory
bool found_GL_ARB_buffer_storage = false;
@ -305,6 +308,8 @@ namespace GLLoader {
string ext((const char*)glGetStringi(GL_EXTENSIONS, i));
// Bonus
if (ext.compare("GL_EXT_texture_filter_anisotropic") == 0) found_GL_EXT_texture_filter_anisotropic = true;
if (ext.compare("GL_NVX_gpu_memory_info") == 0) found_GL_NVX_gpu_memory_info = true;
if (ext.compare("GL_ATI_meminfo") == 0) found_GL_ATI_meminfo = true;
// GL4.0
if (ext.compare("GL_ARB_gpu_shader5") == 0) found_GL_ARB_gpu_shader5 = true;
if (ext.compare("GL_ARB_draw_buffers_blend") == 0) found_GL_ARB_draw_buffers_blend = true;

View File

@ -354,4 +354,6 @@ namespace GLLoader {
extern bool found_GL_ARB_clear_texture;
extern bool found_GL_ARB_direct_state_access;
extern bool found_GL_EXT_texture_filter_anisotropic;
extern bool found_GL_NVX_gpu_memory_info;
extern bool found_GL_ATI_meminfo;
}

View File

@ -486,6 +486,25 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
PboPool::Init();
}
// ****************************************************************
// Get Available Memory
// ****************************************************************
GLint vram[4] = {0};
if (GLLoader::found_GL_NVX_gpu_memory_info) {
glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, vram);
} else if (GLLoader::found_GL_ATI_meminfo) {
// Why openGL is always that complicated !
//glGetIntegerv(GL_RENDERBUFFER_FREE_MEMORY_ATI, vram);
glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, vram);
} else {
fprintf(stdout, "No extenstion supported to get available memory. Use default value !\n");
}
if (vram[0] > 0)
GLState::available_vram = (uint64)vram[0] * 1024ul;
fprintf(stdout, "Available VRAM:%lluMB\n", GLState::available_vram >> 20u);
// ****************************************************************
// Finish window setup and backbuffer
// ****************************************************************