Skip to content
Snippets Groups Projects
Commit 83000d94 authored by Christian Mattes's avatar Christian Mattes
Browse files

TiledDisplay: skip transferring to host if all displays are on the rendering device

parent 0eb38a39
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,8 @@
#include <lava/objects/Device.hh>
#include <lava/objects/Image.hh>
#include <lava/objects/MemoryChunk.hh>
#include <thread>
#include <iostream>
namespace lava {
......@@ -52,8 +54,13 @@ void TiledDisplay::submit(const SharedImage &image) {
throw std::logic_error(
"For now you should present to the original device, too");
// if true, we can skip transferring to other devices
bool all_master = std::all_of(begin(mConfig.tiles), end(mConfig.tiles),
[&](TileConfig const& cfg) { return cfg.device == master_idx; });
// Step 1 - GPUs-Side: Work with mHostImages[gpu_side]
if (!all_master) {
{ // Step 1.1 transfer master image to Host
auto cmd = mDevices[master_idx]->graphicsQueue().beginCommandBuffer();
mHostImages[master_idx][gpu_side]->copyFrom(image, cmd);
......@@ -70,6 +77,8 @@ void TiledDisplay::submit(const SharedImage &image) {
vk::ImageLayout::eTransferSrcOptimal);
}
}
}
// Step 1.3 blit and present host images
for (size_t i = 0; i < mConfig.tiles.size(); i++) {
auto const &tile = mConfig.tiles[i];
......@@ -110,6 +119,9 @@ void TiledDisplay::submit(const SharedImage &image) {
vk::ImageLayout::ePresentSrcKHR, cmd);
}
}
auto cpu_side = (gpu_side + 1) % 2;
if (!all_master) {
{ // Step 1.4 change (non-master) hostImages layout back to general
for (size_t i = 0; i < mDevices.size(); i++) {
if (i == master_idx)
......@@ -123,7 +135,6 @@ void TiledDisplay::submit(const SharedImage &image) {
mDevices[i]->graphicsQueue().catchUp(1);
// Step 2: Exchange Data between hostImages
auto cpu_side = (gpu_side + 1) % 2;
{
auto master_map =
mHostImages[master_idx][cpu_side]->memoryChunk()->map();
......@@ -136,7 +147,7 @@ void TiledDisplay::submit(const SharedImage &image) {
mHostImages[master_idx][0]->levelBytes(0));
}
}
}
gpu_side = cpu_side;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment