From 8c20662ff77a9672917aa127f80a2fa9efda7119 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 1 Apr 2025 20:35:52 +0300 Subject: #3712 CMakeFindFrameworks deprecation --- indra/llwindow/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index 2996f58fe0..5bfac34ca5 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -182,7 +182,6 @@ endif (SDL_FOUND) target_include_directories(llwindow INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) if (DARWIN) - include(CMakeFindFrameworks) find_library(CARBON_LIBRARY Carbon) target_link_libraries(llwindow ${CARBON_LIBRARY}) endif (DARWIN) -- cgit v1.3 From 2da46c38305f6002993cd1974a9342935e97f8c6 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 1 Apr 2025 22:59:22 +0300 Subject: #3575 Clean up obsolete VRAM detectin logic --- indra/llrender/llgl.cpp | 19 - indra/llwindow/lldxhardware.cpp | 652 ------------------------- indra/llwindow/lldxhardware.h | 68 --- indra/newview/llappviewerwin32.cpp | 60 +-- indra/newview/skins/default/xui/en/strings.xml | 1 - 5 files changed, 1 insertion(+), 799 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 1966e48f2e..0be27b8975 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -1228,28 +1228,9 @@ bool LLGLManager::initGL() } #endif -#if LL_WINDOWS - if (mVRAM < 256) - { - // Something likely went wrong using the above extensions - // try WMI first and fall back to old method (from dxdiag) if all else fails - // Function will check all GPUs WMI knows of and will pick up the one with most - // memory. We need to check all GPUs because system can switch active GPU to - // weaker one, to preserve power when not under load. - U32 mem = LLDXHardware::getMBVideoMemoryViaWMI(); - if (mem != 0) - { - mVRAM = mem; - LL_WARNS("RenderInit") << "VRAM Detected (WMI):" << mVRAM<< LL_ENDL; - } - } -#endif - if (mVRAM < 256 && old_vram > 0) { // fall back to old method - // Note: on Windows value will be from LLDXHardware. - // Either received via dxdiag or via WMI by id from dxdiag. mVRAM = old_vram; } diff --git a/indra/llwindow/lldxhardware.cpp b/indra/llwindow/lldxhardware.cpp index 4bc069c5a4..387982dfc2 100644 --- a/indra/llwindow/lldxhardware.cpp +++ b/indra/llwindow/lldxhardware.cpp @@ -47,7 +47,6 @@ #include "llstl.h" #include "lltimer.h" -void (*gWriteDebug)(const char* msg) = NULL; LLDXHardware gDXHardware; //----------------------------------------------------------------------------- @@ -61,170 +60,6 @@ typedef BOOL ( WINAPI* PfnCoSetProxyBlanket )( IUnknown* pProxy, DWORD dwAuthnSv OLECHAR* pServerPrincName, DWORD dwAuthnLevel, DWORD dwImpLevel, RPC_AUTH_IDENTITY_HANDLE pAuthInfo, DWORD dwCapabilities ); -HRESULT GetVideoMemoryViaWMI(WCHAR* strInputDeviceID, DWORD* pdwAdapterRam) -{ - HRESULT hr; - bool bGotMemory = false; - IWbemLocator* pIWbemLocator = nullptr; - IWbemServices* pIWbemServices = nullptr; - BSTR pNamespace = nullptr; - - *pdwAdapterRam = 0; - CoInitializeEx(0, COINIT_APARTMENTTHREADED); - - hr = CoCreateInstance( CLSID_WbemLocator, - nullptr, - CLSCTX_INPROC_SERVER, - IID_IWbemLocator, - ( LPVOID* )&pIWbemLocator ); -#ifdef PRINTF_DEBUGGING - if( FAILED( hr ) ) wprintf( L"WMI: CoCreateInstance failed: 0x%0.8x\n", hr ); -#endif - - if( SUCCEEDED( hr ) && pIWbemLocator ) - { - // Using the locator, connect to WMI in the given namespace. - pNamespace = SysAllocString( L"\\\\.\\root\\cimv2" ); - - hr = pIWbemLocator->ConnectServer( pNamespace, nullptr, nullptr, 0L, - 0L, nullptr, nullptr, &pIWbemServices ); -#ifdef PRINTF_DEBUGGING - if( FAILED( hr ) ) wprintf( L"WMI: pIWbemLocator->ConnectServer failed: 0x%0.8x\n", hr ); -#endif - if( SUCCEEDED( hr ) && pIWbemServices != 0 ) - { - HINSTANCE hinstOle32 = nullptr; - - hinstOle32 = LoadLibraryW( L"ole32.dll" ); - if( hinstOle32 ) - { - PfnCoSetProxyBlanket pfnCoSetProxyBlanket = nullptr; - - pfnCoSetProxyBlanket = ( PfnCoSetProxyBlanket )GetProcAddress( hinstOle32, "CoSetProxyBlanket" ); - if( pfnCoSetProxyBlanket != 0 ) - { - // Switch security level to IMPERSONATE. - pfnCoSetProxyBlanket( pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, nullptr, - RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, nullptr, 0 ); - } - - FreeLibrary( hinstOle32 ); - } - - IEnumWbemClassObject* pEnumVideoControllers = nullptr; - BSTR pClassName = nullptr; - - pClassName = SysAllocString( L"Win32_VideoController" ); - - hr = pIWbemServices->CreateInstanceEnum( pClassName, 0, - nullptr, &pEnumVideoControllers ); -#ifdef PRINTF_DEBUGGING - if( FAILED( hr ) ) wprintf( L"WMI: pIWbemServices->CreateInstanceEnum failed: 0x%0.8x\n", hr ); -#endif - - if( SUCCEEDED( hr ) && pEnumVideoControllers ) - { - IWbemClassObject* pVideoControllers[10] = {0}; - DWORD uReturned = 0; - BSTR pPropName = nullptr; - - // Get the first one in the list - pEnumVideoControllers->Reset(); - hr = pEnumVideoControllers->Next( 5000, // timeout in 5 seconds - 10, // return the first 10 - pVideoControllers, - &uReturned ); -#ifdef PRINTF_DEBUGGING - if( FAILED( hr ) ) wprintf( L"WMI: pEnumVideoControllers->Next failed: 0x%0.8x\n", hr ); - if( uReturned == 0 ) wprintf( L"WMI: pEnumVideoControllers uReturned == 0\n" ); -#endif - - VARIANT var; - if( SUCCEEDED( hr ) ) - { - bool bFound = false; - for( UINT iController = 0; iController < uReturned; iController++ ) - { - if ( !pVideoControllers[iController] ) - continue; - - // if strInputDeviceID is set find this specific device and return memory or specific device - // if strInputDeviceID is not set return the best device - if (strInputDeviceID) - { - pPropName = SysAllocString( L"PNPDeviceID" ); - hr = pVideoControllers[iController]->Get( pPropName, 0L, &var, nullptr, nullptr ); -#ifdef PRINTF_DEBUGGING - if( FAILED( hr ) ) - wprintf( L"WMI: pVideoControllers[iController]->Get PNPDeviceID failed: 0x%0.8x\n", hr ); -#endif - if( SUCCEEDED( hr ) && strInputDeviceID) - { - if( wcsstr( var.bstrVal, strInputDeviceID ) != 0 ) - bFound = true; - } - VariantClear( &var ); - if( pPropName ) SysFreeString( pPropName ); - } - - if( bFound || !strInputDeviceID ) - { - pPropName = SysAllocString( L"AdapterRAM" ); - hr = pVideoControllers[iController]->Get( pPropName, 0L, &var, nullptr, nullptr ); -#ifdef PRINTF_DEBUGGING - if( FAILED( hr ) ) - wprintf( L"WMI: pVideoControllers[iController]->Get AdapterRAM failed: 0x%0.8x\n", - hr ); -#endif - if( SUCCEEDED( hr ) ) - { - bGotMemory = true; - *pdwAdapterRam = llmax(var.ulVal, *pdwAdapterRam); - } - VariantClear( &var ); - if( pPropName ) SysFreeString( pPropName ); - } - - SAFE_RELEASE( pVideoControllers[iController] ); - - if (bFound) - { - break; - } - } - } - } - - if( pClassName ) - SysFreeString( pClassName ); - SAFE_RELEASE( pEnumVideoControllers ); - } - - if( pNamespace ) - SysFreeString( pNamespace ); - SAFE_RELEASE( pIWbemServices ); - } - - SAFE_RELEASE( pIWbemLocator ); - - CoUninitialize(); - - if( bGotMemory ) - return S_OK; - else - return E_FAIL; -} - -//static -U32 LLDXHardware::getMBVideoMemoryViaWMI() -{ - DWORD vram = 0; - if (SUCCEEDED(GetVideoMemoryViaWMI(NULL, &vram))) - { - return vram / (1024 * 1024);; - } - return 0; -} //Getting the version of graphics controller driver via WMI std::string LLDXHardware::getDriverVersionWMI(EGPUVendor vendor) @@ -480,495 +315,14 @@ std::string get_string(IDxDiagContainer *containerp, const WCHAR *wszPropName) return utf16str_to_utf8str(wszPropValue); } - -LLVersion::LLVersion() -{ - mValid = false; - S32 i; - for (i = 0; i < 4; i++) - { - mFields[i] = 0; - } -} - -bool LLVersion::set(const std::string &version_string) -{ - S32 i; - for (i = 0; i < 4; i++) - { - mFields[i] = 0; - } - // Split the version string. - std::string str(version_string); - typedef boost::tokenizer > tokenizer; - boost::char_separator sep(".", "", boost::keep_empty_tokens); - tokenizer tokens(str, sep); - - tokenizer::iterator iter = tokens.begin(); - S32 count = 0; - for (;(iter != tokens.end()) && (count < 4);++iter) - { - mFields[count] = atoi(iter->c_str()); - count++; - } - if (count < 4) - { - //LL_WARNS() << "Potentially bogus version string!" << version_string << LL_ENDL; - for (i = 0; i < 4; i++) - { - mFields[i] = 0; - } - mValid = false; - } - else - { - mValid = true; - } - return mValid; -} - -S32 LLVersion::getField(const S32 field_num) -{ - if (!mValid) - { - return -1; - } - else - { - return mFields[field_num]; - } -} - -std::string LLDXDriverFile::dump() -{ - if (gWriteDebug) - { - gWriteDebug("Filename:"); - gWriteDebug(mName.c_str()); - gWriteDebug("\n"); - gWriteDebug("Ver:"); - gWriteDebug(mVersionString.c_str()); - gWriteDebug("\n"); - gWriteDebug("Date:"); - gWriteDebug(mDateString.c_str()); - gWriteDebug("\n"); - } - LL_INFOS() << mFilepath << LL_ENDL; - LL_INFOS() << mName << LL_ENDL; - LL_INFOS() << mVersionString << LL_ENDL; - LL_INFOS() << mDateString << LL_ENDL; - - return ""; -} - -LLDXDevice::~LLDXDevice() -{ - for_each(mDriverFiles.begin(), mDriverFiles.end(), DeletePairedPointer()); - mDriverFiles.clear(); -} - -std::string LLDXDevice::dump() -{ - if (gWriteDebug) - { - gWriteDebug("StartDevice\n"); - gWriteDebug("DeviceName:"); - gWriteDebug(mName.c_str()); - gWriteDebug("\n"); - gWriteDebug("PCIString:"); - gWriteDebug(mPCIString.c_str()); - gWriteDebug("\n"); - } - LL_INFOS() << LL_ENDL; - LL_INFOS() << "DeviceName:" << mName << LL_ENDL; - LL_INFOS() << "PCIString:" << mPCIString << LL_ENDL; - LL_INFOS() << "Drivers" << LL_ENDL; - LL_INFOS() << "-------" << LL_ENDL; - for (driver_file_map_t::iterator iter = mDriverFiles.begin(), - end = mDriverFiles.end(); - iter != end; iter++) - { - LLDXDriverFile *filep = iter->second; - filep->dump(); - } - if (gWriteDebug) - { - gWriteDebug("EndDevice\n"); - } - - return ""; -} - -LLDXDriverFile *LLDXDevice::findDriver(const std::string &driver) -{ - for (driver_file_map_t::iterator iter = mDriverFiles.begin(), - end = mDriverFiles.end(); - iter != end; iter++) - { - LLDXDriverFile *filep = iter->second; - if (!utf8str_compare_insensitive(filep->mName,driver)) - { - return filep; - } - } - - return NULL; -} - LLDXHardware::LLDXHardware() { - mVRAM = 0; - gWriteDebug = NULL; } void LLDXHardware::cleanup() { - // for_each(mDevices.begin(), mDevices.end(), DeletePairedPointer()); - // mDevices.clear(); -} - -/* -std::string LLDXHardware::dumpDevices() -{ - if (gWriteDebug) - { - gWriteDebug("\n"); - gWriteDebug("StartAllDevices\n"); - } - for (device_map_t::iterator iter = mDevices.begin(), - end = mDevices.end(); - iter != end; iter++) - { - LLDXDevice *devicep = iter->second; - devicep->dump(); - } - if (gWriteDebug) - { - gWriteDebug("EndAllDevices\n\n"); - } - return ""; } -LLDXDevice *LLDXHardware::findDevice(const std::string &vendor, const std::string &devices) -{ - // Iterate through different devices tokenized in devices string - std::string str(devices); - typedef boost::tokenizer > tokenizer; - boost::char_separator sep("|", "", boost::keep_empty_tokens); - tokenizer tokens(str, sep); - - tokenizer::iterator iter = tokens.begin(); - for (;iter != tokens.end();++iter) - { - std::string dev_str = *iter; - for (device_map_t::iterator iter = mDevices.begin(), - end = mDevices.end(); - iter != end; iter++) - { - LLDXDevice *devicep = iter->second; - if ((devicep->mVendorID == vendor) - && (devicep->mDeviceID == dev_str)) - { - return devicep; - } - } - } - - return NULL; -} -*/ - -bool LLDXHardware::getInfo(bool vram_only) -{ - LLTimer hw_timer; - bool ok = false; - HRESULT hr; - - // CLSID_DxDiagProvider does not work with Multithreaded? - CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); - - IDxDiagProvider *dx_diag_providerp = NULL; - IDxDiagContainer *dx_diag_rootp = NULL; - IDxDiagContainer *devices_containerp = NULL; - // IDxDiagContainer *system_device_containerp= NULL; - IDxDiagContainer *device_containerp = NULL; - IDxDiagContainer *file_containerp = NULL; - IDxDiagContainer *driver_containerp = NULL; - DWORD dw_device_count; - - mVRAM = 0; - - // CoCreate a IDxDiagProvider* - LL_DEBUGS("AppInit") << "CoCreateInstance IID_IDxDiagProvider" << LL_ENDL; - hr = CoCreateInstance(CLSID_DxDiagProvider, - NULL, - CLSCTX_INPROC_SERVER, - IID_IDxDiagProvider, - (LPVOID*) &dx_diag_providerp); - - if (FAILED(hr)) - { - LL_WARNS("AppInit") << "No DXDiag provider found! DirectX 9 not installed!" << LL_ENDL; - gWriteDebug("No DXDiag provider found! DirectX 9 not installed!\n"); - goto LCleanup; - } - if (SUCCEEDED(hr)) // if FAILED(hr) then dx9 is not installed - { - // Fill out a DXDIAG_INIT_PARAMS struct and pass it to IDxDiagContainer::Initialize - // Passing in TRUE for bAllowWHQLChecks, allows dxdiag to check if drivers are - // digital signed as logo'd by WHQL which may connect via internet to update - // WHQL certificates. - DXDIAG_INIT_PARAMS dx_diag_init_params; - ZeroMemory(&dx_diag_init_params, sizeof(DXDIAG_INIT_PARAMS)); - - dx_diag_init_params.dwSize = sizeof(DXDIAG_INIT_PARAMS); - dx_diag_init_params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION; - dx_diag_init_params.bAllowWHQLChecks = TRUE; - dx_diag_init_params.pReserved = NULL; - - LL_DEBUGS("AppInit") << "dx_diag_providerp->Initialize" << LL_ENDL; - hr = dx_diag_providerp->Initialize(&dx_diag_init_params); - if(FAILED(hr)) - { - goto LCleanup; - } - - LL_DEBUGS("AppInit") << "dx_diag_providerp->GetRootContainer" << LL_ENDL; - hr = dx_diag_providerp->GetRootContainer( &dx_diag_rootp ); - if(FAILED(hr) || !dx_diag_rootp) - { - goto LCleanup; - } - - HRESULT hr; - - // Get display driver information - LL_DEBUGS("AppInit") << "dx_diag_rootp->GetChildContainer" << LL_ENDL; - hr = dx_diag_rootp->GetChildContainer(L"DxDiag_DisplayDevices", &devices_containerp); - if(FAILED(hr) || !devices_containerp) - { - // do not release 'dirty' devices_containerp at this stage, only dx_diag_rootp - devices_containerp = NULL; - goto LCleanup; - } - - // make sure there is something inside - hr = devices_containerp->GetNumberOfChildContainers(&dw_device_count); - if (FAILED(hr) || dw_device_count == 0) - { - goto LCleanup; - } - - // Get device 0 - // By default 0 device is the primary one, howhever in case of various hybrid graphics - // like itegrated AMD and PCI AMD GPUs system might switch. - LL_DEBUGS("AppInit") << "devices_containerp->GetChildContainer" << LL_ENDL; - hr = devices_containerp->GetChildContainer(L"0", &device_containerp); - if(FAILED(hr) || !device_containerp) - { - goto LCleanup; - } - - DWORD vram = 0; - - WCHAR deviceID[512]; - - get_wstring(device_containerp, L"szDeviceID", deviceID, 512); - // Example: searches id like 1F06 in pnp string (aka VEN_10DE&DEV_1F06) - // doesn't seem to work on some systems since format is unrecognizable - // but in such case keyDeviceID works - if (SUCCEEDED(GetVideoMemoryViaWMI(deviceID, &vram))) - { - mVRAM = vram/(1024*1024); - } - else - { - get_wstring(device_containerp, L"szKeyDeviceID", deviceID, 512); - LL_WARNS() << "szDeviceID" << deviceID << LL_ENDL; - // '+9' to avoid ENUM\\PCI\\ prefix - // Returns string like Enum\\PCI\\VEN_10DE&DEV_1F06&SUBSYS... - // and since GetVideoMemoryViaWMI searches by PNPDeviceID it is sufficient - if (SUCCEEDED(GetVideoMemoryViaWMI(deviceID + 9, &vram))) - { - mVRAM = vram / (1024 * 1024); - } - } - - if (mVRAM == 0) - { // Get the English VRAM string - std::string ram_str = get_string(device_containerp, L"szDisplayMemoryEnglish"); - - // We don't need the device any more - SAFE_RELEASE(device_containerp); - - // Dump the string as an int into the structure - char *stopstring; - mVRAM = strtol(ram_str.c_str(), &stopstring, 10); - LL_INFOS("AppInit") << "VRAM Detected: " << mVRAM << " DX9 string: " << ram_str << LL_ENDL; - } - - if (vram_only) - { - ok = true; - goto LCleanup; - } - - - /* for now, we ONLY do vram_only the rest of this - is commented out, to ensure no-one is tempted - to use it - - // Now let's get device and driver information - // Get the IDxDiagContainer object called "DxDiag_SystemDevices". - // This call may take some time while dxdiag gathers the info. - DWORD num_devices = 0; - WCHAR wszContainer[256]; - LL_DEBUGS("AppInit") << "dx_diag_rootp->GetChildContainer DxDiag_SystemDevices" << LL_ENDL; - hr = dx_diag_rootp->GetChildContainer(L"DxDiag_SystemDevices", &system_device_containerp); - if (FAILED(hr)) - { - goto LCleanup; - } - - hr = system_device_containerp->GetNumberOfChildContainers(&num_devices); - if (FAILED(hr)) - { - goto LCleanup; - } - - LL_DEBUGS("AppInit") << "DX9 iterating over devices" << LL_ENDL; - S32 device_num = 0; - for (device_num = 0; device_num < (S32)num_devices; device_num++) - { - hr = system_device_containerp->EnumChildContainerNames(device_num, wszContainer, 256); - if (FAILED(hr)) - { - goto LCleanup; - } - - hr = system_device_containerp->GetChildContainer(wszContainer, &device_containerp); - if (FAILED(hr) || device_containerp == NULL) - { - goto LCleanup; - } - - std::string device_name = get_string(device_containerp, L"szDescription"); - - std::string device_id = get_string(device_containerp, L"szDeviceID"); - - LLDXDevice *dxdevicep = new LLDXDevice; - dxdevicep->mName = device_name; - dxdevicep->mPCIString = device_id; - mDevices[dxdevicep->mPCIString] = dxdevicep; - - // Split the PCI string based on vendor, device, subsys, rev. - std::string str(device_id); - typedef boost::tokenizer > tokenizer; - boost::char_separator sep("&\\", "", boost::keep_empty_tokens); - tokenizer tokens(str, sep); - - tokenizer::iterator iter = tokens.begin(); - S32 count = 0; - bool valid = true; - for (;(iter != tokens.end()) && (count < 3);++iter) - { - switch (count) - { - case 0: - if (strcmp(iter->c_str(), "PCI")) - { - valid = false; - } - break; - case 1: - dxdevicep->mVendorID = iter->c_str(); - break; - case 2: - dxdevicep->mDeviceID = iter->c_str(); - break; - default: - // Ignore it - break; - } - count++; - } - - - - - // Now, iterate through the related drivers - hr = device_containerp->GetChildContainer(L"Drivers", &driver_containerp); - if (FAILED(hr) || !driver_containerp) - { - goto LCleanup; - } - - DWORD num_files = 0; - hr = driver_containerp->GetNumberOfChildContainers(&num_files); - if (FAILED(hr)) - { - goto LCleanup; - } - - S32 file_num = 0; - for (file_num = 0; file_num < (S32)num_files; file_num++ ) - { - - hr = driver_containerp->EnumChildContainerNames(file_num, wszContainer, 256); - if (FAILED(hr)) - { - goto LCleanup; - } - - hr = driver_containerp->GetChildContainer(wszContainer, &file_containerp); - if (FAILED(hr) || file_containerp == NULL) - { - goto LCleanup; - } - - std::string driver_path = get_string(file_containerp, L"szPath"); - std::string driver_name = get_string(file_containerp, L"szName"); - std::string driver_version = get_string(file_containerp, L"szVersion"); - std::string driver_date = get_string(file_containerp, L"szDatestampEnglish"); - - LLDXDriverFile *dxdriverfilep = new LLDXDriverFile; - dxdriverfilep->mName = driver_name; - dxdriverfilep->mFilepath= driver_path; - dxdriverfilep->mVersionString = driver_version; - dxdriverfilep->mVersion.set(driver_version); - dxdriverfilep->mDateString = driver_date; - - dxdevicep->mDriverFiles[driver_name] = dxdriverfilep; - - SAFE_RELEASE(file_containerp); - } - SAFE_RELEASE(device_containerp); - } - */ - } - - // dumpDevices(); - ok = true; - -LCleanup: - if (!ok) - { - LL_WARNS("AppInit") << "DX9 probe failed" << LL_ENDL; - gWriteDebug("DX9 probe failed\n"); - } - - SAFE_RELEASE(file_containerp); - SAFE_RELEASE(driver_containerp); - SAFE_RELEASE(device_containerp); - SAFE_RELEASE(devices_containerp); - SAFE_RELEASE(dx_diag_rootp); - SAFE_RELEASE(dx_diag_providerp); - - CoUninitialize(); - - return ok; - } - LLSD LLDXHardware::getDisplayInfo() { LLTimer hw_timer; @@ -995,7 +349,6 @@ LLSD LLDXHardware::getDisplayInfo() if (FAILED(hr)) { LL_WARNS() << "No DXDiag provider found! DirectX 9 not installed!" << LL_ENDL; - gWriteDebug("No DXDiag provider found! DirectX 9 not installed!\n"); goto LCleanup; } if (SUCCEEDED(hr)) // if FAILED(hr) then dx9 is not installed @@ -1111,9 +464,4 @@ LCleanup: return ret; } -void LLDXHardware::setWriteDebugFunc(void (*func)(const char*)) -{ - gWriteDebug = func; -} - #endif diff --git a/indra/llwindow/lldxhardware.h b/indra/llwindow/lldxhardware.h index 2b879e021c..8d8a08a4eb 100644 --- a/indra/llwindow/lldxhardware.h +++ b/indra/llwindow/lldxhardware.h @@ -30,64 +30,16 @@ #include #include "stdtypes.h" -#include "llstring.h" #include "llsd.h" -class LLVersion -{ -public: - LLVersion(); - bool set(const std::string &version_string); - S32 getField(const S32 field_num); -protected: - std::string mVersionString; - S32 mFields[4]; - bool mValid; -}; - -class LLDXDriverFile -{ -public: - std::string dump(); - -public: - std::string mFilepath; - std::string mName; - std::string mVersionString; - LLVersion mVersion; - std::string mDateString; -}; - -class LLDXDevice -{ -public: - ~LLDXDevice(); - std::string dump(); - - LLDXDriverFile *findDriver(const std::string &driver); -public: - std::string mName; - std::string mPCIString; - std::string mVendorID; - std::string mDeviceID; - - typedef std::map driver_file_map_t; - driver_file_map_t mDriverFiles; -}; - class LLDXHardware { public: LLDXHardware(); - void setWriteDebugFunc(void (*func)(const char*)); void cleanup(); - // Returns true on success. - // vram_only true does a "light" probe. - bool getInfo(bool vram_only); - // WMI can return multiple GPU drivers // specify which one to output typedef enum { @@ -98,29 +50,9 @@ public: } EGPUVendor; std::string getDriverVersionWMI(EGPUVendor vendor); - S32 getVRAM() const { return mVRAM; } - LLSD getDisplayInfo(); - - // Will get memory of best GPU in MB, return memory on sucsess, 0 on failure - // Note: WMI is not accurate in some cases - static U32 getMBVideoMemoryViaWMI(); - - // Find a particular device that matches the following specs. - // Empty strings indicate that you don't care. - // You can separate multiple devices with '|' chars to indicate you want - // ANY of them to match and return. - // LLDXDevice *findDevice(const std::string &vendor, const std::string &devices); - - // std::string dumpDevices(); -public: - typedef std::map device_map_t; - // device_map_t mDevices; -protected: - S32 mVRAM; }; -extern void (*gWriteDebug)(const char* msg); extern LLDXHardware gDXHardware; #endif // LL_LLDXHARDWARE_H diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp index aaf2a7ea3e..4f5fa53312 100644 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -842,69 +842,11 @@ void write_debug_dx(const std::string& str) bool LLAppViewerWin32::initHardwareTest() { - // - // Do driver verification and initialization based on DirectX - // hardware polling and driver versions - // - if (true == gSavedSettings.getBOOL("ProbeHardwareOnStartup") && false == gSavedSettings.getBOOL("NoHardwareProbe")) - { - // per DEV-11631 - disable hardware probing for everything - // but vram. - bool vram_only = true; - - LLSplashScreen::update(LLTrans::getString("StartupDetectingHardware")); - - LL_DEBUGS("AppInit") << "Attempting to poll DirectX for hardware info" << LL_ENDL; - gDXHardware.setWriteDebugFunc(write_debug_dx); - bool probe_ok = gDXHardware.getInfo(vram_only); - - if (!probe_ok - && gWarningSettings.getBOOL("AboutDirectX9")) - { - LL_WARNS("AppInit") << "DirectX probe failed, alerting user." << LL_ENDL; - - // Warn them that runnin without DirectX 9 will - // not allow us to tell them about driver issues - std::ostringstream msg; - msg << LLTrans::getString ("MBNoDirectX"); - S32 button = OSMessageBox( - msg.str(), - LLTrans::getString("MBWarning"), - OSMB_YESNO); - if (OSBTN_NO== button) - { - LL_INFOS("AppInit") << "User quitting after failed DirectX 9 detection" << LL_ENDL; - LLWeb::loadURLExternal("http://secondlife.com/support/", false); - return false; - } - gWarningSettings.setBOOL("AboutDirectX9", false); - } - LL_DEBUGS("AppInit") << "Done polling DirectX for hardware info" << LL_ENDL; - - // Only probe once after installation - gSavedSettings.setBOOL("ProbeHardwareOnStartup", false); - - // Disable so debugger can work - std::string splash_msg; - LLStringUtil::format_map_t args; - args["[APP_NAME]"] = LLAppViewer::instance()->getSecondLifeTitle(); - splash_msg = LLTrans::getString("StartupLoading", args); - - LLSplashScreen::update(splash_msg); - } - if (!restoreErrorTrap()) { - LL_WARNS("AppInit") << " Someone took over my exception handler (post hardware probe)!" << LL_ENDL; + LL_WARNS("AppInit") << " Someone took over my exception handler!" << LL_ENDL; } - if (gGLManager.mVRAM == 0) - { - gGLManager.mVRAM = gDXHardware.getVRAM(); - } - - LL_INFOS("AppInit") << "Detected VRAM: " << gGLManager.mVRAM << LL_ENDL; - return true; } diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index f0a26f9c56..d909a95b83 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -13,7 +13,6 @@ Second Life Support Portal - Detecting hardware... Loading [APP_NAME]... Clearing cache... Initializing texture cache... -- cgit v1.3 From 0c056c77f4eddb13e3e7a2a1d3d4b881dc07ea46 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 1 Apr 2025 23:24:51 +0300 Subject: #3575 Adjust VRAM budget test a bit --- indra/llwindow/llwindowwin32.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 832cf254d1..c190295512 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -4684,9 +4684,18 @@ void LLWindowWin32::LLWindowWin32Thread::checkDXMem() if (phys_mb > 0) { - // Intel uses 'shared' vram, cap it to 25% of total memory - // Todo: consider caping all adapters at least to 50% ram - budget_mb = llmin(budget_mb, (UINT64)(phys_mb * 0.25)); + if (gGLManager.mIsIntel) + { + // Intel uses 'shared' vram, cap it to 25% of total memory + // Todo: consider a way of detecting integrated Intel and AMD + budget_mb = llmin(budget_mb, (UINT64)(phys_mb * 0.25)); + } + else + { + // More budget is generally better, but the way viewer + // utilizes even dedicated VRAM leaves a footprint in RAM + budget_mb = llmin(budget_mb, (UINT64)(phys_mb * 0.75)); + } } else { -- cgit v1.3 From f5ab6e11f13699c03a696611f67f8384434130a1 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Tue, 13 May 2025 10:22:54 +0800 Subject: Not rely on (LL_)USESYSTEMLIBS macro & CMake setting but the fact that we keep on using as many system libraries as we can (and only resort to other sources in certain cases), hasn't changed, of course. Also stop having to set USE_AUTOBUILD_3P to OFF. Lines are reindented, and when a system library can be found for a dependency, then that should be the way. If later we find out that using some other way is better, than stick to that. So, one option at a time, whichever is best for the situation. GLEXT hasn't been used, and in order to be not having to hack its .cmake file, we bypass it and refer to GLH (which is still used) right away in LLWindow. CMake commands that need to be bypassed, if it's a one-liner then it's just commented out, but if it's multiple lines, then scope them with if (FALSE) to minimise difference. --- README.md | 16 ++--- indra/CMakeLists.txt | 4 -- indra/cmake/APR.cmake | 14 ++-- indra/cmake/Audio.cmake | 14 ++-- indra/cmake/Boost.cmake | 49 ++++++------- indra/cmake/CMakeLists.txt | 1 - indra/cmake/CURL.cmake | 10 ++- indra/cmake/FMODSTUDIO.cmake | 8 +-- indra/cmake/FreeType.cmake | 15 ++-- indra/cmake/GLEXT.cmake | 7 +- indra/cmake/GLH.cmake | 4 +- indra/cmake/GLM.cmake | 11 ++- indra/cmake/LLPrimitive.cmake | 144 +++++++++++++++++++-------------------- indra/cmake/LLWindow.cmake | 4 +- indra/cmake/LibVLCPlugin.cmake | 77 +++++++++------------ indra/cmake/Meshoptimizer.cmake | 17 ++--- indra/cmake/NDOF.cmake | 7 +- indra/cmake/OPENAL.cmake | 16 ++--- indra/cmake/OpenJPEG.cmake | 8 +-- indra/cmake/OpenSSL.cmake | 16 ++--- indra/cmake/Prebuilt.cmake | 85 ++++++++++++----------- indra/cmake/UI.cmake | 5 +- indra/cmake/ViewerMiscLibs.cmake | 10 +-- indra/cmake/VulkanGltf.cmake | 2 - indra/cmake/ZLIBNG.cmake | 12 ++-- indra/cmake/xxHash.cmake | 8 +-- indra/llcommon/CMakeLists.txt | 33 ++++----- indra/llimage/CMakeLists.txt | 16 ++--- indra/llmath/CMakeLists.txt | 2 +- indra/llmessage/CMakeLists.txt | 7 +- indra/llwebrtc/CMakeLists.txt | 4 +- indra/llwindow/CMakeLists.txt | 5 +- indra/llwindow/llwindowsdl.cpp | 6 -- indra/newview/CMakeLists.txt | 67 ++++++++---------- 34 files changed, 310 insertions(+), 394 deletions(-) (limited to 'indra/llwindow') diff --git a/README.md b/README.md index ae3a178803..2621c522b8 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ $ cd build-`uname -s|tr '[:upper:]' '[:lower:]'`-`uname -m` ``` $ sudo pacman -S cmake base-devel python apr-util boost fltk glm glu hunspell minizip nanosvg libnghttp2 libpipewire sdl2 vlc libvorbis xxhash $ export LL_BUILD="-O3 -std=c++20 -fPIC -DLL_LINUX=1" -$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DADDRESS_SIZE:STRING=64 -DUSESYSTEMLIBS:BOOL=ON -DUSE_OPENAL:BOOL=OFF -DUSE_FMODSTUDIO:BOOL=ON -DENABLE_MEDIA_PLUGINS:BOOL=ON -DLL_TESTS:BOOL=OFF -DNDOF:BOOL=ON -DROOT_PROJECT_NAME:STRING=Megapahit -DVIEWER_CHANNEL:STRING=Megapahit -DVIEWER_BINARY_NAME:STRING=megapahit -DBUILD_SHARED_LIBS:BOOL=OFF -DINSTALL:BOOL=ON -DPACKAGE:BOOL=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr ../indra +$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DADDRESS_SIZE:STRING=64 -DUSE_OPENAL:BOOL=OFF -DUSE_FMODSTUDIO:BOOL=ON -DENABLE_MEDIA_PLUGINS:BOOL=ON -DLL_TESTS:BOOL=OFF -DNDOF:BOOL=ON -DROOT_PROJECT_NAME:STRING=Megapahit -DVIEWER_CHANNEL:STRING=Megapahit -DVIEWER_BINARY_NAME:STRING=megapahit -DBUILD_SHARED_LIBS:BOOL=OFF -DINSTALL:BOOL=ON -DPACKAGE:BOOL=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr ../indra $ make -j`nproc` $ makepkg -R $ sudo pacman -U megapahit-`cat newview/viewer_version.txt|sed 's/\(.*\)\./\1-/'`-`uname -m`.pkg.tar.zst @@ -33,7 +33,7 @@ $ megapahit ``` $ sudo apt install cmake pkg-config libxml2-utils libalut-dev libaprutil1-dev libboost-fiber1.81-dev libboost-json1.81-dev libboost-program-options1.81-dev libboost-regex1.81-dev libboost-url1.81-dev libexpat1-dev libfltk1.3-dev libfontconfig-dev libfreetype-dev libglu1-mesa-dev libhunspell-dev libjpeg-dev libmeshoptimizer-dev libminizip-dev libnghttp2-dev libpipewire-0.3-dev libpng-dev libsdl2-dev libvlc-dev libvlccore-dev libvorbis-dev libxft-dev libxml2-dev libxxhash-dev $ export LL_BUILD="-O3 -std=c++20 -fPIC -DLL_LINUX=1" -$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DADDRESS_SIZE:STRING=64 -DUSESYSTEMLIBS:BOOL=ON -DUSE_OPENAL:BOOL=ON -DUSE_FMODSTUDIO:BOOL=OFF -DENABLE_MEDIA_PLUGINS:BOOL=ON -DLL_TESTS:BOOL=OFF -DNDOF:BOOL=ON -DROOT_PROJECT_NAME:STRING=Megapahit -DVIEWER_CHANNEL:STRING=Megapahit -DVIEWER_BINARY_NAME:STRING=megapahit -DBUILD_SHARED_LIBS:BOOL=OFF -DINSTALL:BOOL=ON -DPACKAGE:BOOL=ON ../indra +$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DADDRESS_SIZE:STRING=64 -DUSE_OPENAL:BOOL=ON -DUSE_FMODSTUDIO:BOOL=OFF -DENABLE_MEDIA_PLUGINS:BOOL=ON -DLL_TESTS:BOOL=OFF -DNDOF:BOOL=ON -DROOT_PROJECT_NAME:STRING=Megapahit -DVIEWER_CHANNEL:STRING=Megapahit -DVIEWER_BINARY_NAME:STRING=megapahit -DBUILD_SHARED_LIBS:BOOL=OFF -DINSTALL:BOOL=ON -DPACKAGE:BOOL=ON ../indra $ make -j`nproc` $ cpack -G DEB $ sudo apt install ./megapahit-`cat newview/viewer_version.txt`-Linux.deb @@ -45,7 +45,7 @@ $ megapahit ``` $ sudo dnf install cmake gcc-c++ patch patchelf rpm-build perl-FindBin apr-util-devel boost-devel boost-url expat-devel fltk-devel glm-devel mesa-libGLU-devel hunspell-devel minizip-ng-compat-devel libnghttp2-devel nanosvg-devel pipewire-devel pulseaudio-libs-devel SDL2-devel vlc-devel libvorbis-devel libXcursor-devel libXfixes-devel libXinerama-devel xxhash-devel $ export LL_BUILD="-O3 -std=c++20 -fPIC -DLL_LINUX=1" -$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DADDRESS_SIZE:STRING=64 -DUSESYSTEMLIBS:BOOL=ON -DUSE_OPENAL:BOOL=OFF -DUSE_FMODSTUDIO:BOOL=ON -DENABLE_MEDIA_PLUGINS:BOOL=ON -DLL_TESTS:BOOL=OFF -DNDOF:BOOL=ON -DROOT_PROJECT_NAME:STRING=Megapahit -DVIEWER_CHANNEL:STRING=Megapahit -DVIEWER_BINARY_NAME:STRING=megapahit -DBUILD_SHARED_LIBS:BOOL=OFF -DINSTALL:BOOL=ON -DPACKAGE:BOOL=ON ../indra +$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DADDRESS_SIZE:STRING=64 -DUSE_OPENAL:BOOL=OFF -DUSE_FMODSTUDIO:BOOL=ON -DENABLE_MEDIA_PLUGINS:BOOL=ON -DLL_TESTS:BOOL=OFF -DNDOF:BOOL=ON -DROOT_PROJECT_NAME:STRING=Megapahit -DVIEWER_CHANNEL:STRING=Megapahit -DVIEWER_BINARY_NAME:STRING=megapahit -DBUILD_SHARED_LIBS:BOOL=OFF -DINSTALL:BOOL=ON -DPACKAGE:BOOL=ON ../indra $ make -j`nproc` $ cpack -G RPM $ sudo dnf install megapahit-`cat newview/viewer_version.txt`-Linux.rpm @@ -58,7 +58,7 @@ $ sudo su - # portmaster devel/cmake devel/pkgconf audio/freealut devel/apr1 devel/boost-libs x11-toolkits/fltk math/glm textproc/hunspell misc/meshoptimizer archivers/minizip graphics/nanosvg www/libnghttp2 devel/sdl20 multimedia/vlc audio/libvorbis devel/xxhash # exit $ setenv LL_BUILD "-O3 -std=c++20 -fPIC" -$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DADDRESS_SIZE:STRING=64 -DUSESYSTEMLIBS:BOOL=ON -DUSE_OPENAL:BOOL=ON -DUSE_FMODSTUDIO:BOOL=OFF -DENABLE_MEDIA_PLUGINS:BOOL=ON -DLL_TESTS:BOOL=OFF -DNDOF:BOOL=OFF -DROOT_PROJECT_NAME:STRING=Megapahit -DVIEWER_CHANNEL:STRING=Megapahit -DVIEWER_BINARY_NAME:STRING=megapahit -DBUILD_SHARED_LIBS:BOOL=OFF -DINSTALL:BOOL=ON -DPACKAGE:BOOL=ON ../indra +$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DADDRESS_SIZE:STRING=64 -DUSE_OPENAL:BOOL=ON -DUSE_FMODSTUDIO:BOOL=OFF -DENABLE_MEDIA_PLUGINS:BOOL=ON -DLL_TESTS:BOOL=OFF -DNDOF:BOOL=OFF -DROOT_PROJECT_NAME:STRING=Megapahit -DVIEWER_CHANNEL:STRING=Megapahit -DVIEWER_BINARY_NAME:STRING=megapahit -DBUILD_SHARED_LIBS:BOOL=OFF -DINSTALL:BOOL=ON -DPACKAGE:BOOL=ON ../indra $ make -j`nproc` $ sudo cpack -G FREEBSD $ sudo pkg add megapahit-`cat newview/viewer_version.txt`-FreeBSD.pkg @@ -81,7 +81,7 @@ $ megapahit ``` $ sudo port install cmake pkgconfig freealut +universal apr-util +universal boost187 +universal glm hunspell +universal freetype +universal libjpeg-turbo +universal minizip +universal libvorbis +universal xxhashlib $ export LL_BUILD="-O3 -gdwarf-2 -stdlib=libc++ -mmacosx-version-min=11 -iwithsysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -std=c++20 -fPIC -DLL_RELEASE=1 -DLL_RELEASE_FOR_DOWNLOAD=1 -DNDEBUG -DPIC -DLL_DARWIN=1" -$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DADDRESS_SIZE:STRING=64 -DUSESYSTEMLIBS:BOOL=ON -DUSE_OPENAL:BOOL=ON -DUSE_FMODSTUDIO:BOOL=OFF -DENABLE_MEDIA_PLUGINS:BOOL=ON -DLL_TESTS:BOOL=OFF -DNDOF:BOOL=ON -DROOT_PROJECT_NAME:STRING=Megapahit -DVIEWER_CHANNEL:STRING=Megapahit -DVIEWER_BINARY_NAME:STRING=megapahit -DBUILD_SHARED_LIBS:BOOL=OFF -DINSTALL:BOOL=ON -DPACKAGE:BOOL=OFF -DCMAKE_INSTALL_PREFIX:PATH=newview/Megapahit.app/Contents/Resources -DCMAKE_OSX_ARCHITECTURES:STRING=`uname -m` -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=11 -DENABLE_SIGNING:BOOL=ON -DSIGNING_IDENTITY:STRING=- ../indra +$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DADDRESS_SIZE:STRING=64 -DUSE_OPENAL:BOOL=ON -DUSE_FMODSTUDIO:BOOL=OFF -DENABLE_MEDIA_PLUGINS:BOOL=ON -DLL_TESTS:BOOL=OFF -DNDOF:BOOL=ON -DROOT_PROJECT_NAME:STRING=Megapahit -DVIEWER_CHANNEL:STRING=Megapahit -DVIEWER_BINARY_NAME:STRING=megapahit -DBUILD_SHARED_LIBS:BOOL=OFF -DINSTALL:BOOL=ON -DPACKAGE:BOOL=OFF -DCMAKE_INSTALL_PREFIX:PATH=newview/Megapahit.app/Contents/Resources -DCMAKE_OSX_ARCHITECTURES:STRING=`uname -m` -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=11 -DENABLE_SIGNING:BOOL=ON -DSIGNING_IDENTITY:STRING=- ../indra $ make -j`sysctl -n hw.ncpu` $ make install $ open newview/Megapahit.app @@ -92,7 +92,7 @@ $ open newview/Megapahit.app ``` $ sudo zypper install gcc-c++ patchelf apr-util-devel boost-devel libboost_program_options-devel libboost_url1_87_0-devel libboost_context-devel libboost_fiber-devel libboost_filesystem-devel libboost_regex-devel libboost_system-devel libboost_thread-devel libexpat-devel fltk-devel glu-devel hunspell-devel minizip-devel nanosvg-devel libnghttp2-devel pipewire-devel libpulse-devel libSDL2_gfx-1_0-0 libSDL2_gfx-devel sdl2-compat-devel vlc-devel libvorbis-devel xxhash-devel zlib-ng-devel libXrender-devel libXcursor-devel libXfixes-devel libXext-devel libXft-devel libXinerama-devel freetype2-devel fontconfig-devel libjpeg8-devel libjpeg8-devel freealut-devel $ export LL_BUILD="-O3 -std=c++20 -fPIC -DLL_LINUX=1" -$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DADDRESS_SIZE:STRING=64 -DUSESYSTEMLIBS:BOOL=ON -DUSE_OPENAL:BOOL=ON -DENABLE_MEDIA_PLUGINS:BOOL=ON -DLL_TESTS:BOOL=OFF -DNDOF:BOOL=ON -DROOT_PROJECT_NAME:STRING=Megapahit -DVIEWER_CHANNEL:STRING=Megapahit -DVIEWER_BINARY_NAME:STRING=megapahit -DBUILD_SHARED_LIBS:BOOL=OFF -DINSTALL:BOOL=ON -DPACKAGE:BOOL=ON ../indra +$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DADDRESS_SIZE:STRING=64 -DUSE_OPENAL:BOOL=ON -DENABLE_MEDIA_PLUGINS:BOOL=ON -DLL_TESTS:BOOL=OFF -DNDOF:BOOL=ON -DROOT_PROJECT_NAME:STRING=Megapahit -DVIEWER_CHANNEL:STRING=Megapahit -DVIEWER_BINARY_NAME:STRING=megapahit -DBUILD_SHARED_LIBS:BOOL=OFF -DINSTALL:BOOL=ON -DPACKAGE:BOOL=ON ../indra $ make -j`nproc` $ cpack -G RPM $ rpm --addsign megapahit-`cat newview/viewer_version.txt`-Linux.rpm (Set up pgp public key first) @@ -105,7 +105,7 @@ $ megapahit ``` $ sudo apt install cmake pkg-config libxml2-utils libaprutil1-dev libboost-fiber-dev libboost-json-dev libboost-program-options-dev libboost-regex-dev libboost-url-dev libexpat1-dev libfltk1.3-dev libfontconfig-dev libfreetype-dev libglu1-mesa-dev libhunspell-dev libjpeg-dev libmeshoptimizer-dev libminizip-dev libnanosvg-dev libnghttp2-dev libpipewire-0.3-dev libpng-dev libsdl2-dev libvlc-dev libvlccore-dev libvorbis-dev libxft-dev libxml2-dev libxxhash-dev $ export LL_BUILD="-O3 -std=c++20 -fPIC -DLL_LINUX=1" -$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DADDRESS_SIZE:STRING=64 -DUSESYSTEMLIBS:BOOL=ON -DUSE_OPENAL:BOOL=OFF -DUSE_FMODSTUDIO:BOOL=ON -DENABLE_MEDIA_PLUGINS:BOOL=ON -DLL_TESTS:BOOL=OFF -DNDOF:BOOL=ON -DROOT_PROJECT_NAME:STRING=Megapahit -DVIEWER_CHANNEL:STRING=Megapahit -DVIEWER_BINARY_NAME:STRING=megapahit -DBUILD_SHARED_LIBS:BOOL=OFF -DINSTALL:BOOL=ON -DPACKAGE:BOOL=ON ../indra +$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DADDRESS_SIZE:STRING=64 -DUSE_OPENAL:BOOL=OFF -DUSE_FMODSTUDIO:BOOL=ON -DENABLE_MEDIA_PLUGINS:BOOL=ON -DLL_TESTS:BOOL=OFF -DNDOF:BOOL=ON -DROOT_PROJECT_NAME:STRING=Megapahit -DVIEWER_CHANNEL:STRING=Megapahit -DVIEWER_BINARY_NAME:STRING=megapahit -DBUILD_SHARED_LIBS:BOOL=OFF -DINSTALL:BOOL=ON -DPACKAGE:BOOL=ON ../indra $ make -j`nproc` $ cpack -G DEB $ sudo apt install ./megapahit-`cat newview/viewer_version.txt`-Linux.deb @@ -116,7 +116,7 @@ $ megapahit ``` $ pacman -S mingw-w64-clang-aarch64-cmake mingw-w64-clang-aarch64-pkgconf mingw-w64-clang-aarch64-freealut mingw-w64-clang-aarch64-apr-util mingw-w64-clang-aarch64-boost mingw-w64-clang-aarch64-fltk mingw-w64-clang-aarch64-glm mingw-w64-clang-aarch64-hunspell mingw-w64-clang-aarch64-minizip mingw-w64-clang-aarch64-nghttp2 mingw-w64-clang-aarch64-SDL2 mingw-w64-clang-aarch64-vlc mingw-w64-clang-aarch64-libvorbis mingw-w64-clang-aarch64-xxhash $ export LL_BUILD="-O3 -std=c++20 -fPIC -DLL_WINDOWS=1" -$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DADDRESS_SIZE:STRING=64 -DUSESYSTEMLIBS:BOOL=ON -DUSE_OPENAL:BOOL=ON -DUSE_FMODSTUDIO:BOOL=OFF -DENABLE_MEDIA_PLUGINS:BOOL=OFF -DLL_TESTS:BOOL=OFF -DNDOF:BOOL=OFF -DROOT_PROJECT_NAME:STRING=Megapahit -DVIEWER_CHANNEL:STRING=Megapahit -DVIEWER_BINARY_NAME:STRING=megapahit -DBUILD_SHARED_LIBS:BOOL=OFF -DINSTALL:BOOL=OFF -DPACKAGE:BOOL=OFF ../indra +$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DADDRESS_SIZE:STRING=64 -DUSE_OPENAL:BOOL=ON -DUSE_FMODSTUDIO:BOOL=OFF -DENABLE_MEDIA_PLUGINS:BOOL=OFF -DLL_TESTS:BOOL=OFF -DNDOF:BOOL=OFF -DROOT_PROJECT_NAME:STRING=Megapahit -DVIEWER_CHANNEL:STRING=Megapahit -DVIEWER_BINARY_NAME:STRING=megapahit -DBUILD_SHARED_LIBS:BOOL=OFF -DINSTALL:BOOL=OFF -DPACKAGE:BOOL=OFF ../indra ``` ## Contribute diff --git a/indra/CMakeLists.txt b/indra/CMakeLists.txt index 5bf08f63aa..74bb5c9355 100644 --- a/indra/CMakeLists.txt +++ b/indra/CMakeLists.txt @@ -24,10 +24,6 @@ if( USE_CONAN ) set( USE_AUTOBUILD_3P OFF ) conan_basic_setup(TARGETS NO_OUTPUT_DIRS) add_compile_definitions(LL_USESYSTEMLIBS USE_CONAN NO_AUTOBUILD_3P) -elseif( USESYSTEMLIBS ) - set( USE_CONAN OFF ) - set( USE_AUTOBUILD_3P OFF ) - add_compile_definitions(LL_USESYSTEMLIBS) else() set( USE_CONAN OFF ) set( USE_AUTOBUILD_3P ON ) diff --git a/indra/cmake/APR.cmake b/indra/cmake/APR.cmake index 78c536e9d4..cf31027c9a 100644 --- a/indra/cmake/APR.cmake +++ b/indra/cmake/APR.cmake @@ -5,14 +5,12 @@ include_guard() add_library( ll::apr INTERFACE IMPORTED ) -if (USESYSTEMLIBS) - include(FindPkgConfig) - pkg_check_modules(Apr REQUIRED apr-1 apr-util-1) - target_include_directories(ll::apr SYSTEM INTERFACE ${Apr_INCLUDE_DIRS}) - target_link_directories(ll::apr INTERFACE ${Apr_LIBRARY_DIRS}) - target_link_libraries(ll::apr INTERFACE ${Apr_LIBRARIES}) - return () -endif () +include(FindPkgConfig) +pkg_check_modules(Apr REQUIRED apr-1 apr-util-1) +target_include_directories(ll::apr SYSTEM INTERFACE ${Apr_INCLUDE_DIRS}) +target_link_directories(ll::apr INTERFACE ${Apr_LIBRARY_DIRS}) +target_link_libraries(ll::apr INTERFACE ${Apr_LIBRARIES}) +return () use_system_binary( apr apr-util ) use_prebuilt_binary(apr_suite) diff --git a/indra/cmake/Audio.cmake b/indra/cmake/Audio.cmake index 514d283e76..c569fba4e8 100644 --- a/indra/cmake/Audio.cmake +++ b/indra/cmake/Audio.cmake @@ -5,14 +5,12 @@ include(Prebuilt) include_guard() add_library( ll::vorbis INTERFACE IMPORTED ) -if (USESYSTEMLIBS) - include(FindPkgConfig) - pkg_check_modules(Vorbis REQUIRED ogg vorbis vorbisenc vorbisfile) - target_include_directories(ll::vorbis SYSTEM INTERFACE ${Vorbis_INCLUDE_DIRS}) - target_link_directories(ll::vorbis INTERFACE ${Vorbis_LIBRARY_DIRS}) - target_link_libraries(ll::vorbis INTERFACE ${Vorbis_LIBRARIES}) - return () -endif () +include(FindPkgConfig) +pkg_check_modules(Vorbis REQUIRED ogg vorbis vorbisenc vorbisfile) +target_include_directories(ll::vorbis SYSTEM INTERFACE ${Vorbis_INCLUDE_DIRS}) +target_link_directories(ll::vorbis INTERFACE ${Vorbis_LIBRARY_DIRS}) +target_link_libraries(ll::vorbis INTERFACE ${Vorbis_LIBRARIES}) +return () use_system_binary(vorbis) use_prebuilt_binary(ogg_vorbis) diff --git a/indra/cmake/Boost.cmake b/indra/cmake/Boost.cmake index c9688d0fe0..ba2eaccf63 100644 --- a/indra/cmake/Boost.cmake +++ b/indra/cmake/Boost.cmake @@ -4,34 +4,35 @@ include(Prebuilt) include_guard() add_library( ll::boost INTERFACE IMPORTED ) + +if (DARWIN) + set(sfx -mt) + target_include_directories( ll::boost SYSTEM INTERFACE /opt/local/libexec/boost/1.87/include) + target_link_directories( ll::boost INTERFACE /opt/local/libexec/boost/1.87/lib) +elseif (WINDOWS) + set(sfx -mt) + target_include_directories( ll::boost SYSTEM INTERFACE /opt/local/x86_64-w64-mingw32/include) + target_link_directories( ll::boost INTERFACE /opt/local/x86_64-w64-mingw32/lib) +else () + find_package( Boost REQUIRED ) +endif () +target_link_libraries( ll::boost INTERFACE + boost_context${sfx} + boost_fiber${sfx} + boost_filesystem${sfx} + boost_program_options${sfx} + boost_regex${sfx} + boost_system${sfx} + boost_thread${sfx} + boost_url${sfx} + ) +target_compile_definitions( ll::boost INTERFACE BOOST_BIND_GLOBAL_PLACEHOLDERS ) +return() + if( USE_CONAN ) target_link_libraries( ll::boost INTERFACE CONAN_PKG::boost ) target_compile_definitions( ll::boost INTERFACE BOOST_ALLOW_DEPRECATED_HEADERS BOOST_BIND_GLOBAL_PLACEHOLDERS ) return() -elseif( NOT USE_AUTOBUILD_3P ) - if (WINDOWS) - set(sfx -mt) - target_include_directories( ll::boost SYSTEM INTERFACE /opt/local/x86_64-w64-mingw32/include) - target_link_directories( ll::boost INTERFACE /opt/local/x86_64-w64-mingw32/lib) - elseif (DARWIN) - set(sfx -mt) - target_include_directories( ll::boost SYSTEM INTERFACE /opt/local/libexec/boost/1.87/include) - target_link_directories( ll::boost INTERFACE /opt/local/libexec/boost/1.87/lib) - else (WINDOWS) - find_package( Boost REQUIRED ) - endif (WINDOWS) - target_link_libraries( ll::boost INTERFACE - boost_context${sfx} - boost_fiber${sfx} - boost_filesystem${sfx} - boost_program_options${sfx} - boost_regex${sfx} - boost_system${sfx} - boost_thread${sfx} - boost_url${sfx} - ) - target_compile_definitions( ll::boost INTERFACE BOOST_BIND_GLOBAL_PLACEHOLDERS ) - return() endif() use_prebuilt_binary(boost) diff --git a/indra/cmake/CMakeLists.txt b/indra/cmake/CMakeLists.txt index 5525ac9f24..746d242560 100644 --- a/indra/cmake/CMakeLists.txt +++ b/indra/cmake/CMakeLists.txt @@ -24,7 +24,6 @@ set(cmake_SOURCE_FILES FindAutobuild.cmake FMODSTUDIO.cmake FreeType.cmake - GLEXT.cmake GLH.cmake GLM.cmake Havok.cmake diff --git a/indra/cmake/CURL.cmake b/indra/cmake/CURL.cmake index 9e9bbce47b..5868d41849 100644 --- a/indra/cmake/CURL.cmake +++ b/indra/cmake/CURL.cmake @@ -5,10 +5,8 @@ include(Linking) include_guard() add_library( ll::libcurl INTERFACE IMPORTED ) -if (NOT USESYSTEMLIBS) -use_system_binary(libcurl) -endif (NOT USESYSTEMLIBS) -if (LINUX AND CMAKE_SYSTEM_PROCESSOR MATCHES x86_64 OR DARWIN OR NOT USESYSTEMLIBS) +#use_system_binary(libcurl) +if (LINUX AND CMAKE_SYSTEM_PROCESSOR MATCHES x86_64 OR DARWIN) use_prebuilt_binary(curl) if (DARWIN) execute_process( @@ -86,8 +84,8 @@ elseif (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRA ${ARCH_PREBUILT_DIRS}/libssl.a ) file(WRITE ${PREBUILD_TRACKING_DIR}/curl_installed "${curl_installed}") -endif (LINUX AND CMAKE_SYSTEM_PROCESSOR MATCHES x86_64 OR DARWIN OR NOT USESYSTEMLIBS) -if (WINDOWS AND NOT USESYSTEMLIBS) +endif () +if (WINDOWS) target_link_libraries(ll::libcurl INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libcurl.lib ll::openssl diff --git a/indra/cmake/FMODSTUDIO.cmake b/indra/cmake/FMODSTUDIO.cmake index 35ce932c1a..4ed9f94caf 100644 --- a/indra/cmake/FMODSTUDIO.cmake +++ b/indra/cmake/FMODSTUDIO.cmake @@ -30,7 +30,7 @@ if (USE_FMODSTUDIO) # Note: if you're not using INSTALL_PROPRIETARY, the package URL should be local (file:/// URL) # as accessing the private LL location will fail if you don't have the credential include(Prebuilt) - if (USESYSTEMLIBS AND (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/fmodstudio_installed OR NOT ${fmodstudio_installed} EQUAL 0)) + if (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/fmodstudio_installed OR NOT ${fmodstudio_installed} EQUAL 0) file(MAKE_DIRECTORY ${ARCH_PREBUILT_DIRS_RELEASE}) if (DARWIN) execute_process( @@ -100,9 +100,9 @@ if (USE_FMODSTUDIO) endif (CMAKE_SYSTEM_PROCESSOR MATCHES aarch64) file(WRITE ${PREBUILD_TRACKING_DIR}/fmodstudio_installed "0") endif (DARWIN) - else (USESYSTEMLIBS AND (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/fmodstudio_installed OR NOT ${fmodstudio_installed} EQUAL 0)) - use_prebuilt_binary(fmodstudio) - endif (USESYSTEMLIBS AND (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/fmodstudio_installed OR NOT ${fmodstudio_installed} EQUAL 0)) + endif () + + #use_prebuilt_binary(fmodstudio) if (WINDOWS) target_link_libraries( ll::fmodstudio INTERFACE fmod_vc) elseif (DARWIN) diff --git a/indra/cmake/FreeType.cmake b/indra/cmake/FreeType.cmake index 7683fe364a..d5c7891032 100644 --- a/indra/cmake/FreeType.cmake +++ b/indra/cmake/FreeType.cmake @@ -5,14 +5,13 @@ include(Linking) include_guard() add_library( ll::freetype INTERFACE IMPORTED ) -if (USESYSTEMLIBS) - include(FindPkgConfig) - pkg_check_modules(Freetype REQUIRED freetype2) - target_include_directories( ll::freetype SYSTEM INTERFACE ${Freetype_INCLUDE_DIRS} ) - target_link_directories( ll::freetype INTERFACE ${Freetype_LIBRARY_DIRS} ) - target_link_libraries( ll::freetype INTERFACE ${Freetype_LIBRARIES} ) - return () -endif (USESYSTEMLIBS) +include(FindPkgConfig) +pkg_check_modules(Freetype REQUIRED freetype2) +target_include_directories( ll::freetype SYSTEM INTERFACE ${Freetype_INCLUDE_DIRS} ) +target_link_directories( ll::freetype INTERFACE ${Freetype_LIBRARY_DIRS} ) +target_link_libraries( ll::freetype INTERFACE ${Freetype_LIBRARIES} ) +return () + use_system_binary(freetype) use_prebuilt_binary(freetype) target_include_directories( ll::freetype SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/freetype2/) diff --git a/indra/cmake/GLEXT.cmake b/indra/cmake/GLEXT.cmake index ea349237d3..a780966f0c 100644 --- a/indra/cmake/GLEXT.cmake +++ b/indra/cmake/GLEXT.cmake @@ -3,10 +3,7 @@ include(Prebuilt) include(GLH) add_library( ll::glext INTERFACE IMPORTED ) - -if (USESYSTEMLIBS) - return () -endif () - use_system_binary(glext) use_prebuilt_binary(glext) + + diff --git a/indra/cmake/GLH.cmake b/indra/cmake/GLH.cmake index 648a08454b..ac86f385c6 100644 --- a/indra/cmake/GLH.cmake +++ b/indra/cmake/GLH.cmake @@ -4,7 +4,5 @@ include(Prebuilt) add_library( ll::glh_linear INTERFACE IMPORTED ) target_include_directories( ll::glh_linear SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include) -if (NOT USESYSTEMLIBS) -use_system_binary( glh_linear ) -endif (NOT USESYSTEMLIBS) +#use_system_binary( glh_linear ) use_prebuilt_binary(glh_linear) diff --git a/indra/cmake/GLM.cmake b/indra/cmake/GLM.cmake index d411c049ec..fcf5e77cae 100644 --- a/indra/cmake/GLM.cmake +++ b/indra/cmake/GLM.cmake @@ -3,12 +3,9 @@ include(Prebuilt) add_library( ll::glm INTERFACE IMPORTED ) -if (NOT USESYSTEMLIBS) -use_system_binary( glm ) -elseif (NOT (${LINUX_DISTRO} MATCHES debian OR (${LINUX_DISTRO} MATCHES ubuntu) OR (${LINUX_DISTRO} MATCHES opensuse-tumbleweed))) - find_package( glm REQUIRED ) -endif (NOT USESYSTEMLIBS) - -if (${LINUX_DISTRO} MATCHES debian OR (${LINUX_DISTRO} MATCHES ubuntu) OR (${LINUX_DISTRO} MATCHES opensuse-tumbleweed) OR NOT USESYSTEMLIBS) +#use_system_binary( glm ) +if (${LINUX_DISTRO} MATCHES debian OR (${LINUX_DISTRO} MATCHES ubuntu) OR (${LINUX_DISTRO} MATCHES opensuse-tumbleweed)) use_prebuilt_binary(glm) +else () + find_package( glm REQUIRED ) endif () diff --git a/indra/cmake/LLPrimitive.cmake b/indra/cmake/LLPrimitive.cmake index 335c2a9258..21952713ca 100644 --- a/indra/cmake/LLPrimitive.cmake +++ b/indra/cmake/LLPrimitive.cmake @@ -18,81 +18,81 @@ if( USE_CONAN ) "${CONAN_INCLUDE_DIRS_COLLADADOM}/collada-dom/1.4/" ) endif() -if( USESYSTEMLIBS ) - if( WINDOWS ) - include(FindPkgConfig) - pkg_check_modules(Colladadom REQUIRED collada-dom-141) - target_compile_definitions( ll::colladadom INTERFACE COLLADA_DOM_SUPPORT141 ) - target_include_directories( ll::colladadom SYSTEM INTERFACE ${Colladadom_INCLUDE_DIRS} ) - target_link_directories( ll::colladadom INTERFACE ${Colladadom_LIBRARY_DIRS} ) - target_link_libraries( ll::colladadom INTERFACE ${Colladadom_LIBRARIES} ) - return () - elseif( LINUX OR CMAKE_SYSTEM_NAME MATCHES FreeBSD ) - # Build of the collada-dom for Linux and FreeBSD is done in - # indra/llprimitive/CMakeLists.txt - return () - else( WINDOWS ) - include(FindPkgConfig) - pkg_check_modules(Minizip REQUIRED minizip) - pkg_check_modules(Libxml2 REQUIRED libxml-2.0) - target_link_libraries( ll::minizip-ng INTERFACE ${Minizip_LIBRARIES} ) - target_link_libraries( ll::libxml INTERFACE ${Libxml2_LIBRARIES} ) - if( ${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/colladadom_installed OR NOT ${colladadom_installed} EQUAL 0 ) - if( NOT EXISTS ${CMAKE_BINARY_DIR}/3p-colladadom-2.3-r8.tar.gz ) - file(DOWNLOAD - https://github.com/secondlife/3p-colladadom/archive/refs/tags/v2.3-r8.tar.gz - ${CMAKE_BINARY_DIR}/3p-colladadom-2.3-r8.tar.gz - ) - endif( NOT EXISTS ${CMAKE_BINARY_DIR}/3p-colladadom-2.3-r8.tar.gz ) - file(ARCHIVE_EXTRACT - INPUT ${CMAKE_BINARY_DIR}/3p-colladadom-2.3-r8.tar.gz - DESTINATION ${CMAKE_BINARY_DIR} +if( WINDOWS ) + include(FindPkgConfig) + pkg_check_modules(Colladadom REQUIRED collada-dom-141) + target_compile_definitions( ll::colladadom INTERFACE COLLADA_DOM_SUPPORT141 ) + target_include_directories( ll::colladadom SYSTEM INTERFACE ${Colladadom_INCLUDE_DIRS} ) + target_link_directories( ll::colladadom INTERFACE ${Colladadom_LIBRARY_DIRS} ) + target_link_libraries( ll::colladadom INTERFACE ${Colladadom_LIBRARIES} ) + return() +elseif( LINUX OR CMAKE_SYSTEM_NAME MATCHES FreeBSD ) + # Build of the collada-dom for Linux and FreeBSD is done in + # indra/llprimitive/CMakeLists.txt + return() +else() + include(FindPkgConfig) + pkg_check_modules(Minizip REQUIRED minizip) + pkg_check_modules(Libxml2 REQUIRED libxml-2.0) + target_link_libraries( ll::minizip-ng INTERFACE ${Minizip_LIBRARIES} ) + target_link_libraries( ll::libxml INTERFACE ${Libxml2_LIBRARIES} ) + if( ${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/colladadom_installed OR NOT ${colladadom_installed} EQUAL 0 ) + if( NOT EXISTS ${CMAKE_BINARY_DIR}/3p-colladadom-2.3-r8.tar.gz ) + file(DOWNLOAD + https://github.com/secondlife/3p-colladadom/archive/refs/tags/v2.3-r8.tar.gz + ${CMAKE_BINARY_DIR}/3p-colladadom-2.3-r8.tar.gz ) + endif() + file(ARCHIVE_EXTRACT + INPUT ${CMAKE_BINARY_DIR}/3p-colladadom-2.3-r8.tar.gz + DESTINATION ${CMAKE_BINARY_DIR} + ) + execute_process( + COMMAND sed -i "" -e "s/SHARED/STATIC/g" CMakeLists.txt + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3p-colladadom-2.3-r8/src/1.4 + ) + if( DARWIN ) + set(BOOST_CFLAGS -I${Libxml2_LIBRARY_DIRS}exec/boost/1.87/include) + set(BOOST_LIBS -L${Minizip_LIBRARY_DIRS}exec/boost/1.87/lib) + set(BOOST_LIBRARY_SUFFIX -mt) + endif() + try_compile(COLLADADOM_RESULT + PROJECT colladadom + SOURCE_DIR ${CMAKE_BINARY_DIR}/3p-colladadom-2.3-r8 + BINARY_DIR ${CMAKE_BINARY_DIR}/3p-colladadom-2.3-r8 + TARGET collada14dom + CMAKE_FLAGS + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} + -DCMAKE_INSTALL_PREFIX:PATH=${LIBS_PREBUILT_DIR} + -DCMAKE_CXX_STANDARD:STRING=17 + -DCMAKE_CXX_FLAGS:STRING=-I${Minizip_INCLUDE_DIRS} + -DBoost_CFLAGS:STRING=${BOOST_CFLAGS} + -DEXTRA_COMPILE_FLAGS:STRING=-I${Libxml2_INCLUDE_DIRS} + "-DCMAKE_SHARED_LINKER_FLAGS:STRING=-L${Minizip_LIBRARY_DIRS} ${BOOST_LIBS}" + -DBoost_FILESYSTEM_LIBRARY:STRING=boost_filesystem${BOOST_LIBRARY_SUFFIX} + -DBoost_SYSTEM_LIBRARY:STRING=boost_system${BOOST_LIBRARY_SUFFIX} + -DZLIB_LIBRARIES:STRING=${Libxml2_LIBRARIES} + -DOPT_COLLADA14:BOOL=ON + -DCOLLADA_DOM_INCLUDE_INSTALL_DIR:PATH=${LIBS_PREBUILT_DIR}/include/collada + ) + if( ${COLLADADOM_RESULT} ) execute_process( - COMMAND sed -i "" -e "s/SHARED/STATIC/g" CMakeLists.txt - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3p-colladadom-2.3-r8/src/1.4 + COMMAND ${CMAKE_MAKE_PROGRAM} install + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3p-colladadom-2.3-r8 + OUTPUT_VARIABLE colladadom_installed ) - if( DARWIN ) - set(BOOST_CFLAGS -I${Libxml2_LIBRARY_DIRS}exec/boost/1.87/include) - set(BOOST_LIBS -L${Minizip_LIBRARY_DIRS}exec/boost/1.87/lib) - set(BOOST_LIBRARY_SUFFIX -mt) - endif() - try_compile(COLLADADOM_RESULT - PROJECT colladadom - SOURCE_DIR ${CMAKE_BINARY_DIR}/3p-colladadom-2.3-r8 - BINARY_DIR ${CMAKE_BINARY_DIR}/3p-colladadom-2.3-r8 - TARGET collada14dom - CMAKE_FLAGS - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES} - -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} - -DCMAKE_INSTALL_PREFIX:PATH=${LIBS_PREBUILT_DIR} - -DCMAKE_CXX_STANDARD:STRING=17 - -DCMAKE_CXX_FLAGS:STRING=-I${Minizip_INCLUDE_DIRS} - -DBoost_CFLAGS:STRING=${BOOST_CFLAGS} - -DEXTRA_COMPILE_FLAGS:STRING=-I${Libxml2_INCLUDE_DIRS} - "-DCMAKE_SHARED_LINKER_FLAGS:STRING=-L${Minizip_LIBRARY_DIRS} ${BOOST_LIBS}" - -DBoost_FILESYSTEM_LIBRARY:STRING=boost_filesystem${BOOST_LIBRARY_SUFFIX} - -DBoost_SYSTEM_LIBRARY:STRING=boost_system${BOOST_LIBRARY_SUFFIX} - -DZLIB_LIBRARIES:STRING=${Libxml2_LIBRARIES} - -DOPT_COLLADA14:BOOL=ON - -DCOLLADA_DOM_INCLUDE_INSTALL_DIR:PATH=${LIBS_PREBUILT_DIR}/include/collada + file(RENAME + ${ARCH_PREBUILT_DIRS}/libcollada14dom.a + ${ARCH_PREBUILT_DIRS_RELEASE}/libcollada14dom.a ) - if( ${COLLADADOM_RESULT} ) - execute_process( - COMMAND ${CMAKE_MAKE_PROGRAM} install - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3p-colladadom-2.3-r8 - OUTPUT_VARIABLE colladadom_installed - ) - file(RENAME - ${ARCH_PREBUILT_DIRS}/libcollada14dom.a - ${ARCH_PREBUILT_DIRS_RELEASE}/libcollada14dom.a - ) - file(WRITE ${PREBUILD_TRACKING_DIR}/colladadom_installed "${colladadom_installed}") - endif( ${COLLADADOM_RESULT} ) - endif( ${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/colladadom_installed OR NOT ${colladadom_installed} EQUAL 0 ) - endif( WINDOWS ) -else( USESYSTEMLIBS ) + file(WRITE ${PREBUILD_TRACKING_DIR}/colladadom_installed "${colladadom_installed}") + endif() + endif() +endif() + +if( FALSE ) use_system_binary( colladadom ) use_prebuilt_binary(colladadom) @@ -110,7 +110,7 @@ if (WINDOWS) else() target_link_libraries( ll::libxml INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libxml2.a) endif() -endif( USESYSTEMLIBS ) +endif( FALSE ) target_include_directories( ll::colladadom SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/collada diff --git a/indra/cmake/LLWindow.cmake b/indra/cmake/LLWindow.cmake index 31907d31df..00bf0b8ef7 100644 --- a/indra/cmake/LLWindow.cmake +++ b/indra/cmake/LLWindow.cmake @@ -1,13 +1,13 @@ # -*- cmake -*- include(Variables) -include(GLEXT) +include(GLH) include(Prebuilt) include_guard() add_library( ll::SDL INTERFACE IMPORTED ) -if (USESYSTEMLIBS AND NOT (WINDOWS OR DARWIN)) +if (NOT (WINDOWS OR DARWIN)) include(FindPkgConfig) pkg_check_modules(Sdl2 REQUIRED sdl2) target_compile_definitions( ll::SDL INTERFACE LL_SDL=1) diff --git a/indra/cmake/LibVLCPlugin.cmake b/indra/cmake/LibVLCPlugin.cmake index 779576a485..5ed77af0c2 100644 --- a/indra/cmake/LibVLCPlugin.cmake +++ b/indra/cmake/LibVLCPlugin.cmake @@ -5,56 +5,41 @@ include(Prebuilt) include_guard() add_library( ll::libvlc INTERFACE IMPORTED ) -if (USESYSTEMLIBS) - if (DARWIN) - if (CMAKE_OSX_ARCHITECTURES MATCHES arm64) - if (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/vlc_installed OR NOT ${vlc_installed} EQUAL 0) - if (NOT EXISTS ${CMAKE_BINARY_DIR}/vlc-3.0.21-arm64.dmg) - file(DOWNLOAD - https://get.videolan.org/vlc/3.0.21/macosx/vlc-3.0.21-arm64.dmg - ${CMAKE_BINARY_DIR}/vlc-3.0.21-arm64.dmg - ) - endif (NOT EXISTS ${CMAKE_BINARY_DIR}/vlc-3.0.21-arm64.dmg) - file(WRITE ${PREBUILD_TRACKING_DIR}/vlc_installed "0") - endif (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/vlc_installed OR NOT ${vlc_installed} EQUAL 0) - execute_process( - COMMAND hdiutil attach -noverify vlc-3.0.21-arm64.dmg - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} +if (DARWIN) + if (CMAKE_OSX_ARCHITECTURES MATCHES x86_64) + set(ARCHITECTURE intel64) + else () + set(ARCHITECTURE ${CMAKE_OSX_ARCHITECTURES}) + endif () + if (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/vlc_installed OR NOT ${vlc_installed} EQUAL 0) + if (NOT EXISTS ${CMAKE_BINARY_DIR}/vlc-3.0.21-${ARCHITECTURE}.dmg) + file(DOWNLOAD + https://get.videolan.org/vlc/3.0.21/macosx/vlc-3.0.21-${ARCHITECTURE}.dmg + ${CMAKE_BINARY_DIR}/vlc-3.0.21-${ARCHITECTURE}.dmg ) - else (CMAKE_OSX_ARCHITECTURES MATCHES arm64) - if (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/vlc_installed OR NOT ${vlc_installed} EQUAL 0) - if (NOT EXISTS ${CMAKE_BINARY_DIR}/vlc-3.0.21-intel64.dmg) - file(DOWNLOAD - https://get.videolan.org/vlc/3.0.21/macosx/vlc-3.0.21-intel64.dmg - ${CMAKE_BINARY_DIR}/vlc-3.0.21-intel64.dmg - ) - endif (NOT EXISTS ${CMAKE_BINARY_DIR}/vlc-3.0.21-intel64.dmg) - file(WRITE ${PREBUILD_TRACKING_DIR}/vlc_installed "0") - endif (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/vlc_installed OR NOT ${vlc_installed} EQUAL 0) - execute_process( - COMMAND hdiutil attach -noverify vlc-3.0.21-intel64.dmg - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - endif (CMAKE_OSX_ARCHITECTURES MATCHES arm64) - target_include_directories( ll::libvlc SYSTEM INTERFACE /Volumes/VLC\ media\ player/VLC.app/Contents/MacOS/include) - target_link_directories( ll::libvlc INTERFACE /Volumes/VLC\ media\ player/VLC.app/Contents/MacOS/lib) - target_link_libraries( ll::libvlc INTERFACE vlc vlccore ) - else (DARWIN) - include(FindPkgConfig) - pkg_check_modules(Libvlc REQUIRED libvlc vlc-plugin) - target_include_directories( ll::libvlc SYSTEM INTERFACE ${Libvlc_INCLUDE_DIRS} ) - target_link_directories( ll::libvlc INTERFACE ${Libvlc_LIBRARY_DIRS} ) - target_link_libraries( ll::libvlc INTERFACE ${Libvlc_LIBRARIES} ) - endif (DARWIN) - set(LIBVLCPLUGIN ON CACHE BOOL - "LIBVLCPLUGIN support for the llplugin/llmedia test apps.") - return() -else (USESYSTEMLIBS) + endif () + file(WRITE ${PREBUILD_TRACKING_DIR}/vlc_installed "0") + endif () + execute_process( + COMMAND hdiutil attach -noverify vlc-3.0.21-${ARCHITECTURE}.dmg + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + target_include_directories( ll::libvlc SYSTEM INTERFACE /Volumes/VLC\ media\ player/VLC.app/Contents/MacOS/include) + target_link_directories( ll::libvlc INTERFACE /Volumes/VLC\ media\ player/VLC.app/Contents/MacOS/lib) + target_link_libraries( ll::libvlc INTERFACE vlc vlccore ) +else () + include(FindPkgConfig) + pkg_check_modules(Libvlc REQUIRED libvlc vlc-plugin) + target_include_directories( ll::libvlc SYSTEM INTERFACE ${Libvlc_INCLUDE_DIRS} ) + target_link_directories( ll::libvlc INTERFACE ${Libvlc_LIBRARY_DIRS} ) + target_link_libraries( ll::libvlc INTERFACE ${Libvlc_LIBRARIES} ) +endif () -use_prebuilt_binary(vlc-bin) +#use_prebuilt_binary(vlc-bin) set(LIBVLCPLUGIN ON CACHE BOOL "LIBVLCPLUGIN support for the llplugin/llmedia test apps.") -endif (USESYSTEMLIBS) + +return() if (WINDOWS) target_link_libraries( ll::libvlc INTERFACE diff --git a/indra/cmake/Meshoptimizer.cmake b/indra/cmake/Meshoptimizer.cmake index d5c6598d94..24be3a256d 100644 --- a/indra/cmake/Meshoptimizer.cmake +++ b/indra/cmake/Meshoptimizer.cmake @@ -6,15 +6,12 @@ include(Prebuilt) include_guard() add_library( ll::meshoptimizer INTERFACE IMPORTED ) -if (NOT USESYSTEMLIBS) -use_system_binary(meshoptimizer) -elseif (${LINUX_DISTRO} MATCHES debian OR (${LINUX_DISTRO} MATCHES ubuntu) OR CMAKE_SYSTEM_NAME MATCHES FreeBSD) +#use_system_binary(meshoptimizer) +if (${LINUX_DISTRO} MATCHES debian OR (${LINUX_DISTRO} MATCHES ubuntu) OR CMAKE_SYSTEM_NAME MATCHES FreeBSD) find_package(meshoptimizer) target_link_libraries( ll::meshoptimizer INTERFACE meshoptimizer) return () -endif (NOT USESYSTEMLIBS) - -if (LINUX AND CMAKE_SYSTEM_PROCESSOR MATCHES x86_64 AND NOT (${LINUX_DISTRO} MATCHES gentoo) OR NOT USESYSTEMLIBS) +elseif (LINUX AND CMAKE_SYSTEM_PROCESSOR MATCHES x86_64 AND NOT (${LINUX_DISTRO} MATCHES gentoo)) use_prebuilt_binary(meshoptimizer) elseif (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/meshoptimizer_installed OR NOT ${meshoptimizer_installed} EQUAL 0) if (NOT EXISTS ${CMAKE_BINARY_DIR}/meshoptimizer-0.21.tar.gz) @@ -48,12 +45,12 @@ elseif (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRA ) file(WRITE ${PREBUILD_TRACKING_DIR}/meshoptimizer_installed "${meshoptimizer_installed}") endif (${MESHOPTIMIZER_RESULT}) -endif (LINUX AND CMAKE_SYSTEM_PROCESSOR MATCHES x86_64 AND NOT (${LINUX_DISTRO} MATCHES gentoo) OR NOT USESYSTEMLIBS) +endif () -if (NOT USESYSTEMLIBS AND WINDOWS) +if (WINDOWS) target_link_libraries( ll::meshoptimizer INTERFACE meshoptimizer.lib) -else (NOT USESYSTEMLIBS AND WINDOWS) +else () target_link_libraries( ll::meshoptimizer INTERFACE libmeshoptimizer.a) -endif (NOT USESYSTEMLIBS AND WINDOWS) +endif (WINDOWS) target_include_directories( ll::meshoptimizer SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/meshoptimizer) diff --git a/indra/cmake/NDOF.cmake b/indra/cmake/NDOF.cmake index 24fb23a0e3..4e93c1f9ca 100644 --- a/indra/cmake/NDOF.cmake +++ b/indra/cmake/NDOF.cmake @@ -8,9 +8,8 @@ add_library( ll::ndof INTERFACE IMPORTED ) if (NDOF) if (WINDOWS OR DARWIN) - if (NOT USESYSTEMLIBS) - use_prebuilt_binary(libndofdev) - elseif (DARWIN AND (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/libndofdev_installed OR NOT ${libndofdev_installed} EQUAL 0)) + #use_prebuilt_binary(libndofdev) + if (DARWIN AND (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/libndofdev_installed OR NOT ${libndofdev_installed} EQUAL 0)) file(DOWNLOAD https://github.com/secondlife/3p-libndofdev/archive/refs/tags/v0.1.8e9edc7.tar.gz ${CMAKE_BINARY_DIR}/3p-libndofdev-0.1.8e9edc7.tar.gz @@ -42,7 +41,7 @@ if (NDOF) ) file(WRITE ${PREBUILD_TRACKING_DIR}/libndofdev_installed "${libndofdev_installed}") endif (${LIBNDOFDEV_RESULT}) - endif (NOT USESYSTEMLIBS) + endif () elseif (LINUX) use_prebuilt_binary(open-libndofdev) endif (WINDOWS OR DARWIN) diff --git a/indra/cmake/OPENAL.cmake b/indra/cmake/OPENAL.cmake index f2eb956e2e..f63e55cdf3 100644 --- a/indra/cmake/OPENAL.cmake +++ b/indra/cmake/OPENAL.cmake @@ -19,15 +19,13 @@ endif() if (USE_OPENAL) add_library( ll::openal INTERFACE IMPORTED ) - if (USESYSTEMLIBS) - target_compile_definitions( ll::openal INTERFACE LL_OPENAL=1) - include(FindPkgConfig) - pkg_check_modules(Openal REQUIRED freealut) - target_include_directories(ll::openal SYSTEM INTERFACE ${Openal_INCLUDE_DIRS}) - target_link_directories(ll::openal INTERFACE ${Openal_LIBRARY_DIRS}) - target_link_libraries(ll::openal INTERFACE ${Openal_LIBRARIES}) - return () - endif () + target_compile_definitions( ll::openal INTERFACE LL_OPENAL=1) + include(FindPkgConfig) + pkg_check_modules(Openal REQUIRED freealut) + target_include_directories(ll::openal SYSTEM INTERFACE ${Openal_INCLUDE_DIRS}) + target_link_directories(ll::openal INTERFACE ${Openal_LIBRARY_DIRS}) + target_link_libraries(ll::openal INTERFACE ${Openal_LIBRARIES}) + return () target_include_directories( ll::openal SYSTEM INTERFACE "${LIBS_PREBUILT_DIR}/include/AL") target_compile_definitions( ll::openal INTERFACE LL_OPENAL=1) diff --git a/indra/cmake/OpenJPEG.cmake b/indra/cmake/OpenJPEG.cmake index cf008faebf..6b65145174 100644 --- a/indra/cmake/OpenJPEG.cmake +++ b/indra/cmake/OpenJPEG.cmake @@ -4,10 +4,8 @@ include(Prebuilt) include_guard() add_library( ll::openjpeg INTERFACE IMPORTED ) -if (NOT USESYSTEMLIBS) -use_system_binary(openjpeg) -endif (NOT USESYSTEMLIBS) -if (LINUX AND CMAKE_SYSTEM_PROCESSOR MATCHES x86_64 OR NOT USESYSTEMLIBS) +#use_system_binary(openjpeg) +if (LINUX AND CMAKE_SYSTEM_PROCESSOR MATCHES x86_64) use_prebuilt_binary(openjpeg) elseif (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/openjpeg_installed OR NOT ${openjpeg_installed} EQUAL 0) if (NOT EXISTS ${CMAKE_BINARY_DIR}/3p-openjpeg-2.5.0.ea12248.tar.gz) @@ -54,7 +52,7 @@ elseif (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRA ) file(WRITE ${PREBUILD_TRACKING_DIR}/openjpeg_installed "${openjpeg_installed}") endif (${OPENJPEG_RESULT}) -endif (LINUX AND CMAKE_SYSTEM_PROCESSOR MATCHES x86_64 OR NOT USESYSTEMLIBS) +endif () target_link_libraries(ll::openjpeg INTERFACE openjp2 ) target_include_directories( ll::openjpeg SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include) diff --git a/indra/cmake/OpenSSL.cmake b/indra/cmake/OpenSSL.cmake index 8b9c737325..ecc9e30ac3 100644 --- a/indra/cmake/OpenSSL.cmake +++ b/indra/cmake/OpenSSL.cmake @@ -5,10 +5,8 @@ include(Linking) include_guard() add_library( ll::openssl INTERFACE IMPORTED ) -if (NOT USESYSTEMLIBS) -use_system_binary(openssl) -endif (NOT USESYSTEMLIBS) -if (LINUX AND CMAKE_SYSTEM_PROCESSOR MATCHES x86_64 OR DARWIN OR NOT USESYSTEMLIBS) +#use_system_binary(openssl) +if (LINUX AND CMAKE_SYSTEM_PROCESSOR MATCHES x86_64 OR DARWIN) use_prebuilt_binary(openssl) if (DARWIN) execute_process( @@ -67,15 +65,15 @@ elseif (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRA RESULT_VARIABLE openssl_installed ) file(WRITE ${PREBUILD_TRACKING_DIR}/openssl_installed "${openssl_installed}") -endif (LINUX AND CMAKE_SYSTEM_PROCESSOR MATCHES x86_64 OR DARWIN OR NOT USESYSTEMLIBS) -if (WINDOWS AND NOT USESYSTEMLIBS) +endif () +if (WINDOWS) target_link_libraries(ll::openssl INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libssl.lib ${ARCH_PREBUILT_DIRS_RELEASE}/libcrypto.lib Crypt32.lib) elseif (LINUX) target_link_libraries(ll::openssl INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libssl.a ${ARCH_PREBUILT_DIRS_RELEASE}/libcrypto.a dl) else() target_link_libraries(ll::openssl INTERFACE ssl crypto) -endif (WINDOWS AND NOT USESYSTEMLIBS) -if (NOT (WINDOWS AND USESYSTEMLIBS)) +endif (WINDOWS) +if (NOT WINDOWS) target_include_directories( ll::openssl SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include) -endif (NOT (WINDOWS AND USESYSTEMLIBS)) +endif () diff --git a/indra/cmake/Prebuilt.cmake b/indra/cmake/Prebuilt.cmake index 751e83051f..2d5eb5d805 100644 --- a/indra/cmake/Prebuilt.cmake +++ b/indra/cmake/Prebuilt.cmake @@ -40,38 +40,37 @@ macro (use_prebuilt_binary _binary) --install-dir=${AUTOBUILD_INSTALL_DIR} ${_binary} ") endif(DEBUG_PREBUILT) - if(USESYSTEMLIBS) + execute_process(COMMAND xmllint + --xpath + "//map/map/map/map/map/map/string[contains(text(),'${_binary}')][contains(text(),'common')]/text()" autobuild.xml + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/.. + OUTPUT_VARIABLE package_url + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if ("${package_url}" STREQUAL "") + string(TOLOWER ${CMAKE_SYSTEM_NAME} system_name) + if (${system_name} MATCHES freebsd) + set(system_name "linux") + endif (${system_name} MATCHES freebsd) execute_process(COMMAND xmllint --xpath - "//map/map/map/map/map/map/string[contains(text(),'${_binary}')][contains(text(),'common')]/text()" autobuild.xml + "//map/map/map/map/map/map/string[contains(text(),'${_binary}')][contains(text(),'${system_name}')]/text()" autobuild.xml WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/.. OUTPUT_VARIABLE package_url OUTPUT_STRIP_TRAILING_WHITESPACE ) - if ("${package_url}" STREQUAL "") - string(TOLOWER ${CMAKE_SYSTEM_NAME} system_name) - if (${system_name} MATCHES freebsd) - set(system_name "linux") - endif (${system_name} MATCHES freebsd) - execute_process(COMMAND xmllint - --xpath - "//map/map/map/map/map/map/string[contains(text(),'${_binary}')][contains(text(),'${system_name}')]/text()" autobuild.xml - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/.. - OUTPUT_VARIABLE package_url - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - endif ("${package_url}" STREQUAL "") - string(REGEX REPLACE "^https?://(megapahit.net/downloads|github.com/secondlife|automated-builds-secondlife-com.s3.amazonaws.com/ct2).*/" "" package_name ${package_url}) - file(DOWNLOAD - ${package_url} - ${CMAKE_BINARY_DIR}/${package_name} - ) - file(ARCHIVE_EXTRACT - INPUT ${CMAKE_BINARY_DIR}/${package_name} - DESTINATION ${AUTOBUILD_INSTALL_DIR} - ) - set(${_binary}_installed 0) - else(USESYSTEMLIBS) + endif ("${package_url}" STREQUAL "") + string(REGEX REPLACE "^https?://(megapahit.net/downloads|github.com/secondlife|automated-builds-secondlife-com.s3.amazonaws.com/ct2).*/" "" package_name ${package_url}) + file(DOWNLOAD + ${package_url} + ${CMAKE_BINARY_DIR}/${package_name} + ) + file(ARCHIVE_EXTRACT + INPUT ${CMAKE_BINARY_DIR}/${package_name} + DESTINATION ${AUTOBUILD_INSTALL_DIR} + ) + set(${_binary}_installed 0) + if(FALSE) execute_process(COMMAND "${AUTOBUILD_EXECUTABLE}" install --install-dir=${AUTOBUILD_INSTALL_DIR} @@ -79,7 +78,7 @@ macro (use_prebuilt_binary _binary) WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" RESULT_VARIABLE ${_binary}_installed ) - endif(USESYSTEMLIBS) + endif() file(WRITE ${PREBUILD_TRACKING_DIR}/${_binary}_installed "${${_binary}_installed}") endif(${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/${_binary}_installed OR NOT ${${_binary}_installed} EQUAL 0) @@ -92,6 +91,22 @@ endmacro (use_prebuilt_binary _binary) #Sadly we need a macro here, otherwise the return() will not properly work macro ( use_system_binary package ) + include(FindPkgConfig) + pkg_check_modules(${package} ${package}) + if( ${package}_FOUND ) + target_link_directories( ll::${package} INTERFACE ${${package}_LIBRARY_DIRS} ) + else() + pkg_check_modules(${package} lib${package}) + if( ${package}_FOUND ) + target_link_directories( ll::${package} INTERFACE ${${package}_LIBRARY_DIRS} ) + else() + find_package( ${package} REQUIRED ) + endif() + endif() + target_include_directories( ll::${package} SYSTEM INTERFACE ${${package}_INCLUDE_DIRS} ) + target_link_libraries( ll::${package} INTERFACE ${${package}_LIBRARIES} ) + return() + if( USE_CONAN ) target_link_libraries( ll::${package} INTERFACE CONAN_PKG::${package} ) foreach( extra_pkg "${ARGN}" ) @@ -100,22 +115,6 @@ macro ( use_system_binary package ) endif() endforeach() return() - elseif( NOT USE_AUTOBUILD_3P ) - include(FindPkgConfig) - pkg_check_modules(${package} ${package}) - if( ${package}_FOUND ) - target_link_directories( ll::${package} INTERFACE ${${package}_LIBRARY_DIRS} ) - else() - pkg_check_modules(${package} lib${package}) - if( ${package}_FOUND ) - target_link_directories( ll::${package} INTERFACE ${${package}_LIBRARY_DIRS} ) - else() - find_package( ${package} REQUIRED ) - endif() - endif() - target_include_directories( ll::${package} SYSTEM INTERFACE ${${package}_INCLUDE_DIRS} ) - target_link_libraries( ll::${package} INTERFACE ${${package}_LIBRARIES} ) - return() endif() endmacro() diff --git a/indra/cmake/UI.cmake b/indra/cmake/UI.cmake index a3423bb895..f1cde54807 100644 --- a/indra/cmake/UI.cmake +++ b/indra/cmake/UI.cmake @@ -6,9 +6,6 @@ include(GLIB) add_library( ll::uilibraries INTERFACE IMPORTED ) if (LINUX OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - if (NOT USESYSTEMLIBS) - use_prebuilt_binary(fltk) - endif () target_compile_definitions(ll::uilibraries INTERFACE LL_FLTK=1 LL_X11=1 ) if( USE_CONAN ) @@ -48,7 +45,7 @@ if( WINDOWS ) ) endif() -if (NOT USESYSTEMLIBS) +if (FALSE) target_include_directories( ll::uilibraries SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include ) diff --git a/indra/cmake/ViewerMiscLibs.cmake b/indra/cmake/ViewerMiscLibs.cmake index 13f5ebf862..d8b94d5fba 100644 --- a/indra/cmake/ViewerMiscLibs.cmake +++ b/indra/cmake/ViewerMiscLibs.cmake @@ -8,16 +8,16 @@ if (NOT (WINDOWS OR DARWIN)) target_link_libraries( ll::fontconfig INTERFACE Fontconfig::Fontconfig ) endif (NOT (WINDOWS OR DARWIN)) -if( USE_AUTOBUILD_3P ) +if (FALSE) +if( NOT USE_CONAN ) use_prebuilt_binary(libhunspell) endif() -if (NOT USESYSTEMLIBS) use_prebuilt_binary(slvoice) -endif (NOT USESYSTEMLIBS) +endif (FALSE) -if ((${LINUX_DISTRO} MATCHES debian OR WINDOWS OR DARWIN) OR NOT USESYSTEMLIBS) +if (${LINUX_DISTRO} MATCHES debian OR DARWIN OR WINDOWS) use_prebuilt_binary(nanosvg) -endif ((${LINUX_DISTRO} MATCHES debian OR WINDOWS OR DARWIN) OR NOT USESYSTEMLIBS) +endif () use_prebuilt_binary(viewer-fonts) use_prebuilt_binary(emoji_shortcodes) diff --git a/indra/cmake/VulkanGltf.cmake b/indra/cmake/VulkanGltf.cmake index d7083a33c9..94541d5307 100644 --- a/indra/cmake/VulkanGltf.cmake +++ b/indra/cmake/VulkanGltf.cmake @@ -1,7 +1,5 @@ # -*- cmake -*- include(Prebuilt) -if (NOT USESYSTEMLIBS) use_prebuilt_binary(vulkan_gltf) -endif () diff --git a/indra/cmake/ZLIBNG.cmake b/indra/cmake/ZLIBNG.cmake index 5aa54b0152..7c2c59a68d 100644 --- a/indra/cmake/ZLIBNG.cmake +++ b/indra/cmake/ZLIBNG.cmake @@ -5,15 +5,15 @@ include(Prebuilt) include_guard() add_library( ll::zlib-ng INTERFACE IMPORTED ) +pkg_check_modules(Zlib REQUIRED zlib) +target_include_directories( ll::zlib-ng SYSTEM INTERFACE ${Zlib_INCLUDE_DIRS}) +target_link_directories( ll::zlib-ng INTERFACE ${Zlib_LIBRARY_DIRS} ) +target_link_libraries( ll::zlib-ng INTERFACE ${Zlib_LIBRARIES}) +return() + if(USE_CONAN ) target_link_libraries( ll::zlib-ng INTERFACE CONAN_PKG::zlib ) return() -elseif(NOT USE_AUTOBUILD_3P) - pkg_check_modules(Zlib REQUIRED zlib) - target_include_directories( ll::zlib-ng SYSTEM INTERFACE ${Zlib_INCLUDE_DIRS}) - target_link_directories( ll::zlib-ng INTERFACE ${Zlib_LIBRARY_DIRS} ) - target_link_libraries( ll::zlib-ng INTERFACE ${Zlib_LIBRARIES}) - return() endif() use_prebuilt_binary(zlib-ng) diff --git a/indra/cmake/xxHash.cmake b/indra/cmake/xxHash.cmake index 7e113feda2..84f4f4e0f2 100644 --- a/indra/cmake/xxHash.cmake +++ b/indra/cmake/xxHash.cmake @@ -6,10 +6,8 @@ set (XXHASH_CMAKE_INCLUDED TRUE) include(Prebuilt) -if (USESYSTEMLIBS) - include(FindPkgConfig) - pkg_check_modules(Xxhash REQUIRED libxxhash) - return () -endif () +include(FindPkgConfig) +pkg_check_modules(Xxhash REQUIRED libxxhash) +return () use_prebuilt_binary(xxhash) diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 6aec3aada7..07f6eb95e0 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -8,9 +8,6 @@ include(bugsplat) include(Linking) include(Boost) include(LLSharedLibs) -if (NOT USESYSTEMLIBS) -include(Copy3rdPartyLibs) -endif () include(ZLIBNG) include(Tracy) @@ -306,23 +303,19 @@ if (${LINUX_DISTRO} MATCHES debian OR (${LINUX_DISTRO} MATCHES ubuntu) OR (${LIN target_include_directories(llcommon PUBLIC ${LIBS_PREBUILT_DIR}/include) endif () -if (NOT USESYSTEMLIBS) -add_dependencies(llcommon stage_third_party_libs) -else () - target_compile_options(${PROJECT_NAME} PUBLIC -Wno-deprecated-declarations) - if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") - set_source_files_properties( - llapp.cpp - llsdutil.cpp - PROPERTIES COMPILE_FLAGS -Wno-stringop-truncation) - set_source_files_properties( - llevent.cpp - llfasttimer.cpp - PROPERTIES COMPILE_FLAGS -Wno-nonnull) - elseif (LINUX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set_source_files_properties(llsys.cpp PROPERTIES - COMPILE_FLAGS -Wno-unused-but-set-variable) - endif() +target_compile_options(${PROJECT_NAME} PUBLIC -Wno-deprecated-declarations) +if (CMAKE_CXX_COMPILER_ID MATCHES GNU) + set_source_files_properties( + llapp.cpp + llsdutil.cpp + PROPERTIES COMPILE_FLAGS -Wno-stringop-truncation) + set_source_files_properties( + llevent.cpp + llfasttimer.cpp + PROPERTIES COMPILE_FLAGS -Wno-nonnull) +elseif (LINUX AND CMAKE_CXX_COMPILER_ID MATCHES Clang) + set_source_files_properties(llsys.cpp PROPERTIES + COMPILE_FLAGS -Wno-unused-but-set-variable) endif () include(LibraryInstall) diff --git a/indra/llimage/CMakeLists.txt b/indra/llimage/CMakeLists.txt index 30a79076ab..3abc85954b 100644 --- a/indra/llimage/CMakeLists.txt +++ b/indra/llimage/CMakeLists.txt @@ -67,15 +67,13 @@ target_link_libraries(llimage ll::libjpeg ) -if (USESYSTEMLIBS) - if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") - set_source_files_properties(llimageworker.cpp PROPERTIES COMPILE_FLAGS -Wno-int-in-bool-context) - set_source_files_properties( - llimage.cpp - llimagefilter.cpp - PROPERTIES COMPILE_FLAGS -Wno-stringop-overflow) - endif() -endif () +if (CMAKE_CXX_COMPILER_ID MATCHES GNU) + set_source_files_properties(llimageworker.cpp PROPERTIES COMPILE_FLAGS -Wno-int-in-bool-context) + set_source_files_properties( + llimage.cpp + llimagefilter.cpp + PROPERTIES COMPILE_FLAGS -Wno-stringop-overflow) +endif() include(LibraryInstall) diff --git a/indra/llmath/CMakeLists.txt b/indra/llmath/CMakeLists.txt index c0a62ad225..e21b6fdb84 100644 --- a/indra/llmath/CMakeLists.txt +++ b/indra/llmath/CMakeLists.txt @@ -105,7 +105,7 @@ add_library (llmath ${llmath_SOURCE_FILES}) target_link_libraries(llmath llcommon llmeshoptimizer) target_include_directories( llmath INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -if (USESYSTEMLIBS AND CMAKE_CXX_COMPILER_ID MATCHES "GNU") +if (CMAKE_CXX_COMPILER_ID MATCHES GNU) set_source_files_properties(llcalc.cpp PROPERTIES COMPILE_FLAGS -Wno-dangling-pointer) endif () diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index 43e9c580dc..f661e2c348 100644 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -197,11 +197,8 @@ target_link_libraries( ) target_include_directories( llmessage INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -if (USESYSTEMLIBS) - if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") - set_source_files_properties(llnamevalue.cpp PROPERTIES - COMPILE_FLAGS -Wno-stringop-truncation) - endif() +if (CMAKE_CXX_COMPILER_ID MATCHES GNU) + set_source_files_properties(llnamevalue.cpp PROPERTIES COMPILE_FLAGS -Wno-stringop-truncation) endif () include(LibraryInstall) diff --git a/indra/llwebrtc/CMakeLists.txt b/indra/llwebrtc/CMakeLists.txt index c4971d44b1..6c0216234c 100644 --- a/indra/llwebrtc/CMakeLists.txt +++ b/indra/llwebrtc/CMakeLists.txt @@ -28,9 +28,7 @@ list(APPEND llwebrtc_SOURCE_FILES ${llwebrtc_HEADER_FILES}) add_library (llwebrtc SHARED ${llwebrtc_SOURCE_FILES}) -if (NOT USESYSTEMLIBS) -set_target_properties(llwebrtc PROPERTIES PUBLIC_HEADER llwebrtc.h) -endif (NOT USESYSTEMLIBS) +#set_target_properties(llwebrtc PROPERTIES PUBLIC_HEADER llwebrtc.h) if (WINDOWS) cmake_policy(SET CMP0091 NEW) diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index ce9134e7f1..d139a3373e 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -55,7 +55,6 @@ set(llwindow_LINK_LIBRARIES llfilesystem llxml ll::glm - ll::glext ll::uilibraries ll::SDL ) @@ -64,7 +63,7 @@ include_directories(${CMAKE_SOURCE_DIR}/llrender) # Libraries on which this library depends, needed for Linux builds # Sort by high-level to low-level -if (USESYSTEMLIBS AND NOT DARWIN) +if (NOT DARWIN) list(APPEND viewer_SOURCE_FILES llkeyboardsdl.cpp llwindowsdl.cpp @@ -86,7 +85,7 @@ if (USESYSTEMLIBS AND NOT DARWIN) fontconfig # For FCInit and other FC* functions. ) endif (BUILD_HEADLESS) -endif (USESYSTEMLIBS AND NOT DARWIN) +endif () if (DARWIN) list(APPEND llwindow_SOURCE_FILES diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 8c90f917b8..f667ff7542 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -2689,13 +2689,7 @@ void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url, bool async) # endif // LL_X11 std::string cmd, arg; -#ifdef LL_USESYSTEMLIBS cmd = gDirUtilp->getExecutableDir(); -#else - cmd = gDirUtilp->getAppRODataDir(); - cmd += gDirUtilp->getDirDelimiter(); - cmd += "etc"; -#endif cmd += gDirUtilp->getDirDelimiter(); cmd += "launch_url.sh"; arg = escaped_url; diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 18b39726aa..69b9022ddc 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -9,15 +9,11 @@ include(Linking) include(Boost) include(bugsplat) -if (NOT USESYSTEMLIBS) -include(BuildPackagesInfo) -endif () +#include(BuildPackagesInfo) include(BuildVersion) include(CMakeCopyIfDifferent) include(CubemapToEquirectangularJS) -if (NOT USESYSTEMLIBS) -include(DBusGlib) -endif () +#include(DBusGlib) include(DragDrop) include(EXPAT) include(Hunspell) @@ -45,11 +41,9 @@ include(ThreeJS) include(Tracy) include(UI) include(ViewerMiscLibs) -if (NOT USESYSTEMLIBS) -include(ViewerManager) -endif () +#include(ViewerManager) include(VisualLeakDetector) -include(VulkanGltf) +#include(VulkanGltf) include(ZLIBNG) include(LLPrimitive) @@ -1494,7 +1488,7 @@ if (DARWIN) list(APPEND viewer_SOURCE_FILES ${viewer_RESOURCE_FILES}) endif (DARWIN) -if (USESYSTEMLIBS AND NOT DARWIN) +if (NOT DARWIN) LIST(APPEND viewer_SOURCE_FILES llappviewerlinux.cpp) set_source_files_properties( llappviewerlinux.cpp @@ -1505,7 +1499,7 @@ if (USESYSTEMLIBS AND NOT DARWIN) SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed") endif () -endif (USESYSTEMLIBS AND NOT DARWIN) +endif () if (WINDOWS) @@ -1687,15 +1681,11 @@ set(viewer_APPSETTINGS_FILES app_settings/viewerart.xml ${CMAKE_SOURCE_DIR}/../etc/message.xml ${CMAKE_SOURCE_DIR}/../scripts/messages/message_template.msg - packages-info.txt + #packages-info.txt featuretable.txt featuretable_mac.txt ) -if (USESYSTEMLIBS) - list(REMOVE_ITEM viewer_APPSETTINGS_FILES packages-info.txt) -endif () - source_group("App Settings" FILES ${viewer_APPSETTINGS_FILES}) set_source_files_properties(${viewer_APPSETTINGS_FILES} @@ -2124,7 +2114,7 @@ foreach(elem ${country_codes}) configure_file(${emoji_mapping_src_file} ${emoji_mapping_dst_file} COPYONLY) endforeach() -if (PACKAGE AND USESYSTEMLIBS) +if (PACKAGE) set(CPACK_PACKAGE_NAME ${VIEWER_BINARY_NAME} CACHE STRING "Viewer binary name.") set(CPACK_PACKAGE_VERSION ${VIEWER_VERSION_MAJOR}.${VIEWER_VERSION_MINOR}.${VIEWER_VERSION_PATCH}.${VIEWER_VERSION_REVISION} @@ -2138,10 +2128,9 @@ if (PACKAGE AND USESYSTEMLIBS) set(VIEWER_PACKAGE_DOMAIN_NAME ${VIEWER_BINARY_NAME}.net ) -endif (PACKAGE AND USESYSTEMLIBS) +endif () if (LINUX) - if (USESYSTEMLIBS) add_custom_command( TARGET ${VIEWER_BINARY_NAME} POST_BUILD COMMAND ${CMAKE_SYSROOT}/usr/bin/sed @@ -2217,7 +2206,8 @@ if (LINUX) ) endif (${LINUX_DISTRO} MATCHES debian OR ${LINUX_DISTRO} MATCHES ubuntu) endif (PACKAGE) - else (USESYSTEMLIBS) + + if (FALSE) set(product SecondLife-${ARCH}-${VIEWER_SHORT_VERSION}.${VIEWER_VERSION_REVISION}) # These are the generated targets that are copied to package/ @@ -2292,8 +2282,8 @@ if (LINUX) add_dependencies(llpackage copy_l_viewer_manifest) check_message_template(llpackage) endif (PACKAGE) - endif (USESYSTEMLIBS) -elseif (USESYSTEMLIBS) + endif (FALSE) + add_custom_command( TARGET ${VIEWER_BINARY_NAME} POST_BUILD COMMAND sed @@ -2379,12 +2369,12 @@ if (DARWIN) "${VIEWER_APP_BUNDLE}/Contents/Info.plist" ) - if (USESYSTEMLIBS) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/English.lproj/InfoPlist.strings ${CMAKE_CURRENT_BINARY_DIR}/InfoPlist.strings ) - else (USESYSTEMLIBS) + + if (FALSE) add_custom_command( TARGET ${VIEWER_BINARY_NAME} POST_BUILD COMMAND ${PYTHON_EXECUTABLE} @@ -2409,7 +2399,7 @@ if (DARWIN) ${VIEWER_BINARY_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py ) - endif (USESYSTEMLIBS) + endif () if (ENABLE_MEDIA_PLUGINS) add_dependencies(${VIEWER_BINARY_NAME} SLPlugin media_plugin_libvlc media_plugin_cef) @@ -2422,10 +2412,9 @@ if (DARWIN) endif (ENABLE_SIGNING) if (PACKAGE) - if (USESYSTEMLIBS) - set(CPACK_DMG_VOLUME_NAME "${product} Installer" - CACHE STRING "Disk image volume name.") - set(CPACK_DMG_FORMAT UDRW CACHE STRING "Disk image format.") + set(CPACK_DMG_VOLUME_NAME "${product} Installer" + CACHE STRING "Disk image volume name.") + set(CPACK_DMG_FORMAT UDRW CACHE STRING "Disk image format.") set(CPACK_DMG_DS_STORE ${CMAKE_CURRENT_SOURCE_DIR}/installers/darwin/release-dmg/_DS_Store CACHE STRING "Disk image .DS_Store file.") @@ -2435,13 +2424,13 @@ if (DARWIN) set(CPACK_DMG_BACKGROUND_IMAGE ${CMAKE_CURRENT_SOURCE_DIR}/installers/darwin/release-dmg/background.jpg CACHE STRING "Disk image background image.") - set(CPACK_BUNDLE_NAME ${product} CACHE STRING "Bundle name.") - set(CPACK_BUNDLE_PLIST ${VIEWER_APP_BUNDLE}/Contents/Info.plist - CACHE STRING "Bundle Property List file.") - set(CPACK_BUNDLE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/secondlife.icns - CACHE STRING "Bundle icon file.") + set(CPACK_BUNDLE_NAME ${product} CACHE STRING "Bundle name.") + set(CPACK_BUNDLE_PLIST ${VIEWER_APP_BUNDLE}/Contents/Info.plist + CACHE STRING "Bundle Property List file.") + set(CPACK_BUNDLE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/secondlife.icns + CACHE STRING "Bundle icon file.") - else (USESYSTEMLIBS) + if (FALSE) add_custom_target(llpackage ALL DEPENDS ${VIEWER_BINARY_NAME}) add_custom_command( @@ -2467,16 +2456,16 @@ if (DARWIN) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py ) - endif (USESYSTEMLIBS) + endif () endif (PACKAGE) endif (DARWIN) if (INSTALL) include(${CMAKE_CURRENT_SOURCE_DIR}/ViewerInstall.cmake) endif (INSTALL) -if (PACKAGE AND USESYSTEMLIBS) +if (PACKAGE) include(CPack) -endif (PACKAGE AND USESYSTEMLIBS) +endif () if (PACKAGE AND (RELEASE_CRASH_REPORTING OR NON_RELEASE_CRASH_REPORTING) AND VIEWER_SYMBOL_FILE) if (USE_BUGSPLAT) -- cgit v1.3 From cf11376a6f371afa1b7bcfbc8b366a60e38ace8b Mon Sep 17 00:00:00 2001 From: Nicky Date: Fri, 26 Jul 2024 16:23:54 +0200 Subject: Post merge cleanup of Linux code --- indra/llwindow/llwindowsdl.cpp | 2 +- indra/llwindow/llwindowsdl.h | 7 +++---- indra/newview/lldirpicker.cpp | 1 + indra/newview/viewer_manifest.py | 28 ---------------------------- 4 files changed, 5 insertions(+), 33 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index f667ff7542..079fca00c0 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -427,7 +427,7 @@ LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks, #if LL_X11 mSDL_XWindowID = None; - mSDL_Display = NULL; + mSDL_Display = nullptr; #endif // LL_X11 // Assume 4:3 aspect ratio until we know better diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h index 3ed2811572..3acda71157 100644 --- a/indra/llwindow/llwindowsdl.h +++ b/indra/llwindow/llwindowsdl.h @@ -285,7 +285,6 @@ protected: int mHaveInputFocus; /* 0=no, 1=yes, else unknown */ int mIsMinimized; /* 0=no, 1=yes, else unknown */ - int mIsActive; /* 0=no, 1=yes, else unknown */ friend class LLWindowManager; @@ -316,6 +315,8 @@ public: void clearSecondaryText() { mSecondaryClipboard.clear(); } private: + void tryFindFullscreenSize(int &aWidth, int &aHeight); + void initialiseX11Clipboard(); bool getSelectionText(Atom selection, LLWString &text); @@ -323,10 +324,8 @@ private: bool getSelectionText(Atom selection, Atom type, LLWString &text); bool setSelectionText(Atom selection, const LLWString &text); -#endif - - void tryFindFullscreenSize(int &aWidth, int &aHeight); +#endif LLWString mPrimaryClipboard; LLWString mSecondaryClipboard; }; diff --git a/indra/newview/lldirpicker.cpp b/indra/newview/lldirpicker.cpp index 1425aab947..fa8acac2ce 100644 --- a/indra/newview/lldirpicker.cpp +++ b/indra/newview/lldirpicker.cpp @@ -272,6 +272,7 @@ bool LLDirPicker::getDir(std::string* filename, bool blocking) } return !mDir.empty(); #endif + return false; } std::string LLDirPicker::getDirName() diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index e9112694d9..c778f1e838 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -1803,34 +1803,6 @@ class Linux_x86_64_Manifest(LinuxManifest): self.path("libalut.so*") self.path("libopenal.so*") self.path("libopenal.so", "libvivoxoal.so.1") # vivox's sdk expects this soname - # KLUDGE: As of 2012-04-11, the 'fontconfig' package installs - # libfontconfig.so.1.4.4, along with symlinks libfontconfig.so.1 - # and libfontconfig.so. Before we added support for library-file - # wildcards, though, this self.path() call specifically named - # libfontconfig.so.1.4.4 WITHOUT also copying the symlinks. When I - # (nat) changed the call to self.path("libfontconfig.so.*"), we - # ended up with the libfontconfig.so.1 symlink in the target - # directory as well. But guess what! At least on Ubuntu 10.04, - # certain viewer fonts look terrible with libfontconfig.so.1 - # present in the target directory. Removing that symlink suffices - # to improve them. I suspect that means we actually do better when - # the viewer fails to find our packaged libfontconfig.so*, falling - # back on the system one instead -- but diagnosing and fixing that - # is a bit out of scope for the present project. Meanwhile, this - # particular wildcard specification gets us exactly what the - # previous call did, without having to explicitly state the - # version number. - self.path("libfontconfig.so.*.*") - - # Include libfreetype.so. but have it work as libfontconfig does. - self.path("libfreetype.so.*.*") - - try: - self.path("libtcmalloc.so*") #formerly called google perf tools - pass - except: - print("tcmalloc files not found, skipping") - pass # Vivox runtimes with self.prefix(src=relpkgdir, dst="bin"): -- cgit v1.3 From 031a29625d40215e8715e4eccac17578984c6907 Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Sat, 27 Jul 2024 18:01:29 +0300 Subject: Fix trailing whitespace --- indra/llwindow/llwindowsdl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h index 3acda71157..cdb8a888d5 100644 --- a/indra/llwindow/llwindowsdl.h +++ b/indra/llwindow/llwindowsdl.h @@ -177,7 +177,7 @@ public: void *getPlatformWindow() override; void bringToFront() override; - + void setLanguageTextInput(const LLCoordGL& pos) override; void spawnWebBrowser(const std::string &escaped_url, bool async) override; -- cgit v1.3 From 619fdda6279341fdb52f98c09c202cf038851a31 Mon Sep 17 00:00:00 2001 From: Ansariel Hiller Date: Wed, 4 Sep 2024 21:24:14 +0200 Subject: Fix name of vsync param in LLWindowSDL (#2502) --- indra/llwindow/llwindowsdl.cpp | 11 +++++------ indra/llwindow/llwindowsdl.h | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 079fca00c0..1f2b8aaac3 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -398,11 +398,10 @@ LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks, const std::string& title, S32 x, S32 y, S32 width, S32 height, U32 flags, bool fullscreen, bool clearBg, - bool disable_vsync, bool use_gl, + bool enable_vsync, bool use_gl, bool ignore_pixel_depth, U32 fsaa_samples) : LLWindow(callbacks, fullscreen, flags), Lock_Display(NULL), - //Unlock_Display(NULL), mGamma(1.0f) Unlock_Display(NULL), mGamma(1.0f) { // Initialize the keyboard @@ -439,7 +438,7 @@ LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks, mWindowTitle = title; // Create the GL context and set it up for windowed or fullscreen, as appropriate. - if(createContext(x, y, width, height, 32, fullscreen, disable_vsync)) + if(createContext(x, y, width, height, 32, fullscreen, enable_vsync)) { gGLManager.initGL(); @@ -675,7 +674,7 @@ void LLWindowSDL::tryFindFullscreenSize( int &width, int &height ) } } -bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, bool fullscreen, bool disable_vsync) +bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, bool fullscreen, bool enable_vsync) { //bool glneedsinit = false; @@ -981,7 +980,7 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b // changing fullscreen resolution, or switching between windowed and fullscreen mode. -bool LLWindowSDL::switchContext(bool fullscreen, const LLCoordScreen &size, bool disable_vsync, const LLCoordScreen * const posp) +bool LLWindowSDL::switchContext(bool fullscreen, const LLCoordScreen &size, bool enable_vsync, const LLCoordScreen * const posp) { const bool needsRebuild = true; // Just nuke the context and start over. bool result = true; @@ -991,7 +990,7 @@ bool LLWindowSDL::switchContext(bool fullscreen, const LLCoordScreen &size, bool if(needsRebuild) { destroyContext(); - result = createContext(0, 0, size.mX, size.mY, 0, fullscreen, disable_vsync); + result = createContext(0, 0, size.mX, size.mY, 0, fullscreen, enable_vsync); if (result) { gGLManager.initGL(); diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h index cdb8a888d5..36bdf0e80a 100644 --- a/indra/llwindow/llwindowsdl.h +++ b/indra/llwindow/llwindowsdl.h @@ -84,7 +84,7 @@ public: bool setSizeImpl(LLCoordWindow size) override; - bool switchContext(bool fullscreen, const LLCoordScreen &size, bool disable_vsync, + bool switchContext(bool fullscreen, const LLCoordScreen &size, bool enable_vsync, const LLCoordScreen *const posp = NULL) override; bool setCursorPosition(LLCoordWindow position) override; @@ -222,7 +222,7 @@ public: protected: LLWindowSDL(LLWindowCallbacks *callbacks, const std::string &title, int x, int y, int width, int height, U32 flags, - bool fullscreen, bool clearBg, bool disable_vsync, bool use_gl, + bool fullscreen, bool clearBg, bool enable_vsync, bool use_gl, bool ignore_pixel_depth, U32 fsaa_samples); ~LLWindowSDL(); @@ -251,7 +251,7 @@ protected: // // create or re-create the GL context/window. Called from the constructor and switchContext(). - bool createContext(int x, int y, int width, int height, int bits, bool fullscreen, bool disable_vsync); + bool createContext(int x, int y, int width, int height, int bits, bool fullscreen, bool enable_vsync); void destroyContext(); -- cgit v1.3 From 2caab6e9aefc5c2538434af0c49d3bd398977c14 Mon Sep 17 00:00:00 2001 From: Rye Cogtail Date: Sat, 28 Sep 2024 23:38:11 -0400 Subject: Update SDL clipboard, icon flash, and url opening handlers to use native SDL functions --- indra/llwindow/llwindowsdl.cpp | 487 ++++------------------------------------- indra/llwindow/llwindowsdl.h | 34 --- 2 files changed, 40 insertions(+), 481 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 1f2b8aaac3..be98a0d6e0 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -152,248 +152,6 @@ Display* LLWindowSDL::get_SDL_Display(void) } #endif // LL_X11 -#if LL_X11 - -// Clipboard handing via native X11, base on the implementation in Cool VL by Henri Beauchamp - -namespace -{ - std::array gSupportedAtoms; - - Atom XA_CLIPBOARD; - Atom XA_TARGETS; - Atom PVT_PASTE_BUFFER; - long const MAX_PASTE_BUFFER_SIZE = 16383; - - void filterSelectionRequest( XEvent aEvent ) - { - auto *display = LLWindowSDL::getSDLDisplay(); - auto &request = aEvent.xselectionrequest; - - XSelectionEvent reply { SelectionNotify, aEvent.xany.serial, aEvent.xany.send_event, display, - request.requestor, request.selection, request.target, - request.property,request.time }; - - if (request.target == XA_TARGETS) - { - XChangeProperty(display, request.requestor, request.property, - XA_ATOM, 32, PropModeReplace, - (unsigned char *) &gSupportedAtoms.front(), gSupportedAtoms.size()); - } - else if (std::find(gSupportedAtoms.begin(), gSupportedAtoms.end(), request.target) != - gSupportedAtoms.end()) - { - std::string utf8; - if (request.selection == XA_PRIMARY) - utf8 = wstring_to_utf8str(gWindowImplementation->getPrimaryText()); - else - utf8 = wstring_to_utf8str(gWindowImplementation->getSecondaryText()); - - XChangeProperty(display, request.requestor, request.property, - request.target, 8, PropModeReplace, - (unsigned char *) utf8.c_str(), utf8.length()); - } - else if (request.selection == XA_CLIPBOARD) - { - // Did not have what they wanted, so no property set - reply.property = None; - } - else - return; - - XSendEvent(request.display, request.requestor, False, NoEventMask, (XEvent *) &reply); - XSync(display, False); - } - - void filterSelectionClearRequest( XEvent aEvent ) - { - auto &request = aEvent.xselectionrequest; - if (request.selection == XA_PRIMARY) - gWindowImplementation->clearPrimaryText(); - else if (request.selection == XA_CLIPBOARD) - gWindowImplementation->clearSecondaryText(); - } - - int x11_clipboard_filter(void*, SDL_Event *evt) - { - Display *display = LLWindowSDL::getSDLDisplay(); - if (!display) - return 1; - - if (evt->type != SDL_SYSWMEVENT) - return 1; - - auto xevent = evt->syswm.msg->msg.x11.event; - - if (xevent.type == SelectionRequest) - filterSelectionRequest( xevent ); - else if (xevent.type == SelectionClear) - filterSelectionClearRequest( xevent ); - return 1; - } - - bool grab_property(Display* display, Window window, Atom selection, Atom target) - { - if( !display ) - return false; - - maybe_lock_display(); - - XDeleteProperty(display, window, PVT_PASTE_BUFFER); - XFlush(display); - - XConvertSelection(display, selection, target, PVT_PASTE_BUFFER, window, CurrentTime); - - // Unlock the connection so that the SDL event loop may function - maybe_unlock_display(); - - const auto start{ SDL_GetTicks() }; - const auto end{ start + 1000 }; - - XEvent xevent {}; - bool response = false; - - do - { - SDL_Event event {}; - - // Wait for an event - SDL_WaitEvent(&event); - - // If the event is a window manager event - if (event.type == SDL_SYSWMEVENT) - { - xevent = event.syswm.msg->msg.x11.event; - - if (xevent.type == SelectionNotify && xevent.xselection.requestor == window) - response = true; - } - } while (!response && SDL_GetTicks() < end ); - - return response && xevent.xselection.property != None; - } -} - -void LLWindowSDL::initialiseX11Clipboard() -{ - if (!mSDL_Display) - return; - - SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); - SDL_SetEventFilter(x11_clipboard_filter, nullptr); - - maybe_lock_display(); - - XA_CLIPBOARD = XInternAtom(mSDL_Display, "CLIPBOARD", False); - - gSupportedAtoms[0] = XInternAtom(mSDL_Display, "UTF8_STRING", False); - gSupportedAtoms[1] = XInternAtom(mSDL_Display, "COMPOUND_TEXT", False); - gSupportedAtoms[2] = XA_STRING; - - // TARGETS atom - XA_TARGETS = XInternAtom(mSDL_Display, "TARGETS", False); - - // SL_PASTE_BUFFER atom - PVT_PASTE_BUFFER = XInternAtom(mSDL_Display, "FS_PASTE_BUFFER", False); - - maybe_unlock_display(); -} - -bool LLWindowSDL::getSelectionText( Atom aSelection, Atom aType, LLWString &text ) -{ - if( !mSDL_Display ) - return false; - - if( !grab_property(mSDL_Display, mSDL_XWindowID, aSelection,aType ) ) - return false; - - maybe_lock_display(); - - Atom type; - int format{}; - unsigned long len{},remaining {}; - unsigned char* data = nullptr; - int res = XGetWindowProperty(mSDL_Display, mSDL_XWindowID, - PVT_PASTE_BUFFER, 0, MAX_PASTE_BUFFER_SIZE, False, - AnyPropertyType, &type, &format, &len, - &remaining, &data); - if (data && len) - { - text = LLWString( - utf8str_to_wstring(reinterpret_cast< char const *>( data ) ) - ); - XFree(data); - } - - maybe_unlock_display(); - return res == Success; -} - -bool LLWindowSDL::getSelectionText(Atom selection, LLWString& text) -{ - if (!mSDL_Display) - return false; - - maybe_lock_display(); - - Window owner = XGetSelectionOwner(mSDL_Display, selection); - if (owner == None) - { - if (selection == XA_PRIMARY) - { - owner = DefaultRootWindow(mSDL_Display); - selection = XA_CUT_BUFFER0; - } - else - { - maybe_unlock_display(); - return false; - } - } - - maybe_unlock_display(); - - for( Atom atom : gSupportedAtoms ) - { - if(getSelectionText(selection, atom, text ) ) - return true; - } - - return false; -} - -bool LLWindowSDL::setSelectionText(Atom selection, const LLWString& text) -{ - maybe_lock_display(); - - if (selection == XA_PRIMARY) - { - std::string utf8 = wstring_to_utf8str(text); - XStoreBytes(mSDL_Display, utf8.c_str(), utf8.length() + 1); - mPrimaryClipboard = text; - } - else - mSecondaryClipboard = text; - - XSetSelectionOwner(mSDL_Display, selection, mSDL_XWindowID, CurrentTime); - - auto owner = XGetSelectionOwner(mSDL_Display, selection); - - maybe_unlock_display(); - - return owner == mSDL_XWindowID; -} - -Display* LLWindowSDL::getSDLDisplay() -{ - if (gWindowImplementation) - return gWindowImplementation->mSDL_Display; - return nullptr; -} - -#endif - - LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks, const std::string& title, S32 x, S32 y, S32 width, S32 height, U32 flags, @@ -452,10 +210,7 @@ LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks, // Stash an object pointer for OSMessageBox() gWindowImplementation = this; -#if LL_X11 mFlashing = false; - initialiseX11Clipboard(); -#endif // LL_X11 mKeyVirtualKey = 0; mKeyModifiers = KMOD_NONE; @@ -1478,116 +1233,70 @@ void LLWindowSDL::afterDialog() } } - -#if LL_X11 -// set/reset the XWMHints flag for 'urgency' that usually makes the icon flash -void LLWindowSDL::x11_set_urgent(bool urgent) -{ - if (mSDL_Display && !mFullscreen) - { - XWMHints *wm_hints; - - LL_INFOS() << "X11 hint for urgency, " << urgent << LL_ENDL; - - maybe_lock_display(); - wm_hints = XGetWMHints(mSDL_Display, mSDL_XWindowID); - if (!wm_hints) - wm_hints = XAllocWMHints(); - - if (urgent) - wm_hints->flags |= XUrgencyHint; - else - wm_hints->flags &= ~XUrgencyHint; - - XSetWMHints(mSDL_Display, mSDL_XWindowID, wm_hints); - XFree(wm_hints); - XSync(mSDL_Display, False); - maybe_unlock_display(); - } -} -#endif // LL_X11 - void LLWindowSDL::flashIcon(F32 seconds) { - if (getMinimized()) - { -#if !LL_X11 - LL_INFOS() << "Stub LLWindowSDL::flashIcon(" << seconds << ")" << LL_ENDL; -#else - LL_INFOS() << "X11 LLWindowSDL::flashIcon(" << seconds << ")" << LL_ENDL; + LL_INFOS() << "LLWindowSDL::flashIcon(" << seconds << ")" << LL_ENDL; - F32 remaining_time = mFlashTimer.getRemainingTimeF32(); - if (remaining_time < seconds) - remaining_time = seconds; - mFlashTimer.reset(); - mFlashTimer.setTimerExpirySec(remaining_time); + F32 remaining_time = mFlashTimer.getRemainingTimeF32(); + if (remaining_time < seconds) + remaining_time = seconds; + mFlashTimer.reset(); + mFlashTimer.setTimerExpirySec(remaining_time); - x11_set_urgent(true); - mFlashing = true; -#endif // LL_X11 - } + SDL_FlashWindow(mWindow, SDL_FLASH_UNTIL_FOCUSED); + mFlashing = true; } bool LLWindowSDL::isClipboardTextAvailable() { -#if LL_X11 - return mSDL_Display && XGetSelectionOwner(mSDL_Display, XA_CLIPBOARD) != None; -#else - return SDL_HasClipboardText(); -#endif + return SDL_HasClipboardText() == SDL_TRUE; } bool LLWindowSDL::pasteTextFromClipboard(LLWString &dst) { -#if LL_X11 - return getSelectionText(XA_CLIPBOARD, dst); -#else - auto data = SDL_GetClipboardText(); - if (data) + if (isClipboardTextAvailable()) { - dst = LLWString(utf8str_to_wstring(data)); - SDL_free(data); - return true; + char* data = SDL_GetClipboardText(); + if (data) + { + dst = LLWString(utf8str_to_wstring(data)); + SDL_free(data); + return true; + } } return false; -#endif } -bool LLWindowSDL::copyTextToClipboard(const LLWString &s) +bool LLWindowSDL::copyTextToClipboard(const LLWString& text) { -#if LL_X11 - return setSelectionText(XA_CLIPBOARD, s); -#else - return !SDL_SetClipboardText(wstring_to_utf8str(s).c_str()); -#endif + const std::string utf8 = wstring_to_utf8str(text); + return SDL_SetClipboardText(utf8.c_str()) == 0; // success == 0 } bool LLWindowSDL::isPrimaryTextAvailable() { -#if LL_X11 - LLWString text; - return getSelectionText(XA_PRIMARY, text) && !text.empty(); -#else - return false; // unsupported -#endif + return SDL_HasPrimarySelectionText() == SDL_TRUE; } bool LLWindowSDL::pasteTextFromPrimary(LLWString &dst) { -#if LL_X11 - return getSelectionText(XA_PRIMARY, dst); -#else - return false; // unsupported -#endif + if (isPrimaryTextAvailable()) + { + char* data = SDL_GetPrimarySelectionText(); + if (data) + { + dst = LLWString(utf8str_to_wstring(data)); + SDL_free(data); + return true; + } + } + return false; } -bool LLWindowSDL::copyTextToPrimary(const LLWString &s) +bool LLWindowSDL::copyTextToPrimary(const LLWString& text) { -#if LL_X11 - return setSelectionText(XA_PRIMARY, s); -#else - return false; // unsupported -#endif + const std::string utf8 = wstring_to_utf8str(text); + return SDL_SetPrimarySelectionText(utf8.c_str()) == 0; // success == 0 } LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_resolutions) @@ -1692,9 +1401,6 @@ bool LLWindowSDL::convertCoords(LLCoordGL from, LLCoordScreen *to) return(convertCoords(from, &window_coord) && convertCoords(window_coord, to)); } - - - void LLWindowSDL::setupFailure(const std::string& text, const std::string& caption, U32 type) { destroyContext(); @@ -1899,7 +1605,7 @@ void check_vm_bloat() last_rss_size = this_rss_size; last_vm_size = this_vm_size; - finally: +finally: if (NULL != ptr) { free(ptr); @@ -2222,20 +1928,18 @@ void LLWindowSDL::gatherInput() updateCursor(); -#if LL_X11 // This is a good time to stop flashing the icon if our mFlashTimer has // expired. if (mFlashing && mFlashTimer.hasExpired()) { - x11_set_urgent(false); + SDL_FlashWindow(mWindow, SDL_FLASH_CANCEL); mFlashing = false; } -#endif // LL_X11 } static SDL_Cursor *makeSDLCursorFromBMP(const char *filename, int hotx, int hoty) { - SDL_Cursor *sdlcursor = NULL; + SDL_Cursor *sdlcursor = nullptr; SDL_Surface *bmpsurface; // Load cursor pixel data from BMP file @@ -2597,62 +2301,6 @@ LLSD LLWindowSDL::getNativeKeyData() } #endif // LL_DARWIN -#if LL_LINUX || LL_SOLARIS || __FreeBSD__ -// extracted from spawnWebBrowser for clarity and to eliminate -// compiler confusion regarding close(int fd) vs. LLWindow::close() -void exec_cmd(const std::string& cmd, const std::string& arg) -{ - char* const argv[] = {(char*)cmd.c_str(), (char*)arg.c_str(), NULL}; - fflush(NULL); - pid_t pid = fork(); - if (pid == 0) - { // child - // disconnect from stdin/stdout/stderr, or child will - // keep our output pipe undesirably alive if it outlives us. - // close(0); - // close(1); - // close(2); - // Reopen stdin, stdout, and stderr to /dev/null. - // It's good practice to always have those file - // descriptors open to something, lest the exec'd - // program actually try to use them. - FILE *result; - result = freopen("/dev/null","r",stdin); - if (result == NULL) - { - LL_WARNS() << "Error reopening stdin for web browser: " - << strerror(errno) << LL_ENDL; - } - result = freopen("/dev/null","w",stdout); - if (result == NULL) - { - LL_WARNS() << "Error reopening stdout for web browser: " - << strerror(errno) << LL_ENDL; - } - result = freopen("/dev/null","w",stderr); - if (result == NULL) - { - LL_WARNS() << "Error reopening stderr for web browser: " - << strerror(errno) << LL_ENDL; - } - // end ourself by running the command - execv(cmd.c_str(), argv); /* Flawfinder: ignore */ - // if execv returns at all, there was a problem. - LL_WARNS() << "execv failure when trying to start " << cmd << LL_ENDL; - _exit(1); // _exit because we don't want atexit() clean-up! - } else { - if (pid > 0) - { - // parent - wait for child to die - int childExitStatus; - waitpid(pid, &childExitStatus, 0); - } else { - LL_WARNS() << "fork failure." << LL_ENDL; - } - } -} -#endif - // Open a URL with the user's default web browser. // Must begin with protocol identifier. void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url, bool async) @@ -2676,69 +2324,14 @@ void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url, bool async) LL_INFOS() << "spawn_web_browser: " << escaped_url << LL_ENDL; -#if LL_LINUX || __FreeBSD__ -# if LL_X11 - if (mSDL_Display) + if (SDL_OpenURL(escaped_url.c_str()) != 0) { - maybe_lock_display(); - // Just in case - before forking. - XSync(mSDL_Display, False); - maybe_unlock_display(); - } -# endif // LL_X11 - - std::string cmd, arg; - cmd = gDirUtilp->getExecutableDir(); - cmd += gDirUtilp->getDirDelimiter(); - cmd += "launch_url.sh"; - arg = escaped_url; - exec_cmd(cmd, arg); - -#elif LL_DARWIN - - S32 result = 0; - CFURLRef urlRef = NULL; - - LL_INFOS() << "Opening URL " << escaped_url << LL_ENDL; - - CFStringRef stringRef = CFStringCreateWithCString(NULL, escaped_url.c_str(), kCFStringEncodingUTF8); - if (stringRef) - { - // This will succeed if the string is a full URL, including the http:// - // Note that URLs specified this way need to be properly percent-escaped. - urlRef = CFURLCreateWithString(NULL, stringRef, NULL); - - // Don't use CRURLCreateWithFileSystemPath -- only want valid URLs - - CFRelease(stringRef); + LL_WARNS() << "spawn_web_browser failed with error: " << SDL_GetError() << LL_ENDL; } - if (urlRef) - { - result = LSOpenCFURLRef(urlRef, NULL); - - if (result != noErr) - { - LL_INFOS() << "Error " << result << " on open." << LL_ENDL; - } - - CFRelease(urlRef); - } - else - { - LL_INFOS() << "Error: couldn't create URL." << LL_ENDL; - } - -#endif // LL_LINUX - LL_INFOS() << "spawn_web_browser returning." << LL_ENDL; } -void LLWindowSDL::openFile(const std::string& file_name) -{ - spawnWebBrowser("file://"+file_name,true); -} - void *LLWindowSDL::getPlatformWindow() { return NULL; diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h index 36bdf0e80a..f86a277391 100644 --- a/indra/llwindow/llwindowsdl.h +++ b/indra/llwindow/llwindowsdl.h @@ -182,8 +182,6 @@ public: void spawnWebBrowser(const std::string &escaped_url, bool async) override; - void openFile(const std::string &file_name); - void setTitle(const std::string title) override; static std::vector getDynamicFallbackFontList(); @@ -257,8 +255,6 @@ protected: void setupFailure(const std::string &text, const std::string &caption, U32 type); - void fixWindowSize(void); - U32 SDLCheckGrabbyKeys(U32 keysym, bool gain); bool SDLReallyCaptureInput(bool capture); @@ -289,45 +285,15 @@ protected: friend class LLWindowManager; private: -#if LL_X11 - - void x11_set_urgent(bool urgent); - bool mFlashing; LLTimer mFlashTimer; -#endif //LL_X11 - U32 mKeyVirtualKey; U32 mKeyModifiers; std::string mInputType; -public: -#if LL_X11 - - static Display *getSDLDisplay(); - - LLWString const &getPrimaryText() const { return mPrimaryClipboard; } - - LLWString const &getSecondaryText() const { return mSecondaryClipboard; } - - void clearPrimaryText() { mPrimaryClipboard.clear(); } - - void clearSecondaryText() { mSecondaryClipboard.clear(); } private: void tryFindFullscreenSize(int &aWidth, int &aHeight); - - void initialiseX11Clipboard(); - - bool getSelectionText(Atom selection, LLWString &text); - - bool getSelectionText(Atom selection, Atom type, LLWString &text); - - bool setSelectionText(Atom selection, const LLWString &text); - -#endif - LLWString mPrimaryClipboard; - LLWString mSecondaryClipboard; }; class LLSplashScreenSDL : public LLSplashScreen -- cgit v1.3 From 387c4012a10615da31f24784e9eb9c79a48529c4 Mon Sep 17 00:00:00 2001 From: Rye Cogtail Date: Sun, 29 Sep 2024 01:03:24 -0400 Subject: Implement various missing functions and callbacks in SDL window backend --- indra/llwindow/llwindowsdl.cpp | 166 +++++++++++++++++++---------------------- 1 file changed, 75 insertions(+), 91 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index be98a0d6e0..54abd10490 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -798,7 +798,6 @@ LLWindowSDL::~LLWindowSDL() void LLWindowSDL::show() { - // *FIX: What to do with SDL? if (mWindow) { SDL_ShowWindow(mWindow); @@ -807,7 +806,6 @@ void LLWindowSDL::show() void LLWindowSDL::hide() { - // *FIX: What to do with SDL? if (mWindow) { SDL_HideWindow(mWindow); @@ -817,7 +815,6 @@ void LLWindowSDL::hide() //virtual void LLWindowSDL::minimize() { - // *FIX: What to do with SDL? if (mWindow) { SDL_MinimizeWindow(mWindow); @@ -827,14 +824,12 @@ void LLWindowSDL::minimize() //virtual void LLWindowSDL::restore() { - // *FIX: What to do with SDL? if (mWindow) { SDL_RestoreWindow(mWindow); } } - // close() destroys all OS-specific code associated with a window. // Usually called from LLWindowManager::destroyWindow() void LLWindowSDL::close() @@ -860,56 +855,54 @@ bool LLWindowSDL::isValid() bool LLWindowSDL::getVisible() { bool result = false; - - // *FIX: This isn't really right... - // Then what is? if (mWindow) { - if( SDL_GetWindowFlags(mWindow) & SDL_WINDOW_SHOWN ) result = true; + Uint32 flags = SDL_GetWindowFlags(mWindow); + if (flags & SDL_WINDOW_SHOWN) + { + result = TRUE; + } } - - return(result); + return result; } bool LLWindowSDL::getMinimized() { bool result = false; - - if (mWindow/*&& (1 == mIsMinimized)*/) + if (mWindow) { - if( SDL_GetWindowFlags(mWindow) & SDL_WINDOW_MINIMIZED ) result = true; + Uint32 flags = SDL_GetWindowFlags(mWindow); + if (flags & SDL_WINDOW_MINIMIZED) + { + result = true; + } } - - mIsMinimized = result; - return(result); + return result; } bool LLWindowSDL::getMaximized() { bool result = false; - if (mWindow) { - // TODO - if( SDL_GetWindowFlags(mWindow) & SDL_WINDOW_MAXIMIZED ) result = true; - else result = false; + Uint32 flags = SDL_GetWindowFlags(mWindow); + if (flags & SDL_WINDOW_MAXIMIZED) + { + result = true; + } } - return(result); + return result; } bool LLWindowSDL::maximize() { - // TODO - bool result = false; - if (mWindow) { SDL_MaximizeWindow(mWindow); - result = true; + return TRUE; } - - return result; + return FALSE; } bool LLWindowSDL::getFullscreen() @@ -919,10 +912,12 @@ bool LLWindowSDL::getFullscreen() bool LLWindowSDL::getPosition(LLCoordScreen *position) { - // *FIX: can anything be done with this? - position->mX = 0; - position->mY = 0; - return true; + if (mWindow) + { + SDL_GetWindowPosition(mWindow, &position->mX, &position->mY); + return true; + } + return false; } bool LLWindowSDL::getSize(LLCoordScreen *size) @@ -957,17 +952,13 @@ bool LLWindowSDL::getSize(LLCoordWindow *size) bool LLWindowSDL::setPosition(const LLCoordScreen position) { - bool result = false; - - if(mWindow) + if (mWindow) { - // *FIX: (?) - //MacMoveWindow(mWindow, position.mX, position.mY, false); SDL_SetWindowPosition(mWindow, position.mX, position.mY); - result = true; + return true; } - return result; + return false; } template< typename T > bool setSizeImpl( const T& newSize, SDL_Window *pWin ) @@ -1024,28 +1015,33 @@ void LLWindowSDL::setFSAASamples(const U32 samples) F32 LLWindowSDL::getGamma() { - return 1/mGamma; + return 1.f / mGamma; } bool LLWindowSDL::restoreGamma() { - //CGDisplayRestoreColorSyncSettings(); - // SDL_SetGamma(1.0f, 1.0f, 1.0f); - Uint16 ramp; - SDL_CalculateGammaRamp(1.0f, &ramp); - SDL_SetWindowGammaRamp(mWindow, &ramp, &ramp, &ramp); + if (mWindow) + { + Uint16 ramp[256]; + SDL_CalculateGammaRamp(1.f, ramp); + SDL_SetWindowGammaRamp(mWindow, ramp, ramp, ramp); + } return true; } bool LLWindowSDL::setGamma(const F32 gamma) { - mGamma = gamma; - if (mGamma == 0) mGamma = 0.1f; - mGamma = 1/mGamma; - // SDL_SetGamma(mGamma, mGamma, mGamma); - Uint16 ramp; - SDL_CalculateGammaRamp(mGamma, &ramp); - SDL_SetWindowGammaRamp(mWindow, &ramp, &ramp, &ramp); + if (mWindow) + { + Uint16 ramp[256]; + + mGamma = gamma; + if (mGamma == 0) mGamma = 0.1f; + mGamma = 1.f / mGamma; + + SDL_CalculateGammaRamp(mGamma, ramp); + SDL_SetWindowGammaRamp(mWindow, ramp, ramp, ramp); + } return true; } @@ -1054,10 +1050,8 @@ bool LLWindowSDL::isCursorHidden() return mCursorHidden; } - - // Constrains the mouse to the window. -void LLWindowSDL::setMouseClipping( bool b ) +void LLWindowSDL::setMouseClipping(bool b) { //SDL_WM_GrabInput(b ? SDL_GRAB_ON : SDL_GRAB_OFF); } @@ -1067,18 +1061,10 @@ void LLWindowSDL::setMinSize(U32 min_width, U32 min_height, bool enforce_immedia { LLWindow::setMinSize(min_width, min_height, enforce_immediately); -#if LL_X11 - // Set the minimum size limits for X11 window - // so the window manager doesn't allow resizing below those limits. - XSizeHints* hints = XAllocSizeHints(); - hints->flags |= PMinSize; - hints->min_width = mMinWindowWidth; - hints->min_height = mMinWindowHeight; - - XSetWMNormalHints(mSDL_Display, mSDL_XWindowID, hints); - - XFree(hints); -#endif + if (mWindow && min_width > 0 && min_height > 0) + { + SDL_SetWindowMinimumSize(mWindow, mMinWindowWidth, mMinWindowHeight); + } } bool LLWindowSDL::setCursorPosition(const LLCoordWindow position) @@ -2030,10 +2016,13 @@ void LLWindowSDL::updateCursor() sdlcursor = mSDLCursors[UI_CURSOR_ARROW]; if (sdlcursor) SDL_SetCursor(sdlcursor); - } else { + + mCurrentCursor = mNextCursor; + } + else + { LL_WARNS() << "Tried to set invalid cursor number " << mNextCursor << LL_ENDL; } - mCurrentCursor = mNextCursor; } } @@ -2043,24 +2032,24 @@ void LLWindowSDL::initCursors() // Blank the cursor pointer array for those we may miss. for (i=0; i Date: Sun, 29 Sep 2024 03:16:54 -0400 Subject: Clean up SDL window event handling and implement missing functionality Horizontal Scrollwheels Proper extra mouse button handling SDL native double click handling --- indra/llwindow/llwindowsdl.cpp | 183 +++++++++++++---------------------------- 1 file changed, 58 insertions(+), 125 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 54abd10490..4ca4fc6001 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -1099,7 +1099,6 @@ bool LLWindowSDL::getCursorPosition(LLCoordWindow *position) //Point cursor_point; LLCoordScreen screen_pos; - //GetMouse(&cursor_point); int x, y; SDL_GetMouseState(&x, &y); @@ -1627,11 +1626,6 @@ void LLWindowSDL::processMiscNativeEvents() void LLWindowSDL::gatherInput() { - const Uint32 CLICK_THRESHOLD = 300; // milliseconds - static int leftClick = 0; - static int rightClick = 0; - static Uint32 lastLeftDown = 0; - static Uint32 lastRightDown = 0; SDL_Event event; // Handle all outstanding SDL events @@ -1640,13 +1634,21 @@ void LLWindowSDL::gatherInput() switch (event.type) { case SDL_MOUSEWHEEL: + { if( event.wheel.y != 0 ) + { mCallbacks->handleScrollWheel(this, -event.wheel.y); + } + if (event.wheel.x != 0) + { + mCallbacks->handleScrollHWheel(this, -event.wheel.x); + } break; + } case SDL_MOUSEMOTION: { - LLCoordWindow winCoord(event.button.x, event.button.y); + LLCoordWindow winCoord(event.motion.x, event.motion.y); LLCoordGL openGlCoord; convertCoords(winCoord, &openGlCoord); @@ -1725,7 +1727,6 @@ void LLWindowSDL::gatherInput() case SDL_MOUSEBUTTONDOWN: { - bool isDoubleClick = false; LLCoordWindow winCoord(event.button.x, event.button.y); LLCoordGL openGlCoord; convertCoords(winCoord, &openGlCoord); @@ -1735,58 +1736,25 @@ void LLWindowSDL::gatherInput() MASK mask = gKeyboard->currentMask(true); - if (event.button.button == SDL_BUTTON_LEFT) // SDL doesn't manage double clicking... - { - Uint32 now = SDL_GetTicks(); - if ((now - lastLeftDown) > CLICK_THRESHOLD) - leftClick = 1; - else - { - if (++leftClick >= 2) - { - leftClick = 0; - isDoubleClick = true; - } - } - lastLeftDown = now; - } - else if (event.button.button == SDL_BUTTON_RIGHT) - { - Uint32 now = SDL_GetTicks(); - if ((now - lastRightDown) > CLICK_THRESHOLD) - rightClick = 1; - else - { - if (++rightClick >= 2) - { - rightClick = 0; - isDoubleClick = true; - } - } - lastRightDown = now; - } - if (event.button.button == SDL_BUTTON_LEFT) // left { - if (isDoubleClick) + if (event.button.clicks >= 2) mCallbacks->handleDoubleClick(this, openGlCoord, mask); else mCallbacks->handleMouseDown(this, openGlCoord, mask); } - else if (event.button.button == SDL_BUTTON_RIGHT) // right { mCallbacks->handleRightMouseDown(this, openGlCoord, mask); } - else if (event.button.button == SDL_BUTTON_MIDDLE) // middle { mCallbacks->handleMiddleMouseDown(this, openGlCoord, mask); } - else if (event.button.button == 4) // mousewheel up...thanks to X11 for making SDL consider these "buttons". - mCallbacks->handleScrollWheel(this, -1); - else if (event.button.button == 5) // mousewheel down...thanks to X11 for making SDL consider these "buttons". - mCallbacks->handleScrollWheel(this, 1); + else + { + mCallbacks->handleOtherMouseDown(this, openGlCoord, mask, event.button.button); + } break; } @@ -1803,99 +1771,64 @@ void LLWindowSDL::gatherInput() MASK mask = gKeyboard->currentMask(true); if (event.button.button == SDL_BUTTON_LEFT) // left + { mCallbacks->handleMouseUp(this, openGlCoord, mask); + } else if (event.button.button == SDL_BUTTON_RIGHT) // right + { mCallbacks->handleRightMouseUp(this, openGlCoord, mask); + } else if (event.button.button == SDL_BUTTON_MIDDLE) // middle + { mCallbacks->handleMiddleMouseUp(this, openGlCoord, mask); - // don't handle mousewheel here... + } + else + { + mCallbacks->handleOtherMouseUp(this, openGlCoord, mask, event.button.button); + } break; } - case SDL_WINDOWEVENT: // *FIX: handle this? + case SDL_WINDOWEVENT: { - if( event.window.event == SDL_WINDOWEVENT_RESIZED - /* || event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED*/ ) // SDL_WINDOWEVENT_SIZE_CHANGED is followed by SDL_WINDOWEVENT_RESIZED, so handling one shall be enough + switch(event.window.event) { - LL_INFOS() << "Handling a resize event: " << event.window.data1 << "x" << event.window.data2 << LL_ENDL; - - S32 width = llmax(event.window.data1, (S32)mMinWindowWidth); - S32 height = llmax(event.window.data2, (S32)mMinWindowHeight); - - // *FIX: I'm not sure this is necessary! - // I think is is not - // SDL_SetWindowSize(mWindow, width, height); - // - - mCallbacks->handleResize(this, width * getSystemUISize(), height * getSystemUISize()); - } - else if(event.window.event == SDL_WINDOWEVENT_ENTER) - { - LL_INFOS() << "SDL_WINDOWEVENT_ENTER" << LL_ENDL; - if(!mHaveInputFocus) mCallbacks->handleFocus(this); - mHaveInputFocus = true; - } - else if(event.window.event == SDL_WINDOWEVENT_LEAVE) - { - LL_INFOS() << "SDL_WINDOWEVENT_LEAVE" << LL_ENDL; - if(mHaveInputFocus) mCallbacks->handleFocusLost(this); - mHaveInputFocus = false; - } - else if( event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED ) // What about SDL_WINDOWEVENT_ENTER (mouse focus) - { - // We have to do our own state massaging because SDL - // can send us two unfocus events in a row for example, - // which confuses the focus code [SL-24071]. - mHaveInputFocus = true; - - mCallbacks->handleFocus(this); - } - else if( event.window.event == SDL_WINDOWEVENT_FOCUS_LOST ) // What about SDL_WINDOWEVENT_LEAVE (mouse focus) - { - // We have to do our own state massaging because SDL - // can send us two unfocus events in a row for example, - // which confuses the focus code [SL-24071]. - mHaveInputFocus = false; - - mCallbacks->handleFocusLost(this); - } - /* - - Bug : the app remains inactive when maximized .. - - else if(event.window.event == SDL_WINDOWEVENT_MINIMIZED) - { - LL_INFOS() << "SDL_WINDOWEVENT_MINIMIZED" << LL_ENDL; - if(!mIsMinimized) mCallbacks->handleActivate(this,false); - mIsMinimized = true; - } - else if(event.window.event == SDL_WINDOWEVENT_MAXIMIZED) - { - LL_INFOS() << "SDL_WINDOWEVENT_MAXIMIZED" << LL_ENDL; - if(mIsMinimized) mCallbacks->handleActivate(this,true); - mIsMinimized = false; - } - */ - else if (event.window.event == SDL_WINDOWEVENT_EXPOSED) - { - int w, h; - SDL_GL_GetDrawableSize(mWindow, &w, &h); + //case SDL_WINDOWEVENT_SIZE_CHANGED: SDL_WINDOWEVENT_SIZE_CHANGED is followed by SDL_WINDOWEVENT_RESIZED, so handling one shall be enough + case SDL_WINDOWEVENT_RESIZED: + { + LL_INFOS() << "Handling a resize event: " << event.window.data1 << "x" << event.window.data2 << LL_ENDL; + S32 width = llmax(event.window.data1, (S32)mMinWindowWidth); + S32 height = llmax(event.window.data2, (S32)mMinWindowHeight); - mCallbacks->handlePaint(this, 0, 0, w, h); - } - else if( event.window.event == SDL_WINDOWEVENT_MINIMIZED || - event.window.event == SDL_WINDOWEVENT_MAXIMIZED || - event.window.event == SDL_WINDOWEVENT_RESTORED || - event.window.event == SDL_WINDOWEVENT_EXPOSED || - event.window.event == SDL_WINDOWEVENT_SHOWN ) - { - mIsMinimized = (event.window.event == SDL_WINDOWEVENT_MINIMIZED); + mCallbacks->handleResize(this, width * getSystemUISize(), height * getSystemUISize()); + break; + } + case SDL_WINDOWEVENT_LEAVE: + mCallbacks->handleMouseLeave(this); + break; + case SDL_WINDOWEVENT_FOCUS_GAINED: + mCallbacks->handleFocus(this); + break; + case SDL_WINDOWEVENT_FOCUS_LOST: + mCallbacks->handleFocusLost(this); + break; + case SDL_WINDOWEVENT_EXPOSED: + case SDL_WINDOWEVENT_SHOWN: + case SDL_WINDOWEVENT_HIDDEN: + case SDL_WINDOWEVENT_MINIMIZED: + case SDL_WINDOWEVENT_MAXIMIZED: + case SDL_WINDOWEVENT_RESTORED: + { + Uint32 flags = SDL_GetWindowFlags(mWindow); + bool minimized = (flags & SDL_WINDOW_MINIMIZED); + bool hidden = (flags & SDL_WINDOW_HIDDEN); - mCallbacks->handleActivate(this, !mIsMinimized); - LL_INFOS() << "SDL deiconification state switched to " << mIsMinimized << LL_ENDL; + mCallbacks->handleActivate(this, !minimized || !hidden); + LL_INFOS() << "SDL deiconification state switched to " << minimized << LL_ENDL; + break; + } } - break; } case SDL_QUIT: -- cgit v1.3 From 300e52d800112fab9f0137d067e9117bb2f9bba8 Mon Sep 17 00:00:00 2001 From: Rye Cogtail Date: Sun, 29 Sep 2024 03:17:43 -0400 Subject: Fix shutdown crash from failing to clean up SDL window properly --- indra/llwindow/llwindowsdl.cpp | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 4ca4fc6001..982f10503e 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -765,7 +765,13 @@ void LLWindowSDL::destroyContext() { LL_INFOS() << "destroyContext begins" << LL_ENDL; + // Stop unicode input SDL_StopTextInput(); + + // Clean up remaining GL state before blowing away window + LL_INFOS() << "shutdownGL begins" << LL_ENDL; + gGLManager.shutdownGL(); + #if LL_X11 mSDL_Display = NULL; mSDL_XWindowID = None; @@ -773,18 +779,38 @@ void LLWindowSDL::destroyContext() Unlock_Display = NULL; #endif // LL_X11 - // Clean up remaining GL state before blowing away window - LL_INFOS() << "shutdownGL begins" << LL_ENDL; - gGLManager.shutdownGL(); + LL_INFOS() << "Destroying SDL cursors" << LL_ENDL; + quitCursors(); + + if (mContext) + { + LL_INFOS() << "Destroying SDL GL Context" << LL_ENDL; + SDL_GL_DeleteContext(mContext); + mContext = nullptr; + } + else + { + LL_INFOS() << "SDL GL Context already destroyed" << LL_ENDL; + } + + if (mWindow) + { + LL_INFOS() << "Destroying SDL Window" << LL_ENDL; + SDL_DestroyWindow(mWindow); + mWindow = nullptr; + } + else + { + LL_INFOS() << "SDL Window already destroyed" << LL_ENDL; + } + LL_INFOS() << "destroyContext end" << LL_ENDL; + LL_INFOS() << "SDL_QuitSS/VID begins" << LL_ENDL; SDL_QuitSubSystem(SDL_INIT_VIDEO); // *FIX: this might be risky... - - mWindow = NULL; } LLWindowSDL::~LLWindowSDL() { - quitCursors(); destroyContext(); if(mSupportedResolutions != NULL) @@ -999,8 +1025,9 @@ void LLWindowSDL::swapBuffers() { if (mWindow) { - SDL_GL_SwapWindow( mWindow ); + SDL_GL_SwapWindow(mWindow); } + LL_PROFILER_GPU_COLLECT; } U32 LLWindowSDL::getFSAASamples() -- cgit v1.3 From 643e3d13dda050e20ae4535f67f99a134d53419a Mon Sep 17 00:00:00 2001 From: Rye Cogtail Date: Sun, 29 Sep 2024 03:19:43 -0400 Subject: Clean up SDL window creation and fix various bugs Add support for Core and Debug GL context creation Fix window position support Fix vsync handling Add minimum GL context support --- indra/llwindow/llwindow.cpp | 2 +- indra/llwindow/llwindowsdl.cpp | 283 ++++++++++++++++++++++------------------- indra/llwindow/llwindowsdl.h | 2 +- 3 files changed, 152 insertions(+), 135 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp index 302d038a79..4f3cc69c75 100644 --- a/indra/llwindow/llwindow.cpp +++ b/indra/llwindow/llwindow.cpp @@ -421,7 +421,7 @@ LLWindow* LLWindowManager::createWindow( fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth); #elif LL_SDL new_window = new LLWindowSDL(callbacks, - title, x, y, width, height, flags, + title, name, x, y, width, height, flags, fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); #elif LL_WINDOWS new_window = new LLWindowWin32(callbacks, diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 982f10503e..3495b8347d 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -153,7 +153,7 @@ Display* LLWindowSDL::get_SDL_Display(void) #endif // LL_X11 LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks, - const std::string& title, S32 x, S32 y, S32 width, + const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, bool fullscreen, bool clearBg, bool enable_vsync, bool use_gl, @@ -191,7 +191,7 @@ LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks, mOriginalAspectRatio = 1024.0 / 768.0; if (title.empty()) - mWindowTitle = "SDL Window"; // *FIX: (?) + mWindowTitle = "Second Life"; else mWindowTitle = title; @@ -488,6 +488,10 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b width = 1024; if (height == 0) width = 768; + if (x == 0) + x = SDL_WINDOWPOS_UNDEFINED; + if (y == 0) + y = SDL_WINDOWPOS_UNDEFINED; mFullscreen = fullscreen; @@ -503,23 +507,22 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b mSDLFlags = sdlflags; + // Setup default backing colors GLint redBits{8}, greenBits{8}, blueBits{8}, alphaBits{8}; - GLint depthBits{(bits <= 16) ? 16 : 24}, stencilBits{8}; if (getenv("LL_GL_NO_STENCIL")) stencilBits = 0; - SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, alphaBits); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, redBits); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, greenBits); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, blueBits); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, depthBits ); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, alphaBits); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, depthBits); // We need stencil support for a few (minor) things. if (stencilBits) SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, stencilBits); - // *FIX: try to toggle vsync here? SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); #if LL_DARWIN @@ -531,30 +534,51 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - if (mFSAASamples > 0) + if (LLRender::sGLCoreProfile) { - SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); - SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, mFSAASamples); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); } + // This is requesting a minimum context version + int major_gl_version = 3; + int minor_gl_version = 2; + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major_gl_version); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor_gl_version); + + U32 context_flags = 0; + if (gDebugGL) + { + context_flags |= SDL_GL_CONTEXT_DEBUG_FLAG; + } + SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, context_flags); SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1); - mWindow = SDL_CreateWindow( mWindowTitle.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, mSDLFlags ); - if( mWindow ) + // Create the window + mWindow = SDL_CreateWindow(mWindowTitle.c_str(), x, y, width, height, mSDLFlags); + if (mWindow == nullptr) { - mContext = SDL_GL_CreateContext( mWindow ); + LL_WARNS() << "Window creation failure. SDL: " << SDL_GetError() << LL_ENDL; + setupFailure("Window creation error", "Error", OSMB_OK); + return FALSE; + } - if( mContext == 0 ) - { - LL_WARNS() << "Cannot create GL context " << SDL_GetError() << LL_ENDL; - setupFailure("GL Context creation error creation error", "Error", OSMB_OK); - return false; - } - // SDL_GL_SetSwapInterval(1); + // Create the context + mContext = SDL_GL_CreateContext(mWindow); + if(!mContext) + { + LL_WARNS() << "Cannot create GL context " << SDL_GetError() << LL_ENDL; + setupFailure("GL Context creation error", "Error", OSMB_OK); + return false; } + if (SDL_GL_MakeCurrent(mWindow, mContext) != 0) + { + LL_WARNS() << "Failed to make context current. SDL: " << SDL_GetError() << LL_ENDL; + setupFailure("GL Context failed to set current failure", "Error", OSMB_OK); + return FALSE; + } - if( mFullscreen ) + if(mFullscreen) { if (mWindow) { @@ -598,70 +622,6 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b } } - // Set the application icon. - SDL_Surface *bmpsurface; - bmpsurface = Load_BMP_Resource("ll_icon.BMP"); - if (bmpsurface) - { - SDL_SetWindowIcon(mWindow, bmpsurface); - SDL_FreeSurface(bmpsurface); - bmpsurface = NULL; - } - - // Detect video memory size. -# if LL_X11 - gGLManager.mVRAM = x11_detect_VRAM_kb() / 1024; - if (gGLManager.mVRAM != 0) - { - LL_INFOS() << "X11 log-parser detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL; - } else - { - PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger; - queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) - glXGetProcAddressARB((const GLubyte *)"glXQueryCurrentRendererIntegerMESA"); - unsigned int vram_megabytes = 0; - queryInteger(GLX_RENDERER_VIDEO_MEMORY_MESA, &vram_megabytes); - if (!vram_megabytes) { - glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, (int *)&vram_megabytes); - vram_megabytes /= 1024; - } - if (!vram_megabytes) { - glGetIntegerv(GL_VBO_FREE_MEMORY_ATI, (int *)&vram_megabytes); - vram_megabytes /= 1024; - } - gGLManager.mVRAM = vram_megabytes; - } -#elif LL_DARWIN - CGLRendererInfoObj info = 0; - GLint vram_megabytes = 0; - int num_renderers = 0; - auto err = CGLQueryRendererInfo(CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay), - &info, &num_renderers); - if (!err) { - CGLDescribeRenderer(info, 0, kCGLRPVideoMemoryMegabytes, &vram_megabytes); - CGLDestroyRendererInfo(info); - } else - vram_megabytes = 256; - gGLManager.mVRAM = vram_megabytes; -# endif // LL_X11 -/* - { - // fallback to letting SDL detect VRAM. - // note: I've not seen SDL's detection ever actually find - // VRAM != 0, but if SDL *does* detect it then that's a bonus. - gGLManager.mVRAM = 0; - if (gGLManager.mVRAM != 0) - { - LL_INFOS() << "SDL detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL; - } - } -*/ - // If VRAM is not detected, that is handled later - - // *TODO: Now would be an appropriate time to check for some - // explicitly unsupported cards. - //const char* RENDERER = (const char*) glGetString(GL_RENDERER); - SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &redBits); SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &greenBits); SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &blueBits); @@ -697,6 +657,20 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b #endif } + LL_PROFILER_GPU_CONTEXT; + + // Enable vertical sync + toggleVSync(enable_vsync); + + // Set the application icon. + SDL_Surface* bmpsurface = Load_BMP_Resource("ll_icon.BMP"); + if (bmpsurface) + { + SDL_SetWindowIcon(mWindow, bmpsurface); + SDL_FreeSurface(bmpsurface); + bmpsurface = NULL; + } + #if LL_X11 /* Grab the window manager specific information */ SDL_SysWMinfo info; @@ -722,6 +696,58 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b } #endif // LL_X11 + // Detect video memory size. +# if LL_X11 + gGLManager.mVRAM = x11_detect_VRAM_kb() / 1024; + if (gGLManager.mVRAM != 0) + { + LL_INFOS() << "X11 log-parser detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL; + } else + { + PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger; + queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)glXGetProcAddressARB((const GLubyte *)"glXQueryCurrentRendererIntegerMESA"); + unsigned int vram_megabytes = 0; + queryInteger(GLX_RENDERER_VIDEO_MEMORY_MESA, &vram_megabytes); + if (!vram_megabytes) + { + glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, (int *)&vram_megabytes); + vram_megabytes /= 1024; + } + if (!vram_megabytes) + { + glGetIntegerv(GL_VBO_FREE_MEMORY_ATI, (int *)&vram_megabytes); + vram_megabytes /= 1024; + } + gGLManager.mVRAM = vram_megabytes; + } +#elif LL_DARWIN + CGLRendererInfoObj info = 0; + GLint vram_megabytes = 0; + int num_renderers = 0; + auto err = CGLQueryRendererInfo(CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay), + &info, &num_renderers); + if (!err) + { + CGLDescribeRenderer(info, 0, kCGLRPVideoMemoryMegabytes, &vram_megabytes); + CGLDestroyRendererInfo(info); + } + else + { + vram_megabytes = 256; + } + gGLManager.mVRAM = vram_megabytes; +# endif // LL_X11 + { + // fallback to letting SDL detect VRAM. + // note: I've not seen SDL's detection ever actually find + // VRAM != 0, but if SDL *does* detect it then that's a bonus. + gGLManager.mVRAM = 0; + if (gGLManager.mVRAM != 0) + { + LL_INFOS() << "SDL detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL; + } + } + // If VRAM is not detected, that is handled later SDL_StartTextInput(); //make sure multisampling is disabled by default @@ -733,6 +759,45 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b return true; } +void* LLWindowSDL::createSharedContext() +{ + SDL_GLContext pContext = SDL_GL_CreateContext(mWindow); + if (pContext) + { + LL_DEBUGS() << "Creating shared OpenGL context successful!" << LL_ENDL; + return (void*)pContext; + } + + LL_WARNS() << "Creating shared OpenGL context failed!" << LL_ENDL; + return nullptr; +} + +void LLWindowSDL::makeContextCurrent(void* contextPtr) +{ + SDL_GL_MakeCurrent(mWindow, contextPtr); + LL_PROFILER_GPU_CONTEXT; +} + +void LLWindowSDL::destroySharedContext(void* contextPtr) +{ + SDL_GL_DeleteContext(contextPtr); +} + +void LLWindowSDL::toggleVSync(bool enable_vsync) +{ + if (!enable_vsync) + { + LL_INFOS("Window") << "Disabling vertical sync" << LL_ENDL; + SDL_GL_SetSwapInterval(0); + SDL_SetHintWithPriority(SDL_HINT_RENDER_VSYNC,"0",SDL_HINT_OVERRIDE); + } + else + { + LL_INFOS("Window") << "Enabling vertical sync" << LL_ENDL; + SDL_GL_SetSwapInterval(1); + SDL_SetHintWithPriority(SDL_HINT_RENDER_VSYNC,"1",SDL_HINT_OVERRIDE); + } +} // changing fullscreen resolution, or switching between windowed and fullscreen mode. bool LLWindowSDL::switchContext(bool fullscreen, const LLCoordScreen &size, bool enable_vsync, const LLCoordScreen * const posp) @@ -745,7 +810,7 @@ bool LLWindowSDL::switchContext(bool fullscreen, const LLCoordScreen &size, bool if(needsRebuild) { destroyContext(); - result = createContext(0, 0, size.mX, size.mY, 0, fullscreen, enable_vsync); + result = createContext(0, 0, size.mX, size.mY, 32, fullscreen, enable_vsync); if (result) { gGLManager.initGL(); @@ -2398,54 +2463,6 @@ std::vector LLWindowSDL::getDynamicFallbackFontList() return rtns; } - -void* LLWindowSDL::createSharedContext() -{ - auto *pContext = SDL_GL_CreateContext(mWindow); - if ( pContext) - { - SDL_GL_SetSwapInterval(0); - SDL_GL_MakeCurrent(mWindow, mContext); - - LLCoordScreen size; - if (getSize(&size)) - setSize(size); - - LL_DEBUGS() << "Creating shared OpenGL context successful!" << LL_ENDL; - - return (void*)pContext; - } - - LL_WARNS() << "Creating shared OpenGL context failed!" << LL_ENDL; - - return nullptr; -} - -void LLWindowSDL::makeContextCurrent(void* contextPtr) -{ - LL_PROFILER_GPU_CONTEXT; - SDL_GL_MakeCurrent( mWindow, contextPtr ); -} - -void LLWindowSDL::destroySharedContext(void* contextPtr) -{ - SDL_GL_DeleteContext( contextPtr ); -} - -void LLWindowSDL::toggleVSync(bool enable_vsync) -{ - if( !enable_vsync) - { - SDL_GL_SetSwapInterval(0); - SDL_SetHintWithPriority(SDL_HINT_RENDER_VSYNC,"0",SDL_HINT_OVERRIDE); - } - else - { - SDL_GL_SetSwapInterval(1); - SDL_SetHintWithPriority(SDL_HINT_RENDER_VSYNC,"1",SDL_HINT_OVERRIDE); - } -} - void LLWindowSDL::setLanguageTextInput(const LLCoordGL& position) { LLCoordWindow win_pos; diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h index f86a277391..144216f658 100644 --- a/indra/llwindow/llwindowsdl.h +++ b/indra/llwindow/llwindowsdl.h @@ -219,7 +219,7 @@ public: protected: LLWindowSDL(LLWindowCallbacks *callbacks, - const std::string &title, int x, int y, int width, int height, U32 flags, + const std::string &title, const std::string& name, int x, int y, int width, int height, U32 flags, bool fullscreen, bool clearBg, bool enable_vsync, bool use_gl, bool ignore_pixel_depth, U32 fsaa_samples); -- cgit v1.3 From 883ca816ce7398ae26e1c87bb403d2586fcce8f2 Mon Sep 17 00:00:00 2001 From: Rye Cogtail Date: Sun, 29 Sep 2024 04:14:39 -0400 Subject: Clean up old linux workarounds --- indra/llwindow/llwindowsdl.cpp | 26 ++++++-------------------- indra/newview/linux_tools/wrapper.sh | 23 ----------------------- 2 files changed, 6 insertions(+), 43 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 3495b8347d..3ac0a2eab1 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -61,9 +61,6 @@ extern bool gDebugWindowProc; const S32 MAX_NUM_RESOLUTIONS = 200; -// static variable for ATI mouse cursor crash work-around: -static bool ATIbug = false; - #if LL_DARWIN #include @@ -1843,10 +1840,10 @@ void LLWindowSDL::gatherInput() { mCallbacks->handleMiddleMouseDown(this, openGlCoord, mask); } - else - { + else + { mCallbacks->handleOtherMouseDown(this, openGlCoord, mask, event.button.button); - } + } break; } @@ -1874,10 +1871,10 @@ void LLWindowSDL::gatherInput() { mCallbacks->handleMiddleMouseUp(this, openGlCoord, mask); } - else - { + else + { mCallbacks->handleOtherMouseUp(this, openGlCoord, mask, event.button.button); - } + } break; } @@ -2024,12 +2021,6 @@ static SDL_Cursor *makeSDLCursorFromBMP(const char *filename, int hotx, int hoty void LLWindowSDL::updateCursor() { - if (ATIbug) { - // cursor-updating is very flaky when this bug is - // present; do nothing. - return; - } - if (mCurrentCursor != mNextCursor) { if (mNextCursor < UI_CURSOR_COUNT) @@ -2107,11 +2098,6 @@ void LLWindowSDL::initCursors() mSDLCursors[UI_CURSOR_TOOLPATHFINDING_PATH_END] = makeSDLCursorFromBMP("lltoolpathfindingpathend.BMP", 16, 16); mSDLCursors[UI_CURSOR_TOOLPATHFINDING_PATH_END_ADD] = makeSDLCursorFromBMP("lltoolpathfindingpathendadd.BMP", 16, 16); mSDLCursors[UI_CURSOR_TOOLNO] = makeSDLCursorFromBMP("llno.BMP",8,8); - - if (getenv("LL_ATI_MOUSE_CURSOR_BUG") != NULL) { - LL_INFOS() << "Disabling cursor updating due to LL_ATI_MOUSE_CURSOR_BUG" << LL_ENDL; - ATIbug = true; - } } void LLWindowSDL::quitCursors() diff --git a/indra/newview/linux_tools/wrapper.sh b/indra/newview/linux_tools/wrapper.sh index a027aaf6d1..3019e844d2 100755 --- a/indra/newview/linux_tools/wrapper.sh +++ b/indra/newview/linux_tools/wrapper.sh @@ -4,16 +4,9 @@ ## These options are for self-assisted troubleshooting during this beta ## testing phase; you should not usually need to touch them. -## - Avoids using any FMOD STUDIO audio driver. -#export LL_BAD_FMODSTUDIO_DRIVER=x ## - Avoids using any OpenAL audio driver. #export LL_BAD_OPENAL_DRIVER=x -## - Avoids using the FMOD Studio or FMOD Ex PulseAudio audio driver. -#export LL_BAD_FMOD_PULSEAUDIO=x -## - Avoids using the FMOD Studio or FMOD Ex ALSA audio driver. -#export LL_BAD_FMOD_ALSA=x - ## - Avoids the optional OpenGL extensions which have proven most problematic ## on some hardware. Disabling this option may cause BETTER PERFORMANCE but ## may also cause CRASHES and hangs on some unstable combinations of drivers @@ -34,16 +27,10 @@ ## LL_GL_BLACKLIST which solves your problems. #export LL_GL_BLACKLIST=abcdefghijklmno -## - Some ATI/Radeon users report random X server crashes when the mouse -## cursor changes shape. If you suspect that you are a victim of this -## driver bug, try enabling this option and report whether it helps: -#export LL_ATI_MOUSE_CURSOR_BUG=x - if [ "`uname -m`" = "x86_64" ]; then echo '64-bit Linux detected.' fi - ## Everything below this line is just for advanced troubleshooters. ##------------------------------------------------------------------- @@ -55,9 +42,6 @@ fi #export LL_WRAPPER='gdb --args' #export LL_WRAPPER='valgrind --smc-check=all --error-limit=no --log-file=secondlife.vg --leak-check=full --suppressions=/usr/lib/valgrind/glibc-2.5.supp --suppressions=secondlife-i686.supp' -## - Avoids an often-buggy X feature that doesn't really benefit us anyway. -export SDL_VIDEO_X11_DGAMOUSE=0 - ## - The 'scim' GTK IM module widely crashes the viewer. Avoid it. if [ "$GTK_IM_MODULE" = "scim" ]; then export GTK_IM_MODULE=xim @@ -67,13 +51,6 @@ if [ "$XMODIFIERS" = "" ]; then export XMODIFIERS="@im=fcitx" fi -## - Automatically work around the ATI mouse cursor crash bug: -## (this workaround is disabled as most fglrx users do not see the bug) -#if lsmod | grep fglrx &>/dev/null ; then -# export LL_ATI_MOUSE_CURSOR_BUG=x -#fi - - ## Nothing worth editing below this line. ##------------------------------------------------------------------- -- cgit v1.3 From e599dc3fc04e7ff48a215643920ec79fe2f99087 Mon Sep 17 00:00:00 2001 From: Rye Cogtail Date: Tue, 1 Oct 2024 02:16:23 -0400 Subject: Clean up more dead X11 code from SDL impl and modernize mouse capture with SDL_CaptureMouse --- indra/llwindow/llwindowsdl.cpp | 233 +++++------------------------------------ 1 file changed, 25 insertions(+), 208 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 3ac0a2eab1..dd4a7593a3 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -229,145 +229,6 @@ static SDL_Surface *Load_BMP_Resource(const char *basename) return SDL_LoadBMP(path_buffer); } -#if LL_X11 -// This is an XFree86/XOrg-specific hack for detecting the amount of Video RAM -// on this machine. It works by searching /var/log/var/log/Xorg.?.log or -// /var/log/XFree86.?.log for a ': (VideoRAM ?|Memory): (%d+) kB' regex, where -// '?' is the X11 display number derived from $DISPLAY -static int x11_detect_VRAM_kb_fp(FILE *fp, const char *prefix_str) -{ - const int line_buf_size = 1000; - char line_buf[line_buf_size]; - while (fgets(line_buf, line_buf_size, fp)) - { - //LL_DEBUGS() << "XLOG: " << line_buf << LL_ENDL; - - // Why the ad-hoc parser instead of using a regex? Our - // favourite regex implementation - libboost_regex - is - // quite a heavy and troublesome dependency for the client, so - // it seems a shame to introduce it for such a simple task. - // *FIXME: libboost_regex is a dependency now anyway, so we may - // as well use it instead of this hand-rolled nonsense. - const char *part1_template = prefix_str; - const char part2_template[] = " kB"; - char *part1 = strstr(line_buf, part1_template); - if (part1) // found start of matching line - { - part1 = &part1[strlen(part1_template)]; // -> after - char *part2 = strstr(part1, part2_template); - if (part2) // found end of matching line - { - // now everything between part1 and part2 is - // supposed to be numeric, describing the - // number of kB of Video RAM supported - int rtn = 0; - for (; part1 < part2; ++part1) - { - if (*part1 < '0' || *part1 > '9') - { - // unexpected char, abort parse - rtn = 0; - break; - } - rtn *= 10; - rtn += (*part1) - '0'; - } - if (rtn > 0) - { - // got the kB number. return it now. - return rtn; - } - } - } - } - return 0; // 'could not detect' -} - -static int x11_detect_VRAM_kb() -{ - std::string x_log_location("/var/log/"); - std::string fname; - int rtn = 0; // 'could not detect' - int display_num = 0; - FILE *fp; - char *display_env = getenv("DISPLAY"); // e.g. :0 or :0.0 or :1.0 etc - // parse DISPLAY number so we can go grab the right log file - if (display_env[0] == ':' && - display_env[1] >= '0' && display_env[1] <= '9') - { - display_num = display_env[1] - '0'; - } - - // *TODO: we could be smarter and see which of Xorg/XFree86 has the - // freshest time-stamp. - - // Try Xorg log first - fname = x_log_location; - fname += "Xorg."; - fname += ('0' + display_num); - fname += ".log"; - fp = fopen(fname.c_str(), "r"); - if (fp) - { - LL_INFOS() << "Looking in " << fname - << " for VRAM info..." << LL_ENDL; - rtn = x11_detect_VRAM_kb_fp(fp, ": VideoRAM: "); - fclose(fp); - if (0 == rtn) - { - fp = fopen(fname.c_str(), "r"); - if (fp) - { - rtn = x11_detect_VRAM_kb_fp(fp, ": Video RAM: "); - fclose(fp); - if (0 == rtn) - { - fp = fopen(fname.c_str(), "r"); - if (fp) - { - rtn = x11_detect_VRAM_kb_fp(fp, ": Memory: "); - fclose(fp); - } - } - } - } - } - else - { - LL_INFOS() << "Could not open " << fname - << " - skipped." << LL_ENDL; - // Try old XFree86 log otherwise - fname = x_log_location; - fname += "XFree86."; - fname += ('0' + display_num); - fname += ".log"; - fp = fopen(fname.c_str(), "r"); - if (fp) - { - LL_INFOS() << "Looking in " << fname - << " for VRAM info..." << LL_ENDL; - rtn = x11_detect_VRAM_kb_fp(fp, ": VideoRAM: "); - fclose(fp); - if (0 == rtn) - { - fp = fopen(fname.c_str(), "r"); - if (fp) - { - rtn = x11_detect_VRAM_kb_fp(fp, ": Memory: "); - fclose(fp); - } - } - } - else - { - LL_INFOS() << "Could not open " << fname - << " - skipped." << LL_ENDL; - } - } - return rtn; -} -#endif // LL_X11 - void LLWindowSDL::setTitle(const std::string title) { SDL_SetWindowTitle( mWindow, title.c_str() ); @@ -693,36 +554,27 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b } #endif // LL_X11 - // Detect video memory size. # if LL_X11 - gGLManager.mVRAM = x11_detect_VRAM_kb() / 1024; - if (gGLManager.mVRAM != 0) + PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger; + queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)glXGetProcAddressARB((const GLubyte *)"glXQueryCurrentRendererIntegerMESA"); + unsigned int vram_megabytes = 0; + queryInteger(GLX_RENDERER_VIDEO_MEMORY_MESA, &vram_megabytes); + if (!vram_megabytes) { - LL_INFOS() << "X11 log-parser detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL; - } else + glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, (int *)&vram_megabytes); + vram_megabytes /= 1024; + } + if (!vram_megabytes) { - PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger; - queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)glXGetProcAddressARB((const GLubyte *)"glXQueryCurrentRendererIntegerMESA"); - unsigned int vram_megabytes = 0; - queryInteger(GLX_RENDERER_VIDEO_MEMORY_MESA, &vram_megabytes); - if (!vram_megabytes) - { - glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, (int *)&vram_megabytes); - vram_megabytes /= 1024; - } - if (!vram_megabytes) - { - glGetIntegerv(GL_VBO_FREE_MEMORY_ATI, (int *)&vram_megabytes); - vram_megabytes /= 1024; - } - gGLManager.mVRAM = vram_megabytes; + glGetIntegerv(GL_VBO_FREE_MEMORY_ATI, (int *)&vram_megabytes); + vram_megabytes /= 1024; } + gGLManager.mVRAM = vram_megabytes; #elif LL_DARWIN CGLRendererInfoObj info = 0; GLint vram_megabytes = 0; int num_renderers = 0; - auto err = CGLQueryRendererInfo(CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay), - &info, &num_renderers); + auto err = CGLQueryRendererInfo(CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay), &info, &num_renderers); if (!err) { CGLDescribeRenderer(info, 0, kCGLRPVideoMemoryMegabytes, &vram_megabytes); @@ -733,19 +585,7 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b vram_megabytes = 256; } gGLManager.mVRAM = vram_megabytes; -# endif // LL_X11 - { - // fallback to letting SDL detect VRAM. - // note: I've not seen SDL's detection ever actually find - // VRAM != 0, but if SDL *does* detect it then that's a bonus. - gGLManager.mVRAM = 0; - if (gGLManager.mVRAM != 0) - { - LL_INFOS() << "SDL detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL; - } - } - // If VRAM is not detected, that is handled later - +# endif SDL_StartTextInput(); //make sure multisampling is disabled by default #if GL_VERSION_1_3 @@ -1509,47 +1349,24 @@ bool LLWindowSDL::SDLReallyCaptureInput(bool capture) bool newGrab = wantGrab; -#if LL_X11 if (!mFullscreen) /* only bother if we're windowed anyway */ { - if (mSDL_Display) + int result; + if (wantGrab == true) { - /* we dirtily mix raw X11 with SDL so that our pointer - isn't (as often) constrained to the limits of the - window while grabbed, which feels nicer and - hopefully eliminates some reported 'sticky pointer' - problems. We use raw X11 instead of - SDL_WM_GrabInput() because the latter constrains - the pointer to the window and also steals all - *keyboard* input from the window manager, which was - frustrating users. */ - int result; - if (wantGrab == true) - { - maybe_lock_display(); - result = XGrabPointer(mSDL_Display, mSDL_XWindowID, - True, 0, GrabModeAsync, - GrabModeAsync, - None, None, CurrentTime); - maybe_unlock_display(); - if (GrabSuccess == result) - newGrab = true; - else - newGrab = false; - } + result = SDL_CaptureMouse(SDL_TRUE); + if (0 == result) + newGrab = true; else - { newGrab = false; - - maybe_lock_display(); - XUngrabPointer(mSDL_Display, CurrentTime); - // Make sure the ungrab happens RIGHT NOW. - XSync(mSDL_Display, False); - maybe_unlock_display(); - } + } + else + { + newGrab = false; + result = SDL_CaptureMouse(SDL_FALSE); } } -#endif // LL_X11 + // return boolean success for whether we ended up in the desired state return capture == newGrab; } -- cgit v1.3 From b6c3d47c007c59cbd3c9913a0b99f9d42bdb8d75 Mon Sep 17 00:00:00 2001 From: Rye Cogtail Date: Thu, 3 Oct 2024 01:52:14 -0400 Subject: Fix GL init on Linux/SDL on various combinations of GPU driver --- indra/llwindow/llwindowsdl.cpp | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index dd4a7593a3..69332e36b6 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -367,20 +367,14 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b // Setup default backing colors GLint redBits{8}, greenBits{8}, blueBits{8}, alphaBits{8}; - GLint depthBits{(bits <= 16) ? 16 : 24}, stencilBits{8}; - - if (getenv("LL_GL_NO_STENCIL")) - stencilBits = 0; + GLint depthBits{24}, stencilBits{8}; SDL_GL_SetAttribute(SDL_GL_RED_SIZE, redBits); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, greenBits); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, blueBits); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, alphaBits); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, depthBits); - - // We need stencil support for a few (minor) things. - if (stencilBits) - SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, stencilBits); + SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, stencilBits); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); #if LL_DARWIN @@ -392,17 +386,6 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - if (LLRender::sGLCoreProfile) - { - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); - } - - // This is requesting a minimum context version - int major_gl_version = 3; - int minor_gl_version = 2; - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major_gl_version); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor_gl_version); - U32 context_flags = 0; if (gDebugGL) { @@ -417,7 +400,7 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b { LL_WARNS() << "Window creation failure. SDL: " << SDL_GetError() << LL_ENDL; setupFailure("Window creation error", "Error", OSMB_OK); - return FALSE; + return false; } // Create the context @@ -433,7 +416,7 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b { LL_WARNS() << "Failed to make context current. SDL: " << SDL_GetError() << LL_ENDL; setupFailure("GL Context failed to set current failure", "Error", OSMB_OK); - return FALSE; + return false; } if(mFullscreen) @@ -788,7 +771,7 @@ bool LLWindowSDL::getVisible() Uint32 flags = SDL_GetWindowFlags(mWindow); if (flags & SDL_WINDOW_SHOWN) { - result = TRUE; + result = true; } } return result; @@ -828,9 +811,9 @@ bool LLWindowSDL::maximize() if (mWindow) { SDL_MaximizeWindow(mWindow); - return TRUE; + return true; } - return FALSE; + return false; } bool LLWindowSDL::getFullscreen() -- cgit v1.3