Clear buffers between each batch render

This commit is contained in:
Atlante45 2016-01-14 16:08:06 -08:00
parent 6ff38bc32f
commit eb55e55367
3 changed files with 8 additions and 6 deletions

View file

@ -161,6 +161,8 @@ void GLBackend::renderPassTransfer(Batch& batch) {
_transform._cameras.clear(); _transform._cameras.clear();
_transform._cameraOffsets.clear(); _transform._cameraOffsets.clear();
_transform._objects.clear(); _transform._objects.clear();
_drawCallInfos.clear();
_namedDrawCallInfos.clear();
for (_commandIndex = 0; _commandIndex < numCommands; ++_commandIndex) { for (_commandIndex = 0; _commandIndex < numCommands; ++_commandIndex) {
switch (*command) { switch (*command) {
@ -286,7 +288,7 @@ GLBackend::DrawCallInfoBuffer& GLBackend::getDrawCallInfoBuffer() {
void GLBackend::captureDrawCallInfo() { void GLBackend::captureDrawCallInfo() {
auto& drawCallInfos = getDrawCallInfoBuffer(); auto& drawCallInfos = getDrawCallInfoBuffer();
drawCallInfos.push_back(_transform._objects.size() - 1); drawCallInfos.push_back((uint16)_transform._objects.size() - 1);
} }
bool GLBackend::checkGLError(const char* name) { bool GLBackend::checkGLError(const char* name) {

View file

@ -251,8 +251,8 @@ protected:
DrawCallInfo(Index idx) : index(idx) {} DrawCallInfo(Index idx) : index(idx) {}
Index index; Index index { 0 };
uint16_t unused; // Reserved space for later uint16_t unused { 0 }; // Reserved space for later
}; };
// Make sure DrawCallInfo has no extra padding // Make sure DrawCallInfo has no extra padding
static_assert(sizeof(DrawCallInfo) == 4, "DrawCallInfo size is incorrect."); static_assert(sizeof(DrawCallInfo) == 4, "DrawCallInfo size is incorrect.");
@ -344,7 +344,7 @@ protected:
void killTransform(); void killTransform();
// Synchronize the state cache of this Backend with the actual real state of the GL Context // Synchronize the state cache of this Backend with the actual real state of the GL Context
void syncTransformStateCache(); void syncTransformStateCache();
void updateTransform() const; void updateTransform();
void resetTransformStage(); void resetTransformStage();
struct TransformStageState { struct TransformStageState {

View file

@ -180,10 +180,10 @@ void GLBackend::TransformStageState::update(size_t commandIndex, const StereoSta
(void)CHECK_GL_ERROR(); (void)CHECK_GL_ERROR();
} }
void GLBackend::updateTransform() const { void GLBackend::updateTransform() {
_transform.update(_commandIndex, _stereo); _transform.update(_commandIndex, _stereo);
auto& drawCallInfo = _drawCallInfos[_currentDraw]; auto& drawCallInfo = getDrawCallInfoBuffer()[_currentDraw];
glVertexAttribI2i(gpu::Stream::DRAW_CALL_INFO, drawCallInfo.index, drawCallInfo.unused); glVertexAttribI2i(gpu::Stream::DRAW_CALL_INFO, drawCallInfo.index, drawCallInfo.unused);
} }