From 22c9c1bcc7b546241b79015bf8c0b5fcf75bdec3 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Mon, 6 Mar 2023 00:02:00 -0500
Subject: [PATCH] Hammer hammer...

---
 indra/llcommon/llmemory.cpp               |  2 +-
 indra/llcommon/llqueuedthread.cpp         |  1 -
 indra/llcommon/threadpool.h               |  1 -
 indra/llinventory/llsettingssky.cpp       |  2 +-
 indra/llmath/llvolume.cpp                 | 30 +++++++++++++++++------
 indra/llmath/llvolume.h                   | 11 ++++-----
 indra/llprimitive/llgltfmaterial.h        |  1 +
 indra/llrender/llimagegl.cpp              |  2 +-
 indra/llrender/llrender.cpp               |  4 +--
 indra/llrender/llshadermgr.cpp            |  4 +--
 indra/llrender/llshadermgr.h              |  2 +-
 indra/llrender/llvertexbuffer.cpp         |  1 -
 indra/newview/alfloaterparticleeditor.cpp |  2 +-
 indra/newview/alrenderutils.cpp           | 12 ++++-----
 indra/newview/llviewerassetupload.cpp     |  2 +-
 indra/newview/llviewerassetupload.h       |  2 +-
 indra/newview/llviewerwindow.cpp          |  4 +--
 indra/newview/pipeline.h                  | 10 ++++----
 18 files changed, 52 insertions(+), 41 deletions(-)

diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index 566548bb35f..b83baee33cc 100644
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -121,7 +121,7 @@ void LLMemory::updateMemoryInfo()
 	{
 		sAvailPhysicalMemInKB = U32Kilobytes(0);
 	}
-
+#endif
 #elif defined(LL_DARWIN)
     task_vm_info info;
     mach_msg_type_number_t  infoCount = TASK_VM_INFO_COUNT;
diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp
index 8b72b57dda4..309bd2761f1 100644
--- a/indra/llcommon/llqueuedthread.cpp
+++ b/indra/llcommon/llqueuedthread.cpp
@@ -242,7 +242,6 @@ bool LLQueuedThread::addRequest(QueuedRequest* req)
 #if _DEBUG
 // 	LL_INFOS() << llformat("LLQueuedThread::Added req [%08d]",handle) << LL_ENDL;
 #endif
-	mRequestQueueSize = mRequestQueue.size();
 	unlockData();
 
     llassert(!mDataLock->isSelfLocked());
diff --git a/indra/llcommon/threadpool.h b/indra/llcommon/threadpool.h
index eb23dd3ece0..60f4a0ce1bc 100644
--- a/indra/llcommon/threadpool.h
+++ b/indra/llcommon/threadpool.h
@@ -94,7 +94,6 @@ namespace LL
         std::string mName;
         size_t mThreadCount;
         std::vector<std::pair<std::string, std::thread>> mThreads;
-        EThreadPrio mThreadPriority;
     };
 
     /**
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index 58e76c4710d..e6c649076f4 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -630,7 +630,7 @@ const LLSettingsSky::validation_list_t& LLSettingsSky::validationList()
             boost::bind(&Validator::verifyFloatRange, boost::placeholders::_1, boost::placeholders::_2, LLSD(LLSDArray(0.0f)(1.0f)))));
 
         validation.push_back(Validator(SETTING_REFLECTION_PROBE_AMBIANCE, false, LLSD::TypeReal,
-            boost::bind(&Validator::verifyFloatRange, _1, _2, LLSD(LLSDArray(0.0f)(1.0f)))));
+            boost::bind(&Validator::verifyFloatRange, boost::placeholders::_1, boost::placeholders::_2, LLSD(LLSDArray(0.0f)(1.0f)))));
 
         validation.push_back(Validator(SETTING_RAYLEIGH_CONFIG, true, LLSD::TypeArray, &validateRayleighLayers));
         validation.push_back(Validator(SETTING_ABSORPTION_CONFIG, true, LLSD::TypeArray, &validateAbsorptionLayers));
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 611238da77e..7b2c500ecd7 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -58,8 +58,6 @@
 #include "mikktspace/mikktspace.h"
 #include "mikktspace/mikktspace.c" // insert mikktspace implementation into llvolume object file
 
-#include "meshoptimizer/meshoptimizer.h"
-
 #define DEBUG_SILHOUETTE_BINORMALS 0
 #define DEBUG_SILHOUETTE_NORMALS 0 // TomY: Use this to display normals using the silhouette
 #define DEBUG_SILHOUETTE_EDGE_MAP 0 // DaveP: Use this to display edge map using the silhouette
@@ -4802,7 +4800,7 @@ LLVolumeFace::LLVolumeFace(const LLVolumeFace& src)
 	mIndices(NULL),
 	mWeights(NULL),
     mWeightsScrubbed(FALSE),
-	mOctree(NULL),
+    mOctree(NULL),
     mOctreeTriangles(NULL),
 	mOptimized(FALSE)
 {
@@ -4846,7 +4844,7 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src)
 
 		if (src.mNormals)
 		{
-			LLVector4a::memcpyNonAliased16((F32*) mNormals, (F32*) src.mNormals, vert_size);
+		LLVector4a::memcpyNonAliased16((F32*) mNormals, (F32*) src.mNormals, vert_size);
 		}
 
 		if(src.mTexCoords)
@@ -4936,10 +4934,26 @@ LLVolumeFace::~LLVolumeFace()
 
 void LLVolumeFace::freeData()
 {
-	allocateVertices(0);
-	allocateTangents(0);
-	allocateWeights(0);
-	allocateIndices(0);
+	ll_aligned_free<64>(mPositions);
+	mPositions = NULL;
+
+	//normals and texture coordinates are part of the same buffer as mPositions, do not free them separately
+	mNormals = NULL;
+	mTexCoords = NULL;
+
+	ll_aligned_free_16(mIndices);
+	mIndices = NULL;
+	ll_aligned_free_16(mTangents);
+	mTangents = NULL;
+	ll_aligned_free_16(mWeights);
+	mWeights = NULL;
+
+#if USE_SEPARATE_JOINT_INDICES_AND_WEIGHTS
+    ll_aligned_free_16(mJointIndices);
+	mJointIndices = NULL;
+    ll_aligned_free_16(mJustWeights);
+	mJustWeights = NULL;
+#endif
 
     destroyOctree();
 }
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index e1bcc276856..115c0aff23a 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -874,12 +874,11 @@ class LLVolumeFace
 	BOOL create(LLVolume* volume, BOOL partial_build = FALSE);
 	void createTangents();
 	
-	bool resizeVertices(S32 num_verts);
-	bool allocateTangents(S32 num_verts);
-	bool allocateWeights(S32 num_verts);
-	bool allocateVertices(S32 num_verts, bool copy = false);
-	bool allocateIndices(S32 num_indices, bool copy = false);
-	bool resizeIndices(S32 num_indices);
+	void resizeVertices(S32 num_verts);
+	void allocateTangents(S32 num_verts);
+	void allocateWeights(S32 num_verts);
+    void allocateJointIndices(S32 num_verts);
+	void resizeIndices(S32 num_indices);
 	void fillFromLegacyData(std::vector<LLVolumeFace::VertexData>& v, std::vector<U16>& idx);
 
 	void pushVertex(const VertexData& cv);
diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h
index b453b91e674..4338f138c59 100644
--- a/indra/llprimitive/llgltfmaterial.h
+++ b/indra/llprimitive/llgltfmaterial.h
@@ -34,6 +34,7 @@
 #include "lluuid.h"
 #include "hbxxh.h"
 
+#include <array>
 #include <string>
 
 namespace tinygltf
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 2ebfd9112b0..23bb70bb678 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -1463,7 +1463,7 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt
             glTexImage2D(target, miplevel, intformat, width, height, 0, pixformat, pixtype, nullptr);
         }
 
-        U8* src = (U8*)(use_scratch ? scratch : pixels);
+        U8* src = (U8*)pixels;
         if (src)
         {
             LL_PROFILE_ZONE_NAMED("glTexImage2D copy");
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 4dd9d2098c8..1cff93ae4a4 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -1099,8 +1099,8 @@ void LLRender::syncMatrices()
 			// Anything beyond the standard proj and inv proj mats are special cases.  Please setup special uniforms accordingly in the future.
             if (shader->getUniformLocation(LLShaderMgr::INVERSE_PROJECTION_MATRIX))
             {
-	            LLMatrix4a inv_proj = mat
-	            mat.invert();
+	            LLMatrix4a inv_proj = mat;
+	            inv_proj.invert();
 	            shader->uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, FALSE, inv_proj.getF32ptr());
             }
 
diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index 5d192b79a49..6ac93a56b9b 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -479,7 +479,7 @@ void LLShaderMgr::dumpObjectLog(GLuint ret, BOOL warns, const std::string& filen
 	}
  }
 
-GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, boost::unordered_map<std::string, std::string>* defines, S32 texture_index_channels)
+GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, std::unordered_map<std::string, std::string>* defines, S32 texture_index_channels)
 {
 
 // endsure work-around for missing GLSL funcs gets propogated to feature shader files (e.g. srgbF.glsl)
@@ -709,7 +709,7 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev
 
 	if (defines)
 	{
-		for (boost::unordered_map<std::string,std::string>::iterator iter = defines->begin(); iter != defines->end(); ++iter)
+		for (std::unordered_map<std::string,std::string>::iterator iter = defines->begin(); iter != defines->end(); ++iter)
 		{
 			std::string define = "#define " + iter->first + " " + iter->second + "\n";
 			extra_code_text[extra_code_count++] = (GLchar *) strdup(define.c_str());
diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h
index 7e5ecefb0e9..127290a973f 100644
--- a/indra/llrender/llshadermgr.h
+++ b/indra/llrender/llshadermgr.h
@@ -304,7 +304,7 @@ class LLShaderMgr
     void dumpShaderSource(U32 shader_code_count, GLchar** shader_code_text);
 	BOOL	linkProgramObject(GLuint obj, BOOL suppress_errors = FALSE);
 	BOOL	validateProgramObject(GLuint obj);
-	GLuint loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, boost::unordered_map<std::string, std::string>* defines = NULL, S32 texture_index_channels = -1);
+	GLuint loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, std::unordered_map<std::string, std::string>* defines = NULL, S32 texture_index_channels = -1);
 
 	// Implemented in the application to actually point to the shader directory.
 	virtual std::string getShaderDirPrefix(void) = 0; // Pure Virtual
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 9fb5eef3a25..e75a6424bd8 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -582,7 +582,6 @@ const U32 LLVertexBuffer::sGLMode[LLRender::NUM_MODES] =
 	GL_POINTS,
 	GL_LINES,
 	GL_LINE_STRIP,
-	GL_QUADS,
 	GL_LINE_LOOP,
 };
 
diff --git a/indra/newview/alfloaterparticleeditor.cpp b/indra/newview/alfloaterparticleeditor.cpp
index ba1a018adeb..7e423e7984d 100644
--- a/indra/newview/alfloaterparticleeditor.cpp
+++ b/indra/newview/alfloaterparticleeditor.cpp
@@ -605,7 +605,7 @@ void ALFloaterParticleEditor::callbackReturned(const LLUUID& inventoryItemID)
 	LLBufferedAssetUploadInfo::taskUploadFinish_f proc =
 		boost::bind(&ALFloaterParticleEditor::finishUpload, _1, _2, _3, _4, true, mObject->getID());
 	LLResourceUploadInfo::ptr_t uploadInfo(new LLScriptAssetUpload(mObject->getID(), inventoryItemID,
-		LLScriptAssetUpload::MONO, true, LLUUID::null, script, proc));
+		LLScriptAssetUpload::MONO, true, LLUUID::null, script, proc, [](LLUUID itemId, LLUUID taskId, LLSD response, std::string reason){ return true; }));
 	LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo);
 
     if (mCloseAfterSave) closeFloater();
diff --git a/indra/newview/alrenderutils.cpp b/indra/newview/alrenderutils.cpp
index d9a307da577..72be0abfa22 100644
--- a/indra/newview/alrenderutils.cpp
+++ b/indra/newview/alrenderutils.cpp
@@ -262,8 +262,8 @@ ALRenderUtil::ALRenderUtil()
 
 void ALRenderUtil::restoreVertexBuffers()
 {
-	mRenderBuffer = new LLVertexBuffer(ALRENDER_BUFFER_MASK, 0);
-	mRenderBuffer->allocateBuffer(3, 0, true);
+	mRenderBuffer = new LLVertexBuffer(ALRENDER_BUFFER_MASK);
+	mRenderBuffer->allocateBuffer(3, 0);
 
 	LLStrider<LLVector3> vert;
 	LLStrider<LLVector2> tc0;
@@ -276,7 +276,7 @@ void ALRenderUtil::restoreVertexBuffers()
 	vert[1].set(3.f, -1.f, 0.f);
 	vert[2].set(-1.f, 3.f, 0.f);
 
-	mRenderBuffer->flush();
+	mRenderBuffer->unmapBuffer();
 }
 
 void ALRenderUtil::resetVertexBuffers()
@@ -585,7 +585,7 @@ void ALRenderUtil::renderTonemap(LLRenderTarget* src, LLRenderTarget* dst, LLRen
 		tone_shader->uniform4fv(LLShaderMgr::COLORGRADE_LUT_SIZE, 1, mCGLutSize.mV);
 	}
 
-	mRenderBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX);
+	mRenderBuffer->setBuffer();
 	mRenderBuffer->drawArrays(LLRender::TRIANGLES, 0, 3);
 	stop_glerror();
 
@@ -676,9 +676,9 @@ void ALRenderUtil::renderSharpen(LLRenderTarget* src, LLRenderTarget* dst)
 	sharpen_shader->bind();
 
 	// Draw
-	src->bindTexture(0, 0, LLTexUnit::TFO_POINT, LLTexUnit::TCS_LINEAR);
+	src->bindTexture(0, 0, LLTexUnit::TFO_POINT);
 
-	mRenderBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX);
+	mRenderBuffer->setBuffer();
 	mRenderBuffer->drawArrays(LLRender::TRIANGLES, 0, 3);
 
 	if (dst)
diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp
index 647e9055e74..0188040b83a 100644
--- a/indra/newview/llviewerassetupload.cpp
+++ b/indra/newview/llviewerassetupload.cpp
@@ -826,7 +826,7 @@ bool LLBufferedAssetUploadInfo::failedUpload(LLSD &result, std::string &reason)
 
 //=========================================================================
 
-LLScriptAssetUpload::LLScriptAssetUpload(LLUUID itemId, std::string buffer, invnUploadFinish_f finish, TargetType_t targetType, uploadFailed_f failed):
+LLScriptAssetUpload::LLScriptAssetUpload(LLUUID itemId, std::string buffer, invnUploadFinish_f finish, uploadFailed_f failed, TargetType_t targetType):
     LLBufferedAssetUploadInfo(itemId, LLAssetType::AT_LSL_TEXT, buffer, finish, failed),
     mExerienceId(),
     mTargetType(targetType),
diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h
index e8017432f40..f2c6fb03b69 100644
--- a/indra/newview/llviewerassetupload.h
+++ b/indra/newview/llviewerassetupload.h
@@ -264,7 +264,7 @@ class LLScriptAssetUpload : public LLBufferedAssetUploadInfo
         MONO
     };
 
-    LLScriptAssetUpload(LLUUID itemId, std::string buffer, invnUploadFinish_f finish, TargetType_t targetType = MONO, uploadFailed_f failed);
+    LLScriptAssetUpload(LLUUID itemId, std::string buffer, invnUploadFinish_f finish, uploadFailed_f failed, TargetType_t targetType = MONO);
     LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, TargetType_t targetType, 
             bool isRunning, LLUUID exerienceId, std::string buffer, taskUploadFinish_f finish, uploadFailed_f failed);
 
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 18c15d5a57f..a17ed7bd49e 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -5493,8 +5493,8 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubea
     LLViewerCamera* camera = LLViewerCamera::getInstance();
     
     LLViewerCamera saved_camera = LLViewerCamera::instance();
-    glh::matrix4f saved_proj = get_current_projection();
-    glh::matrix4f saved_mod = get_current_modelview();
+    LLMatrix4a saved_proj = get_current_projection();
+    LLMatrix4a saved_mod = get_current_modelview();
 
     // camera constants for the square, cube map capture image
     camera->setAspect(1.0); // must set aspect ratio first to avoid undesirable clamping of vertical FoV
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index a38e3facc9f..7e5f2d61f8a 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -289,7 +289,7 @@ class LLPipeline
 
 	void renderHighlight(const LLViewerObject* obj, F32 fade);
 	
-	void renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera& camera, LLCullResult& result, bool depth_clamp);
+	void renderShadow(LLMatrix4a& view, LLMatrix4a& proj, LLCamera& camera, LLCullResult& result, bool depth_clamp);
 	void renderHighlights();
 	void renderDebug();
 	void renderPhysicsDisplay();
@@ -689,10 +689,10 @@ class LLPipeline
 	LLCamera				mShadowCamera[8];
 	LLVector3				mShadowExtents[4][2];
     // TODO : separate Sun Shadow and Spot Shadow matrices
-	glh::matrix4f			mSunShadowMatrix[6];
-	glh::matrix4f			mShadowModelview[6];
-	glh::matrix4f			mShadowProjection[6];
-    glh::matrix4f           mReflectionModelView;
+	LLMatrix4a				mSunShadowMatrix[6];
+	LLMatrix4a				mShadowModelview[6];
+	LLMatrix4a				mShadowProjection[6];
+    LLMatrix4a			    mReflectionModelView;
 
 	LLPointer<LLDrawable>	mShadowSpotLight[2];
 	F32						mSpotLightFade[2];
-- 
GitLab