diff --git a/src/hwrenderer/dynlights/hw_lightbuffer.cpp b/src/hwrenderer/dynlights/hw_lightbuffer.cpp index 641015833..a9e24353c 100644 --- a/src/hwrenderer/dynlights/hw_lightbuffer.cpp +++ b/src/hwrenderer/dynlights/hw_lightbuffer.cpp @@ -36,7 +36,7 @@ static const int ELEMENT_SIZE = (4*sizeof(float)); FLightBuffer::FLightBuffer() { - int maxNumberOfLights = 40000; + int maxNumberOfLights = 80000; mBufferSize = maxNumberOfLights * ELEMENTS_PER_LIGHT; mByteSize = mBufferSize * ELEMENT_SIZE; @@ -77,28 +77,6 @@ void FLightBuffer::Clear() mIndex = 0; } -void FLightBuffer::CheckSize() -{ - // create the new buffer's storage (at least twice as large as the old one) - int oldbytesize = mByteSize; - unsigned int bufferbytesize = mBufferedData.Size() * 4; - if (bufferbytesize > mByteSize) - { - mByteSize += bufferbytesize; - } - else - { - mByteSize *= 2; - } - mBufferSize = mByteSize / ELEMENT_SIZE; - mBuffer->Resize(mByteSize); - - Map(); - memcpy(((float*)mBuffer->Memory()) + mBlockSize*4, &mBufferedData[0], bufferbytesize); - mBufferedData.Clear(); - Unmap(); -} - int FLightBuffer::UploadLights(FDynLightData &data) { // All meaasurements here are in vec4's. @@ -145,16 +123,7 @@ int FLightBuffer::UploadLights(FDynLightData &data) } else { - // The buffered data always starts at the old buffer's end to avoid more extensive synchronization. - std::lock_guard lock(mBufferMutex); - auto index = mBufferedData.Reserve(totalsize); - float *copyptr =&mBufferedData[index]; - // The copy operation must be inside the mutexed block of code here! - memcpy(©ptr[0], parmcnt, ELEMENT_SIZE); - memcpy(©ptr[4], &data.arrays[0][0], size0 * ELEMENT_SIZE); - memcpy(©ptr[4 + 4*size0], &data.arrays[1][0], size1 * ELEMENT_SIZE); - memcpy(©ptr[4 + 4*(size0 + size1)], &data.arrays[2][0], size2 * ELEMENT_SIZE); - return mBufferSize + index; + return -1; // Buffer is full. Since it is being used live at the point of the upload we cannot do much here but to abort. } } diff --git a/src/hwrenderer/dynlights/hw_lightbuffer.h b/src/hwrenderer/dynlights/hw_lightbuffer.h index 9cdcbe5a1..6355508ba 100644 --- a/src/hwrenderer/dynlights/hw_lightbuffer.h +++ b/src/hwrenderer/dynlights/hw_lightbuffer.h @@ -22,9 +22,6 @@ class FLightBuffer unsigned int mByteSize; unsigned int mMaxUploadSize; - std::mutex mBufferMutex; - TArray mBufferedData; - void CheckSize(); public: @@ -34,7 +31,7 @@ public: void Clear(); int UploadLights(FDynLightData &data); void Map() { mBuffer->Map(); } - void Unmap() { mBuffer->Unmap(); if (mBufferedData.Size() > 0) CheckSize(); } + void Unmap() { mBuffer->Unmap(); } unsigned int GetBlockSize() const { return mBlockSize; } bool GetBufferType() const { return mBufferType; } diff --git a/src/hwrenderer/scene/hw_flats.cpp b/src/hwrenderer/scene/hw_flats.cpp index da2a6e604..776346114 100644 --- a/src/hwrenderer/scene/hw_flats.cpp +++ b/src/hwrenderer/scene/hw_flats.cpp @@ -184,7 +184,7 @@ void GLFlat::DrawSubsectors(HWDrawInfo *di, FRenderState &state) { auto vcount = sector->ibocount; - if (screen->BuffersArePersistent()) + if (level.HasDynamicLights && screen->BuffersArePersistent()) { SetupLights(di, sector->lighthead, lightdata, sector->PortalGroup); }