diff --git a/autobuild.xml b/autobuild.xml
index a848729023..edf7477fdd 100644
--- a/autobuild.xml
+++ b/autobuild.xml
@@ -3240,11 +3240,11 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors
archive
name
common
diff --git a/doc/contributions.txt b/doc/contributions.txt
index 8f3e494018..5c338493c3 100755
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -248,7 +248,7 @@ Ansariel Hiller
SL-4126
SL-20224
SL-20524
- https://github.com/secondlife/viewer/issues/1051
+ secondlife/viewer#1051
Aralara Rajal
Arare Chantilly
CHUIBUG-191
diff --git a/indra/cmake/Copy3rdPartyLibs.cmake b/indra/cmake/Copy3rdPartyLibs.cmake
index 0fedf579b1..3a3546a8ef 100644
--- a/indra/cmake/Copy3rdPartyLibs.cmake
+++ b/indra/cmake/Copy3rdPartyLibs.cmake
@@ -124,7 +124,6 @@ if(WINDOWS)
MESSAGE(WARNING "New MSVC_VERSION ${MSVC_VERSION} of MSVC: adapt Copy3rdPartyLibs.cmake")
endif (MSVC80)
- # Try using the VC runtime redistributables that came with the VS installation first
if (MSVC_TOOLSET_VER AND DEFINED ENV{VCTOOLSREDISTDIR})
if(ADDRESS_SIZE EQUAL 32)
set(redist_find_path "$ENV{VCTOOLSREDISTDIR}x86\\Microsoft.VC${MSVC_TOOLSET_VER}.CRT")
@@ -134,7 +133,6 @@ if(WINDOWS)
get_filename_component(redist_path "${redist_find_path}" ABSOLUTE)
MESSAGE(STATUS "VC Runtime redist path: ${redist_path}")
endif (MSVC_TOOLSET_VER AND DEFINED ENV{VCTOOLSREDISTDIR})
- #
if(ADDRESS_SIZE EQUAL 32)
# this folder contains the 32bit DLLs.. (yes really!)
@@ -158,14 +156,12 @@ if(WINDOWS)
vcruntime${MSVC_VER}.dll
vcruntime${MSVC_VER}_1.dll
)
- # Try using the VC runtime redistributables that came with the VS installation first
if(redist_path AND EXISTS "${redist_path}/${release_msvc_file}")
MESSAGE(STATUS "Copying redist file from ${redist_path}/${release_msvc_file}")
to_staging_dirs(
${redist_path}
third_party_targets
${release_msvc_file})
- #
elseif(EXISTS "${registry_path}/${release_msvc_file}")
MESSAGE(STATUS "Copying redist file from ${registry_path}/${release_msvc_file}")
to_staging_dirs(
diff --git a/indra/llappearance/llavatarappearance.cpp b/indra/llappearance/llavatarappearance.cpp
index ea5124b3f3..30ac98eeac 100644
--- a/indra/llappearance/llavatarappearance.cpp
+++ b/indra/llappearance/llavatarappearance.cpp
@@ -496,21 +496,69 @@ void LLAvatarAppearance::computeBodySize()
mCurrBodySizeState["mAnkleLeft scale"] = mAnkleLeftp->getScale();
mCurrBodySizeState["mFootLeft pos"] = mFootLeftp->getPosition();
- F32 old_height = mBodySize.mV[VZ];
+ LLVector3 pelvis_scale = mPelvisp->getScale();
+
+ // some of the joints have not been cached
+ LLVector3 skull = mSkullp->getPosition();
+ //LLVector3 skull_scale = mSkullp->getScale();
+
+ LLVector3 neck = mNeckp->getPosition();
+ LLVector3 neck_scale = mNeckp->getScale();
+
+ LLVector3 chest = mChestp->getPosition();
+ LLVector3 chest_scale = mChestp->getScale();
+
+ // the rest of the joints have been cached
+ LLVector3 head = mHeadp->getPosition();
+ LLVector3 head_scale = mHeadp->getScale();
+
+ LLVector3 torso = mTorsop->getPosition();
+ LLVector3 torso_scale = mTorsop->getScale();
+
+ LLVector3 hip = mHipLeftp->getPosition();
+ LLVector3 hip_scale = mHipLeftp->getScale();
+
+ LLVector3 knee = mKneeLeftp->getPosition();
+ LLVector3 knee_scale = mKneeLeftp->getScale();
+
+ LLVector3 ankle = mAnkleLeftp->getPosition();
+ LLVector3 ankle_scale = mAnkleLeftp->getScale();
+
+ LLVector3 foot = mFootLeftp->getPosition();
+
F32 old_offset = mAvatarOffset.mV[VZ];
- // TODO: Measure the real depth and width
- mPelvisToFoot = computePelvisToFoot();
- F32 new_height = computeBodyHeight();
- mBodySize.set(DEFAULT_AGENT_DEPTH, DEFAULT_AGENT_WIDTH, new_height);
// [RLVa:KB] - Checked: 2013-03-03 (RLVa-1.4.8)
- F32 new_offset = getAvatarOffset();
+ mAvatarOffset.mV[VZ] = getAvatarOffset();
// [/RLVa:KB]
-// F32 new_offset = getVisualParamWeight(AVATAR_HOVER);
- mAvatarOffset.set(0, 0, new_offset);
+// mAvatarOffset.mV[VZ] = getVisualParamWeight(AVATAR_HOVER);
- if (mBodySize.mV[VZ] != old_height || new_offset != old_offset)
+ mPelvisToFoot = hip.mV[VZ] * pelvis_scale.mV[VZ] -
+ knee.mV[VZ] * hip_scale.mV[VZ] -
+ ankle.mV[VZ] * knee_scale.mV[VZ] -
+ foot.mV[VZ] * ankle_scale.mV[VZ];
+
+ LLVector3 new_body_size;
+ new_body_size.mV[VZ] = mPelvisToFoot +
+ // the sqrt(2) correction below is an approximate
+ // correction to get to the top of the head
+ F_SQRT2 * (skull.mV[VZ] * head_scale.mV[VZ]) +
+ head.mV[VZ] * neck_scale.mV[VZ] +
+ neck.mV[VZ] * chest_scale.mV[VZ] +
+ chest.mV[VZ] * torso_scale.mV[VZ] +
+ torso.mV[VZ] * pelvis_scale.mV[VZ];
+
+ // TODO -- measure the real depth and width
+ new_body_size.mV[VX] = DEFAULT_AGENT_DEPTH;
+ new_body_size.mV[VY] = DEFAULT_AGENT_WIDTH;
+
+ mAvatarOffset.mV[VX] = 0.0f;
+ mAvatarOffset.mV[VY] = 0.0f;
+
+ if (new_body_size != mBodySize || old_offset != mAvatarOffset.mV[VZ])
{
+ mBodySize = new_body_size;
+
// [Legacy Bake]
bodySizeChanged();
@@ -518,29 +566,6 @@ void LLAvatarAppearance::computeBodySize()
}
}
-F32 LLAvatarAppearance::computeBodyHeight()
-{
- F32 result = mPelvisToFoot +
- // all these relative positions usually are positive
- mPelvisp->getScale().mV[VZ] * mTorsop->getPosition().mV[VZ] +
- mTorsop->getScale().mV[VZ] * mChestp->getPosition().mV[VZ] +
- mChestp->getScale().mV[VZ] * mNeckp->getPosition().mV[VZ] +
- mNeckp->getScale().mV[VZ] * mHeadp->getPosition().mV[VZ] +
- mHeadp->getScale().mV[VZ] * mSkullp->getPosition().mV[VZ] * 2;
- return result;
-}
-
-F32 LLAvatarAppearance::computePelvisToFoot()
-{
- F32 result =
- // all these relative positions usually are negative
- mPelvisp->getScale().mV[VZ] * mHipLeftp->getPosition().mV[VZ] +
- mHipLeftp->getScale().mV[VZ] * mKneeLeftp->getPosition().mV[VZ] +
- mKneeLeftp->getScale().mV[VZ] * mAnkleLeftp->getPosition().mV[VZ] +
- mAnkleLeftp->getScale().mV[VZ] * mFootLeftp->getPosition().mV[VZ] / 2;
- return -result;
-}
-
// [RLVa:KB] - Checked: 2013-03-03 (RLVa-1.4.8)
F32 LLAvatarAppearance::getAvatarOffset() /*const*/
{
diff --git a/indra/llappearance/llavatarappearance.h b/indra/llappearance/llavatarappearance.h
index 431950c25a..f0bf080427 100644
--- a/indra/llappearance/llavatarappearance.h
+++ b/indra/llappearance/llavatarappearance.h
@@ -153,8 +153,6 @@ public:
void compareJointStateMaps(joint_state_map_t& last_state,
joint_state_map_t& curr_state);
void computeBodySize();
- F32 computeBodyHeight();
- F32 computePelvisToFoot();
public:
typedef std::vector avatar_joint_list_t;
diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp
index 64f9b1629f..17555e7da7 100644
--- a/indra/llcommon/llapp.cpp
+++ b/indra/llcommon/llapp.cpp
@@ -592,9 +592,10 @@ void default_unix_signal_handler(int signum, siginfo_t *info, void *)
switch (signum)
{
case SIGCHLD:
+ case SIGHUP:
if (LLApp::sLogInSignal)
{
- LL_INFOS() << "Signal handler - Got SIGCHLD from " << info->si_pid << LL_ENDL;
+ LL_INFOS() << "Signal handler - Got SIGCHLD or SIGHUP from " << info->si_pid << LL_ENDL;
}
return;
@@ -609,11 +610,10 @@ void default_unix_signal_handler(int signum, siginfo_t *info, void *)
raise(signum);
return;
case SIGINT:
- case SIGHUP:
case SIGTERM:
if (LLApp::sLogInSignal)
{
- LL_WARNS() << "Signal handler - Got SIGINT, HUP, or TERM, exiting gracefully" << LL_ENDL;
+ LL_WARNS() << "Signal handler - Got SIGINT, or TERM, exiting gracefully" << LL_ENDL;
}
// Graceful exit
// Just set our state to quitting, not error
diff --git a/indra/llcommon/llleap.cpp b/indra/llcommon/llleap.cpp
index d0fb586459..e93ba83434 100644
--- a/indra/llcommon/llleap.cpp
+++ b/indra/llcommon/llleap.cpp
@@ -18,9 +18,6 @@
#include
// std headers
// external library headers
-#include
-#include
-#include
// other Linden headers
#include "llerror.h"
#include "llstring.h"
@@ -64,7 +61,9 @@ public:
// Pass it a callback to our connect() method, so it can send events
// from a particular LLEventPump to the plugin without having to know
// this class or method name.
- mListener(new LLLeapListener(boost::bind(&LLLeapImpl::connect, this, _1, _2)))
+ mListener(new LLLeapListener(
+ [this](LLEventPump& pump, const std::string& listener)
+ { return connect(pump, listener); }))
{
// Rule out unpopulated Params block
if (! cparams.executable.isProvided())
@@ -93,7 +92,7 @@ public:
}
// Listen for child "termination" right away to catch launch errors.
- mDonePump.listen("LLLeap", boost::bind(&LLLeapImpl::bad_launch, this, _1));
+ mDonePump.listen("LLLeap", [this](const LLSD& data){ return bad_launch(data); });
// Okay, launch child.
// Get a modifiable copy of params block to set files and postend.
@@ -113,7 +112,7 @@ public:
// Okay, launch apparently worked. Change our mDonePump listener.
mDonePump.stopListening("LLLeap");
- mDonePump.listen("LLLeap", boost::bind(&LLLeapImpl::done, this, _1));
+ mDonePump.listen("LLLeap", [this](const LLSD& data){ return done(data); });
// Child might pump large volumes of data through either stdout or
// stderr. Don't bother copying all that data into notification event.
@@ -128,13 +127,9 @@ public:
// Listening on stdout is stateful. In general, we're either waiting
// for the length prefix or waiting for the specified length of data.
- // We address that with two different listener methods -- one of which
- // is blocked at any given time.
+ mReadPrefix = true;
mStdoutConnection = childout.getPump()
- .listen("prefix", boost::bind(&LLLeapImpl::rstdout, this, _1));
- mStdoutDataConnection = childout.getPump()
- .listen("data", boost::bind(&LLLeapImpl::rstdoutData, this, _1));
- mBlocker.reset(new LLEventPump::Blocker(mStdoutDataConnection));
+ .listen("LLLeap", [this](const LLSD& data){ return rstdout(data); });
// Log anything sent up through stderr. When a typical program
// encounters an error, it writes its error message to stderr and
@@ -142,7 +137,7 @@ public:
// interpreter behaves that way. More generally, though, a plugin
// author can log whatever s/he wants to the viewer log using stderr.
mStderrConnection = childerr.getPump()
- .listen("LLLeap", boost::bind(&LLLeapImpl::rstderr, this, _1));
+ .listen("LLLeap", [this](const LLSD& data){ return rstderr(data); });
// For our lifespan, intercept any LL_ERRS so we can notify plugin
mRecorder = LLError::addGenericRecorder(
@@ -255,120 +250,120 @@ public:
return false;
}
- // Initial state of stateful listening on child stdout: wait for a length
- // prefix, followed by ':'.
- bool rstdout(const LLSD& data)
+ // Stateful listening on child stdout:
+ // wait for a length prefix, followed by ':'.
+ bool rstdout(const LLSD&)
{
LLProcess::ReadPipe& childout(mChild->getReadPipe(LLProcess::STDOUT));
- // It's possible we got notified of a couple digit characters without
- // seeing the ':' -- unlikely, but still. Until we see ':', keep
- // waiting.
- if (childout.contains(':'))
+ while (childout.size())
{
- std::istream& childstream(childout.get_istream());
- // Saw ':', read length prefix and store in mExpect.
- size_t expect;
- childstream >> expect;
- int colon(childstream.get());
- if (colon != ':')
+ /*----------------- waiting for length prefix ------------------*/
+ if (mReadPrefix)
{
- // Protocol failure. Clear out the rest of the pending data in
- // childout (well, up to a max length) to log what was wrong.
- LLProcess::ReadPipe::size_type
- readlen((std::min)(childout.size(), LLProcess::ReadPipe::size_type(80)));
- bad_protocol(STRINGIZE(expect << char(colon) << childout.read(readlen)));
- }
- else
- {
- // Saw length prefix, saw colon, life is good. Now wait for
- // that length of data to arrive.
- mExpect = expect;
- LL_DEBUGS("LLLeap") << "got length, waiting for "
- << mExpect << " bytes of data" << LL_ENDL;
- // Block calls to this method; resetting mBlocker unblocks
- // calls to the other method.
- mBlocker.reset(new LLEventPump::Blocker(mStdoutConnection));
- // Go check if we've already received all the advertised data.
- if (childout.size())
+ // It's possible we got notified of a couple digit characters without
+ // seeing the ':' -- unlikely, but still. Until we see ':', keep
+ // waiting.
+ if (! childout.contains(':'))
{
- LLSD updata(data);
- updata["len"] = LLSD::Integer(childout.size());
- rstdoutData(updata);
+ if (childout.contains('\n'))
+ {
+ // Since this is the initial listening state, this is where we'd
+ // arrive if the child isn't following protocol at all -- say
+ // because the user specified 'ls' or some darn thing.
+ bad_protocol(childout.getline());
+ }
+ // Either way, stop looping.
+ break;
}
- }
- }
- else if (childout.contains('\n'))
- {
- // Since this is the initial listening state, this is where we'd
- // arrive if the child isn't following protocol at all -- say
- // because the user specified 'ls' or some darn thing.
- bad_protocol(childout.getline());
- }
- return false;
- }
- // State in which we listen on stdout for the specified length of data to
- // arrive.
- bool rstdoutData(const LLSD& data)
- {
- LLProcess::ReadPipe& childout(mChild->getReadPipe(LLProcess::STDOUT));
- // Until we've accumulated the promised length of data, keep waiting.
- if (childout.size() >= mExpect)
- {
- // Ready to rock and roll.
- LL_DEBUGS("LLLeap") << "needed " << mExpect << " bytes, got "
- << childout.size() << ", parsing LLSD" << LL_ENDL;
- LLSD data;
-#if 1
- // specifically require notation LLSD from child
- LLPointer parser(new LLSDNotationParser());
- S32 parse_status(parser->parse(childout.get_istream(), data, mExpect));
- if (parse_status == LLSDParser::PARSE_FAILURE)
-#else
- // SL-18330: accept any valid LLSD serialization format from child
- // Unfortunately this runs into trouble we have not yet debugged.
- bool parse_status(LLSDSerialize::deserialize(data, childout.get_istream(), mExpect));
- if (! parse_status)
-#endif
- {
- bad_protocol("unparseable LLSD data");
- }
- else if (! (data.isMap() && data["pump"].isString() && data.has("data")))
- {
- // we got an LLSD object, but it lacks required keys
- bad_protocol("missing 'pump' or 'data'");
+ // Saw ':', read length prefix and store in mExpect.
+ std::istream& childstream(childout.get_istream());
+ size_t expect;
+ childstream >> expect;
+ int colon(childstream.get());
+ if (colon != ':')
+ {
+ // Protocol failure. Clear out the rest of the pending data in
+ // childout (well, up to a max length) to log what was wrong.
+ LLProcess::ReadPipe::size_type
+ readlen((std::min)(childout.size(),
+ LLProcess::ReadPipe::size_type(80)));
+ bad_protocol(stringize(expect, char(colon), childout.read(readlen)));
+ break;
+ }
+ else
+ {
+ // Saw length prefix, saw colon, life is good. Now wait for
+ // that length of data to arrive.
+ mExpect = expect;
+ LL_DEBUGS("LLLeap") << "got length, waiting for "
+ << mExpect << " bytes of data" << LL_ENDL;
+ // Transition to "read data" mode and loop back to check
+ // if we've already received all the advertised data.
+ mReadPrefix = false;
+ continue;
+ }
}
+ /*----------------- saw prefix, wait for data ------------------*/
else
{
- try
+ // Until we've accumulated the promised length of data, keep waiting.
+ if (childout.size() < mExpect)
{
- // The LLSD object we got from our stream contains the
- // keys we need.
- LLEventPumps::instance().obtain(data["pump"]).post(data["data"]);
+ break;
}
- catch (const std::exception& err)
+
+ // We have the data we were told to expect! Ready to rock and roll.
+ LL_DEBUGS("LLLeap") << "needed " << mExpect << " bytes, got "
+ << childout.size() << ", parsing LLSD" << LL_ENDL;
+ LLSD data;
+#if 1
+ // specifically require notation LLSD from child
+ LLPointer parser(new LLSDNotationParser());
+ S32 parse_status(parser->parse(childout.get_istream(), data, mExpect));
+ if (parse_status == LLSDParser::PARSE_FAILURE)
+#else
+ // SL-18330: accept any valid LLSD serialization format from child
+ // Unfortunately this runs into trouble we have not yet debugged.
+ bool parse_status(LLSDSerialize::deserialize(data, childout.get_istream(), mExpect));
+ if (! parse_status)
+#endif
{
- // No plugin should be allowed to crash the viewer by
- // driving an exception -- intentionally or not.
- LOG_UNHANDLED_EXCEPTION(stringize("handling request ", data));
- // Whether or not the plugin added a "reply" key to the
- // request, send a reply. We happen to know who originated
- // this request, and the reply LLEventPump of interest.
- // Not our problem if the plugin ignores the reply event.
- data["reply"] = mReplyPump.getName();
- sendReply(llsd::map("error",
- stringize(LLError::Log::classname(err), ": ", err.what())),
- data);
+ bad_protocol("unparseable LLSD data");
+ break;
}
- // Block calls to this method; resetting mBlocker unblocks
- // calls to the other method.
- mBlocker.reset(new LLEventPump::Blocker(mStdoutDataConnection));
- // Go check for any more pending events in the buffer.
- if (childout.size())
+ else if (! (data.isMap() && data["pump"].isString() && data.has("data")))
{
- LLSD updata(data);
- data["len"] = LLSD::Integer(childout.size());
- rstdout(updata);
+ // we got an LLSD object, but it lacks required keys
+ bad_protocol("missing 'pump' or 'data'");
+ break;
+ }
+ else
+ {
+ try
+ {
+ // The LLSD object we got from our stream contains the
+ // keys we need.
+ LLEventPumps::instance().obtain(data["pump"]).post(data["data"]);
+ }
+ catch (const std::exception& err)
+ {
+ // No plugin should be allowed to crash the viewer by
+ // driving an exception -- intentionally or not.
+ LOG_UNHANDLED_EXCEPTION(stringize("handling request ", data));
+ // Whether or not the plugin added a "reply" key to the
+ // request, send a reply. We happen to know who originated
+ // this request, and the reply LLEventPump of interest.
+ // Not our problem if the plugin ignores the reply event.
+ data["reply"] = mReplyPump.getName();
+ sendReply(llsd::map("error",
+ stringize(LLError::Log::classname(err), ": ", err.what())),
+ data);
+ }
+ // Transition to "read prefix" mode and go check for any
+ // more pending events in the buffer.
+ mReadPrefix = true;
+ continue;
}
}
}
@@ -453,7 +448,8 @@ private:
// child's stdin, suitably enriched with the pump name on which it was
// received.
return pump.listen(listener,
- boost::bind(&LLLeapImpl::wstdin, this, pump.getName(), _1));
+ [this, name=pump.getName()](const LLSD& data)
+ { return wstdin(name, data); });
}
std::string mDesc;
@@ -461,11 +457,11 @@ private:
LLEventStream mReplyPump;
LLProcessPtr mChild;
LLTempBoundListener
- mStdinConnection, mStdoutConnection, mStdoutDataConnection, mStderrConnection;
- std::unique_ptr mBlocker;
+ mStdinConnection, mStdoutConnection, mStderrConnection;
LLProcess::ReadPipe::size_type mExpect;
LLError::RecorderPtr mRecorder;
std::unique_ptr mListener;
+ bool mReadPrefix;
};
// These must follow the declaration of LLLeapImpl, so they may as well be last.
diff --git a/indra/llcommon/llprofiler.h b/indra/llcommon/llprofiler.h
index 428702e0e7..2d228e03ce 100644
--- a/indra/llcommon/llprofiler.h
+++ b/indra/llcommon/llprofiler.h
@@ -237,7 +237,7 @@ namespace LLProfiler
#define LL_LABEL_OBJECT_GL(type, name, length, label)
-#if LL_PROFILER_CONFIGURATION > 1
+#if !LL_DARWIN && LL_PROFILER_CONFIGURATION > 1
#define LL_PROFILE_ALLOC(ptr, size) TracyAlloc(ptr, size)
#define LL_PROFILE_FREE(ptr) TracyFree(ptr)
#else
diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index 6bb5947dcd..4841174b10 100644
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -830,7 +830,7 @@ std::string utf8str_showBytesUTF8(const std::string& utf8str)
}
// Search for any emoji symbol, return true if found
-bool wstring_has_emoji(const LLWString& wstr)
+bool wstring_has_emoji(LLWStringView wstr)
{
for (const llwchar& wch : wstr)
{
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index 0ecc289b73..0e70bf94d5 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -456,6 +456,7 @@ template std::string LLStringUtilBase::sLocale;
typedef LLStringUtilBase LLStringUtil;
typedef LLStringUtilBase LLWStringUtil;
typedef std::basic_string LLWString;
+typedef std::basic_string_view LLWStringView;
//@ Use this where we want to disallow input in the form of "foo"
// This is used to catch places where english text is embedded in the code
@@ -762,7 +763,7 @@ LL_COMMON_API llwchar utf8str_to_wchar(const std::string& utf8str, size_t offset
LL_COMMON_API std::string utf8str_showBytesUTF8(const std::string& utf8str);
-LL_COMMON_API bool wstring_has_emoji(const LLWString& wstr);
+LL_COMMON_API bool wstring_has_emoji(LLWStringView wstr);
LL_COMMON_API bool wstring_remove_emojis(LLWString& wstr);
diff --git a/indra/llcommon/lluuid.h b/indra/llcommon/lluuid.h
index 2bf11fdd34..9b1dfa8ac9 100644
--- a/indra/llcommon/lluuid.h
+++ b/indra/llcommon/lluuid.h
@@ -37,8 +37,8 @@ class LLMutex;
const S32 UUID_BYTES = 16;
const S32 UUID_WORDS = 4;
-const S32 UUID_STR_LENGTH = 37; // actually wrong, should be 36 and use size below
-const S32 UUID_STR_SIZE = 37;
+const S32 UUID_STR_LENGTH = 37; // number of bytes needed to store a UUID as a string
+const S32 UUID_STR_SIZE = 36; // .size() of a UUID in a std::string
const S32 UUID_BASE85_LENGTH = 21; // including the trailing NULL.
struct uuid_time_t {
diff --git a/indra/llcommon/tests/threadsafeschedule_test.cpp b/indra/llcommon/tests/threadsafeschedule_test.cpp
index f2f17dd2e6..5e5d6e1259 100644
--- a/indra/llcommon/tests/threadsafeschedule_test.cpp
+++ b/indra/llcommon/tests/threadsafeschedule_test.cpp
@@ -47,11 +47,11 @@ namespace tut
// the timestamp for each one -- but since we're passing explicit
// timestamps, make the queue reorder them.
auto now{ Queue::Clock::now() };
- queue.push(Queue::TimeTuple(now + 200ms, "ghi"));
+ queue.push(Queue::TimeTuple(now + 200ms, "ghi"s));
// Given the various push() overloads, you have to match the type
// exactly: conversions are ambiguous.
- queue.push("abc"s);
- queue.push(now + 100ms, "def");
+ queue.push(now, "abc"s);
+ queue.push(now + 100ms, "def"s);
queue.close();
auto entry = queue.pop();
ensure_equals("failed to pop first", std::get<0>(entry), "abc"s);
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index f10392a1f6..c2eb8d96c4 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -2274,6 +2274,61 @@ LLImageFormatted* LLImageFormatted::createFromType(S8 codec)
return image;
}
+// static
+S8 LLImageFormatted::getCodecFromMimeType(std::string_view mimetype)
+{
+ if (mimetype == "image/bmp")
+ {
+ return IMG_CODEC_BMP;
+ }
+ else if (mimetype == "image/tga")
+ {
+ return IMG_CODEC_TGA;
+ }
+ else if (mimetype == "image/jpeg")
+ {
+ return IMG_CODEC_JPEG;
+ }
+ else if (mimetype == "image/png")
+ {
+ return IMG_CODEC_PNG;
+ }
+ else if (mimetype == "image/j2c")
+ {
+ return IMG_CODEC_J2C;
+ }
+ else if (mimetype == "image/dxt")
+ {
+ return IMG_CODEC_DXT;
+ }
+ return IMG_CODEC_INVALID;
+}
+
+// static
+LLImageFormatted* LLImageFormatted::createFromMimeType(std::string_view mimetype)
+{
+ S8 codec = getCodecFromMimeType(mimetype);
+ return createFromType(codec);
+}
+
+// static
+LLImageFormatted* LLImageFormatted::loadFromMemory(const U8* data_in, U32 size, std::string_view mimetype)
+{
+ LLImageFormatted* image = createFromMimeType(mimetype);
+ if (image)
+ {
+ U8* data = image->allocateData(size);
+ memcpy(data, data_in, size);
+
+ if (!image->updateData())
+ {
+ delete image;
+ image = NULL;
+ }
+ }
+ return image;
+}
+
// static
LLImageFormatted* LLImageFormatted::createFromExtension(const std::string& instring)
{
@@ -2457,6 +2512,7 @@ void LLImageFormatted::appendData(U8 *data, S32 size)
//----------------------------------------------------------------------------
+
bool LLImageFormatted::load(const std::string &filename, int load_size)
{
resetLastError();
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index f79c4ed217..a2ab98cc3e 100644
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -332,7 +332,10 @@ class LLImageFormatted : public LLImageBase
{
public:
static LLImageFormatted* createFromType(S8 codec);
+ static LLImageFormatted* loadFromMemory(const U8* data, U32 size, std::string_view mimetype);
static LLImageFormatted* createFromExtension(const std::string& instring);
+ static LLImageFormatted* createFromMimeType(std::string_view mimetype);
+ static S8 getCodecFromMimeType(std::string_view mimetype);
protected:
/*virtual*/ ~LLImageFormatted();
diff --git a/indra/llinventory/llpermissions.h b/indra/llinventory/llpermissions.h
index f9f1fd75f5..ac3c247f56 100644
--- a/indra/llinventory/llpermissions.h
+++ b/indra/llinventory/llpermissions.h
@@ -270,36 +270,23 @@ public:
inline bool allowModifyBy(const LLUUID &agent_id) const;
inline bool allowCopyBy(const LLUUID& agent_id) const;
inline bool allowMoveBy(const LLUUID& agent_id) const;
+
inline bool allowModifyBy(const LLUUID &agent_id, const LLUUID& group) const;
inline bool allowCopyBy(const LLUUID& agent_id, const LLUUID& group) const;
inline bool allowMoveBy(const LLUUID &agent_id, const LLUUID &group) const;
- inline bool allowExportBy(const LLUUID& agent_id) const; // OpenSim export permission
// This somewhat specialized function is meant for testing if the
// current owner is allowed to transfer to the specified agent id.
inline bool allowTransferTo(const LLUUID &agent_id) const;
- //
- // DEPRECATED.
- //
- // These return true if the given agent can perform the function.
- // They also return true if the object isn't owned, or the
- // requesting agent is a system agent. See llpermissionsflags.h
- // for bits.
- //bool allowDeleteBy(const LLUUID& agent_id) const { return allowModifyBy(agent_id); }
- //bool allowEditBy(const LLUUID& agent_id) const { return allowModifyBy(agent_id); }
- // saves last owner and sets current owner
- //bool setOwner(const LLUUID& agent, const LLUUID& owner);
- // This method saves the last owner, sets the current owner to the
- // one provided, and sets the base mask as indicated.
- //bool setOwner(const LLUUID& agent, const LLUUID& owner, U32 new_base_mask);
-
- // Attempt to set or clear the given bitmask. Returns true if you
- // are allowed to modify the permissions. If you attempt to turn
- // on bits not allowed by the base bits, the function will return
- // true, but those bits will not be set.
- //bool setGroupBits( const LLUUID& agent, bool set, PermissionMask bits);
- //bool setEveryoneBits(const LLUUID& agent, bool set, PermissionMask bits);
+ // Returns true if the object can exported by the given agent
+ // (e.g. saved as a local .gltf file)
+ // The current test should return true if the agent is the owner
+ // AND the creator of the object.
+ inline bool allowExportBy(const LLUUID& agent_id) const;
+#ifdef OPENSIM
+ inline bool allowOpenSimExportBy(const LLUUID& agent_id) const; // OpenSim export permission
+#endif
//
// MISC METHODS and OPERATORS
@@ -354,6 +341,20 @@ bool LLPermissions::allowMoveBy(const LLUUID& agent) const
return allowOperationBy(PERM_MOVE, agent, LLUUID::null);
}
+bool LLPermissions::allowExportBy(const LLUUID& agent) const
+{
+ return agent == mOwner && agent == mCreator;
+}
+
+// Opensim Export Permissions
+#ifdef OPENSIM
+bool LLPermissions::allowOpenSimExportBy(const LLUUID& agent) const
+{
+ return ((mCreator == agent) ? true : (allowOperationBy(PERM_EXPORT, agent, LLUUID::null)));
+}
+#endif
+//
+
bool LLPermissions::allowTransferTo(const LLUUID &agent_id) const
{
if (mIsGroupOwned)
@@ -366,13 +367,6 @@ bool LLPermissions::allowTransferTo(const LLUUID &agent_id) const
}
}
-// Opensim Export Permissions
-bool LLPermissions::allowExportBy(const LLUUID& agent) const
-{
- return ((mCreator == agent) ? true : (allowOperationBy(PERM_EXPORT, agent, LLUUID::null)));
-}
-//
-
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLAggregatePermissions
//
diff --git a/indra/llmath/llvector4a.h b/indra/llmath/llvector4a.h
index 47f2a095a8..1c3bc74f15 100644
--- a/indra/llmath/llvector4a.h
+++ b/indra/llmath/llvector4a.h
@@ -127,6 +127,39 @@ public:
return !(*this == rhs);
}
+ const LLVector4a& operator+=(const LLVector4a& rhs)
+ {
+ add(rhs);
+ return *this;
+ }
+
+ const LLVector4a& operator-=(const LLVector4a& rhs)
+ {
+ sub(rhs);
+ return *this;
+ }
+
+ LLVector4a operator+(const LLVector4a& rhs) const
+ {
+ LLVector4a result = *this;
+ result.add(rhs);
+ return result;
+ }
+
+ LLVector4a operator-(const LLVector4a& rhs) const
+ {
+ LLVector4a result = *this;
+ result.sub(rhs);
+ return result;
+ }
+
+ LLVector4a cross3(const LLVector4a& b) const
+ {
+ LLVector4a result;
+ result.setCross3(*this, b);
+ return result;
+ }
+
////////////////////////////////////
// LOAD/STORE
////////////////////////////////////
diff --git a/indra/llmath/llvolumeoctree.cpp b/indra/llmath/llvolumeoctree.cpp
index 7a4d313fb1..faa169e295 100644
--- a/indra/llmath/llvolumeoctree.cpp
+++ b/indra/llmath/llvolumeoctree.cpp
@@ -151,7 +151,7 @@ void LLOctreeTriangleRayIntersect::visit(const LLOctreeNodemIndex[1];
U32 idx2 = tri->mIndex[2];
- if (mTexCoord != NULL)
+ if (mTexCoord != NULL && mFace->mTexCoords)
{
LLVector2* tc = (LLVector2*) mFace->mTexCoords;
*mTexCoord = ((1.f - a - b) * tc[idx0] +
@@ -160,7 +160,7 @@ void LLOctreeTriangleRayIntersect::visit(const LLOctreeNodemNormals)
{
LLVector4a* norm = mFace->mNormals;
@@ -180,7 +180,7 @@ void LLOctreeTriangleRayIntersect::visit(const LLOctreeNodemTangents)
{
LLVector4a* tangents = mFace->mTangents;
diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp
index 94bc5ef74c..008c72462c 100644
--- a/indra/llprimitive/llgltfmaterial.cpp
+++ b/indra/llprimitive/llgltfmaterial.cpp
@@ -681,7 +681,7 @@ void LLGLTFMaterial::applyOverride(const LLGLTFMaterial& override_mat)
}
}
-void LLGLTFMaterial::getOverrideLLSD(const LLGLTFMaterial& override_mat, LLSD& data)
+void LLGLTFMaterial::getOverrideLLSD(const LLGLTFMaterial& override_mat, LLSD& data) const
{
LL_PROFILE_ZONE_SCOPED;
llassert(data.isUndefined());
@@ -690,7 +690,7 @@ void LLGLTFMaterial::getOverrideLLSD(const LLGLTFMaterial& override_mat, LLSD& d
for (U32 i = 0; i < GLTF_TEXTURE_INFO_COUNT; ++i)
{
- LLUUID& texture_id = mTextureId[i];
+ const LLUUID& texture_id = mTextureId[i];
const LLUUID& override_texture_id = override_mat.mTextureId[i];
if (override_texture_id.notNull() && override_texture_id != texture_id)
{
diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h
index 67b22f56e2..e04b6d5eee 100644
--- a/indra/llprimitive/llgltfmaterial.h
+++ b/indra/llprimitive/llgltfmaterial.h
@@ -202,7 +202,7 @@ public:
// Get the given override on this LLGLTFMaterial as LLSD
// override_mat -- the override source data
// data -- output LLSD object (should be passed in empty)
- void getOverrideLLSD(const LLGLTFMaterial& override_mat, LLSD& data);
+ void getOverrideLLSD(const LLGLTFMaterial& override_mat, LLSD& data) const;
// For base materials only (i.e. assets). Clears transforms to
// default since they're not supported in assets yet.
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index a7da22b38d..97066bfba9 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -1274,6 +1274,11 @@ bool LLGLManager::initGL()
glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &mMaxIntegerSamples);
glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &mMaxSampleMaskWords);
glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples);
+ glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &mMaxUniformBlockSize);
+
+ // sanity clamp max uniform block size to 64k just in case
+ // there's some implementation that reports a crazy value
+ mMaxUniformBlockSize = llmin(mMaxUniformBlockSize, 65536);
if (mGLVersion >= 4.59f)
{
diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h
index 7af7d4dbc5..22862f7f7c 100644
--- a/indra/llrender/llgl.h
+++ b/indra/llrender/llgl.h
@@ -99,6 +99,7 @@ public:
S32 mGLMaxIndexRange;
S32 mGLMaxTextureSize;
F32 mMaxAnisotropy = 0.f;
+ S32 mMaxUniformBlockSize = 0;
// GL 4.x capabilities
bool mHasCubeMapArray = false;
@@ -169,13 +170,18 @@ void assert_glerror();
void clear_glerror();
-//#if LL_DEBUG
+
# define stop_glerror() assert_glerror()
# define llglassertok() assert_glerror()
-//#else
-//# define stop_glerror()
-//# define llglassertok()
-//#endif
+
+// stop_glerror is still needed on OS X but has performance implications
+// use macro below to conditionally add stop_glerror to non-release builds
+// on OS X
+#if LL_DARWIN && !LL_RELEASE_FOR_DOWNLOAD
+#define STOP_GLERROR stop_glerror()
+#else
+#define STOP_GLERROR
+#endif
#define llglassertok_always() assert_glerror()
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index b0addd7e61..ba745e0fca 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -381,13 +381,10 @@ void LLGLSLShader::unloadInternal()
stop_glerror();
}
-bool LLGLSLShader::createShader(std::vector* attributes,
- std::vector* uniforms,
- U32 varying_count,
- const char** varyings)
+bool LLGLSLShader::createShader()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
-
+
unloadInternal();
sInstances.insert(this);
@@ -454,11 +451,11 @@ bool LLGLSLShader::createShader(std::vector* attributes,
// Map attributes and uniforms
if (success)
{
- success = mapAttributes(attributes);
+ success = mapAttributes();
}
if (success)
{
- success = mapUniforms(uniforms);
+ success = mapUniforms();
}
if (!success)
{
@@ -469,7 +466,7 @@ bool LLGLSLShader::createShader(std::vector* attributes,
{
LL_SHADER_LOADING_WARNS() << "Failed to link using shader level " << mShaderLevel << " trying again using shader level " << (mShaderLevel - 1) << LL_ENDL;
mShaderLevel--;
- return createShader(attributes, uniforms);
+ return createShader();
}
else
{
@@ -602,7 +599,7 @@ void LLGLSLShader::attachObjects(GLuint* objects, S32 count)
}
}
-bool LLGLSLShader::mapAttributes(const std::vector* attributes)
+bool LLGLSLShader::mapAttributes()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
@@ -621,11 +618,10 @@ bool LLGLSLShader::mapAttributes(const std::vector* attrib
}
mAttribute.clear();
- U32 numAttributes = (attributes == NULL) ? 0 : attributes->size();
#if LL_RELEASE_WITH_DEBUG_INFO
- mAttribute.resize(LLShaderMgr::instance()->mReservedAttribs.size() + numAttributes, { -1, NULL });
+ mAttribute.resize(LLShaderMgr::instance()->mReservedAttribs.size(), { -1, NULL });
#else
- mAttribute.resize(LLShaderMgr::instance()->mReservedAttribs.size() + numAttributes, -1);
+ mAttribute.resize(LLShaderMgr::instance()->mReservedAttribs.size(), -1);
#endif
if (res)
@@ -649,19 +645,6 @@ bool LLGLSLShader::mapAttributes(const std::vector* attrib
LL_DEBUGS("ShaderUniform") << "Attribute " << name << " assigned to channel " << index << LL_ENDL;
}
}
- if (attributes != NULL)
- {
- for (U32 i = 0; i < numAttributes; i++)
- {
- const char* name = (*attributes)[i].String().c_str();
- S32 index = glGetAttribLocation(mProgramObject, name);
- if (index != -1)
- {
- mAttribute[LLShaderMgr::instance()->mReservedAttribs.size() + i] = index;
- LL_DEBUGS("ShaderUniform") << "Attribute " << name << " assigned to channel " << index << LL_ENDL;
- }
- }
- }
return true;
}
@@ -669,7 +652,7 @@ bool LLGLSLShader::mapAttributes(const std::vector* attrib
return false;
}
-void LLGLSLShader::mapUniform(GLint index, const vector* uniforms)
+void LLGLSLShader::mapUniform(GLint index)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
@@ -756,21 +739,6 @@ void LLGLSLShader::mapUniform(GLint index, const vector* u
return;
}
}
-
- if (uniforms != NULL)
- {
- for (U32 i = 0; i < uniforms->size(); i++)
- {
- if ((mUniform[i + LLShaderMgr::instance()->mReservedUniforms.size()] == -1)
- && ((*uniforms)[i].String() == name))
- {
- //found it
- mUniform[i + LLShaderMgr::instance()->mReservedUniforms.size()] = location;
- mTexture[i + LLShaderMgr::instance()->mReservedUniforms.size()] = mapUniformTextureChannel(location, type, size);
- return;
- }
- }
- }
}
}
@@ -830,7 +798,7 @@ GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type, GLint
return -1;
}
-bool LLGLSLShader::mapUniforms(const vector* uniforms)
+bool LLGLSLShader::mapUniforms()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
@@ -843,9 +811,8 @@ bool LLGLSLShader::mapUniforms(const vector* uniforms)
mTexture.clear();
mValue.clear();
//initialize arrays
- U32 numUniforms = (uniforms == NULL) ? 0 : uniforms->size();
- mUniform.resize(numUniforms + LLShaderMgr::instance()->mReservedUniforms.size(), -1);
- mTexture.resize(numUniforms + LLShaderMgr::instance()->mReservedUniforms.size(), -1);
+ mUniform.resize(LLShaderMgr::instance()->mReservedUniforms.size(), -1);
+ mTexture.resize(LLShaderMgr::instance()->mReservedUniforms.size(), -1);
bind();
@@ -946,26 +913,26 @@ bool LLGLSLShader::mapUniforms(const vector* uniforms)
if (specularDiff || bumpLessDiff || envLessDiff || refLessDiff)
{
- mapUniform(diffuseMap, uniforms);
+ mapUniform(diffuseMap);
skip_index.insert(diffuseMap);
if (-1 != specularMap) {
- mapUniform(specularMap, uniforms);
+ mapUniform(specularMap);
skip_index.insert(specularMap);
}
if (-1 != bumpMap) {
- mapUniform(bumpMap, uniforms);
+ mapUniform(bumpMap);
skip_index.insert(bumpMap);
}
if (-1 != environmentMap) {
- mapUniform(environmentMap, uniforms);
+ mapUniform(environmentMap);
skip_index.insert(environmentMap);
}
if (-1 != reflectionMap) {
- mapUniform(reflectionMap, uniforms);
+ mapUniform(reflectionMap);
skip_index.insert(reflectionMap);
}
}
@@ -979,21 +946,29 @@ bool LLGLSLShader::mapUniforms(const vector* uniforms)
if (skip_index.end() != skip_index.find(i)) continue;
//........................................................................................
- mapUniform(i, uniforms);
+ mapUniform(i);
}
//........................................................................................................................................
- if (mFeatures.hasReflectionProbes) // Set up block binding, in a way supported by Apple (rather than binding = 1 in .glsl).
- { // See slide 35 and more of https://docs.huihoo.com/apple/wwdc/2011/session_420__advances_in_opengl_for_mac_os_x_lion.pdf
- static const GLuint BLOCKBINDING = 1; //picked by us
- //Get the index, similar to a uniform location
- GLuint UBOBlockIndex = glGetUniformBlockIndex(mProgramObject, "ReflectionProbes");
+ // Set up block binding, in a way supported by Apple (rather than binding = 1 in .glsl).
+ // See slide 35 and more of https://docs.huihoo.com/apple/wwdc/2011/session_420__advances_in_opengl_for_mac_os_x_lion.pdf
+ const char* ubo_names[] =
+ {
+ "ReflectionProbes", // UB_REFLECTION_PROBES
+ "GLTFJoints", // UB_GLTF_JOINTS
+ };
+
+ llassert(LL_ARRAY_SIZE(ubo_names) == NUM_UNIFORM_BLOCKS);
+
+ for (U32 i = 0; i < NUM_UNIFORM_BLOCKS; ++i)
+ {
+ GLuint UBOBlockIndex = glGetUniformBlockIndex(mProgramObject, ubo_names[i]);
if (UBOBlockIndex != GL_INVALID_INDEX)
{
- //Set this index to a binding index
- glUniformBlockBinding(mProgramObject, UBOBlockIndex, BLOCKBINDING);
+ glUniformBlockBinding(mProgramObject, UBOBlockIndex, i);
}
}
+
unbind();
LL_DEBUGS("ShaderUniform") << "Total Uniform Size: " << mTotalUniformSize << LL_ENDL;
@@ -1049,6 +1024,13 @@ void LLGLSLShader::bind()
}
}
+void LLGLSLShader::bind(U8 variant)
+{
+ llassert(mGLTFVariants.size() == LLGLSLShader::NUM_GLTF_VARIANTS);
+ llassert(variant < LLGLSLShader::NUM_GLTF_VARIANTS);
+ mGLTFVariants[variant].bind();
+}
+
void LLGLSLShader::bind(bool rigged)
{
if (rigged)
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h
index 75e1bdfd54..f2b5c4881c 100644
--- a/indra/llrender/llglslshader.h
+++ b/indra/llrender/llglslshader.h
@@ -44,6 +44,7 @@ public:
bool hasTransport = false; // implies no lighting (it's possible to have neither though)
bool hasSkinning = false;
bool hasObjectSkinning = false;
+ bool mGLTF = false;
bool hasAtmospherics = false;
bool hasGamma = false;
bool hasShadows = false;
@@ -145,6 +146,14 @@ public:
SG_COUNT
} eGroup;
+ enum UniformBlock : GLuint
+ {
+ UB_REFLECTION_PROBES,
+ UB_GLTF_JOINTS,
+ NUM_UNIFORM_BLOCKS
+ };
+
+
static std::set sInstances;
static bool sProfileEnabled;
@@ -175,17 +184,14 @@ public:
// If force_read is true, will force an immediate readback (severe performance penalty)
bool readProfileQuery(bool for_runtime = false, bool force_read = false);
- bool createShader(std::vector* attributes,
- std::vector* uniforms,
- U32 varying_count = 0,
- const char** varyings = NULL);
+ bool createShader();
bool attachFragmentObject(std::string object);
bool attachVertexObject(std::string object);
void attachObject(GLuint object);
void attachObjects(GLuint* objects = NULL, S32 count = 0);
- bool mapAttributes(const std::vector* attributes);
- bool mapUniforms(const std::vector*);
- void mapUniform(GLint index, const std::vector*);
+ bool mapAttributes();
+ bool mapUniforms();
+ void mapUniform(GLint index);
void uniform1i(U32 index, GLint i);
void uniform1f(U32 index, GLfloat v);
void fastUniform1f(U32 index, GLfloat v);
@@ -318,6 +324,24 @@ public:
// this pointer should be set to whichever shader represents this shader's rigged variant
LLGLSLShader* mRiggedVariant = nullptr;
+ // variants for use by GLTF renderer
+ // bit 0 = alpha mode blend (1) or opaque (0)
+ // bit 1 = rigged (1) or static (0)
+ // bit 2 = unlit (1) or lit (0)
+ struct GLTFVariant
+ {
+ constexpr static U8 ALPHA_BLEND = 1;
+ constexpr static U8 RIGGED = 2;
+ constexpr static U8 UNLIT = 4;
+ };
+
+ constexpr static U8 NUM_GLTF_VARIANTS = 8;
+
+ std::vector mGLTFVariants;
+
+ //helper to bind GLTF variant
+ void bind(U8 variant);
+
// hacky flag used for optimization in LLDrawPoolAlpha
bool mCanBindFast = false;
diff --git a/indra/llrender/llgltexture.cpp b/indra/llrender/llgltexture.cpp
index 3abaf664d6..682bbf698a 100644
--- a/indra/llrender/llgltexture.cpp
+++ b/indra/llrender/llgltexture.cpp
@@ -49,6 +49,10 @@ LLGLTexture::LLGLTexture(const LLImageRaw* raw, bool usemipmaps)
mUseMipMaps = usemipmaps ;
// Create an empty image of the specified size and width
mGLTexturep = new LLImageGL(raw, usemipmaps) ;
+ mFullWidth = mGLTexturep->getWidth();
+ mFullHeight = mGLTexturep->getHeight();
+ mComponents = mGLTexturep->getComponents();
+ setTexelsPerImage();
}
LLGLTexture::~LLGLTexture()
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index c8dc2399a3..9e69f565f6 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -1012,6 +1012,7 @@ void LLRender::syncLightState()
void LLRender::syncMatrices()
{
+ STOP_GLERROR;
static const U32 name[] =
{
LLShaderMgr::MODELVIEW_MATRIX,
@@ -1034,8 +1035,6 @@ void LLRender::syncMatrices()
if (shader)
{
- //llassert(shader);
-
bool mvp_done = false;
U32 i = MM_MODELVIEW;
@@ -1156,6 +1155,7 @@ void LLRender::syncMatrices()
syncLightState();
}
}
+ STOP_GLERROR;
}
void LLRender::translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z)
@@ -1628,6 +1628,7 @@ void LLRender::end()
}
void LLRender::flush()
{
+ STOP_GLERROR;
if (mCount > 0)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE;
@@ -1738,6 +1739,9 @@ void LLRender::flush()
vb->setColorData(mColorsp.get());
}
+#if LL_DARWIN
+ vb->unmapBuffer();
+#endif
vb->unbind();
sVBCache[vhash] = { vb , std::chrono::steady_clock::now() };
diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index e1e6d00d30..cb04f8cd89 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -1163,6 +1163,7 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedAttribs.push_back("weight");
mReservedAttribs.push_back("weight4");
mReservedAttribs.push_back("clothing");
+ mReservedAttribs.push_back("joint");
mReservedAttribs.push_back("texture_index");
//matrix state
@@ -1231,6 +1232,9 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedUniforms.push_back("diffuseMap");
mReservedUniforms.push_back("altDiffuseMap");
mReservedUniforms.push_back("specularMap");
+ mReservedUniforms.push_back("metallicRoughnessMap");
+ mReservedUniforms.push_back("normalMap");
+ mReservedUniforms.push_back("occlusionMap");
mReservedUniforms.push_back("emissiveMap");
mReservedUniforms.push_back("bumpMap");
mReservedUniforms.push_back("bumpMap2");
@@ -1242,7 +1246,6 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedUniforms.push_back("heroProbes");
mReservedUniforms.push_back("cloud_noise_texture");
mReservedUniforms.push_back("cloud_noise_texture_next");
- mReservedUniforms.push_back("fullbright");
mReservedUniforms.push_back("lightnorm");
mReservedUniforms.push_back("sunlight_color");
mReservedUniforms.push_back("ambient_color");
@@ -1354,7 +1357,6 @@ void LLShaderMgr::initAttribsAndUniforms()
llassert(mReservedUniforms.size() == LLShaderMgr::DEFERRED_SHADOW5+1);
- mReservedUniforms.push_back("normalMap");
mReservedUniforms.push_back("positionMap");
mReservedUniforms.push_back("diffuseRect");
mReservedUniforms.push_back("specularRect");
@@ -1367,7 +1369,6 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedUniforms.push_back("bloomMap");
mReservedUniforms.push_back("projectionMap");
mReservedUniforms.push_back("norm_mat");
- mReservedUniforms.push_back("texture_gamma");
mReservedUniforms.push_back("specular_color");
mReservedUniforms.push_back("env_intensity");
diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h
index 6d03d95a8a..165b668b76 100644
--- a/indra/llrender/llshadermgr.h
+++ b/indra/llrender/llshadermgr.h
@@ -93,6 +93,9 @@ public:
DIFFUSE_MAP, // "diffuseMap"
ALTERNATE_DIFFUSE_MAP, // "altDiffuseMap"
SPECULAR_MAP, // "specularMap"
+ METALLIC_ROUGHNESS_MAP, // "metallicRoughnessMap"
+ NORMAL_MAP, // "normalMap"
+ OCCLUSION_MAP, // "occlusionMap"
EMISSIVE_MAP, // "emissiveMap"
BUMP_MAP, // "bumpMap"
BUMP_MAP2, // "bumpMap2"
@@ -104,7 +107,6 @@ public:
HERO_PROBE, // "heroProbes"
CLOUD_NOISE_MAP, // "cloud_noise_texture"
CLOUD_NOISE_MAP_NEXT, // "cloud_noise_texture_next"
- FULLBRIGHT, // "fullbright"
LIGHTNORM, // "lightnorm"
SUNLIGHT_COLOR, // "sunlight_color"
AMBIENT, // "ambient_color"
@@ -202,7 +204,6 @@ public:
DEFERRED_SHADOW3, // "shadowMap3"
DEFERRED_SHADOW4, // "shadowMap4"
DEFERRED_SHADOW5, // "shadowMap5"
- DEFERRED_NORMAL, // "normalMap"
DEFERRED_POSITION, // "positionMap"
DEFERRED_DIFFUSE, // "diffuseRect"
DEFERRED_SPECULAR, // "specularRect"
@@ -215,7 +216,6 @@ public:
DEFERRED_BLOOM, // "bloomMap"
DEFERRED_PROJECTION, // "projectionMap"
DEFERRED_NORM_MATRIX, // "norm_mat"
- TEXTURE_GAMMA, // "texture_gamma"
SPECULAR_COLOR, // "specular_color"
ENVIRONMENT_INTENSITY, // "env_intensity"
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 8116297244..2baec1e12c 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -290,6 +290,62 @@ static GLuint gen_buffer()
#define ANALYZE_VBO_POOL 0
+#if LL_DARWIN
+
+// experimental -- disable VBO pooling on OS X and use glMapBuffer
+class LLVBOPool
+{
+public:
+ U64 mAllocated = 0;
+
+ U64 getVramBytesUsed()
+ {
+ return mAllocated;
+ }
+
+ void allocate(GLenum type, U32 size, GLuint& name, U8*& data)
+ {
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX;
+ STOP_GLERROR;
+ llassert(type == GL_ARRAY_BUFFER || type == GL_ELEMENT_ARRAY_BUFFER);
+ llassert(name == 0); // non zero name indicates a gl name that wasn't freed
+ llassert(data == nullptr); // non null data indicates a buffer that wasn't freed
+ llassert(size >= 2); // any buffer size smaller than a single index is nonsensical
+
+ mAllocated += size;
+
+ { //allocate a new buffer
+ LL_PROFILE_GPU_ZONE("vbo alloc");
+ // ON OS X, we don't allocate a VBO until the last possible moment
+ // in unmapBuffer
+ data = (U8*) ll_aligned_malloc_16(size);
+ STOP_GLERROR;
+ }
+ }
+
+ void free(GLenum type, U32 size, GLuint name, U8* data)
+ {
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX;
+ llassert(type == GL_ARRAY_BUFFER || type == GL_ELEMENT_ARRAY_BUFFER);
+ llassert(size >= 2);
+
+ if (data)
+ {
+ ll_aligned_free_16(data);
+ }
+
+ mAllocated -= size;
+ STOP_GLERROR;
+ if (name)
+ {
+ glDeleteBuffers(1, &name);
+ }
+ STOP_GLERROR;
+ }
+};
+
+#else
+
class LLVBOPool
{
public:
@@ -509,9 +565,8 @@ public:
mIBOPool.clear();
mVBOPool.clear();
}
-
-
};
+#endif
static LLVBOPool* sVBOPool = nullptr;
@@ -545,6 +600,7 @@ const U32 LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_MAX] =
sizeof(F32), // TYPE_WEIGHT,
sizeof(LLVector4), // TYPE_WEIGHT4,
sizeof(LLVector4), // TYPE_CLOTHWEIGHT,
+ sizeof(U64), // TYPE_JOINT,
sizeof(LLVector4), // TYPE_TEXTURE_INDEX (actually exists as position.w), no extra data, but stride is 16 bytes
};
@@ -562,6 +618,7 @@ static const std::string vb_type_name[] =
"TYPE_WEIGHT",
"TYPE_WEIGHT4",
"TYPE_CLOTHWEIGHT",
+ "TYPE_JOINT"
"TYPE_TEXTURE_INDEX",
"TYPE_MAX",
"TYPE_INDEX",
@@ -645,6 +702,8 @@ void LLVertexBuffer::drawElements(U32 mode, const LLVector4a* pos, const LLVecto
}
//
+ STOP_GLERROR;
+
gGL.syncMatrices();
U32 mask = LLVertexBuffer::MAP_VERTEX;
@@ -703,6 +762,7 @@ bool LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_of
}
{
+#if 0 // not a reliable test for VBOs that are not backed by a CPU buffer
U16* idx = (U16*) mMappedIndexData+indices_offset;
for (U32 i = 0; i < count; ++i)
{
@@ -740,6 +800,7 @@ bool LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_of
}
}
}
+#endif
}
return true;
@@ -757,8 +818,10 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi
llassert(mGLBuffer == sGLRenderBuffer);
llassert(mGLIndices == sGLRenderIndices);
gGL.syncMatrices();
+ STOP_GLERROR;
glDrawRangeElements(sGLMode[mode], start, end, count, mIndicesType,
(GLvoid*) (indices_offset * (size_t) mIndicesStride));
+ STOP_GLERROR;
}
void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const
@@ -774,7 +837,9 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const
llassert(mGLIndices == sGLRenderIndices);
gGL.syncMatrices();
+ STOP_GLERROR;
glDrawArrays(sGLMode[mode], first, count);
+ STOP_GLERROR;
}
//static
@@ -797,9 +862,10 @@ void LLVertexBuffer::initClass(LLWindow* window)
//static
void LLVertexBuffer::unbind()
{
+ STOP_GLERROR;
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
-
+ STOP_GLERROR;
sGLRenderBuffer = 0;
sGLRenderIndices = 0;
}
@@ -1052,8 +1118,7 @@ bool LLVertexBuffer::updateNumIndices(U32 nindices)
bool LLVertexBuffer::allocateBuffer(U32 nverts, U32 nindices)
{
- if (nverts < 0 || nindices < 0 ||
- nverts > 65536)
+ if (nverts < 0 || nindices < 0)
{
LL_ERRS() << "Bad vertex buffer allocation: " << nverts << " : " << nindices << LL_ENDL;
}
@@ -1096,6 +1161,7 @@ U8* LLVertexBuffer::mapVertexBuffer(LLVertexBuffer::AttributeType type, U32 inde
count = mNumVerts - index;
}
+#if !LL_DARWIN
U32 start = mOffsets[type] + sTypeSize[type] * index;
U32 end = start + sTypeSize[type] * count-1;
@@ -1116,7 +1182,7 @@ U8* LLVertexBuffer::mapVertexBuffer(LLVertexBuffer::AttributeType type, U32 inde
//didn't expand an existing region, make a new one
mMappedVertexRegions.push_back({ start, end });
}
-
+#endif
return mMappedData+mOffsets[type]+sTypeSize[type]*index;
}
@@ -1130,6 +1196,7 @@ U8* LLVertexBuffer::mapIndexBuffer(U32 index, S32 count)
count = mNumIndices-index;
}
+#if !LL_DARWIN
U32 start = sizeof(U16) * index;
U32 end = start + sizeof(U16) * count-1;
@@ -1150,6 +1217,7 @@ U8* LLVertexBuffer::mapIndexBuffer(U32 index, S32 count)
//didn't expand an existing region, make a new one
mMappedIndexRegions.push_back({ start, end });
}
+#endif
return mMappedIndexData + sizeof(U16)*index;
}
@@ -1158,9 +1226,17 @@ U8* LLVertexBuffer::mapIndexBuffer(U32 index, S32 count)
// target -- "target" parameter for glBufferSubData
// start -- first byte to copy
// end -- last byte to copy (NOT last byte + 1)
-// data -- mMappedData or mMappedIndexData
-static void flush_vbo(GLenum target, U32 start, U32 end, void* data)
+// data -- data to be flushed
+// dst -- mMappedData or mMappedIndexData
+static void flush_vbo(GLenum target, U32 start, U32 end, void* data, U8* dst)
{
+#if LL_DARWIN
+ LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb memcpy");
+ STOP_GLERROR;
+ // copy into mapped buffer
+ memcpy(dst+start, data, end-start+1);
+#else
+ // skip mapped data and stream to GPU via glBufferSubData
if (end != 0)
{
LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("glBufferSubData");
@@ -1179,10 +1255,12 @@ static void flush_vbo(GLenum target, U32 start, U32 end, void* data)
glBufferSubData(target, i, size, (U8*) data + (i-start));
}
}
+#endif
}
void LLVertexBuffer::unmapBuffer()
{
+ STOP_GLERROR;
struct SortMappedRegion
{
bool operator()(const MappedRegion& lhs, const MappedRegion& rhs)
@@ -1191,9 +1269,51 @@ void LLVertexBuffer::unmapBuffer()
}
};
+#if LL_DARWIN
+ STOP_GLERROR;
+ if (mMappedData)
+ {
+ if (mGLBuffer)
+ {
+ glDeleteBuffers(1, &mGLBuffer);
+ }
+ mGLBuffer = gen_buffer();
+ glBindBuffer(GL_ARRAY_BUFFER, mGLBuffer);
+ sGLRenderBuffer = mGLBuffer;
+ glBufferData(GL_ARRAY_BUFFER, mSize, mMappedData, GL_STATIC_DRAW);
+ }
+ else if (mGLBuffer != sGLRenderBuffer)
+ {
+ glBindBuffer(GL_ARRAY_BUFFER, mGLBuffer);
+ sGLRenderBuffer = mGLBuffer;
+ }
+ STOP_GLERROR;
+
+ if (mMappedIndexData)
+ {
+ if (mGLIndices)
+ {
+ glDeleteBuffers(1, &mGLIndices);
+ }
+
+ mGLIndices = gen_buffer();
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mGLIndices);
+ sGLRenderIndices = mGLIndices;
+
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, mIndicesSize, mMappedIndexData, GL_STATIC_DRAW);
+ }
+ else if (mGLIndices != sGLRenderIndices)
+ {
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mGLIndices);
+ sGLRenderIndices = mGLIndices;
+ }
+ STOP_GLERROR;
+#else
+
if (!mMappedVertexRegions.empty())
{
LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("unmapBuffer - vertex");
+
if (sGLRenderBuffer != mGLBuffer)
{
glBindBuffer(GL_ARRAY_BUFFER, mGLBuffer);
@@ -1214,14 +1334,13 @@ void LLVertexBuffer::unmapBuffer()
}
else
{
- flush_vbo(GL_ARRAY_BUFFER, start, end, (U8*)mMappedData + start);
+ flush_vbo(GL_ARRAY_BUFFER, start, end, (U8*)mMappedData + start, mMappedData);
start = region.mStart;
end = region.mEnd;
}
}
- flush_vbo(GL_ARRAY_BUFFER, start, end, (U8*)mMappedData + start);
-
+ flush_vbo(GL_ARRAY_BUFFER, start, end, (U8*)mMappedData + start, mMappedData);
mMappedVertexRegions.clear();
}
@@ -1248,16 +1367,16 @@ void LLVertexBuffer::unmapBuffer()
}
else
{
- flush_vbo(GL_ELEMENT_ARRAY_BUFFER, start, end, (U8*)mMappedIndexData + start);
+ flush_vbo(GL_ELEMENT_ARRAY_BUFFER, start, end, (U8*)mMappedIndexData + start, mMappedIndexData);
start = region.mStart;
end = region.mEnd;
}
}
- flush_vbo(GL_ELEMENT_ARRAY_BUFFER, start, end, (U8*)mMappedIndexData + start);
-
+ flush_vbo(GL_ELEMENT_ARRAY_BUFFER, start, end, (U8*)mMappedIndexData + start, mMappedIndexData);
mMappedIndexRegions.clear();
}
+#endif
}
//----------------------------------------------------------------------------
@@ -1389,10 +1508,17 @@ bool LLVertexBuffer::getClothWeightStrider(LLStrider& strider, U32 i
// Set for rendering
void LLVertexBuffer::setBuffer()
{
+ STOP_GLERROR;
+#if LL_DARWIN
+ if (!mGLBuffer)
+ { // OS X doesn't allocate a buffer until we call unmapBuffer
+ return;
+ }
+#endif
// no data may be pending
llassert(mMappedVertexRegions.empty());
llassert(mMappedIndexRegions.empty());
-
+
// a shader must be bound
llassert(LLGLSLShader::sCurBoundShaderPtr);
@@ -1421,12 +1547,15 @@ void LLVertexBuffer::setBuffer()
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mGLIndices);
sGLRenderIndices = mGLIndices;
}
+
+ STOP_GLERROR;
}
// virtual (default)
void LLVertexBuffer::setupVertexBuffer()
{
+ STOP_GLERROR;
U8* base = nullptr;
U32 data_mask = LLGLSLShader::sCurBoundShaderPtr->mAttributeMask;
@@ -1498,6 +1627,12 @@ void LLVertexBuffer::setupVertexBuffer()
void* ptr = (void*)(base + mOffsets[TYPE_WEIGHT4]);
glVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT4], ptr);
}
+ if (data_mask & MAP_JOINT)
+ {
+ AttributeType loc = TYPE_JOINT;
+ void* ptr = (void*)(base + mOffsets[TYPE_JOINT]);
+ glVertexAttribIPointer(loc, 4, GL_UNSIGNED_SHORT, LLVertexBuffer::sTypeSize[TYPE_JOINT], ptr);
+ }
if (data_mask & MAP_CLOTHWEIGHT)
{
AttributeType loc = TYPE_CLOTHWEIGHT;
@@ -1516,59 +1651,84 @@ void LLVertexBuffer::setupVertexBuffer()
void* ptr = (void*)(base + mOffsets[TYPE_VERTEX]);
glVertexAttribPointer(loc, 3, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_VERTEX], ptr);
}
+ STOP_GLERROR;
}
void LLVertexBuffer::setPositionData(const LLVector4a* data)
{
+#if !LL_DARWIN
llassert(sGLRenderBuffer == mGLBuffer);
- flush_vbo(GL_ARRAY_BUFFER, 0, sizeof(LLVector4a) * getNumVerts()-1, (U8*) data);
+#endif
+ flush_vbo(GL_ARRAY_BUFFER, 0, sizeof(LLVector4a) * getNumVerts()-1, (U8*) data, mMappedData);
}
void LLVertexBuffer::setTexCoordData(const LLVector2* data)
{
+#if !LL_DARWIN
llassert(sGLRenderBuffer == mGLBuffer);
- flush_vbo(GL_ARRAY_BUFFER, mOffsets[TYPE_TEXCOORD0], mOffsets[TYPE_TEXCOORD0] + sTypeSize[TYPE_TEXCOORD0] * getNumVerts() - 1, (U8*)data);
+#endif
+ flush_vbo(GL_ARRAY_BUFFER, mOffsets[TYPE_TEXCOORD0], mOffsets[TYPE_TEXCOORD0] + sTypeSize[TYPE_TEXCOORD0] * getNumVerts() - 1, (U8*)data, mMappedData);
}
void LLVertexBuffer::setColorData(const LLColor4U* data)
{
+#if !LL_DARWIN
llassert(sGLRenderBuffer == mGLBuffer);
- flush_vbo(GL_ARRAY_BUFFER, mOffsets[TYPE_COLOR], mOffsets[TYPE_COLOR] + sTypeSize[TYPE_COLOR] * getNumVerts() - 1, (U8*) data);
+#endif
+ flush_vbo(GL_ARRAY_BUFFER, mOffsets[TYPE_COLOR], mOffsets[TYPE_COLOR] + sTypeSize[TYPE_COLOR] * getNumVerts() - 1, (U8*) data, mMappedData);
}
void LLVertexBuffer::setNormalData(const LLVector4a* data)
{
+#if !LL_DARWIN
llassert(sGLRenderBuffer == mGLBuffer);
- flush_vbo(GL_ARRAY_BUFFER, mOffsets[TYPE_NORMAL], mOffsets[TYPE_NORMAL] + sTypeSize[TYPE_NORMAL] * getNumVerts() - 1, (U8*) data);
+#endif
+ flush_vbo(GL_ARRAY_BUFFER, mOffsets[TYPE_NORMAL], mOffsets[TYPE_NORMAL] + sTypeSize[TYPE_NORMAL] * getNumVerts() - 1, (U8*) data, mMappedData);
}
void LLVertexBuffer::setTangentData(const LLVector4a* data)
{
+#if !LL_DARWIN
llassert(sGLRenderBuffer == mGLBuffer);
- flush_vbo(GL_ARRAY_BUFFER, mOffsets[TYPE_TANGENT], mOffsets[TYPE_TANGENT] + sTypeSize[TYPE_TANGENT] * getNumVerts() - 1, (U8*) data);
+#endif
+ flush_vbo(GL_ARRAY_BUFFER, mOffsets[TYPE_TANGENT], mOffsets[TYPE_TANGENT] + sTypeSize[TYPE_TANGENT] * getNumVerts() - 1, (U8*) data, mMappedData);
}
void LLVertexBuffer::setWeight4Data(const LLVector4a* data)
{
+#if !LL_DARWIN
llassert(sGLRenderBuffer == mGLBuffer);
- flush_vbo(GL_ARRAY_BUFFER, mOffsets[TYPE_WEIGHT4], mOffsets[TYPE_WEIGHT4] + sTypeSize[TYPE_WEIGHT4] * getNumVerts() - 1, (U8*) data);
+#endif
+ flush_vbo(GL_ARRAY_BUFFER, mOffsets[TYPE_WEIGHT4], mOffsets[TYPE_WEIGHT4] + sTypeSize[TYPE_WEIGHT4] * getNumVerts() - 1, (U8*) data, mMappedData);
+}
+
+void LLVertexBuffer::setJointData(const U64* data)
+{
+#if !LL_DARWIN
+ llassert(sGLRenderBuffer == mGLBuffer);
+#endif
+ flush_vbo(GL_ARRAY_BUFFER, mOffsets[TYPE_JOINT], mOffsets[TYPE_JOINT] + sTypeSize[TYPE_JOINT] * getNumVerts() - 1, (U8*) data, mMappedData);
}
void LLVertexBuffer::setIndexData(const U16* data)
{
+#if !LL_DARWIN
llassert(sGLRenderIndices == mGLIndices);
- flush_vbo(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(U16) * getNumIndices() - 1, (U8*) data);
+#endif
+ flush_vbo(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(U16) * getNumIndices() - 1, (U8*) data, mMappedIndexData);
}
void LLVertexBuffer::setIndexData(const U32* data)
{
+#if !LL_DARWIN
llassert(sGLRenderIndices == mGLIndices);
+#endif
if (mIndicesType != GL_UNSIGNED_INT)
{ // HACK -- vertex buffers are initialized as 16-bit indices, but can be switched to 32-bit indices
mIndicesType = GL_UNSIGNED_INT;
mIndicesStride = 4;
mNumIndices /= 2;
}
- flush_vbo(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(U32) * getNumIndices() - 1, (U8*)data);
+ flush_vbo(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(U32) * getNumIndices() - 1, (U8*)data, mMappedIndexData);
}
diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index 51a7943217..76ef5570eb 100644
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -110,6 +110,7 @@ public:
TYPE_WEIGHT, // "weight"
TYPE_WEIGHT4, // "weight4"
TYPE_CLOTHWEIGHT, // "clothing"
+ TYPE_JOINT, // "joint"
TYPE_TEXTURE_INDEX, // "texture_index"
TYPE_MAX, // TYPE_MAX is the size/boundary marker for attributes that go in the vertex buffer
TYPE_INDEX, // TYPE_INDEX is beyond _MAX because it lives in a separate (index) buffer
@@ -129,6 +130,7 @@ public:
MAP_WEIGHT = (1<
@@ -417,12 +411,9 @@ struct LLWindowWin32::LLWindowWin32Thread : public LL::ThreadPool
// *HACK: Attempt to prevent startup crashes by deferring memory accounting
// until after some graphics setup. See SL-20177. -Cosmic,2023-09-18
bool mGLReady = false;
+ bool mGotGLBuffer = false;
U32 mMaxVRAM = 0; // maximum amount of vram to allow in the "budget", or 0 for no maximum (see updateVRAMUsage)
-
- IDXGIAdapter3* mDXGIAdapter = nullptr;
- LPDIRECT3D9 mD3D = nullptr;
- LPDIRECT3DDEVICE9 mD3DDevice = nullptr;
};
@@ -4741,39 +4732,55 @@ private:
std::string mPrev;
};
-// Print hardware debug info about available graphics adapters in ordinal order
-void debugEnumerateGraphicsAdapters()
+void LLWindowWin32::LLWindowWin32Thread::checkDXMem()
{
- LL_INFOS("Window") << "Enumerating graphics adapters..." << LL_ENDL;
+ if (!mGLReady || mGotGLBuffer) { return; }
- IDXGIFactory1* factory;
- HRESULT res = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&factory);
- if (FAILED(res) || !factory)
+ IDXGIFactory4* p_factory = nullptr;
+
+ HRESULT res = CreateDXGIFactory1(__uuidof(IDXGIFactory4), (void**)&p_factory);
+
+ if (FAILED(res))
{
LL_WARNS() << "CreateDXGIFactory1 failed: 0x" << std::hex << res << LL_ENDL;
}
else
{
+ IDXGIAdapter3* p_dxgi_adapter = nullptr;
UINT graphics_adapter_index = 0;
- IDXGIAdapter3* dxgi_adapter;
while (true)
{
- res = factory->EnumAdapters(graphics_adapter_index, reinterpret_cast(&dxgi_adapter));
+ res = p_factory->EnumAdapters(graphics_adapter_index, reinterpret_cast(&p_dxgi_adapter));
if (FAILED(res))
{
if (graphics_adapter_index == 0)
{
LL_WARNS() << "EnumAdapters failed: 0x" << std::hex << res << LL_ENDL;
}
- else
- {
- LL_INFOS("Window") << "Done enumerating graphics adapters" << LL_ENDL;
- }
}
else
{
+ if (graphics_adapter_index == 0) // Should it check largest one isntead of first?
+ {
+ DXGI_QUERY_VIDEO_MEMORY_INFO info;
+ p_dxgi_adapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &info);
+
+ // Alternatively use GetDesc from below to get adapter's memory
+ UINT64 budget_mb = info.Budget / (1024 * 1024);
+ if (gGLManager.mVRAM < (S32)budget_mb)
+ {
+ gGLManager.mVRAM = (S32)budget_mb;
+ LL_INFOS("RenderInit") << "New VRAM Budget (DX9): " << gGLManager.mVRAM << " MB" << LL_ENDL;
+ }
+ else
+ {
+ LL_INFOS("RenderInit") << "VRAM Budget (DX9): " << budget_mb
+ << " MB, current (WMI): " << gGLManager.mVRAM << " MB" << LL_ENDL;
+ }
+ }
+
DXGI_ADAPTER_DESC desc;
- dxgi_adapter->GetDesc(&desc);
+ p_dxgi_adapter->GetDesc(&desc);
std::wstring description_w((wchar_t*)desc.Description);
std::string description(description_w.begin(), description_w.end());
LL_INFOS("Window") << "Graphics adapter index: " << graphics_adapter_index << ", "
@@ -4786,10 +4793,10 @@ void debugEnumerateGraphicsAdapters()
<< "SharedSystemMemory: " << desc.SharedSystemMemory / 1024 / 1024 << LL_ENDL;
}
- if (dxgi_adapter)
+ if (p_dxgi_adapter)
{
- dxgi_adapter->Release();
- dxgi_adapter = NULL;
+ p_dxgi_adapter->Release();
+ p_dxgi_adapter = NULL;
}
else
{
@@ -4800,95 +4807,12 @@ void debugEnumerateGraphicsAdapters()
}
}
- if (factory)
+ if (p_factory)
{
- factory->Release();
- }
-}
-
-void LLWindowWin32::LLWindowWin32Thread::initDX()
-{
- if (!mGLReady) { return; }
-
- if (mDXGIAdapter == NULL)
- {
- debugEnumerateGraphicsAdapters();
-
- IDXGIFactory4* pFactory = nullptr;
-
- HRESULT res = CreateDXGIFactory1(__uuidof(IDXGIFactory4), (void**)&pFactory);
-
- if (FAILED(res))
- {
- LL_WARNS() << "CreateDXGIFactory1 failed: 0x" << std::hex << res << LL_ENDL;
- }
- else
- {
- res = pFactory->EnumAdapters(0, reinterpret_cast(&mDXGIAdapter));
- if (FAILED(res))
- {
- LL_WARNS() << "EnumAdapters failed: 0x" << std::hex << res << LL_ENDL;
- }
- else
- {
- LL_INFOS() << "EnumAdapters success" << LL_ENDL;
- }
- }
-
- if (pFactory)
- {
- pFactory->Release();
- }
- }
-}
-
-void LLWindowWin32::LLWindowWin32Thread::initD3D()
-{
- if (!mGLReady) { return; }
-
- if (mDXGIAdapter == NULL && mD3DDevice == NULL && mWindowHandleThrd != 0)
- {
- mD3D = Direct3DCreate9(D3D_SDK_VERSION);
-
- D3DPRESENT_PARAMETERS d3dpp;
-
- ZeroMemory(&d3dpp, sizeof(d3dpp));
- d3dpp.Windowed = TRUE;
- d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
-
- HRESULT res = mD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, mWindowHandleThrd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &mD3DDevice);
-
- if (FAILED(res))
- {
- LL_WARNS() << "(fallback) CreateDevice failed: 0x" << std::hex << res << LL_ENDL;
- }
- else
- {
- LL_INFOS() << "(fallback) CreateDevice success" << LL_ENDL;
- }
- }
-}
-
-void LLWindowWin32::LLWindowWin32Thread::cleanupDX()
-{
- //clean up DXGI/D3D resources
- if (mDXGIAdapter)
- {
- mDXGIAdapter->Release();
- mDXGIAdapter = nullptr;
+ p_factory->Release();
}
- if (mD3DDevice)
- {
- mD3DDevice->Release();
- mD3DDevice = nullptr;
- }
-
- if (mD3D)
- {
- mD3D->Release();
- mD3D = nullptr;
- }
+ mGotGLBuffer = true;
}
void LLWindowWin32::LLWindowWin32Thread::run()
@@ -4907,15 +4831,11 @@ void LLWindowWin32::LLWindowWin32Thread::run()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_WIN32;
- // lazily call initD3D inside this loop to catch when mGLReady has been set to true
- initDX();
+ // Check memory budget using DirectX
+ checkDXMem();
if (mWindowHandleThrd != 0)
{
- // lazily call initD3D inside this loop to catch when mWindowHandle has been set, and mGLReady has been set to true
- // *TODO: Shutdown if this fails when mWindowHandle exists
- initD3D();
-
MSG msg;
BOOL status;
if (mhDCThrd == 0)
@@ -4955,8 +4875,6 @@ void LLWindowWin32::LLWindowWin32Thread::run()
}
#endif
}
-
- cleanupDX();
}
void LLWindowWin32::LLWindowWin32Thread::wakeAndDestroy()
@@ -5056,7 +4974,6 @@ void LLWindowWin32::LLWindowWin32Thread::wakeAndDestroy()
// very unsafe
TerminateThread(pair.second.native_handle(), 0);
pair.second.detach();
- cleanupDX();
}
}
LL_DEBUGS("Window") << "thread pool shutdown complete" << LL_ENDL;
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 9ae4637fec..f84a699c5f 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -618,6 +618,7 @@ set(viewer_SOURCE_FILES
llpathfindingobject.cpp
llpathfindingobjectlist.cpp
llpathfindingpathtool.cpp
+ llpbrterrainfeatures.cpp
llpersistentnotificationstorage.cpp
llphysicsmotion.cpp
llphysicsshapebuilderutil.cpp
@@ -1406,6 +1407,7 @@ set(viewer_HEADER_FILES
llpathfindingobject.h
llpathfindingobjectlist.h
llpathfindingpathtool.h
+ llpbrterrainfeatures.h
llpersistentnotificationstorage.h
llphysicsmotion.h
llphysicsshapebuilderutil.h
diff --git a/indra/newview/VIEWER_VERSION.txt b/indra/newview/VIEWER_VERSION.txt
index 2fe040f424..5978ab1324 100644
--- a/indra/newview/VIEWER_VERSION.txt
+++ b/indra/newview/VIEWER_VERSION.txt
@@ -1 +1 @@
-7.1.8
+7.1.9
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 45b3ce5d30..161344e852 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -12816,6 +12816,17 @@ Change of this parameter will affect the layout of buttons in notification toast
Value
8.0
+ RenderTerrainPBRTransformsEnabled
+
RenderTerrainPBRNormalsEnabled