Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Multi GPU Rendering Mode #177

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add skipping non-actual data
that would be sent from a worker device
  • Loading branch information
AlexanderVeselov committed Jul 17, 2018
commit 33f67522b079afa57768a008f0497810f00b12b7
23 changes: 14 additions & 9 deletions BaikalStandalone/Application/cl_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ namespace Baikal
m_ctrl[i].stop.store(0);
m_ctrl[i].newdata.store(0);
m_ctrl[i].idx = static_cast<int>(i);
m_ctrl[i].scene_state = 0;
}

if (force_disable_itnerop)
Expand Down Expand Up @@ -234,13 +235,13 @@ namespace Baikal

void AppClRender::UpdateScene()
{

for (std::size_t i = 0; i < m_cfgs.size(); ++i)
{
if (i == static_cast<std::size_t>(m_primary))
{
m_cfgs[i].controller->CompileScene(m_scene);
m_cfgs[i].renderer->Clear(float3(0, 0, 0), *m_outputs[i].output);
m_cfgs[i].controller->CompileScene(m_scene);
++m_ctrl[i].scene_state;

#ifdef ENABLE_DENOISER
ClearDenoiserOutputs(i);
Expand All @@ -254,8 +255,6 @@ namespace Baikal

void AppClRender::Update(AppSettings& settings)
{
//if (std::chrono::duration_cast<std::chrono::seconds>(time - updatetime).count() > 1)
//{
for (std::size_t i = 0; i < m_cfgs.size(); ++i)
{
if (m_cfgs[i].type == ConfigManager::kPrimary)
Expand All @@ -264,6 +263,12 @@ namespace Baikal
int desired = 1;
if (std::atomic_compare_exchange_strong(&m_ctrl[i].newdata, &desired, 0))
{
if (m_ctrl[i].scene_state != m_ctrl[m_primary].scene_state)
{
// Skip update if worker has sent us non-actual data
continue;
}

{
m_cfgs[m_primary].context.WriteBuffer(0, m_outputs[m_primary].copybuffer, &m_outputs[i].fdata[0], settings.width * settings.height);
}
Expand All @@ -280,9 +285,6 @@ namespace Baikal
}
}

//updatetime = time;
//}

if (!settings.interop)
{
#ifdef ENABLE_DENOISER
Expand Down Expand Up @@ -344,7 +346,6 @@ namespace Baikal
settings.rt_benchmarked = true;
}

//ClwClass::Update();
}

void AppClRender::Render(int sample_cnt)
Expand All @@ -357,6 +358,7 @@ namespace Baikal
wavelet_denoiser->Update(static_cast<PerspectiveCamera*>(m_camera.get()));
}
#endif

auto& scene = m_cfgs[m_primary].controller->GetCachedScene(m_scene);
m_cfgs[m_primary].renderer->Render(scene);

Expand Down Expand Up @@ -479,15 +481,17 @@ namespace Baikal

auto updatetime = std::chrono::high_resolution_clock::now();

std::uint32_t scene_state = 0;

while (!cd.stop.load())
{
int result = 1;
bool update = false;

if (std::atomic_compare_exchange_strong(&cd.clear, &result, 0))
{
renderer->Clear(float3(0, 0, 0), *output);
controller->CompileScene(m_scene);
scene_state = m_ctrl[m_primary].scene_state;
update = true;
}

Expand All @@ -502,6 +506,7 @@ namespace Baikal
{
m_outputs[cd.idx].output->GetData(&m_outputs[cd.idx].fdata[0]);
updatetime = now;
m_ctrl[cd.idx].scene_state = scene_state;
cd.newdata.store(1);
}

Expand Down
1 change: 1 addition & 0 deletions BaikalStandalone/Application/cl_render.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ namespace Baikal
std::atomic<int> newdata;
std::mutex datamutex;
int idx;
std::uint32_t scene_state;
};

public:
Expand Down