mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 21:11:39 +00:00
- disabled the buffer reallocation option for the light buffer.
The entire idea with CPU side buffering simply can not work since the buffer is being used live. To compensate the buffer's size was doubled.
This commit is contained in:
parent
2e02b7e555
commit
b56e80a556
3 changed files with 4 additions and 38 deletions
|
@ -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<std::mutex> 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.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,6 @@ class FLightBuffer
|
|||
unsigned int mByteSize;
|
||||
unsigned int mMaxUploadSize;
|
||||
|
||||
std::mutex mBufferMutex;
|
||||
TArray<float> 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; }
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue