minor reorganizing of the command loop

This commit is contained in:
Mathias Agopian
2018-11-21 13:46:07 -08:00
committed by Mathias Agopian
parent 454c102e3c
commit 9bb87b8725
+12 -14
View File
@@ -122,7 +122,7 @@ void RenderPass::recordDriverCommands(
if (!commands.empty()) {
Driver::PipelineState pipeline;
Handle<HwUniformBuffer> uboHandle = scene.getRenderableUBO();
FMaterialInstance const* UTILS_RESTRICT previousMi = nullptr;
FMaterialInstance const* UTILS_RESTRICT mi = nullptr;
FMaterial const* UTILS_RESTRICT ma = nullptr;
Command const* UTILS_RESTRICT c;
for (c = commands.cbegin(); c->key != -1LLU; ++c) {
@@ -131,24 +131,22 @@ void RenderPass::recordDriverCommands(
*/
// per-renderable uniform
PrimitiveInfo const& UTILS_RESTRICT info = c->primitive;
size_t offset = info.index * sizeof(PerRenderableUib);
driver.bindUniformBufferRange(BindingPoints::PER_RENDERABLE, uboHandle, offset, sizeof(PerRenderableUib));
if (info.perRenderableBones) {
driver.bindUniformBuffer(BindingPoints::PER_RENDERABLE_BONES, info.perRenderableBones);
}
FMaterialInstance const* const UTILS_RESTRICT mi = info.mi;
if (UTILS_UNLIKELY(mi != previousMi)) {
const PrimitiveInfo info = c->primitive;
pipeline.rasterState = info.rasterState;
if (UTILS_UNLIKELY(mi != info.mi)) {
// this is always taken the first time
previousMi = mi;
mi->use(driver);
mi = info.mi;
pipeline.polygonOffset = mi->getPolygonOffset();
ma = mi->getMaterial();
mi->use(driver);
}
pipeline.program = ma->getProgram(info.materialVariant.key);
pipeline.rasterState = info.rasterState;
pipeline.polygonOffset = mi->getPolygonOffset();
size_t offset = info.index * sizeof(PerRenderableUib);
if (info.perRenderableBones) {
driver.bindUniformBuffer(BindingPoints::PER_RENDERABLE_BONES, info.perRenderableBones);
}
driver.bindUniformBufferRange(BindingPoints::PER_RENDERABLE, uboHandle, offset, sizeof(PerRenderableUib));
driver.draw(pipeline, info.primitiveHandle);
}