Refactoring of streamer code to integrate texture and vbo memory management in progress.

This commit is contained in:
2014-05-29 00:14:18 -07:00
parent 5bd97ed47e
commit 5963ca5154
4 changed files with 13 additions and 39 deletions

View File

@@ -334,8 +334,8 @@ void KRContext::getMemoryStats(long &free_memory)
void KRContext::doStreaming() void KRContext::doStreaming()
{ {
if(m_streamingEnabled) { if(m_streamingEnabled) {
long memoryRemaining = KRENGINE_TARGET_TEXTURE_MEM_MAX + KRENGINE_MAX_VBO_MEM; long memoryRemaining = KRENGINE_TARGET_TEXTURE_MEM_MAX/* + KRENGINE_MAX_VBO_MEM*/;
long memoryRemainingThisFrame = KRENGINE_MAX_TEXTURE_MEM + KRENGINE_MAX_VBO_MEM - m_pTextureManager->getMemUsed() - m_pMeshManager->getMemUsed(); long memoryRemainingThisFrame = KRENGINE_MAX_TEXTURE_MEM/* + KRENGINE_MAX_VBO_MEM */ - m_pTextureManager->getMemUsed() - m_pMeshManager->getMemUsed();
m_pMeshManager->doStreaming(memoryRemaining, memoryRemainingThisFrame); m_pMeshManager->doStreaming(memoryRemaining, memoryRemainingThisFrame);
m_pTextureManager->doStreaming(memoryRemaining, memoryRemainingThisFrame); m_pTextureManager->doStreaming(memoryRemaining, memoryRemainingThisFrame);
} }

View File

@@ -153,39 +153,6 @@ void KRMeshManager::unbindVBO() {
} }
} }
/*
void KRMeshManager::releaseVBO(KRDataBlock &data)
{
if(m_currentVBO) {
if(m_currentVBO->m_data == &data) {
unbindVBO();
}
}
if(m_vbosActive.find(&data) != m_vbosActive.end()) {
KRContext::Log(KRContext::LOG_LEVEL_WARNING, "glFinish called due to releasing a VBO that is active in the current frame.");
GLDEBUG(glFinish());
// The VBO is active
KRVBOData *vbo_to_release = m_vbosActive[&data];
m_vbosActive.erase(&data);
m_vboMemUsed -= vbo_to_release->getSize();
switch(vbo_to_release->getType()) {
case KRVBOData::STREAMING:
vbo_to_release->unload();
break;
case KRVBOData::TEMPORARY:
delete vbo_to_release;
break;
case KRVBOData::CONSTANT:
// CONSTANT VBO's are not unloaded
break;
}
}
}
*/
void KRMeshManager::bindVBO(KRVBOData *vbo_data, float lodCoverage) void KRMeshManager::bindVBO(KRVBOData *vbo_data, float lodCoverage)
{ {
vbo_data->resetPoolExpiry(lodCoverage); vbo_data->resetPoolExpiry(lodCoverage);
@@ -239,7 +206,7 @@ void KRMeshManager::startFrame(float deltaTime)
if(m_streamerComplete) { if(m_streamerComplete) {
assert(m_activeVBOs_streamer_copy.size() == 0); // The streamer should have emptied this if it really did complete assert(m_activeVBOs_streamer_copy.size() == 0); // The streamer should have emptied this if it really did complete
const long KRENGINE_VBO_EXPIRY_FRAMES = 30; const long KRENGINE_VBO_EXPIRY_FRAMES = 3;
std::set<KRVBOData *> expiredVBOs; std::set<KRVBOData *> expiredVBOs;
for(auto itr=m_vbosActive.begin(); itr != m_vbosActive.end(); itr++) { for(auto itr=m_vbosActive.begin(); itr != m_vbosActive.end(); itr++) {

View File

@@ -149,7 +149,7 @@ void KRModel::loadModel() {
void KRModel::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass) { void KRModel::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass) {
if(m_lod_visible == LOD_VISIBILITY_PRESTREAM && renderPass == KRNode::RENDER_PASS_PRESTREAM) { if(m_lod_visible >= LOD_VISIBILITY_PRESTREAM && renderPass == KRNode::RENDER_PASS_PRESTREAM) {
preStream(viewport); preStream(viewport);
} }

View File

@@ -213,8 +213,15 @@ void KRScene::render(KROctreeNode *pOctreeNode, unordered_map<KRAABB, int> &visi
pOctreeNode->m_occlusionQuery = 0; pOctreeNode->m_occlusionQuery = 0;
} }
} else { } else {
bool in_viewport = false;
if(viewport.visible(pOctreeNode->getBounds())) { if(renderPass == KRNode::RENDER_PASS_PRESTREAM) {
// When pre-streaming, objects are streamed in behind and in-front of the camera
KRAABB viewportExtents = KRAABB(viewport.getCameraPosition() - KRVector3(pCamera->settings.getPerspectiveFarZ()), viewport.getCameraPosition() + KRVector3(pCamera->settings.getPerspectiveFarZ()));
in_viewport = octreeBounds.intersects(viewportExtents);
} else {
in_viewport = viewport.visible(pOctreeNode->getBounds());
}
if(in_viewport) {
// ----====---- Rendering and occlusion test pass ----====---- // ----====---- Rendering and occlusion test pass ----====----
bool bVisible = false; bool bVisible = false;