diff options
Diffstat (limited to 'indra')
27 files changed, 219 insertions, 177 deletions
diff --git a/indra/llcommon/workqueue.h b/indra/llcommon/workqueue.h index b88aef989a..5ec790da79 100644 --- a/indra/llcommon/workqueue.h +++ b/indra/llcommon/workqueue.h @@ -94,6 +94,12 @@ namespace LL void postEvery(const std::chrono::duration<Rep, Period>& interval, CALLABLE&& callable); + template <typename CALLABLE> + bool tryPost(CALLABLE&& callable) + { + return mQueue.tryPush(TimedWork(TimePoint::clock::now(), std::move(callable))); + } + /*------------------------- handshake API --------------------------*/ /** diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 23f9c8e9d7..0ada97ad3f 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -1214,9 +1214,9 @@ LLColor3 LLSettingsSky::getLightTransmittanceFast( const LLColor3& total_density // performs soft scale clip and gamma correction ala the shader implementation // scales colors down to 0 - 1 range preserving relative ratios -LLColor3 LLSettingsSky::gammaCorrect(const LLColor3& in) const +LLColor3 LLSettingsSky::gammaCorrect(const LLColor3& in,const F32 &gamma) const { - F32 gamma = getGamma(); + //F32 gamma = getGamma(); // SL-16127: Use cached gamma from atmospheric vars LLColor3 v(in); // scale down to 0 to 1 range preserving relative ratio (aka homegenize) diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 77d9d8e87c..fa9326f006 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -254,7 +254,7 @@ public: LLColor3 getLightTransmittance(F32 distance) const; LLColor3 getLightTransmittanceFast(const LLColor3& total_density, const F32 density_multiplier, const F32 distance) const; LLColor3 getTotalDensity() const; - LLColor3 gammaCorrect(const LLColor3& in) const; + LLColor3 gammaCorrect(const LLColor3& in,const F32 &gamma) const; LLColor3 getBlueDensity() const; LLColor3 getBlueHorizon() const; diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 09b1c71f02..cbc5392882 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -2288,7 +2288,10 @@ bool LLImageGLThread::postCallback(const std::function<void()>& callback) { try { - mCallbackQueue.post(callback); + if (!mCallbackQueue.tryPost(callback)) + { + mPendingCallbackQ.push(callback); + } } catch (LLThreadSafeQueueInterrupt e) { @@ -2304,6 +2307,18 @@ void LLImageGLThread::executeCallbacks() LL_PROFILE_ZONE_SCOPED; //executed from main thread mCallbackQueue.runPending(); + + while (!mPendingCallbackQ.empty()) + { + if (mCallbackQueue.tryPost(mPendingCallbackQ.front())) + { + mPendingCallbackQ.pop(); + } + else + { + break; + } + } } void LLImageGLThread::run() diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index 95b60bd0bd..8264e4a5f2 100644 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -332,6 +332,8 @@ public: void* mContext; LLAtomicBool mFinished; + std::queue<std::function<void()>> mPendingCallbackQ; + static LLImageGLThread* sInstance; }; diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp index 67ef98d7b3..f4678a70c5 100644 --- a/indra/llwindow/llwindow.cpp +++ b/indra/llwindow/llwindow.cpp @@ -403,7 +403,7 @@ LLWindow* LLWindowManager::createWindow( const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clearBg, - BOOL disable_vsync, + BOOL enable_vsync, BOOL use_gl, BOOL ignore_pixel_depth, U32 fsaa_samples) @@ -415,26 +415,26 @@ LLWindow* LLWindowManager::createWindow( #if LL_MESA_HEADLESS new_window = new LLWindowMesaHeadless(callbacks, title, name, x, y, width, height, flags, - fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth); + fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth); #elif LL_SDL new_window = new LLWindowSDL(callbacks, title, x, y, width, height, flags, - fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); + fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); #elif LL_WINDOWS new_window = new LLWindowWin32(callbacks, title, name, x, y, width, height, flags, - fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); + fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); #elif LL_DARWIN new_window = new LLWindowMacOSX(callbacks, title, name, x, y, width, height, flags, - fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); + fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); #endif } else { new_window = new LLWindowHeadless(callbacks, title, name, x, y, width, height, flags, - fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth); + fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth); } if (FALSE == new_window->isValid()) diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index b76d313011..43d81e4d59 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -77,7 +77,7 @@ public: BOOL setSize(LLCoordScreen size); BOOL setSize(LLCoordWindow size); virtual void setMinSize(U32 min_width, U32 min_height, bool enforce_immediately = true); - virtual BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL) = 0; + virtual BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL enable_vsync, const LLCoordScreen * const posp = NULL) = 0; //create a new GL context that shares a namespace with this Window's main GL context and make it current on the current thread // returns a pointer to be handed back to destroySharedConext/makeContextCurrent @@ -92,6 +92,7 @@ public: virtual BOOL setCursorPosition(LLCoordWindow position) = 0; virtual BOOL getCursorPosition(LLCoordWindow *position) = 0; #if LL_WINDOWS + virtual void toggleVSync(bool enable_vsync) = 0; virtual BOOL getCursorDelta(LLCoordCommon* delta) = 0; #endif virtual void showCursor() = 0; @@ -295,7 +296,7 @@ public: U32 flags = 0, BOOL fullscreen = FALSE, BOOL clearBg = FALSE, - BOOL disable_vsync = TRUE, + BOOL enable_vsync = FALSE, BOOL use_gl = TRUE, BOOL ignore_pixel_depth = FALSE, U32 fsaa_samples = 0); diff --git a/indra/llwindow/llwindowheadless.cpp b/indra/llwindow/llwindowheadless.cpp index 70f473281b..c3738af6ca 100644 --- a/indra/llwindow/llwindowheadless.cpp +++ b/indra/llwindow/llwindowheadless.cpp @@ -35,7 +35,7 @@ // LLWindowHeadless::LLWindowHeadless(LLWindowCallbacks* callbacks, const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clear_background, - BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth) + BOOL enable_vsync, BOOL use_gl, BOOL ignore_pixel_depth) : LLWindow(callbacks, fullscreen, flags) { // Initialize a headless keyboard. diff --git a/indra/llwindow/llwindowheadless.h b/indra/llwindow/llwindowheadless.h index f8ba9bbed4..78c5e4bae4 100644 --- a/indra/llwindow/llwindowheadless.h +++ b/indra/llwindow/llwindowheadless.h @@ -48,13 +48,14 @@ public: /*virtual*/ BOOL setPosition(LLCoordScreen position) {return FALSE;}; /*virtual*/ BOOL setSizeImpl(LLCoordScreen size) {return FALSE;}; /*virtual*/ BOOL setSizeImpl(LLCoordWindow size) {return FALSE;}; - /*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL) {return FALSE;}; + /*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL enable_vsync, const LLCoordScreen * const posp = NULL) {return FALSE;}; void* createSharedContext() { return nullptr; } void makeContextCurrent(void*) {} void destroySharedContext(void*) {} /*virtual*/ BOOL setCursorPosition(LLCoordWindow position) {return FALSE;}; /*virtual*/ BOOL getCursorPosition(LLCoordWindow *position) {return FALSE;}; #if LL_WINDOWS + /*virtual*/ virtual void toggleVSync(bool enable_vsync) { } /*virtual*/ BOOL getCursorDelta(LLCoordCommon* delta) { return FALSE; } #endif /*virtual*/ void showCursor() {}; @@ -103,7 +104,7 @@ public: S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clear_background, - BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth); + BOOL enable_vsync, BOOL use_gl, BOOL ignore_pixel_depth); virtual ~LLWindowHeadless(); private: diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 23830dd24e..a74fa78388 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -111,7 +111,7 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks, const std::string& title, const std::string& name, 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(NULL, fullscreen, flags) @@ -165,7 +165,7 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks, // Stash an object pointer for OSMessageBox() gWindowImplementation = this; // 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)) { if(mWindow != NULL) { @@ -610,7 +610,7 @@ void LLWindowMacOSX::getMouseDeltas(float* delta) delta[1] = mCursorLastEventDeltaY; } -BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, BOOL disable_vsync) +BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, BOOL enable_vsync) { BOOL glNeedsInit = FALSE; @@ -625,7 +625,7 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits { // Our OpenGL view is already defined within SecondLife.xib. // Get the view instead. - mGLView = createOpenGLView(mWindow, mFSAASamples, !disable_vsync); + mGLView = createOpenGLView(mWindow, mFSAASamples, enable_vsync); mContext = getCGLContextObj(mGLView); // Since we just created the context, it needs to be set up. @@ -653,7 +653,7 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits // Disable vertical sync for swap GLint frames_per_swap = 0; - if (disable_vsync) + if (!enable_vsync) { frames_per_swap = 0; } @@ -689,7 +689,7 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits // We only support OS X 10.7's fullscreen app mode which is literally a full screen window that fills a virtual desktop. // This makes this method obsolete. -BOOL LLWindowMacOSX::switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp) +BOOL LLWindowMacOSX::switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL enable_vsync, const LLCoordScreen * const posp) { return FALSE; } diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index ede2b453d5..18fa86930f 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -60,7 +60,7 @@ public: BOOL setPosition(LLCoordScreen position) override; BOOL setSizeImpl(LLCoordScreen size) override; BOOL setSizeImpl(LLCoordWindow size) override; - BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL) override; + BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL enable_vsync, const LLCoordScreen * const posp = NULL) override; BOOL setCursorPosition(LLCoordWindow position) override; BOOL getCursorPosition(LLCoordWindow *position) override; void showCursor() override; @@ -143,7 +143,7 @@ public: protected: LLWindowMacOSX(LLWindowCallbacks* callbacks, const std::string& title, const std::string& name, 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); ~LLWindowMacOSX(); @@ -176,7 +176,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(); void setupFailure(const std::string& text, const std::string& caption, U32 type); void adjustCursorDecouple(bool warpingMouse = false); diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 70cf839510..e52624d66a 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -473,7 +473,7 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks, const std::string& title, const std::string& name, 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) @@ -800,7 +800,7 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks, LLCoordScreen windowPos(x,y); LLCoordScreen windowSize(window_rect.right - window_rect.left, window_rect.bottom - window_rect.top); - if (!switchContext(mFullscreen, windowSize, disable_vsync, &windowPos)) + if (!switchContext(mFullscreen, windowSize, enable_vsync, &windowPos)) { return; } @@ -1126,7 +1126,7 @@ BOOL LLWindowWin32::setSizeImpl(const LLCoordWindow size) } // changing fullscreen resolution -BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen& size, BOOL disable_vsync, const LLCoordScreen* const posp) +BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen& size, BOOL enable_vsync, const LLCoordScreen* const posp) { //called from main thread GLuint pixel_format; @@ -1802,16 +1802,7 @@ const S32 max_format = (S32)num_formats - 1; } // Disable vertical sync for swap - if (disable_vsync && wglSwapIntervalEXT) - { - LL_DEBUGS("Window") << "Disabling vertical sync" << LL_ENDL; - wglSwapIntervalEXT(0); - } - else - { - LL_DEBUGS("Window") << "Keeping vertical sync" << LL_ENDL; - wglSwapIntervalEXT(1); - } + toggleVSync(enable_vsync); SetWindowLongPtr(mWindowHandle, GWLP_USERDATA, (LONG_PTR)this); @@ -1906,6 +1897,20 @@ void LLWindowWin32::destroySharedContext(void* contextPtr) wglDeleteContext((HGLRC)contextPtr); } +void LLWindowWin32::toggleVSync(bool enable_vsync) +{ + if (!enable_vsync && wglSwapIntervalEXT) + { + LL_INFOS("Window") << "Disabling vertical sync" << LL_ENDL; + wglSwapIntervalEXT(0); + } + else + { + LL_INFOS("Window") << "Enabling vertical sync" << LL_ENDL; + wglSwapIntervalEXT(1); + } +} + void LLWindowWin32::moveWindow( const LLCoordScreen& position, const LLCoordScreen& size ) { if( mIsMouseClipping ) @@ -2203,6 +2208,17 @@ void LLWindowWin32::gatherInput() } { + LL_PROFILE_ZONE_NAMED("gi - PeekMessage"); + S32 msg_count = 0; + while ((msg_count < MAX_MESSAGE_PER_UPDATE) && PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + msg_count++; + } + } + + { LL_PROFILE_ZONE_NAMED("gi - function queue"); //process any pending functions std::function<void()> curFunc; diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 7a9a30ccea..d082080807 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -93,11 +93,12 @@ public: /*virtual*/ BOOL setPosition(LLCoordScreen position); /*virtual*/ BOOL setSizeImpl(LLCoordScreen size); /*virtual*/ BOOL setSizeImpl(LLCoordWindow size); - /*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL); + /*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL enable_vsync, const LLCoordScreen * const posp = NULL); /*virtual*/ void setTitle(const std::string title); void* createSharedContext() override; void makeContextCurrent(void* context) override; void destroySharedContext(void* context) override; + /*virtual*/ void toggleVSync(bool enable_vsync); /*virtual*/ BOOL setCursorPosition(LLCoordWindow position); /*virtual*/ BOOL getCursorPosition(LLCoordWindow *position); /*virtual*/ BOOL getCursorDelta(LLCoordCommon* delta); @@ -164,7 +165,7 @@ public: protected: LLWindowWin32(LLWindowCallbacks* callbacks, const std::string& title, const std::string& name, 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); ~LLWindowWin32(); diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 291f0f7d95..f15b5d0981 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -3352,16 +3352,16 @@ <key>Value</key> <integer>0</integer> </map> - <key>DisableVerticalSync</key> + <key>RenderVSyncEnable</key> <map> <key>Comment</key> - <string>Update frames as fast as possible (FALSE = update frames between display scans). Requires restart.</string> + <string>Update frames between display scans (FALSE = Update frames as fast as possible).</string> <key>Persist</key> <integer>1</integer> <key>Type</key> <string>Boolean</string> <key>Value</key> - <integer>0</integer> + <integer>1</integer> </map> <key>EnableGroupChatPopups</key> <map> diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index aa426cd785..5f9e623b4c 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -337,7 +337,8 @@ void LLDrawPoolWater::render(S32 pass) // for low end hardware void LLDrawPoolWater::renderOpaqueLegacyWater() { - LLVOSky *voskyp = gSky.mVOSkyp; + LL_PROFILE_ZONE_SCOPED; + LLVOSky *voskyp = gSky.mVOSkyp; LLGLSLShader* shader = NULL; if (LLGLSLShader::sNoFixedFunction) @@ -444,6 +445,7 @@ void LLDrawPoolWater::renderOpaqueLegacyWater() void LLDrawPoolWater::renderReflection(LLFace* face) { + LL_PROFILE_ZONE_SCOPED; LLVOSky *voskyp = gSky.mVOSkyp; if (!voskyp) @@ -472,6 +474,7 @@ void LLDrawPoolWater::renderReflection(LLFace* face) void LLDrawPoolWater::shade2(bool edge, LLGLSLShader* shader, const LLColor3& light_diffuse, const LLVector3& light_dir, F32 light_exp) { + LL_PROFILE_ZONE_SCOPED; F32 water_height = LLEnvironment::instance().getWaterHeight(); F32 camera_height = LLViewerCamera::getInstance()->getOrigin().mV[2]; F32 eyedepth = camera_height - water_height; @@ -680,7 +683,8 @@ void LLDrawPoolWater::shade2(bool edge, LLGLSLShader* shader, const LLColor3& li void LLDrawPoolWater::shade() { - if (!deferred_render) + LL_PROFILE_ZONE_SCOPED; + if (!deferred_render) { gGL.setColorMask(true, true); } diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 9eda254b25..238e9fe0e1 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -202,14 +202,8 @@ void LLAtmospherics::init() mInitialized = true; } -LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVector3 &dir, bool isShiny) -{ - LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - return calcSkyColorInDir(psky, vars, dir, isShiny); -} - // This cubemap is used as "environmentMap" in indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl -LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, AtmosphericsVars& vars, const LLVector3 &dir, bool isShiny) +LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, AtmosphericsVars& vars, const LLVector3 &dir, bool isShiny, bool low_end) { const F32 sky_saturation = 0.25f; const F32 land_saturation = 0.1f; @@ -227,7 +221,7 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, Atm } F32 greyscale_sat = brightness * (1.0f - land_saturation); desat_fog = desat_fog * land_saturation + smear(greyscale_sat); - if (!gPipeline.canUseWindLightShaders()) + if (low_end) { col = LLColor4(desat_fog, 0.f); } @@ -258,8 +252,7 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, Atm return LLColor4(sky_color, 0.0f); } - bool low_end = !gPipeline.canUseWindLightShaders(); - LLColor3 sky_color = low_end ? vars.hazeColor * 2.0f : psky->gammaCorrect(vars.hazeColor * 2.0f); + LLColor3 sky_color = low_end ? vars.hazeColor * 2.0f : psky->gammaCorrect(vars.hazeColor * 2.0f, vars.gamma); return LLColor4(sky_color, 0.0f); } @@ -437,12 +430,16 @@ void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + // NOTE: This is very similar to LLVOSky::cacheEnvironment() + // Differences: + // vars.sun_norm + // vars.sunlight // invariants across whole sky tex process... - vars.blue_density = psky->getBlueDensity(); + vars.blue_density = psky->getBlueDensity(); vars.blue_horizon = psky->getBlueHorizon(); vars.haze_density = psky->getHazeDensity(); vars.haze_horizon = psky->getHazeHorizon(); - vars.density_multiplier = psky->getDensityMultiplier(); + vars.density_multiplier = psky->getDensityMultiplier(); vars.distance_multiplier = psky->getDistanceMultiplier(); vars.max_y = psky->getMaxY(); vars.sun_norm = LLEnvironment::instance().getSunDirectionCFR(); @@ -457,9 +454,9 @@ void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) vars.total_density = psky->getTotalDensity(); vars.gamma = psky->getGamma(); - res_color[0] = calcSkyColorInDir(vars, tosun); - res_color[1] = calcSkyColorInDir(vars, perp_tosun); - res_color[2] = calcSkyColorInDir(vars, tosun_45); + res_color[0] = calcSkyColorInDir(psky, vars, tosun); + res_color[1] = calcSkyColorInDir(psky, vars, perp_tosun); + res_color[2] = calcSkyColorInDir(psky, vars, tosun_45); sky_fog_color = color_norm(res_color[0] + res_color[1] + res_color[2]); diff --git a/indra/newview/lllegacyatmospherics.h b/indra/newview/lllegacyatmospherics.h index 03c8efb91a..d48f3040c3 100644 --- a/indra/newview/lllegacyatmospherics.h +++ b/indra/newview/lllegacyatmospherics.h @@ -257,13 +257,11 @@ public: void setCloudDensity(F32 cloud_density) { mCloudDensity = cloud_density; } void setWind ( const LLVector3& wind ) { mWind = wind.length(); } - LLColor4 calcSkyColorInDir(AtmosphericsVars& vars, const LLVector3& dir, bool isShiny = false); - LLColor4 calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, AtmosphericsVars& vars, const LLVector3& dir, bool isShiny = false); + LLColor4 calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, AtmosphericsVars& vars, const LLVector3& dir, bool isShiny = false, const bool low_end = false); -protected: +protected: void calcSkyColorWLVert(const LLSettingsSky::ptr_t &psky, LLVector3 & Pn, AtmosphericsVars& vars); - LLColor3 getHazeColor(LLSettingsSky::ptr_t psky, AtmosphericsVars& vars, F32 costheta, F32 cloud_shadow); LLHaze mHaze; F32 mHazeConcentration; diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 6a88a8ef2c..0c59de5ea0 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -666,6 +666,7 @@ void LLSettingsVOSky::updateSettings() void LLSettingsVOSky::applySpecial(void *ptarget, bool force) { + LL_PROFILE_ZONE_SCOPED LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); LLShaderUniforms* shader = &((LLShaderUniforms*)ptarget)[LLGLSLShader::SG_DEFAULT]; @@ -908,6 +909,8 @@ LLSD LLSettingsVOWater::convertToLegacy(const LLSettingsWater::ptr_t &pwater) //------------------------------------------------------------------------- void LLSettingsVOWater::applySpecial(void *ptarget, bool force) { + LL_PROFILE_ZONE_SCOPED + LLEnvironment& env = LLEnvironment::instance(); auto group = LLGLSLShader::SG_WATER; diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 76dc9a6790..3e7459ee8a 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -241,6 +241,12 @@ static bool handleAnisotropicChanged(const LLSD& newvalue) return true; } +static bool handleVSyncChanged(const LLSD& newvalue) +{ + gViewerWindow->getWindow()->toggleVSync(newvalue.asBoolean()); + return true; +} + static bool handleVolumeLODChanged(const LLSD& newvalue) { LLVOVolume::sLODFactor = llclamp((F32) newvalue.asReal(), 0.01f, MAX_LOD_FACTOR); @@ -665,6 +671,7 @@ void settings_setup_listeners() gSavedSettings.getControl("RenderAutoMaskAlphaNonDeferred")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2)); gSavedSettings.getControl("RenderObjectBump")->getSignal()->connect(boost::bind(&handleRenderBumpChanged, _2)); gSavedSettings.getControl("RenderMaxVBOSize")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2)); + gSavedSettings.getControl("RenderVSyncEnable")->getSignal()->connect(boost::bind(&handleVSyncChanged, _2)); gSavedSettings.getControl("RenderDeferredNoise")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2)); gSavedSettings.getControl("RenderDebugGL")->getSignal()->connect(boost::bind(&handleRenderDebugGLChanged, _2)); gSavedSettings.getControl("RenderDebugPipeline")->getSignal()->connect(boost::bind(&handleRenderDebugPipelineChanged, _2)); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 7dc7b33938..a35ad55cf7 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1903,7 +1903,7 @@ LLViewerWindow::LLViewerWindow(const Params& p) p.title, p.name, p.x, p.y, p.width, p.height, 0, p.fullscreen, gHeadlessClient, - gSavedSettings.getBOOL("DisableVerticalSync"), + gSavedSettings.getBOOL("RenderVSyncEnable"), !gHeadlessClient, p.ignore_pixel_depth, gSavedSettings.getBOOL("RenderDeferred") ? 0 : gSavedSettings.getU32("RenderFSAASamples")); //don't use window level anti-aliasing if FBOs are enabled @@ -5569,7 +5569,7 @@ void LLViewerWindow::restartDisplay(BOOL show_progress_bar) } } -BOOL LLViewerWindow::changeDisplaySettings(LLCoordScreen size, BOOL disable_vsync, BOOL show_progress_bar) +BOOL LLViewerWindow::changeDisplaySettings(LLCoordScreen size, BOOL enable_vsync, BOOL show_progress_bar) { //BOOL was_maximized = gSavedSettings.getBOOL("WindowMaximized"); diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 8a6df613dc..93194b1884 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -424,7 +424,7 @@ public: void requestResolutionUpdate(); void checkSettings(); void restartDisplay(BOOL show_progress_bar); - BOOL changeDisplaySettings(LLCoordScreen size, BOOL disable_vsync, BOOL show_progress_bar); + BOOL changeDisplaySettings(LLCoordScreen size, BOOL enable_vsync, BOOL show_progress_bar); BOOL getIgnoreDestroyWindow() { return mIgnoreActivate; } F32 getWorldViewAspectRatio() const; const LLVector2& getDisplayScale() const { return mDisplayScale; } diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 1e546861b9..72ec8390a4 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -64,7 +64,7 @@ namespace const S32 NUM_TILES_X = 8; const S32 NUM_TILES_Y = 4; const S32 NUM_TILES = NUM_TILES_X * NUM_TILES_Y; - const S32 NUM_CUBEMAP_FACES = 6; // See sResolution for face dimensions + const S32 NUM_CUBEMAP_FACES = 6; // See SKYTEX_RESOLUTION for face dimensions const S32 TOTAL_TILES = NUM_CUBEMAP_FACES * NUM_TILES; const S32 MAX_TILES = TOTAL_TILES + 1; @@ -87,8 +87,6 @@ namespace SkyTex ***************************************/ -S32 LLSkyTex::sComponents = 4; -S32 LLSkyTex::sResolution = 64; S32 LLSkyTex::sCurrent = 0; @@ -102,14 +100,14 @@ LLSkyTex::LLSkyTex() : void LLSkyTex::init(bool isShiny) { mIsShiny = isShiny; - mSkyData = new LLColor4[sResolution * sResolution]; - mSkyDirs = new LLVector3[sResolution * sResolution]; + mSkyData = new LLColor4[SKYTEX_RESOLUTION * SKYTEX_RESOLUTION]; + mSkyDirs = new LLVector3[SKYTEX_RESOLUTION * SKYTEX_RESOLUTION]; for (S32 i = 0; i < 2; ++i) { mTexture[i] = LLViewerTextureManager::getLocalTexture(FALSE); mTexture[i]->setAddressMode(LLTexUnit::TAM_CLAMP); - mImageRaw[i] = new LLImageRaw(sResolution, sResolution, sComponents); + mImageRaw[i] = new LLImageRaw(SKYTEX_RESOLUTION, SKYTEX_RESOLUTION, SKYTEX_COMPONENTS); initEmpty(i); } @@ -141,7 +139,7 @@ LLSkyTex::~LLSkyTex() S32 LLSkyTex::getResolution() { - return sResolution; + return SKYTEX_RESOLUTION; } S32 LLSkyTex::getCurrent() @@ -169,12 +167,12 @@ S32 LLSkyTex::getWhich(const BOOL curr) void LLSkyTex::initEmpty(const S32 tex) { U8* data = mImageRaw[tex]->getData(); - for (S32 i = 0; i < sResolution; ++i) + for (S32 i = 0; i < SKYTEX_RESOLUTION; ++i) { - for (S32 j = 0; j < sResolution; ++j) + for (S32 j = 0; j < SKYTEX_RESOLUTION; ++j) { - const S32 basic_offset = (i * sResolution + j); - S32 offset = basic_offset * sComponents; + const S32 basic_offset = (i * SKYTEX_RESOLUTION + j); + S32 offset = basic_offset * SKYTEX_COMPONENTS; data[offset] = 0; data[offset+1] = 0; data[offset+2] = 0; @@ -190,12 +188,12 @@ void LLSkyTex::initEmpty(const S32 tex) void LLSkyTex::create() { U8* data = mImageRaw[sCurrent]->getData(); - for (S32 i = 0; i < sResolution; ++i) + for (S32 i = 0; i < SKYTEX_RESOLUTION; ++i) { - for (S32 j = 0; j < sResolution; ++j) + for (S32 j = 0; j < SKYTEX_RESOLUTION; ++j) { - const S32 basic_offset = (i * sResolution + j); - S32 offset = basic_offset * sComponents; + const S32 basic_offset = (i * SKYTEX_RESOLUTION + j); + S32 offset = basic_offset * SKYTEX_COMPONENTS; U32* pix = (U32*)(data + offset); LLColor4U temp = LLColor4U(mSkyData[basic_offset]); *pix = temp.asRGBA(); @@ -392,10 +390,8 @@ const LLVector3* LLHeavenBody::corners() const Sky ***************************************/ - -S32 LLVOSky::sResolution = LLSkyTex::getResolution(); -S32 LLVOSky::sTileResX = sResolution/NUM_TILES_X; -S32 LLVOSky::sTileResY = sResolution/NUM_TILES_Y; +const S32 SKYTEX_TILE_RES_X = SKYTEX_RESOLUTION / NUM_TILES_X; +const S32 SKYTEX_TILE_RES_Y = SKYTEX_RESOLUTION / NUM_TILES_Y; LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) : LLStaticViewerObject(id, pcode, regionp, TRUE), @@ -490,6 +486,7 @@ void LLVOSky::init() void LLVOSky::cacheEnvironment(LLSettingsSky::ptr_t psky,AtmosphericsVars& atmosphericsVars) { + // NOTE: Also see: LLAtmospherics::updateFog() // invariants across whole sky tex process... atmosphericsVars.blue_density = psky->getBlueDensity(); atmosphericsVars.blue_horizon = psky->getBlueHorizon(); @@ -598,8 +595,8 @@ void LLVOSky::initSkyTextureDirs(const S32 side, const S32 tile) S32 tile_x = tile % NUM_TILES_X; S32 tile_y = tile / NUM_TILES_X; - S32 tile_x_pos = tile_x * sTileResX; - S32 tile_y_pos = tile_y * sTileResY; + S32 tile_x_pos = tile_x * SKYTEX_TILE_RES_X; + S32 tile_y_pos = tile_y * SKYTEX_TILE_RES_Y; F32 coeff[3] = {0, 0, 0}; const S32 curr_coef = side >> 1; // 0/1 = Z axis, 2/3 = Y, 4/5 = X @@ -609,11 +606,11 @@ void LLVOSky::initSkyTextureDirs(const S32 side, const S32 tile) coeff[curr_coef] = (F32)side_dir; - F32 inv_res = 1.f/sResolution; + F32 inv_res = 1.f/SKYTEX_RESOLUTION; S32 x, y; - for (y = tile_y_pos; y < (tile_y_pos + sTileResY); ++y) + for (y = tile_y_pos; y < (tile_y_pos + SKYTEX_TILE_RES_Y); ++y) { - for (x = tile_x_pos; x < (tile_x_pos + sTileResX); ++x) + for (x = tile_x_pos; x < (tile_x_pos + SKYTEX_TILE_RES_X); ++x) { coeff[x_coef] = F32((x<<1) + 1) * inv_res - 1.f; coeff[y_coef] = F32((y<<1) + 1) * inv_res - 1.f; @@ -625,21 +622,23 @@ void LLVOSky::initSkyTextureDirs(const S32 side, const S32 tile) } } -void LLVOSky::createSkyTexture(LLSettingsSky::ptr_t psky, AtmosphericsVars& vars, const S32 side, const S32 tile) +void LLVOSky::createSkyTexture(const LLSettingsSky::ptr_t &psky, AtmosphericsVars& vars, const S32 side, const S32 tile) { + const bool low_end = !gPipeline.canUseWindLightShaders(); + S32 tile_x = tile % NUM_TILES_X; S32 tile_y = tile / NUM_TILES_X; - S32 tile_x_pos = tile_x * sTileResX; - S32 tile_y_pos = tile_y * sTileResY; + S32 tile_x_pos = tile_x * SKYTEX_TILE_RES_X; + S32 tile_y_pos = tile_y * SKYTEX_TILE_RES_Y; S32 x, y; - for (y = tile_y_pos; y < (tile_y_pos + sTileResY); ++y) + for (y = tile_y_pos; y < (tile_y_pos + SKYTEX_TILE_RES_Y); ++y) { - for (x = tile_x_pos; x < (tile_x_pos + sTileResX); ++x) + for (x = tile_x_pos; x < (tile_x_pos + SKYTEX_TILE_RES_X); ++x) { - mSkyTex [side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(psky, vars, mSkyTex [side].getDir(x, y), false), x, y); - mShinyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(psky, vars, mShinyTex[side].getDir(x, y), true ), x, y); + mSkyTex [side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(psky, vars, mSkyTex [side].getDir(x, y), false, low_end), x, y); + mShinyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(psky, vars, mShinyTex[side].getDir(x, y), true , low_end), x, y); } } } diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index 793dcf4cbf..5941ab6e3b 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -43,6 +43,9 @@ const F32 HEAVENLY_BODY_DIST = HORIZON_DIST - 20.f; const F32 HEAVENLY_BODY_FACTOR = 0.1f; const F32 HEAVENLY_BODY_SCALE = HEAVENLY_BODY_DIST * HEAVENLY_BODY_FACTOR; +const F32 SKYTEX_COMPONENTS = 4; +const F32 SKYTEX_RESOLUTION = 64; + class LLFace; class LLHaze; @@ -50,8 +53,6 @@ class LLSkyTex { friend class LLVOSky; private: - static S32 sResolution; - static S32 sComponents; LLPointer<LLViewerTexture> mTexture[2]; LLPointer<LLImageRaw> mImageRaw[2]; LLColor4 *mSkyData; @@ -82,25 +83,25 @@ protected: void setDir(const LLVector3 &dir, const S32 i, const S32 j) { - S32 offset = i * sResolution + j; + S32 offset = i * SKYTEX_RESOLUTION + j; mSkyDirs[offset] = dir; } const LLVector3 &getDir(const S32 i, const S32 j) const { - S32 offset = i * sResolution + j; + S32 offset = i * SKYTEX_RESOLUTION + j; return mSkyDirs[offset]; } void setPixel(const LLColor4 &col, const S32 i, const S32 j) { - S32 offset = i * sResolution + j; + S32 offset = i * SKYTEX_RESOLUTION + j; mSkyData[offset] = col; } void setPixel(const LLColor4U &col, const S32 i, const S32 j) { - S32 offset = (i * sResolution + j) * sComponents; + S32 offset = (i * SKYTEX_RESOLUTION + j) * SKYTEX_COMPONENTS; U32* pix = (U32*) &(mImageRaw[sCurrent]->getData()[offset]); *pix = col.asRGBA(); } @@ -108,7 +109,7 @@ protected: LLColor4U getPixel(const S32 i, const S32 j) { LLColor4U col; - S32 offset = (i * sResolution + j) * sComponents; + S32 offset = (i * SKYTEX_RESOLUTION + j) * SKYTEX_COMPONENTS; U32* pix = (U32*) &(mImageRaw[sCurrent]->getData()[offset]); col.fromRGBA( *pix ); return col; @@ -300,7 +301,7 @@ protected: void updateDirections(LLSettingsSky::ptr_t psky); void initSkyTextureDirs(const S32 side, const S32 tile); - void createSkyTexture(LLSettingsSky::ptr_t psky, AtmosphericsVars& vars, const S32 side, const S32 tile); + void createSkyTexture(const LLSettingsSky::ptr_t &psky, AtmosphericsVars& vars, const S32 side, const S32 tile); LLPointer<LLViewerFetchedTexture> mSunTexturep[2]; LLPointer<LLViewerFetchedTexture> mMoonTexturep[2]; diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index 5a8126fa38..d1f584cbca 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -36,8 +36,8 @@ #include "llenvironment.h" #include "llsettingssky.h" -static const U32 MIN_SKY_DETAIL = 8; -static const U32 MAX_SKY_DETAIL = 180; +constexpr U32 MIN_SKY_DETAIL = 8; +constexpr U32 MAX_SKY_DETAIL = 180; inline U32 LLVOWLSky::getNumStacks(void) { @@ -97,13 +97,14 @@ LLDrawable * LLVOWLSky::createDrawable(LLPipeline * pipeline) return mDrawable; } -inline F32 LLVOWLSky::calcPhi(U32 i) +// a tiny helper function for controlling the sky dome tesselation. +inline F32 calcPhi(const U32 &i, const F32 &reciprocal_num_stacks) { // Calc: PI/8 * 1-((1-t^4)*(1-t^4)) { 0<t<1 } // Demos: \pi/8*\left(1-((1-x^{4})*(1-x^{4}))\right)\ \left\{0<x\le1\right\} // i should range from [0..SKY_STACKS] so t will range from [0.f .. 1.f] - F32 t = float(i) / float(getNumStacks()); + F32 t = float(i) * reciprocal_num_stacks; //SL-16127: remove: / float(getNumStacks()); // ^4 the parameter of the tesselation to bias things toward 0 (the dome's apex) t *= t; @@ -187,6 +188,8 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) } { + const F32 dome_radius = LLEnvironment::instance().getCurrentSky()->getDomeRadius(); + const U32 max_buffer_bytes = gSavedSettings.getS32("RenderMaxVBOSize")*1024; const U32 data_mask = LLDrawPoolWLSky::SKY_VERTEX_DATA_MASK; const U32 max_verts = max_buffer_bytes / LLVertexBuffer::calcVertexSize(data_mask); @@ -202,12 +205,14 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) // round up to a whole number of segments const U32 strips_segments = (total_stacks+stacks_per_seg-1) / stacks_per_seg; - LL_INFOS() << "WL Skydome strips in " << strips_segments << " batches." << LL_ENDL; - mStripsVerts.resize(strips_segments, NULL); +#if RELEASE_SHOW_DEBUG + LL_INFOS() << "WL Skydome strips in " << strips_segments << " batches." << LL_ENDL; + LLTimer timer; timer.start(); +#endif for (U32 i = 0; i < strips_segments ;++i) { @@ -232,34 +237,42 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) const U32 num_indices_this_seg = 1+num_stacks_this_seg*(2+2*verts_per_stack); llassert(num_indices_this_seg * sizeof(U16) <= max_buffer_bytes); - if (!segment->allocateBuffer(num_verts_this_seg, num_indices_this_seg, TRUE)) + bool allocated = segment->allocateBuffer(num_verts_this_seg, num_indices_this_seg, TRUE); +#if RELEASE_SHOW_WARNS + if( !allocated ) { LL_WARNS() << "Failed to allocate Vertex Buffer on update to " << num_verts_this_seg << " vertices and " << num_indices_this_seg << " indices" << LL_ENDL; } +#else + (void) allocated; +#endif // lock the buffer BOOL success = segment->getVertexStrider(vertices) && segment->getTexCoord0Strider(texCoords) && segment->getIndexStrider(indices); - if(!success) +#if RELEASE_SHOW_DEBUG + if(!success) { LL_ERRS() << "Failed updating WindLight sky geometry." << LL_ENDL; } - - U32 vertex_count = 0; - U32 index_count = 0; +#else + (void) success; +#endif // fill it - buildStripsBuffer(begin_stack, end_stack, vertex_count, index_count, vertices, texCoords, indices); + buildStripsBuffer(begin_stack, end_stack, vertices, texCoords, indices, dome_radius, verts_per_stack, total_stacks); // and unlock the buffer segment->flush(); } +#if RELEASE_SHOW_DEBUG LL_INFOS() << "completed in " << llformat("%.2f", timer.getElapsedTimeF32().value()) << "seconds" << LL_ENDL; +#endif } updateStarColors(); @@ -364,23 +377,16 @@ void LLVOWLSky::initStars() void LLVOWLSky::buildStripsBuffer(U32 begin_stack, U32 end_stack, - U32& vertex_count, - U32& index_count, - LLStrider<LLVector3> & vertices, - LLStrider<LLVector2> & texCoords, - LLStrider<U16> & indices) + LLStrider<LLVector3> & vertices, + LLStrider<LLVector2> & texCoords, + LLStrider<U16> & indices, + const F32 dome_radius, + const U32& num_slices, + const U32& num_stacks) { - const F32 RADIUS = LLEnvironment::instance().getCurrentSky()->getDomeRadius(); - - U32 i, j, num_slices, num_stacks; + U32 i, j; F32 phi0, theta, x0, y0, z0; - - // paranoia checking for SL-55986/SL-55833 - U32 count_verts = 0; - U32 count_indices = 0; - - num_slices = getNumSlices(); - num_stacks = getNumStacks(); + const F32 reciprocal_num_stacks = 1.f / num_stacks; llassert(end_stack <= num_stacks); @@ -391,7 +397,7 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, for(i = begin_stack + 1; i <= end_stack+1; ++i) #endif { - phi0 = calcPhi(i); + phi0 = calcPhi(i, reciprocal_num_stacks); for(j = 0; j < num_slices; ++j) { @@ -404,24 +410,22 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, z0 = sin(phi0) * sin(theta); #if NEW_TESS - *vertices++ = LLVector3(x0 * RADIUS, y0 * RADIUS, z0 * RADIUS); + *vertices++ = LLVector3(x0 * dome_radius, y0 * dome_radius, z0 * dome_radius); #else if (i == num_stacks-2) { - *vertices++ = LLVector3(x0*RADIUS, y0*RADIUS-1024.f*2.f, z0*RADIUS); + *vertices++ = LLVector3(x0*dome_radius, y0*dome_radius-1024.f*2.f, z0*dome_radius); } else if (i == num_stacks-1) { - *vertices++ = LLVector3(0, y0*RADIUS-1024.f*2.f, 0); + *vertices++ = LLVector3(0, y0*dome_radius-1024.f*2.f, 0); } else { - *vertices++ = LLVector3(x0 * RADIUS, y0 * RADIUS, z0 * RADIUS); + *vertices++ = LLVector3(x0 * dome_radius, y0 * dome_radius, z0 * dome_radius); } #endif - ++count_verts; - // generate planar uv coordinates // note: x and z are transposed in order for things to animate // correctly in the global coordinate system where +x is east and @@ -432,12 +436,11 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, //build triangle strip... *indices++ = 0 ; - count_indices++ ; + S32 k = 0 ; for(i = 1; i <= end_stack - begin_stack; ++i) { *indices++ = i * num_slices + k ; - count_indices++ ; k = (k+1) % num_slices ; for(j = 0; j < num_slices ; ++j) @@ -445,8 +448,6 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, *indices++ = (i-1) * num_slices + k ; *indices++ = i * num_slices + k ; - count_indices += 2 ; - k = (k+1) % num_slices ; } @@ -456,11 +457,7 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, } *indices++ = i * num_slices + k ; - count_indices++ ; } - - vertex_count = count_verts; - index_count = count_indices; } void LLVOWLSky::updateStarColors() diff --git a/indra/newview/llvowlsky.h b/indra/newview/llvowlsky.h index 2b7ebe75dd..3853dd2c70 100644 --- a/indra/newview/llvowlsky.h +++ b/indra/newview/llvowlsky.h @@ -55,8 +55,6 @@ public: void restoreGL(); private: - // a tiny helper function for controlling the sky dome tesselation. - static F32 calcPhi(U32 i); // helper function for initializing the stars. void initStars(); @@ -66,11 +64,12 @@ private: // begin_stack is the first stack to be included, end_stack is the first // stack not to be included. static void buildStripsBuffer(U32 begin_stack, U32 end_stack, - U32& vertex_count, - U32& index_count, - LLStrider<LLVector3> & vertices, - LLStrider<LLVector2> & texCoords, - LLStrider<U16> & indices); + LLStrider<LLVector3> & vertices, + LLStrider<LLVector2> & texCoords, + LLStrider<U16> & indices, + const F32 RADIUS, + const U32& num_slices, + const U32& num_stacks); // helper function for updating the stars colors. void updateStarColors(); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 6ed6e20b03..71a438302a 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1231,7 +1231,8 @@ void LLPipeline::releaseShadowTargets() void LLPipeline::createGLBuffers() { - stop_glerror(); + LL_PROFILE_ZONE_SCOPED; + stop_glerror(); assertInitialized(); updateRenderDeferred(); @@ -1384,7 +1385,7 @@ void LLPipeline::restoreGL() if (part) { part->restoreGL(); - } + } } } } @@ -2428,8 +2429,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl LLVOCachePartition* vo_part = region->getVOCachePartition(); if(vo_part) { - bool do_occlusion_cull = can_use_occlusion && use_occlusion && !gUseWireframe && 0 > water_clip /* && !gViewerWindow->getProgressView()->getVisible()*/; - do_occlusion_cull &= !sReflectionRender; + bool do_occlusion_cull = can_use_occlusion && use_occlusion && !gUseWireframe; // && 0 > water_clip vo_part->cull(camera, do_occlusion_cull); } } @@ -2629,7 +2629,8 @@ void LLPipeline::doOcclusion(LLCamera& camera, LLRenderTarget& source, LLRenderT void LLPipeline::doOcclusion(LLCamera& camera) { - if (LLPipeline::sUseOcclusion > 1 && !LLSpatialPartition::sTeleportRequested && + LL_PROFILE_ZONE_SCOPED; + if (LLPipeline::sUseOcclusion > 1 && !LLSpatialPartition::sTeleportRequested && (sCull->hasOcclusionGroups() || LLVOCachePartition::sNeedsOcclusionCheck)) { LLVertexBuffer::unbind(); @@ -3422,7 +3423,8 @@ void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera) void LLPipeline::stateSort(LLSpatialBridge* bridge, LLCamera& camera, BOOL fov_changed) { - if (bridge->getSpatialGroup()->changeLOD() || fov_changed) + LL_PROFILE_ZONE_SCOPED; + if (bridge->getSpatialGroup()->changeLOD() || fov_changed) { bool force_update = false; bridge->updateDistance(camera, force_update); @@ -3431,7 +3433,8 @@ void LLPipeline::stateSort(LLSpatialBridge* bridge, LLCamera& camera, BOOL fov_c void LLPipeline::stateSort(LLDrawable* drawablep, LLCamera& camera) { - if (!drawablep + LL_PROFILE_ZONE_SCOPED; + if (!drawablep || drawablep->isDead() || !hasRenderType(drawablep->getRenderType())) { @@ -4708,7 +4711,8 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) void LLPipeline::renderGeomShadow(LLCamera& camera) { - U32 cur_type = 0; + LL_PROFILE_ZONE_SCOPED; + U32 cur_type = 0; LLGLEnable cull(GL_CULL_FACE); @@ -8384,15 +8388,13 @@ LLVector4 pow4fsrgb(LLVector4 v, F32 f) return v; } -static LLTrace::BlockTimerStatHandle FTM_DEFERRED_LIGHTING("Deferred Lighting"); - void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) { + LL_PROFILE_ZONE_SCOPED; if (!sCull) { return; } - LL_RECORD_BLOCK_TIME(FTM_DEFERRED_LIGHTING); LLRenderTarget *deferred_target = &mDeferredScreen; LLRenderTarget *deferred_depth_target = &mDeferredDepth; @@ -9200,6 +9202,7 @@ inline float sgn(float a) void LLPipeline::generateWaterReflection(LLCamera& camera_in) { + LL_PROFILE_ZONE_SCOPED; if (LLPipeline::sWaterReflections && assertInitialized() && LLDrawPoolWater::sNeedsReflectionUpdate) { bool skip_avatar_update = false; @@ -9254,11 +9257,6 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) water_clip = -1; } - S32 occlusion = LLPipeline::sUseOcclusion; - - //disable occlusion culling for reflection map for now - LLPipeline::sUseOcclusion = 0; - if (!camera_is_underwater) { //generate planar reflection map @@ -9374,8 +9372,6 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) set_current_modelview(saved_modelview); } - //LLPipeline::sUseOcclusion = occlusion; - camera.setOrigin(camera_in.getOrigin()); //render distortion map static bool last_update = true; @@ -9470,7 +9466,6 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gPipeline.popRenderTypeMask(); - LLPipeline::sUseOcclusion = occlusion; LLPipeline::sUnderWaterRender = false; LLPipeline::sReflectionRender = false; diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml index 7786ba8a1c..cba75e8ea7 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml @@ -334,15 +334,15 @@ width="256" /> <check_box - control_name="RenderVBOEnable" + control_name="RenderVSyncEnable" height="16" initial_value="true" - label="Enable OpenGL Vertex Buffer Objects" + label="Enable VSync" layout="topleft" left="30" top_delta="16" - name="vbo" - tool_tip="Enabling this on modern hardware gives a performance gain. However, older hardware often has poor implementations of VBOs and you may get crashes when this is enabled." + name="vsync" + tool_tip="Synchronizes the frame rate to the refresh rate of the monitor, which results in smooth performance." width="315" /> <check_box |