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:
- bufferInfo0 compiled, Buffer object created and assigned
- bufferInfo1 not compiled, Buffer object is null
|
task->earlyTransferTask->assign(resourceRequirements.earlyDynamicData); |
Dynamic data info is passed to earlyTranfserTask:
|
_dynamicDataMap[bufferInfo->buffer][bufferInfo->offset] = bufferInfo; |
_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):
Describe the bug
When using multiple command graphs with separate recordAndSubmitTasks
_dynamicDataMapin 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 thecollectResourcespasses 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).
VulkanSceneGraph/src/vsg/app/Viewer.cpp
Lines 233 to 245 in c169dbe
We have all the dynamic bufferInfos in collectResources.
VulkanSceneGraph/src/vsg/app/Viewer.cpp
Lines 300 to 313 in c169dbe
Processing the first recordAndSubmitTask:
VulkanSceneGraph/src/vsg/app/Viewer.cpp
Line 327 in c169dbe
Dynamic data info is passed to earlyTranfserTask:
VulkanSceneGraph/src/vsg/app/TransferTask.cpp
Line 87 in c169dbe
_dynamicDataMapfrom the first recordAndSubmitTask contains as keys: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):