1
0
forked from 0ad/0ad

Replaces occurrences of "VBO" in comments by "backend buffer". Refs cff79b421a

This was SVN commit r26835.
This commit is contained in:
Vladislav Belov 2022-04-27 20:04:56 +00:00
parent d8b8128abb
commit ac60b12045
7 changed files with 41 additions and 38 deletions

View File

@ -128,11 +128,11 @@ struct OverlayRendererInternals
VertexArray::Attribute quadAttributeUV;
VertexIndexArray quadIndices;
/// Maximum amount of quad overlays we support for rendering. This limit is set to be able to
/// render all quads from a single dedicated VB without having to reallocate it, which is much
/// faster in the typical case of rendering only a handful of quads. When modifying this value,
/// you must take care for the new amount of quads to fit in a single VBO (which is not likely
/// to be a problem).
// Maximum amount of quad overlays we support for rendering. This limit is set to be able to
// render all quads from a single dedicated VB without having to reallocate it, which is much
// faster in the typical case of rendering only a handful of quads. When modifying this value,
// you must take care for the new amount of quads to fit in a single backend buffer (which is
// not likely to be a problem).
static const size_t MAX_QUAD_OVERLAYS = 1024;
// Sets of commonly-(re)used shader defines.
@ -145,9 +145,10 @@ struct OverlayRendererInternals
std::vector<u16> sphereIndexes;
void GenerateSphere();
/// Performs one-time setup. Called from CRenderer::Open, after graphics capabilities have
/// been detected. Note that no VBOs must be created before this is called, since the shader
/// path and graphics capabilities are not guaranteed to be stable before this point.
// Performs one-time setup. Called from CRenderer::Open, after graphics capabilities have
// been detected. Note that no backend buffer must be created before this is called, since
// the shader path and graphics capabilities are not guaranteed to be stable before this
// point.
void Initialize();
};
@ -178,7 +179,7 @@ OverlayRendererInternals::OverlayRendererInternals()
void OverlayRendererInternals::Initialize()
{
// Perform any initialization after graphics capabilities have been detected. Notably,
// only at this point can we safely allocate VBOs (in contrast to e.g. in the constructor),
// only at this point can we safely allocate backend buffer (in contrast to e.g. in the constructor),
// because their creation depends on the shader path, which is not reliably set before this point.
quadVertices.SetNumberOfVertices(MAX_QUAD_OVERLAYS * 4);

View File

@ -44,7 +44,7 @@ public:
/**
* Performs one-time initialization. Called by CRenderer::Open after graphics
* capabilities and the shader path have been determined (notably VBO support).
* capabilities and the shader path have been determined.
*/
void Initialize();

View File

@ -320,9 +320,11 @@ void CTexturedLineRData::Update(const SOverlayTexturedLine& line)
m_VB = g_VBMan.AllocateChunk(
sizeof(SVertex), vertices.size(), Renderer::Backend::GL::CBuffer::Type::VERTEX, false);
if (m_VB) // allocation might fail (e.g. due to too many vertices)
// Allocation might fail (e.g. due to too many vertices).
if (m_VB)
{
m_VB->m_Owner->UpdateChunkVertices(m_VB.Get(), &vertices[0]); // copy data into VBO
// Copy data into backend buffer.
m_VB->m_Owner->UpdateChunkVertices(m_VB.Get(), &vertices[0]);
for (size_t k = 0; k < indices.size(); ++k)
indices[k] += static_cast<u16>(m_VB->m_Index);

View File

@ -225,7 +225,7 @@ static size_t RoundStride(size_t stride)
// Re-layout by assigning offsets on a first-come first-serve basis,
// then round up to a reasonable stride.
// Backing store is also created here, VBOs are created on upload.
// Backing store is also created here, backend buffers are created on upload.
void VertexArray::Layout()
{
Free();
@ -262,7 +262,7 @@ void VertexArray::PrepareForRendering()
}
// (Re-)Upload the attributes.
// Create the VBO if necessary.
// Create the backend buffer if necessary.
void VertexArray::Upload()
{
ENSURE(m_BackingStore);
@ -275,7 +275,7 @@ void VertexArray::Upload()
if (!m_VB)
{
LOGERROR("Failed to allocate VBO for vertex array");
LOGERROR("Failed to allocate backend buffer for vertex array");
return;
}

View File

@ -211,11 +211,11 @@ void CVertexBuffer::UpdateChunkVertices(VBChunk* chunk, void* data)
ENSURE(m_Buffer);
if (UseStreaming(m_Buffer->IsDynamic()))
{
// The VBO is now out of sync with the backing store
// The backend buffer is now out of sync with the backing store.
chunk->m_Dirty = true;
// Sanity check: Make sure the caller hasn't tried to reallocate
// their backing store
// their backing store.
ENSURE(data == chunk->m_BackingStore);
}
else
@ -234,8 +234,8 @@ void CVertexBuffer::UploadIfNeeded(
if (!m_HasNeededChunks)
return;
// If any chunks are out of sync with the current VBO, and are
// needed for rendering this frame, we'll need to re-upload the VBO
// If any chunks are out of sync with the current backend buffer, and are
// needed for rendering this frame, we'll need to re-upload the backend buffer.
bool needUpload = false;
for (VBChunk* const& chunk : m_AllocList)
{
@ -258,16 +258,16 @@ void CVertexBuffer::UploadIfNeeded(
#endif
// Copy only the chunks we need. (This condition is helpful when
// the VBO contains data for every unit in the world, but only a
// handful are visible on screen and we don't need to bother copying
// the rest.)
// the backend buffer contains data for every unit in the world,
// but only a handful are visible on screen and we don't need to
// bother copying the rest.)
for (VBChunk* const& chunk : m_AllocList)
if (chunk->m_Needed)
std::memcpy(mappedData + chunk->m_Index * m_VertexSize, chunk->m_BackingStore, chunk->m_Count * m_VertexSize);
});
// Anything we just uploaded is clean; anything else is dirty
// since the rest of the VBO content is now undefined
// since the rest of the backend buffer content is now undefined
for (VBChunk* const& chunk : m_AllocList)
{
if (chunk->m_Needed)

View File

@ -16,7 +16,7 @@
*/
/*
* encapsulation of VBOs with batching and sharing
* Encapsulation of backend buffers with batching and sharing.
*/
#ifndef INCLUDED_VERTEXBUFFER
@ -29,14 +29,14 @@
#include <vector>
/**
* CVertexBuffer: encapsulation of ARB_vertex_buffer_object, also supplying
* CVertexBuffer: encapsulation of backend buffers, also supplying
* some additional functionality for sharing buffers between multiple objects.
*
* The class can be used in two modes, depending on the usage parameter:
*
* Static buffer: Call Allocate() with backingStore = nullptr. Then call
* UpdateChunkVertices() with any pointer - the data will be immediately copied
* to the VBO. This should be used for vertex data that rarely changes.
* to the buffer. This should be used for vertex data that rarely changes.
*
* Dynamic buffer: Call Allocate() with backingStore pointing
* at some memory that will remain valid for the lifetime of the CVertexBuffer.
@ -59,29 +59,30 @@ class CVertexBuffer
public:
/// VBChunk: describes a portion of this vertex buffer
// VBChunk: describes a portion of this vertex buffer
struct VBChunk
{
/// Owning (parent) vertex buffer
// Owning (parent) vertex buffer
CVertexBuffer* m_Owner;
/// Start index of this chunk in owner
// Start index of this chunk in owner
size_t m_Index;
/// Number of vertices used by chunk
// Number of vertices used by chunk
size_t m_Count;
/// If UseStreaming() is true, points at the data for this chunk
// If UseStreaming() is true, points at the data for this chunk
void* m_BackingStore;
/// If true, the VBO is not consistent with the chunk's backing store
/// (and will need to be re-uploaded before rendering with this chunk)
// If true, the backend buffer is not consistent with the chunk's
// backing store (and will need to be re-uploaded before rendering with
// this chunk).
bool m_Dirty;
/// If true, we have been told this chunk is going to be used for
/// rendering in the next uploading phase and will need to be uploaded
// If true, we have been told this chunk is going to be used for
// rendering in the next uploading phase and will need to be uploaded
bool m_Needed;
private:
// Only CVertexBuffer can construct/delete these
// (Other people should use g_VBMan.Allocate, g_VBMan.Release)
// (Other people should use g_VBMan.AllocateChunk)
friend class CVertexBuffer;
VBChunk() {}
~VBChunk() {}

View File

@ -21,7 +21,6 @@
#include "lib/ogl.h"
#include "ps/CLogger.h"
#include "ps/CStr.h"
#define DUMP_VB_STATS 0 // for debugging
@ -174,7 +173,7 @@ CVertexBufferManager::Handle CVertexBufferManager::AllocateChunk(
if (!result)
{
LOGERROR("Failed to create VBOs (%zu*%zu)", vertexSize, numberOfVertices);
LOGERROR("Failed to create backend buffer (%zu*%zu)", vertexSize, numberOfVertices);
return Handle();
}