Skip to content

Commit 2dff3de

Browse files
committed
Fix memory leak for vertex buffers in dx103DFluidGrid.
1 parent 10efe46 commit 2dff3de

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Layers/xrRenderDX10/3DFluid/dx103DFluidGrid.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ inline void ComputeRowColsForFlat3DTexture(int depth, int* outCols, int* outRows
3535
dx103DFluidGrid::dx103DFluidGrid() {}
3636
dx103DFluidGrid::~dx103DFluidGrid()
3737
{
38-
// TODO: implement init/deinit functionality and guards
38+
DestroyVertexBuffers();
3939
}
4040

4141
void dx103DFluidGrid::Initialize(int gridWidth, int gridHeight, int gridDepth)
@@ -145,6 +145,14 @@ void dx103DFluidGrid::CreateVertexBuffers()
145145
boundaryLines = NULL;
146146
}
147147

148+
void dx103DFluidGrid::DestroyVertexBuffers()
149+
{
150+
_RELEASE(m_pRenderQuadBuffer);
151+
_RELEASE(m_pSlicesBuffer);
152+
_RELEASE(m_pBoundarySlicesBuffer);
153+
_RELEASE(m_pBoundaryLinesBuffer);
154+
}
155+
148156
void dx103DFluidGrid::InitScreenSlice(VS_INPUT_FLUIDSIM_STRUCT** vertices, int z, int& index)
149157
{
150158
VS_INPUT_FLUIDSIM_STRUCT tempVertex1;

src/Layers/xrRenderDX10/3DFluid/dx103DFluidGrid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class dx103DFluidGrid
1919

2020
private:
2121
void CreateVertexBuffers();
22+
void DestroyVertexBuffers();
2223

2324
void InitScreenSlice(VS_INPUT_FLUIDSIM_STRUCT** vertices, int z, int& index);
2425
void InitSlice(int z, VS_INPUT_FLUIDSIM_STRUCT** vertices, int& index);

0 commit comments

Comments
 (0)