History

Merge pull request #5885 from ZappoMan/batchOptimizations

Batch optimizations

samcake committed 11 years ago

Commit 46e9c462 parents 5a80c4d 432dc2014 files · +723 −687Browse files

Showing the changes to interface/src/Application.cpp (1 of 14 files). Show all

Unified · Split

interface/src/Application.cpp+10−17
@@ -1035,13 +1035,6 @@ void Application::initializeUi() { · 1034 unmodified lines
10351035 updateInputModes();
10361036 }
10371037
1038−template<typename F>
1039−void doInBatch(RenderArgs* args, F f) {
1040− gpu::Batch batch;
1041− f(batch);
1042− args->_context->render(batch);
1043−}
1044−
10451038 void Application::paintGL() {
10461039 PROFILE_RANGE(__FUNCTION__);
10471040 if (nullptr == _displayPlugin) {
@@ -1095,12 +1088,12 @@ void Application::paintGL() { · 47 unmodified lines
10951088 auto mirrorRectDest = glm::ivec4(mirrorRect.z, mirrorRect.y, mirrorRect.x, mirrorRect.w);
10961089
10971090 auto selfieFbo = DependencyManager::get<FramebufferCache>()->getSelfieFramebuffer();
1098− gpu::Batch batch;
1099− batch.setFramebuffer(selfieFbo);
1100− batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f));
1101− batch.blit(primaryFbo, mirrorRect, selfieFbo, mirrorRectDest);
1102− batch.setFramebuffer(nullptr);
1103− renderArgs._context->render(batch);
1091+ doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
1092+ batch.setFramebuffer(selfieFbo);
1093+ batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f));
1094+ batch.blit(primaryFbo, mirrorRect, selfieFbo, mirrorRectDest);
1095+ batch.setFramebuffer(nullptr);
1096+ });
11041097 }
11051098 }
11061099
@@ -1224,7 +1217,7 @@ void Application::paintGL() { · 117 unmodified lines
12241217 }
12251218 displaySide(&renderArgs, _myCamera);
12261219 renderArgs._context->enableStereo(false);
1227− doInBatch(&renderArgs, [](gpu::Batch& batch) {
1220+ doInBatch(renderArgs._context, [](gpu::Batch& batch) {
12281221 batch.setFramebuffer(nullptr);
12291222 });
12301223 }
@@ -1288,9 +1281,9 @@ void Application::paintGL() { · 57 unmodified lines
12881281
12891282 // Reset the gpu::Context Stages
12901283 // Back to the default framebuffer;
1291− gpu::Batch batch;
1292− batch.resetStages();
1293− renderArgs._context->render(batch);
1284+ doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
1285+ batch.resetStages();
1286+ });
12941287 }
12951288
12961289 void Application::runTests() {