From 8d1381b42af6e770582a884dfc24475b1e669589 Mon Sep 17 00:00:00 2001 From: zilmar Date: Fri, 9 Oct 2015 15:50:44 +1100 Subject: [PATCH] [glide64] remove vram.cpp (from Fix build under MinGW) https://github.com/mupen64plus/mupen64plus-video-glide64mk2/commit/3b8d826964cc8a5dfd2404306f0bba823b909320 --- Source/Glitch64/Glitch64.vcproj | 4 -- Source/Glitch64/OGLglitchmain.cpp | 5 -- Source/Glitch64/vram.cpp | 114 ------------------------------ 3 files changed, 123 deletions(-) delete mode 100644 Source/Glitch64/vram.cpp diff --git a/Source/Glitch64/Glitch64.vcproj b/Source/Glitch64/Glitch64.vcproj index 15a142bce..9ee432601 100644 --- a/Source/Glitch64/Glitch64.vcproj +++ b/Source/Glitch64/Glitch64.vcproj @@ -160,10 +160,6 @@ RelativePath=".\OGLtextures.cpp" > - - diff --git a/Source/Glitch64/OGLglitchmain.cpp b/Source/Glitch64/OGLglitchmain.cpp index 7db272f07..c8a9ceb5f 100644 --- a/Source/Glitch64/OGLglitchmain.cpp +++ b/Source/Glitch64/OGLglitchmain.cpp @@ -2759,11 +2759,6 @@ FX_ENTRY void FX_CALL grConfigWrapperExt(FxI32 resolution, FxI32 vram, FxBool fb config.vram_size = vram; config.fbo = fbo; config.anisofilter = aniso; -#ifdef _WIN32 - int getVRAMSize(); - if (config.vram_size == 0) - config.vram_size = getVRAMSize(); -#endif // _WIN32 } // unused by glide64 diff --git a/Source/Glitch64/vram.cpp b/Source/Glitch64/vram.cpp deleted file mode 100644 index 99c2f24be..000000000 --- a/Source/Glitch64/vram.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include - -#ifdef _WIN32 //Windows, duh! -#include -#include -#include "dxdiag.h" -#include "main.h" -#pragma comment(lib, "ole32.lib") -#define SAFE_RELEASE(x) { if (x != NULL) { x->Release(); x = NULL; } } - -IDxDiagProvider* Provider; -IDxDiagContainer* RootContainer; -bool ComInitialized; - -static void InitCom() -{ - try - { - Provider = NULL; - RootContainer = NULL; - - // Init COM - ComInitialized = SUCCEEDED(CoInitialize(NULL)); - - // Create a provider interface - if (FAILED(CoCreateInstance(CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER, IID_IDxDiagProvider, (void**)&Provider))) - throw "Unable to create provider instance"; - - // Initialize the provider - DXDIAG_INIT_PARAMS initParams; - ZeroMemory(&initParams, sizeof(DXDIAG_INIT_PARAMS)); - initParams.dwSize = sizeof(DXDIAG_INIT_PARAMS); - initParams.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION; - if (FAILED(Provider->Initialize(&initParams))) - throw "Unable to initialize provider"; - - // Get the root container - if (FAILED(Provider->GetRootContainer(&RootContainer))) - throw "Unable to get root container"; - } - catch (const char* msg) - { - LOG("\nDxDiag Error: %s", msg); - } -} - -static IDxDiagContainer* GetContainer(IDxDiagContainer* parent, const WCHAR* name) -{ - IDxDiagContainer* container; - if (SUCCEEDED(parent->GetChildContainer(name, &container))) - return container; - - return NULL; -} - -static void GetPropertyValue(IDxDiagContainer* container, const WCHAR* name, WCHAR* value, int maxValueLen) -{ - VARIANT var; - VariantInit(&var); - if (SUCCEEDED(container->GetProp(name, &var))) - { - // Assuming an integer or bstring value here - // @@ Handle all the VT_* types properly... - if (var.vt != VT_BSTR) - wsprintf((LPSTR)value, "%i", var.iVal); - else - wcsncpy(value, var.bstrVal, maxValueLen - 1); - - value[maxValueLen - 1] = 0; - VariantClear(&var); - } - else - { - value[0] = 0; - } -} - -static int GetTotalVideoMemory() -{ - if (RootContainer != NULL) - { - // Get device container - IDxDiagContainer* container = GetContainer(RootContainer, L"DxDiag_DisplayDevices"); - if (container != NULL) - { - // Get device name - container = GetContainer(container, L"0"); - if (container != NULL) - { - const int bufferLength = 256; - WCHAR buffer[bufferLength]; - GetPropertyValue(container, L"szDisplayMemoryLocalized", buffer, bufferLength); - // Value in MB is first token in string - return _wtoi(buffer); - } - } - } - - // No good! - return -1; -} - -int getVRAMSize() -{ - static int mem; - if (!mem) { - InitCom(); - mem = GetTotalVideoMemory(); - } - return mem * 1024 * 1024; -} -#endif - -