From e63f89ee1b3a7495cb2a67416c406e17c6f25ca9 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 5 Feb 2022 20:48:13 +1100 Subject: [PATCH] Direct3D11: Improve /client gpuinfo and fix resource leakage --- src/Graphics_D3D11.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Graphics_D3D11.c b/src/Graphics_D3D11.c index 1a099c32c..8aa25a6a3 100644 --- a/src/Graphics_D3D11.c +++ b/src/Graphics_D3D11.c @@ -1096,20 +1096,30 @@ void Gfx_GetApiInfo(cc_string* info) { IDXGIAdapter* dxgi_adapter; hr = IDXGIDevice_GetAdapter(dxgi_device, &dxgi_adapter); - if (hr || !dxgi_adapter) return; + if (hr || !dxgi_adapter) goto release_device; DXGI_ADAPTER_DESC desc = { 0 }; hr = IDXGIAdapter_GetDesc(dxgi_adapter, &desc); - if (hr) return; + if (hr) goto release_adapter; // desc.Description is a WCHAR, convert to char char adapter[128] = { 0 }; for (int i = 0; i < 128; i++) { adapter[i] = desc.Description[i]; } - // TODO check what desc.DedicatedSystemMemory gives on intel laptop - float vram = desc.DedicatedVideoMemory / (1024.0 * 1024.0); + SIZE_T vram = desc.DedicatedVideoMemory; + SIZE_T dram = desc.DedicatedSystemMemory; + SIZE_T sram = desc.SharedSystemMemory; + float tram_ = (vram + dram + sram) / (1024.0 * 1024.0); + float vram_ = vram / (1024.0 * 1024.0); + String_Format1(info, "Adapter: %c\n", adapter); - String_Format1(info, "Video memory: %f2 MB total\n", &vram); + String_Format2(info, "Graphics memory: %f2 MB total (%f2 MB VRAM)\n", &tram_, &vram_); + String_Format2(info, "Max texture size: (%i x %i)\n", &Gfx.MaxTexWidth, &Gfx.MaxTexHeight); + +release_adapter: + IDXGIAdapter_Release(dxgi_adapter); +release_device: + IDXGIDevice_Release(dxgi_device); } void Gfx_OnWindowResize(void) {