Working on build

This commit is contained in:
Bradley Austin Davis 2016-07-29 15:51:33 -07:00 committed by Brad Davis
parent cab1843eff
commit 66cc9136eb
2 changed files with 21 additions and 8 deletions

View file

@ -282,11 +282,6 @@ void Buffer::markDirty(Size offset, Size bytes) {
_pages.markRegion(offset, bytes);
}
void Buffer::applyUpdate(const Update& update) {
_renderPages = update.pages;
update.updateOperator(_renderSysmem);
}
Buffer::Update Buffer::getUpdate() const {
static Update EMPTY_UPDATE;
if (!_pages) {
@ -319,6 +314,21 @@ Buffer::Update Buffer::getUpdate() const {
return result;
}
void Buffer::applyUpdate(const Update& update) {
_renderPages = update.pages;
update.updateOperator(_renderSysmem);
}
void Buffer::flush() {
_renderPages = _pages;
_renderSysmem.resize(_sysmem.getSize());
auto dirtyPages = _pages.getMarkedPages();
for (Size page : dirtyPages) {
Size offset = page * _pages._pageSize;
memcpy(_renderSysmem.editData() + offset, _sysmem.readData() + offset, _pages._pageSize);
}
}
Buffer::Size Buffer::setData(Size size, const Byte* data) {
resize(size);
setSubData(0, size, data);

View file

@ -105,8 +105,6 @@ public:
};
protected:
using Sysmem = gpu::Sysmem;
Resource() {}
virtual ~Resource() {}
@ -135,7 +133,7 @@ struct PageManager {
uint8 _flags{ 0 };
const Size _pageSize;
operator bool const() {
operator bool() const {
return (*this)(DIRTY);
}
@ -346,6 +344,11 @@ public:
// Main thread operation to say that the buffer is ready to be used as a frame
Update getUpdate() const;
// For use by the render thread to avoid the intermediate step of getUpdate/applyUpdate
void flush();
// FIXME don't maintain a second buffer continuously. We should be able to apply updates
// directly to the GL object and discard _renderSysmem and _renderPages
mutable PageManager _renderPages;
Sysmem _renderSysmem;