Skip to content

Commit

Permalink
optimize displacement bind/clear/render
Browse files Browse the repository at this point in the history
Stop thrashing render targets, and group things together into single
render-passes.  And only bind/clear if we will actually draw.
  • Loading branch information
robclark committed Aug 18, 2015
1 parent eaae950 commit 2ae4b1e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/graphics/render_geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1561,11 +1561,6 @@ void IrrDriver::renderTransparent()
return;

// Render displacement nodes
irr_driver->getFBO(FBO_TMP1_WITH_DS).bind();
glClear(GL_COLOR_BUFFER_BIT);
irr_driver->getFBO(FBO_DISPLACE).bind();
glClear(GL_COLOR_BUFFER_BIT);

DisplaceProvider * const cb =
(DisplaceProvider *)Shaders::getCallback(ES_DISPLACE);
cb->update();
Expand All @@ -1582,7 +1577,11 @@ void IrrDriver::renderTransparent()
glBindVertexArray(VAOManager::getInstance()->getVAO(video::EVT_2TCOORDS));
// Generate displace mask
// Use RTT_TMP4 as displace mask
irr_driver->getFBO(FBO_TMP1_WITH_DS).bind();
if (ListDisplacement::getInstance()->size() > 0)
{
irr_driver->getFBO(FBO_TMP1_WITH_DS).bind();
glClear(GL_COLOR_BUFFER_BIT);
}
for (unsigned i = 0; i < ListDisplacement::getInstance()->size(); i++)
{
const GLMesh &mesh =
Expand All @@ -1609,7 +1608,11 @@ void IrrDriver::renderTransparent()
(GLvoid *)mesh.vaoOffset, (int)mesh.vaoBaseVertex);
}

irr_driver->getFBO(FBO_DISPLACE).bind();
if (ListDisplacement::getInstance()->size() > 0)
{
irr_driver->getFBO(FBO_DISPLACE).bind();
glClear(GL_COLOR_BUFFER_BIT);
}
if (!displaceTex)
displaceTex = irr_driver->getTexture(FileManager::TEXTURE, "displace.png");
for (unsigned i = 0; i < ListDisplacement::getInstance()->size(); i++)
Expand Down

0 comments on commit 2ae4b1e

Please sign in to comment.