- extended 2D buffer lifetime to the end of the frame

This commit is contained in:
alexey.lysiuk 2021-08-11 11:11:01 +03:00 committed by Christoph Oelckers
parent 387aef27ad
commit ed606b8ed3
3 changed files with 16 additions and 1 deletions

View file

@ -528,13 +528,15 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms)
offset = osave;
}
static TArray<RefCountedPtr<DShape2DBufferInfo>> buffersToDestroy;
void DShape2D::OnDestroy() {
if (lastParms) delete lastParms;
lastParms = nullptr;
mIndices.Reset();
mVertices.Reset();
mCoords.Reset();
bufferInfo = nullptr;
buffersToDestroy.Push(std::move(bufferInfo));
}
//==========================================================================
@ -1082,6 +1084,17 @@ void F2DDrawer::Clear()
screenFade = 1.f;
}
//==========================================================================
//
//
//
//==========================================================================
void F2DDrawer::OnFrameDone()
{
buffersToDestroy.Clear();
}
F2DVertexBuffer::F2DVertexBuffer()
{
mVertexBuffer = screen->CreateVertexBuffer();

View file

@ -216,6 +216,7 @@ public:
void Begin(int w, int h) { isIn2D = true; Width = w; Height = h; }
void End() { isIn2D = false; }
bool HasBegun2D() { return isIn2D; }
void OnFrameDone();
void ClearClipRect() { clipleft = cliptop = 0; clipwidth = clipheight = -1; }
void SetClipRect(int x, int y, int w, int h);

View file

@ -903,6 +903,7 @@ static void End2DAndUpdate()
twod->End();
CheckBench();
screen->Update();
twod->OnFrameDone();
}
//==========================================================================