From 6e234d971bde1a7b71ec2e99a29aacf1d90b7c3a Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Tue, 14 Dec 2021 23:24:43 -0500
Subject: [PATCH] Faster VAO name list

---
 indra/llrender/llvertexbuffer.cpp | 12 ++++++------
 indra/llrender/llvertexbuffer.h   |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 913f49eb48b..f8fbad3dcf3 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -94,7 +94,7 @@ U64 LLVBOPool::sBytesPooled = 0;
 U64 LLVBOPool::sIndexBytesPooled = 0;
 std::vector<U32> LLVBOPool::sPendingDeletions;
 
-std::list<U32> LLVertexBuffer::sAvailableVAOName;
+std::vector<U32> LLVertexBuffer::sAvailableVAOName;
 U32 LLVertexBuffer::sCurVAOName = 1;
 
 U64 LLVertexBuffer::sAllocatedIndexBytes = 0;
@@ -509,8 +509,8 @@ U32 LLVertexBuffer::getVAOName()
 
 	if (!sAvailableVAOName.empty())
 	{
-		ret = sAvailableVAOName.front();
-		sAvailableVAOName.pop_front();
+		ret = sAvailableVAOName.back();
+		sAvailableVAOName.pop_back();
 	}
 	else
 	{
@@ -1058,12 +1058,12 @@ void LLVertexBuffer::cleanupClass()
 	sDynamicVBOPool.cleanup();
 	clean_validate_buffers();
 
-	while (!sAvailableVAOName.empty())
+	if (!sAvailableVAOName.empty())
 	{
 #if GL_ARB_vertex_array_object
-		glDeleteVertexArrays(1, &sAvailableVAOName.front());
+		glDeleteVertexArrays(sAvailableVAOName.size(), sAvailableVAOName.data());
 #endif
-		sAvailableVAOName.pop_front();
+		sAvailableVAOName.clear();
 	}
 	sLastMask = 0;
 
diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index 511aaaae962..e9103c7271d 100644
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -121,8 +121,8 @@ class LLVertexBuffer final : public LLRefCount, public LLTrace::MemTrackable<LLV
 	static LLVBOPool sDynamicVBOPool;
 	static LLVBOPool sStreamIBOPool;
 	static LLVBOPool sDynamicIBOPool;
-	
-	static std::list<U32> sAvailableVAOName;
+
+	static std::vector<U32> sAvailableVAOName;
 	static U32 sCurVAOName;
 
 	static bool	sUseStreamDraw;
-- 
GitLab