Skip to content

Segfault on dynamic data update #764

@asafran

Description

@asafran

Describe the bug
When using multiple command graphs with separate recordAndSubmitTasks _dynamicDataMap in a transfer task can be filled with uninitialized data from another command graph. This happens because the TransferTasks is initialized for each recordAndSubmitTask separately, but the collectResources passes for all recordAndSubmitTasks collecting dynamic buffers, so TransferTasks get dynamic buffers that may not be used in any commandGraphs from associated recordAndSubmitTask. Since initialization occurs sequentially, some buffers from other recordAndSubmitTasks pass in TransferTask may be uninitialized.

Example:
Let's say we have bufferInfo0 and bufferInfo1, both contain dynamic data, are located in separate recordAndSubmitTasks and are not compiled (no VkBuffer assigned).

using DeviceResourceMap = std::map<ref_ptr<vsg::Device>, DeviceResources>;
DeviceResourceMap deviceResourceMap;
for (auto& task : recordAndSubmitTasks)
{
auto& collectResources = deviceResourceMap[task->device].collectResources;
for (auto& commandGraph : task->commandGraphs)
{
commandGraph->accept(collectResources);
}
if (task->databasePager && !databasePager) databasePager = task->databasePager;
}

We have all the dynamic bufferInfos in collectResources.

for (auto& task : recordAndSubmitTasks)
{
auto& deviceResource = deviceResourceMap[task->device];
auto& resourceRequirements = deviceResource.collectResources.requirements;
bool task_containsPagedLOD = false;
for (auto& commandGraph : task->commandGraphs)
{
commandGraph->maxSlot = resourceRequirements.maxSlot;
commandGraph->accept(*deviceResource.compile);
if (resourceRequirements.containsPagedLOD) task_containsPagedLOD = true;
}

Processing the first recordAndSubmitTask:

_dynamicDataMap from the first recordAndSubmitTask contains as keys:

  • compiled Buffer object from bufferInfo0
  • null Buffer object from bufferInfo1

We should collect and compile dynamic buffers for each task separately to avoid null Buffer objects in _dynamicDataMap.

To Reproduce
Assign the viewer several recordAndSubmitTasks, each of which contains dynamic data in.

Desktop (please complete the following information):

  • OS: Fedora 37
  • VSG-v1.0.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions