mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 03:53:34 +02:00
Use move constructor for building buffer shadow updates
This commit is contained in:
parent
c2509e9492
commit
02b4873ab0
4 changed files with 23 additions and 11 deletions
|
@ -636,7 +636,7 @@ void Batch::finish(BufferUpdates& updates) {
|
|||
if (!buffer || !buffer->isDirty()) {
|
||||
continue;
|
||||
}
|
||||
updates.push_back({ buffer, buffer->getUpdate() });
|
||||
updates.emplace_back(buffer->getUpdate());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -645,7 +645,7 @@ void Batch::finish(BufferUpdates& updates) {
|
|||
if (!buffer || !buffer->isDirty()) {
|
||||
continue;
|
||||
}
|
||||
updates.push_back({ buffer, buffer->getUpdate() });
|
||||
updates.emplace_back(buffer->getUpdate());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,10 +34,8 @@ void Frame::finish() {
|
|||
}
|
||||
|
||||
void Frame::preRender() {
|
||||
for (auto& bufferUpdate : bufferUpdates) {
|
||||
const BufferPointer& buffer = bufferUpdate.first;
|
||||
const Buffer::Update& update = bufferUpdate.second;
|
||||
buffer->applyUpdate(update);
|
||||
for (auto& update : bufferUpdates) {
|
||||
update.apply();
|
||||
}
|
||||
bufferUpdates.clear();
|
||||
}
|
||||
|
|
|
@ -410,6 +410,22 @@ void Buffer::markDirty(Size offset, Size bytes) {
|
|||
_pages.markRegion(offset, bytes);
|
||||
}
|
||||
|
||||
extern bool isRenderThread();
|
||||
|
||||
Buffer::Update::Update(const Update& other) :
|
||||
buffer(other.buffer),
|
||||
updateNumber(other.updateNumber),
|
||||
size(other.size),
|
||||
dirtyPages(other.dirtyPages),
|
||||
dirtyData(other.dirtyData) { }
|
||||
|
||||
Buffer::Update::Update(Update&& other) :
|
||||
buffer(other.buffer),
|
||||
updateNumber(other.updateNumber),
|
||||
size(other.size),
|
||||
dirtyPages(std::move(other.dirtyPages)),
|
||||
dirtyData(std::move(other.dirtyData)) { }
|
||||
|
||||
Buffer::Update::Update(const Buffer& parent) : buffer(parent) {
|
||||
const auto pageSize = buffer._pages._pageSize;
|
||||
updateNumber = ++buffer._getUpdateCount;
|
||||
|
@ -426,8 +442,6 @@ Buffer::Update::Update(const Buffer& parent) : buffer(parent) {
|
|||
}
|
||||
}
|
||||
|
||||
extern bool isRenderThread();
|
||||
|
||||
void Buffer::Update::apply() const {
|
||||
// Make sure we're loaded in order
|
||||
++buffer._applyUpdateCount;
|
||||
|
|
|
@ -159,12 +159,13 @@ public:
|
|||
class Update {
|
||||
public:
|
||||
Update(const Buffer& buffer);
|
||||
Update(const Update& other);
|
||||
Update(Update&& other);
|
||||
void apply() const;
|
||||
|
||||
private:
|
||||
const Buffer& buffer;
|
||||
size_t updateNumber;
|
||||
//PageManager pages;
|
||||
Size size;
|
||||
PageManager::Pages dirtyPages;
|
||||
std::vector<uint8> dirtyData;
|
||||
|
@ -284,8 +285,7 @@ public:
|
|||
friend class Frame;
|
||||
};
|
||||
|
||||
using BufferUpdate = std::pair<BufferPointer, Buffer::Update>;
|
||||
using BufferUpdates = std::vector<BufferUpdate>;
|
||||
using BufferUpdates = std::vector<Buffer::Update>;
|
||||
|
||||
typedef std::shared_ptr<Buffer> BufferPointer;
|
||||
typedef std::vector< BufferPointer > Buffers;
|
||||
|
|
Loading…
Reference in a new issue