- 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; offset = osave;
} }
static TArray<RefCountedPtr<DShape2DBufferInfo>> buffersToDestroy;
void DShape2D::OnDestroy() { void DShape2D::OnDestroy() {
if (lastParms) delete lastParms; if (lastParms) delete lastParms;
lastParms = nullptr; lastParms = nullptr;
mIndices.Reset(); mIndices.Reset();
mVertices.Reset(); mVertices.Reset();
mCoords.Reset(); mCoords.Reset();
bufferInfo = nullptr; buffersToDestroy.Push(std::move(bufferInfo));
} }
//========================================================================== //==========================================================================
@ -1082,6 +1084,17 @@ void F2DDrawer::Clear()
screenFade = 1.f; screenFade = 1.f;
} }
//==========================================================================
//
//
//
//==========================================================================
void F2DDrawer::OnFrameDone()
{
buffersToDestroy.Clear();
}
F2DVertexBuffer::F2DVertexBuffer() F2DVertexBuffer::F2DVertexBuffer()
{ {
mVertexBuffer = screen->CreateVertexBuffer(); mVertexBuffer = screen->CreateVertexBuffer();

View File

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

View File

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