Changeset View
Changeset View
Standalone View
Standalone View
source/renderer/VertexBuffer.h
/* Copyright (C) 2015 Wildfire Games. | /* Copyright (C) 2020 Wildfire Games. | ||||
vladislavbelov: You need to update the year. | |||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | public: | ||||
/// Get the address that Bind() will return, without actually binding | /// Get the address that Bind() will return, without actually binding | ||||
u8* GetBindAddress(); | u8* GetBindAddress(); | ||||
/// Unbind any currently-bound buffer, so glVertexPointer etc calls will not attempt to use it | /// Unbind any currently-bound buffer, so glVertexPointer etc calls will not attempt to use it | ||||
static void Unbind(); | static void Unbind(); | ||||
/// Make the vertex data available for the next call to Bind() | /// Make the vertex data available for the next call to Bind() | ||||
void PrepareForRendering(VBChunk* chunk) { chunk->m_Needed = true; } | void PrepareForRendering(VBChunk* chunk) | ||||
{ | |||||
chunk->m_Needed = true; | |||||
m_HasNeededChunks = true; | |||||
} | |||||
Done Inline Actions{ on a new line. vladislavbelov: `{` on a new line. | |||||
/// Update vertex data for given chunk. Transfers the provided data to the actual OpenGL vertex buffer. | /// Update vertex data for given chunk. Transfers the provided data to the actual OpenGL vertex buffer. | ||||
void UpdateChunkVertices(VBChunk* chunk, void* data); | void UpdateChunkVertices(VBChunk* chunk, void* data); | ||||
size_t GetVertexSize() const { return m_VertexSize; } | size_t GetVertexSize() const { return m_VertexSize; } | ||||
size_t GetBytesReserved() const; | size_t GetBytesReserved() const; | ||||
size_t GetBytesAllocated() const; | size_t GetBytesAllocated() const; | ||||
Show All 26 Lines | |||||
private: | private: | ||||
/// Vertex size of this vertex buffer | /// Vertex size of this vertex buffer | ||||
size_t m_VertexSize; | size_t m_VertexSize; | ||||
/// Number of vertices of above size in this buffer | /// Number of vertices of above size in this buffer | ||||
size_t m_MaxVertices; | size_t m_MaxVertices; | ||||
/// List of free chunks in this buffer | /// List of free chunks in this buffer | ||||
std::list<VBChunk*> m_FreeList; | std::deque<VBChunk*> m_FreeList; | ||||
vladislavbelovUnsubmitted Not Done Inline ActionsI have little doubts about std::deque, because erasing takes linear time. I think it'd be better to use allocator container to have O(1) for erase and the same cost for the capacity increment as the std::deque. But maybe in the next patch. vladislavbelov: I have little doubts about `std::deque`, because erasing takes linear time. I think it'd be… | |||||
/// List of allocated chunks | /// List of allocated chunks | ||||
std::list<VBChunk*> m_AllocList; | std::deque<VBChunk*> m_AllocList; | ||||
/// Available free vertices - total of all free vertices in the free list | /// Available free vertices - total of all free vertices in the free list | ||||
size_t m_FreeVertices; | size_t m_FreeVertices; | ||||
/// Handle to the actual GL vertex buffer object | /// Handle to the actual GL vertex buffer object | ||||
GLuint m_Handle; | GLuint m_Handle; | ||||
/// Raw system memory for systems not supporting VBOs | /// Raw system memory for systems not supporting VBOs | ||||
u8* m_SysMem; | u8* m_SysMem; | ||||
/// Usage type of the buffer (GL_STATIC_DRAW etc) | /// Usage type of the buffer (GL_STATIC_DRAW etc) | ||||
GLenum m_Usage; | GLenum m_Usage; | ||||
/// Buffer target (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER) | /// Buffer target (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER) | ||||
GLenum m_Target; | GLenum m_Target; | ||||
Done Inline Actionsm_ModifiedSinceBind maybe m_Dirty ? Stan: m_**M**odifiedSinceBind maybe m_Dirty ? | |||||
Done Inline ActionsMaybe m_HasNeededChunks? vladislavbelov: Maybe `m_HasNeededChunks`? | |||||
bool m_HasNeededChunks; | |||||
}; | }; | ||||
#endif | #endif |
Wildfire Games · Phabricator
You need to update the year.