Skip to content

Commit

Permalink
- extended 2D buffer lifetime to the end of the frame
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-lysiuk authored and coelckers committed Aug 11, 2021
1 parent 387aef2 commit ed606b8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/common/2d/v_2ddrawer.cpp
Expand Up @@ -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));
}

//==========================================================================
Expand Down Expand Up @@ -1082,6 +1084,17 @@ void F2DDrawer::Clear()
screenFade = 1.f;
}

//==========================================================================
//
//
//
//==========================================================================

void F2DDrawer::OnFrameDone()
{
buffersToDestroy.Clear();
}

F2DVertexBuffer::F2DVertexBuffer()
{
mVertexBuffer = screen->CreateVertexBuffer();
Expand Down
1 change: 1 addition & 0 deletions src/common/2d/v_2ddrawer.h
Expand Up @@ -216,6 +216,7 @@ class F2DDrawer
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);
Expand Down
1 change: 1 addition & 0 deletions src/d_main.cpp
Expand Up @@ -903,6 +903,7 @@ static void End2DAndUpdate()
twod->End();
CheckBench();
screen->Update();
twod->OnFrameDone();
}

//==========================================================================
Expand Down

0 comments on commit ed606b8

Please sign in to comment.