From 724193e5b01e5c1ae879a6364f54601cdb22c2c1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 23 Nov 2021 20:46:27 +0000 Subject: SL-16239 Fix for slowdown on AMD GPUs (disable core profile and remove volatile members from LLVertexBuffer) --- indra/llrender/llvertexbuffer.cpp | 54 ++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 23 deletions(-) (limited to 'indra/llrender/llvertexbuffer.cpp') diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 5ea07ddcb1..46654cc5b9 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -157,12 +157,12 @@ LLVBOPool::LLVBOPool(U32 vboUsage, U32 vboType) std::fill(mMissCount.begin(), mMissCount.end(), 0); } -volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) +U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) { LL_PROFILE_ZONE_SCOPED llassert(vbo_block_size(size) == size); - volatile U8* ret = NULL; + U8* ret = NULL; U32 i = vbo_block_index(size); @@ -256,7 +256,7 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed) return ret; } -void LLVBOPool::release(U32 name, volatile U8* buffer, U32 size) +void LLVBOPool::release(U32 name, U8* buffer, U32 size) { llassert(vbo_block_size(size) == size); @@ -749,7 +749,7 @@ void LLVertexBuffer::drawRangeFast(U32 mode, U32 start, U32 end, U32 count, U32 mMappable = false; gGL.syncMatrices(); - U16* idx = ((U16*)(U8*)mAlignedIndexOffset) + indices_offset; + U16* idx = ((U16*)getIndicesPointer()) + indices_offset; LL_PROFILER_GPU_ZONEC("gl.DrawRangeElements", 0xFFFF00) glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, @@ -1539,7 +1539,7 @@ bool expand_region(LLVertexBuffer::MappedRegion& region, S32 index, S32 count) // Map for data access -volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_range) +U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_range) { LL_PROFILE_ZONE_SCOPED; bindGLBuffer(true); @@ -1601,7 +1601,7 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo } else { - volatile U8* src = NULL; + U8* src = NULL; waitFence(); if (gGLManager.mHasMapBufferRange) { @@ -1660,7 +1660,7 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo llassert(src != NULL); - mMappedData = LL_NEXT_ALIGNED_ADDRESS(src); + mMappedData = LL_NEXT_ALIGNED_ADDRESS(src); mAlignedOffset = mMappedData - src; stop_glerror(); @@ -1716,7 +1716,7 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo } -volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range) +U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range) { LL_PROFILE_ZONE_SCOPED; bindGLIndices(true); @@ -1786,7 +1786,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range } else { - volatile U8* src = NULL; + U8* src = NULL; waitFence(); if (gGLManager.mHasMapBufferRange) { @@ -2068,7 +2068,7 @@ template struct VertexBufferStrider { if (type == LLVertexBuffer::TYPE_INDEX) { - volatile U8* ptr = vbo.mapIndexBuffer(index, count, map_range); + U8* ptr = vbo.mapIndexBuffer(index, count, map_range); if (ptr == NULL) { @@ -2084,7 +2084,7 @@ template struct VertexBufferStrider { S32 stride = LLVertexBuffer::sTypeSize[type]; - volatile U8* ptr = vbo.mapVertexBuffer(type, index, count, map_range); + U8* ptr = vbo.mapVertexBuffer(type, index, count, map_range); if (ptr == NULL) { @@ -2454,29 +2454,37 @@ void LLVertexBuffer::setBuffer(U32 data_mask) void LLVertexBuffer::setBufferFast(U32 data_mask) { - //set up pointers if the data mask is different ... - bool setup = (sLastMask != data_mask); + if (useVBOs()) + { + //set up pointers if the data mask is different ... + bool setup = (sLastMask != data_mask); - - const bool bindBuffer = bindGLBufferFast(); - const bool bindIndices = bindGLIndicesFast(); + const bool bindBuffer = bindGLBufferFast(); + const bool bindIndices = bindGLIndicesFast(); - setup = setup || bindBuffer || bindIndices; + setup = setup || bindBuffer || bindIndices; + + setupClientArrays(data_mask); - setupClientArrays(data_mask); - - if (data_mask && setup) + if (data_mask && setup) + { + setupVertexBufferFast(data_mask); + sSetCount++; + } + } + else { - setupVertexBufferFast(data_mask); - sSetCount++; + //fallback to slow path when not using VBOs + setBuffer(data_mask); } } + // virtual (default) void LLVertexBuffer::setupVertexBuffer(U32 data_mask) { stop_glerror(); - volatile U8* base = useVBOs() ? (U8*) mAlignedOffset : mMappedData; + U8* base = useVBOs() ? (U8*) mAlignedOffset : mMappedData; if (gDebugGL && ((data_mask & mTypeMask) != data_mask)) { -- cgit v1.2.3