mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 11:37:58 +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()) {
|
if (!buffer || !buffer->isDirty()) {
|
||||||
continue;
|
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()) {
|
if (!buffer || !buffer->isDirty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
updates.push_back({ buffer, buffer->getUpdate() });
|
updates.emplace_back(buffer->getUpdate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,10 +34,8 @@ void Frame::finish() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::preRender() {
|
void Frame::preRender() {
|
||||||
for (auto& bufferUpdate : bufferUpdates) {
|
for (auto& update : bufferUpdates) {
|
||||||
const BufferPointer& buffer = bufferUpdate.first;
|
update.apply();
|
||||||
const Buffer::Update& update = bufferUpdate.second;
|
|
||||||
buffer->applyUpdate(update);
|
|
||||||
}
|
}
|
||||||
bufferUpdates.clear();
|
bufferUpdates.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -410,6 +410,22 @@ void Buffer::markDirty(Size offset, Size bytes) {
|
||||||
_pages.markRegion(offset, 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) {
|
Buffer::Update::Update(const Buffer& parent) : buffer(parent) {
|
||||||
const auto pageSize = buffer._pages._pageSize;
|
const auto pageSize = buffer._pages._pageSize;
|
||||||
updateNumber = ++buffer._getUpdateCount;
|
updateNumber = ++buffer._getUpdateCount;
|
||||||
|
@ -426,8 +442,6 @@ Buffer::Update::Update(const Buffer& parent) : buffer(parent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern bool isRenderThread();
|
|
||||||
|
|
||||||
void Buffer::Update::apply() const {
|
void Buffer::Update::apply() const {
|
||||||
// Make sure we're loaded in order
|
// Make sure we're loaded in order
|
||||||
++buffer._applyUpdateCount;
|
++buffer._applyUpdateCount;
|
||||||
|
|
|
@ -159,12 +159,13 @@ public:
|
||||||
class Update {
|
class Update {
|
||||||
public:
|
public:
|
||||||
Update(const Buffer& buffer);
|
Update(const Buffer& buffer);
|
||||||
|
Update(const Update& other);
|
||||||
|
Update(Update&& other);
|
||||||
void apply() const;
|
void apply() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Buffer& buffer;
|
const Buffer& buffer;
|
||||||
size_t updateNumber;
|
size_t updateNumber;
|
||||||
//PageManager pages;
|
|
||||||
Size size;
|
Size size;
|
||||||
PageManager::Pages dirtyPages;
|
PageManager::Pages dirtyPages;
|
||||||
std::vector<uint8> dirtyData;
|
std::vector<uint8> dirtyData;
|
||||||
|
@ -284,8 +285,7 @@ public:
|
||||||
friend class Frame;
|
friend class Frame;
|
||||||
};
|
};
|
||||||
|
|
||||||
using BufferUpdate = std::pair<BufferPointer, Buffer::Update>;
|
using BufferUpdates = std::vector<Buffer::Update>;
|
||||||
using BufferUpdates = std::vector<BufferUpdate>;
|
|
||||||
|
|
||||||
typedef std::shared_ptr<Buffer> BufferPointer;
|
typedef std::shared_ptr<Buffer> BufferPointer;
|
||||||
typedef std::vector< BufferPointer > Buffers;
|
typedef std::vector< BufferPointer > Buffers;
|
||||||
|
|
Loading…
Reference in a new issue