diff --git a/indra/cmake/CMakeLists.txt b/indra/cmake/CMakeLists.txt index 5ff1b0399..d2e9f2249 100644 --- a/indra/cmake/CMakeLists.txt +++ b/indra/cmake/CMakeLists.txt @@ -81,6 +81,7 @@ set(cmake_SOURCE_FILES Linking.cmake MediaPluginBase.cmake NDOF.cmake + NVAPI.cmake OPENAL.cmake OpenGL.cmake OpenJPEG.cmake diff --git a/indra/cmake/NVAPI.cmake b/indra/cmake/NVAPI.cmake new file mode 100644 index 000000000..d60e42c87 --- /dev/null +++ b/indra/cmake/NVAPI.cmake @@ -0,0 +1,21 @@ +# -*- cmake -*- +include(Prebuilt) +include(Variables) + +set(NVAPI ON CACHE BOOL "Use NVAPI.") + +if (NVAPI) + if (WINDOWS) + use_prebuilt_binary(nvapi) + if (WORD_SIZE EQUAL 32) + set(NVAPI_LIBRARY nvapi) + elseif (WORD_SIZE EQUAL 64) + set(NVAPI_LIBRARY nvapi64) + endif (WORD_SIZE EQUAL 32) + else (WINDOWS) + set(NVAPI_LIBRARY "") + endif (WINDOWS) +else (NVAPI) + set(NVAPI_LIBRARY "") +endif (NVAPI) + diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 5d7091261..525f0be17 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -38,6 +38,7 @@ include(LLXML) #include(LScript) include(Linking) include(NDOF) +include(NVAPI) include(StateMachine) include(TemplateCheck) include(UI) @@ -1598,6 +1599,7 @@ target_link_libraries(${VIEWER_BINARY_NAME} ${LLMATH_LIBRARIES} ${LLCOMMON_LIBRARIES} ${NDOF_LIBRARY} + ${NVAPI_LIBRARY} ${viewer_LIBRARIES} ${Boost_CONTEXT_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 6f1a98444..54f0eef85 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -13785,6 +13785,17 @@ This should be as low as possible, but too low may break functionality Value 1 + RevokePermsOnStopAnimation + + Comment + Clear animation permssions when choosing "Stop Animating Me" + Persist + 1 + Type + Boolean + Value + 1 + RotateRight Comment diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index d6188bcc0..081e3b65f 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -84,6 +84,7 @@ #include "llworld.h" #include "llworldmap.h" #include "llworldmapmessage.h" +#include "../lscript/lscript_byteformat.h" //Misc non-standard includes #include "llurldispatcher.h" @@ -3061,7 +3062,7 @@ LLQuaternion LLAgent::getHeadRotation() return rot; } -void LLAgent::sendAnimationRequests(LLDynamicArray &anim_ids, EAnimRequest request) +void LLAgent::sendAnimationRequests(const std::vector &anim_ids, EAnimRequest request) { if (gAgentID.isNull()) { @@ -3076,7 +3077,7 @@ void LLAgent::sendAnimationRequests(LLDynamicArray &anim_ids, EAnimReque msg->addUUIDFast(_PREHASH_AgentID, getID()); msg->addUUIDFast(_PREHASH_SessionID, getSessionID()); - for (S32 i = 0; i < anim_ids.count(); i++) + for (U32 i = 0; i < anim_ids.size(); i++) { if (anim_ids[i].isNull()) { @@ -3118,6 +3119,55 @@ void LLAgent::sendAnimationRequest(const LLUUID &anim_id, EAnimRequest request) sendReliableMessage(); } +// Send a message to the region to stop the NULL animation state +// This will reset animation state overrides for the agent. +void LLAgent::sendAnimationStateReset() +{ + if (gAgentID.isNull() || !mRegionp) + { + return; + } + + LLMessageSystem* msg = gMessageSystem; + msg->newMessageFast(_PREHASH_AgentAnimation); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, getID()); + msg->addUUIDFast(_PREHASH_SessionID, getSessionID()); + + msg->nextBlockFast(_PREHASH_AnimationList); + msg->addUUIDFast(_PREHASH_AnimID, LLUUID::null ); + msg->addBOOLFast(_PREHASH_StartAnim, FALSE); + + msg->nextBlockFast(_PREHASH_PhysicalAvatarEventList); + msg->addBinaryDataFast(_PREHASH_TypeData, NULL, 0); + sendReliableMessage(); +} + + +// Send a message to the region to revoke sepecified permissions on ALL scripts in the region +// If the target is an object in the region, permissions in scripts on that object are cleared. +// If it is the region ID, all scripts clear the permissions for this agent +void LLAgent::sendRevokePermissions(const LLUUID & target, U32 permissions) +{ + // Currently only the bits for SCRIPT_PERMISSION_TRIGGER_ANIMATION and SCRIPT_PERMISSION_OVERRIDE_ANIMATIONS + // are supported by the server. Sending any other bits will cause the message to be dropped without changing permissions + + if (gAgentID.notNull() && gMessageSystem) + { + LLMessageSystem* msg = gMessageSystem; + msg->newMessageFast(_PREHASH_RevokePermissions); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, getID()); // Must be our ID + msg->addUUIDFast(_PREHASH_SessionID, getSessionID()); + + msg->nextBlockFast(_PREHASH_Data); + msg->addUUIDFast(_PREHASH_ObjectID, target); // Must be in the region + msg->addU32Fast(_PREHASH_ObjectPermissions, permissions); + + sendReliableMessage(); + } +} + // [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i void LLAgent::setAlwaysRun() { @@ -4338,6 +4388,8 @@ void LLAgent::stopCurrentAnimations() // avatar, propagating this change back to the server. if (isAgentAvatarValid()) { + std::vector anim_ids; + for ( LLVOAvatar::AnimIterator anim_it = gAgentAvatarp->mPlayingAnimations.begin(); anim_it != gAgentAvatarp->mPlayingAnimations.end(); @@ -4355,7 +4407,24 @@ void LLAgent::stopCurrentAnimations() // stop this animation locally gAgentAvatarp->stopMotion(anim_it->first, TRUE); // ...and tell the server to tell everyone. - sendAnimationRequest(anim_it->first, ANIM_REQUEST_STOP); + anim_ids.push_back(anim_it->first); + } + } + + sendAnimationRequests(anim_ids, ANIM_REQUEST_STOP); + + // Tell the region to clear any animation state overrides + sendAnimationStateReset(); + + // Revoke all animation permissions + if (mRegionp && + gSavedSettings.getBOOL("RevokePermsOnStopAnimation")) + { + U32 permissions = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_TRIGGER_ANIMATION] | LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_OVERRIDE_ANIMATIONS]; + sendRevokePermissions(mRegionp->getRegionID(), permissions); + if (gAgentAvatarp->isSitting()) + { // Also stand up, since auto-granted sit animation permission has been revoked + gAgent.standUp(); } } diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 8a01093bf..26501953a 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -464,8 +464,11 @@ public: void stopCurrentAnimations(); void requestStopMotion(LLMotion* motion); void onAnimStop(const LLUUID& id); - void sendAnimationRequests(LLDynamicArray &anim_ids, EAnimRequest request); + void sendAnimationRequests(const std::vector &anim_ids, EAnimRequest request); void sendAnimationRequest(const LLUUID &anim_id, EAnimRequest request); + void sendAnimationStateReset(); + void sendRevokePermissions(const LLUUID & target, U32 permissions); + void endAnimationUpdateUI(); void unpauseAnimation() { mPauseRequest = NULL; } BOOL getCustomAnim() const { return mCustomAnim; } diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp index 8630ed1f9..ee775932f 100644 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -52,6 +52,11 @@ #include "llviewercontrol.h" #include "lldxhardware.h" +#include "nvapi/nvapi.h" +#include "nvapi/NvApiDriverSettings.h" + +#include + #include "llweb.h" #include "llsecondlifeurls.h" @@ -79,6 +84,19 @@ extern "C" { const std::string LLAppViewerWin32::sWindowClass = "Second Life"; +/* + This function is used to print to the command line a text message + describing the nvapi error and quits +*/ +void nvapi_error(NvAPI_Status status) +{ + NvAPI_ShortString szDesc = {0}; + NvAPI_GetErrorMessage(status, szDesc); + llwarns << szDesc << llendl; + + //should always trigger when asserts are enabled + //llassert(status == NVAPI_OK); +} // Create app mutex creates a unique global windows object. // If the object can be created it returns true, otherwise @@ -101,6 +119,79 @@ bool create_app_mutex() return result; } +void ll_nvapi_init(NvDRSSessionHandle hSession) +{ + // (2) load all the system settings into the session + NvAPI_Status status = NvAPI_DRS_LoadSettings(hSession); + if (status != NVAPI_OK) + { + nvapi_error(status); + return; + } + + NvAPI_UnicodeString profile_name; + //std::string app_name = LLTrans::getString("APP_NAME"); + std::string app_name("Second Life"); // + llutf16string w_app_name = utf8str_to_utf16str(app_name); + wsprintf(profile_name, L"%s", w_app_name.c_str()); + status = NvAPI_DRS_SetCurrentGlobalProfile(hSession, profile_name); + if (status != NVAPI_OK) + { + nvapi_error(status); + return; + } + + // (3) Obtain the current profile. + NvDRSProfileHandle hProfile = 0; + status = NvAPI_DRS_GetCurrentGlobalProfile(hSession, &hProfile); + if (status != NVAPI_OK) + { + nvapi_error(status); + return; + } + + // load settings for querying + status = NvAPI_DRS_LoadSettings(hSession); + if (status != NVAPI_OK) + { + nvapi_error(status); + return; + } + + //get the preferred power management mode for Second Life + NVDRS_SETTING drsSetting = {0}; + drsSetting.version = NVDRS_SETTING_VER; + status = NvAPI_DRS_GetSetting(hSession, hProfile, PREFERRED_PSTATE_ID, &drsSetting); + if (status == NVAPI_SETTING_NOT_FOUND) + { //only override if the user hasn't specifically set this setting + // (4) Specify that we want the VSYNC disabled setting + // first we fill the NVDRS_SETTING struct, then we call the function + drsSetting.version = NVDRS_SETTING_VER; + drsSetting.settingId = PREFERRED_PSTATE_ID; + drsSetting.settingType = NVDRS_DWORD_TYPE; + drsSetting.u32CurrentValue = PREFERRED_PSTATE_PREFER_MAX; + status = NvAPI_DRS_SetSetting(hSession, hProfile, &drsSetting); + if (status != NVAPI_OK) + { + nvapi_error(status); + return; + } + + // (5) Now we apply (or save) our changes to the system + status = NvAPI_DRS_SaveSettings(hSession); + if (status != NVAPI_OK) + { + nvapi_error(status); + return; + } + } + else if (status != NVAPI_OK) + { + nvapi_error(status); + return; + } +} + //#define DEBUGGING_SEH_FILTER 1 #if DEBUGGING_SEH_FILTER # define WINMAIN DebuggingWinMain @@ -157,6 +248,27 @@ int APIENTRY WINMAIN(HINSTANCE hInstance, return -1; } + NvAPI_Status status; + + // Initialize NVAPI + status = NvAPI_Initialize(); + NvDRSSessionHandle hSession = 0; + + if (status == NVAPI_OK) + { + // Create the session handle to access driver settings + status = NvAPI_DRS_CreateSession(&hSession); + if (status != NVAPI_OK) + { + nvapi_error(status); + } + else + { + //override driver setting as needed + ll_nvapi_init(hSession); + } + } + // Have to wait until after logging is initialized to display LFH info if (num_heaps > 0) { @@ -224,6 +336,15 @@ int APIENTRY WINMAIN(HINSTANCE hInstance, LLAppViewer::sUpdaterInfo = NULL ; } + + + // (NVAPI) (6) We clean up. This is analogous to doing a free() + if (hSession) + { + NvAPI_DRS_DestroySession(hSession); + hSession = 0; + } + return 0; } diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index a3b3ee524..ae0b13470 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -116,6 +116,7 @@ #include "aifile.h" #include "llavatarname.h" +#include "../lscript/lscript_byteformat.h" #include "hippogridmanager.h" @@ -6606,14 +6607,8 @@ void LLVOAvatar::getOffObject() if (sit_object && !sit_object->permYouOwner() && gSavedSettings.getBOOL("RevokePermsOnStandUp")) { - gMessageSystem->newMessageFast(_PREHASH_RevokePermissions); - gMessageSystem->nextBlockFast(_PREHASH_AgentData); - gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - gMessageSystem->nextBlockFast(_PREHASH_Data); - gMessageSystem->addUUIDFast(_PREHASH_ObjectID, sit_object->getID()); - gMessageSystem->addU32Fast(_PREHASH_ObjectPermissions, 0xFFFFFFFF); - gAgent.sendReliableMessage(); + U32 permissions = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_TRIGGER_ANIMATION] | LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_OVERRIDE_ANIMATIONS]; + gAgent.sendRevokePermissions(sit_object->getID(), permissions); } } } diff --git a/install.xml b/install.xml index 2c02e94ba..cd0bedaee 100644 --- a/install.xml +++ b/install.xml @@ -1061,6 +1061,32 @@ + nvapi + + copyright + Copyright (C) NVIDIA + description + NVAPI is the library suite to access nvidia profiles and performance options on windows + license + NVAPI + packages + + windows + + md5sum + 99d1b70c1305257d521edfbd34587187 + url + https://bitbucket.org/SingularityViewer/libraries/downloads/nvapi-304-windows-20121116-singu.tar.bz2 + + windows64 + + md5sum + 5578017f13783fb7279dd39537d1e0fd + url + https://bitbucket.org/SingularityViewer/libraries/downloads/nvapi-304-windows64-20131116-singu.tar.bz2 + + + ndofdev copyright @@ -1873,6 +1899,11 @@ Cass Everitt - cass@r3.nu text http://www.jclark.com/xml/copying.txt + NVAPI + + url + Licenes dir + ogg-vorbis url diff --git a/scripts/install.py b/scripts/install.py index e027c7322..288b19b90 100755 --- a/scripts/install.py +++ b/scripts/install.py @@ -835,10 +835,10 @@ def _default_installable_cache(): """In general, the installable files do not change much, so find a host/user specific location to cache files.""" user = _getuser() - cache_dir = "/var/tmp/%s/install.cache" % user + cache_dir = "/var/tmp/%s/sg.install.cache" % user if _get_platform() == 'windows': cache_dir = os.path.join(tempfile.gettempdir(), \ - 'install.cache.%s' % user) + 'sg.install.cache.%s' % user) return cache_dir def parse_args(): diff --git a/scripts/public_fetch_tarballs.py b/scripts/public_fetch_tarballs.py index 455a42549..45eb4c5a8 100755 --- a/scripts/public_fetch_tarballs.py +++ b/scripts/public_fetch_tarballs.py @@ -173,10 +173,10 @@ def _default_installable_cache(): """In general, the installable files do not change much, so find a host/user specific location to cache files.""" user = _getuser() - cache_dir = "/var/tmp/%s/install.cache" % user + cache_dir = "/var/tmp/%s/sg.install.cache" % user if _get_platform() == 'windows': cache_dir = os.path.join(tempfile.gettempdir(), \ - 'install.cache.%s' % user) + 'sg.install.cache.%s' % user) return cache_dir # For status messages (e.g. "Loading..."). May come in handy if