diff options
author | Erik Kundiman <erik@megapahit.org> | 2024-08-19 20:36:17 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2024-08-19 22:35:01 +0800 |
commit | b7afbe59c42a3e6e92f712153172364f4ebaa5e2 (patch) | |
tree | b10784783099c002ed1cc8fd694915ade40b6e67 /indra/llrender | |
parent | 495f103000137b3288eaa05a4298fd33ceb3c2dc (diff) | |
parent | 135fcd19541f414c3278b25b02b7bd34fbc3065f (diff) |
Merge branch 'webrtc-voice' into 2024.06-atlasaurus
Diffstat (limited to 'indra/llrender')
-rw-r--r-- | indra/llrender/llglheaders.h | 2 | ||||
-rw-r--r-- | indra/llrender/llrender.cpp | 2 | ||||
-rw-r--r-- | indra/llrender/llvertexbuffer.cpp | 45 |
3 files changed, 31 insertions, 18 deletions
diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h index 0b3258c105..7d56f12766 100644 --- a/indra/llrender/llglheaders.h +++ b/indra/llrender/llglheaders.h @@ -839,7 +839,7 @@ extern PFNGLPOLYGONOFFSETCLAMPPROC glPolygonOffsetClamp; #define GL_EXT_separate_specular_color 1 #define GL_GLEXT_PROTOTYPES -#include "GL/glext.h" +#include <OpenGL/glext.h> #define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED #include <OpenGL/gl3.h> diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 1037fbbfe3..633a453ab0 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1714,7 +1714,7 @@ void LLRender::flush() } //LL_INFOS() << "LLVertexBuffer::sMappingMode " << LLVertexBuffer::sMappingMode << LL_ENDL; - if(LLVertexBuffer::sMappingMode > 1) + if(LLVertexBuffer::sMappingMode == 3) { vb->unmapBuffer(); } diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index b522eb5218..6cded7f67a 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -373,7 +373,7 @@ public: ~LLVBOPool() { - if(mMappingMode > 1) return; + if(mMappingMode == 3) return; clear(); } @@ -392,7 +392,7 @@ public: U64 getVramBytesUsed() { - if(mMappingMode > 1) return mAllocated; + if(mMappingMode == 3) return mAllocated; else return mAllocated + mReserved; } @@ -415,7 +415,7 @@ public: 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 - if(mMappingMode > 1) + if(mMappingMode == 3) { mAllocated += size; @@ -483,7 +483,7 @@ public: llassert(type == GL_ARRAY_BUFFER || type == GL_ELEMENT_ARRAY_BUFFER); llassert(size >= 2); - if(mMappingMode > 1) + if(mMappingMode == 3) { if (data) { @@ -887,7 +887,7 @@ void LLVertexBuffer::initClass(LLWindow* window) sVBOPool = new LLVBOPool(); sVBOPool->mMappingMode = sMappingMode; - //LL_INFOS() << "milo sVBOPool intialized with " << sMappingMode << LL_ENDL; + //LL_INFOS() << "sVBOPool intialized with mapping mode: " << sMappingMode << LL_ENDL; #if ENABLE_GL_WORK_QUEUE sQueue = new GLWorkQueue(); @@ -1196,7 +1196,7 @@ U8* LLVertexBuffer::mapVertexBuffer(LLVertexBuffer::AttributeType type, U32 inde count = mNumVerts - index; } - if(sMappingMode < 2) + if(sMappingMode != 3) { U32 start = mOffsets[type] + sTypeSize[type] * index; U32 end = start + sTypeSize[type] * count-1; @@ -1233,7 +1233,7 @@ U8* LLVertexBuffer::mapIndexBuffer(U32 index, S32 count) count = mNumIndices-index; } - if(sMappingMode < 2) + if(sMappingMode != 3) { U32 start = sizeof(U16) * index; U32 end = start + sizeof(U16) * count-1; @@ -1268,9 +1268,24 @@ U8* LLVertexBuffer::mapIndexBuffer(U32 index, S32 count) // dst -- mMappedData or mMappedIndexData void LLVertexBuffer::flush_vbo(GLenum target, U32 start, U32 end, void* data, U8* dst) { - if(sMappingMode > 1) + if(sMappingMode == 2) + { + //LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb glMapBufferRange"); + if (end == 0) return; + U32 buffer_size = end-start+1; + U8 * mptr = (U8*) glMapBufferRange( target, start, end-start+1, GL_MAP_WRITE_BIT); + + if (mptr) + { + std::memcpy(mptr, (U8*) data, buffer_size); + if(!glUnmapBuffer(target)) LL_WARNS() << "glUnmapBuffer() failed" << LL_ENDL; + } + else LL_WARNS() << "glMapBufferRange() returned NULL" << LL_ENDL; + return; + } + + if(sMappingMode == 3) { - //LL_INFOS() << "milo flush_vbo() NO POOL" << LL_ENDL; LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb memcpy"); //STOP_GLERROR; // copy into mapped buffer @@ -1312,7 +1327,7 @@ void LLVertexBuffer::unmapBuffer() } }; - if(sMappingMode > 1) + if(sMappingMode == 3) { //STOP_GLERROR; if (mMappedData) @@ -1324,8 +1339,7 @@ void LLVertexBuffer::unmapBuffer() mGLBuffer = gen_buffer(); glBindBuffer(GL_ARRAY_BUFFER, mGLBuffer); sGLRenderBuffer = mGLBuffer; - if(sMappingMode==2) glBufferData(GL_ARRAY_BUFFER, mSize, mMappedData, GL_STATIC_DRAW); - else glBufferData(GL_ARRAY_BUFFER, mSize, mMappedData, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, mSize, mMappedData, GL_DYNAMIC_DRAW); } else if (mGLBuffer != sGLRenderBuffer) { @@ -1345,8 +1359,7 @@ void LLVertexBuffer::unmapBuffer() glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mGLIndices); sGLRenderIndices = mGLIndices; - if(sMappingMode==2) glBufferData(GL_ELEMENT_ARRAY_BUFFER, mIndicesSize, mMappedIndexData, GL_STATIC_DRAW); - else glBufferData(GL_ELEMENT_ARRAY_BUFFER, mIndicesSize, mMappedIndexData, GL_DYNAMIC_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, mIndicesSize, mMappedIndexData, GL_DYNAMIC_DRAW); } else if (mGLIndices != sGLRenderIndices) { @@ -1543,10 +1556,10 @@ bool LLVertexBuffer::getClothWeightStrider(LLStrider<LLVector4>& strider, U32 in // Set for rendering void LLVertexBuffer::setBuffer() { - if(sMappingMode > 1) + if(sMappingMode == 3) { if (!mGLBuffer) - { // OS X doesn't allocate a buffer until we call unmapBuffer + { return; } } |