Uses CVertexBufferManager handle instead of raw VBChunk pointer management.

Tested By: Stan
Differential Revision: https://code.wildfiregames.com/D4430
This was SVN commit r26196.
This commit is contained in:
vladislavbelov
2022-01-10 16:51:43 +00:00
parent 795fb070af
commit 0cda752ec3
8 changed files with 84 additions and 139 deletions
+5 -14
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2015 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -36,12 +36,10 @@ VertexArray::VertexArray(GLenum usage, GLenum target)
m_Target = target;
m_NumVertices = 0;
m_VB = 0;
m_BackingStore = 0;
m_Stride = 0;
}
VertexArray::~VertexArray()
{
Free();
@@ -53,14 +51,9 @@ void VertexArray::Free()
rtl_FreeAligned(m_BackingStore);
m_BackingStore = 0;
if (m_VB)
{
g_VBMan.Release(m_VB);
m_VB = 0;
}
m_VB.Reset();
}
// Set the number of vertices stored in the array
void VertexArray::SetNumVertices(size_t num)
{
@@ -71,7 +64,6 @@ void VertexArray::SetNumVertices(size_t num)
m_NumVertices = num;
}
// Add vertex attributes like Position, Normal, UV
void VertexArray::AddAttribute(Attribute* attr)
{
@@ -87,7 +79,6 @@ void VertexArray::AddAttribute(Attribute* attr)
Free();
}
// Template specialization for GetIterator().
// We can put this into the source file because only a fixed set of types
// is supported for type safety.
@@ -276,7 +267,7 @@ void VertexArray::Layout()
void VertexArray::PrepareForRendering()
{
m_VB->m_Owner->PrepareForRendering(m_VB);
m_VB->m_Owner->PrepareForRendering(m_VB.Get());
}
// (Re-)Upload the attributes.
@@ -286,7 +277,7 @@ void VertexArray::Upload()
ENSURE(m_BackingStore);
if (!m_VB)
m_VB = g_VBMan.Allocate(m_Stride, m_NumVertices, m_Usage, m_Target, m_BackingStore);
m_VB = g_VBMan.AllocateChunk(m_Stride, m_NumVertices, m_Usage, m_Target, m_BackingStore);
if (!m_VB)
{
@@ -294,7 +285,7 @@ void VertexArray::Upload()
return;
}
m_VB->m_Owner->UpdateChunkVertices(m_VB, m_BackingStore);
m_VB->m_Owner->UpdateChunkVertices(m_VB.Get(), m_BackingStore);
}