DescriptorSet - debugging a validation error #949
-
I have a DescriptorSet that contains several DescriptorImages. I create this and then compile it in a background thread, as in the vsgdynamicload example. I am getting a validation error during viewer->compileManager->compile():
I discovered that the DescriptorSet I just created already had a set of descriptors in it's Implementation object, and is un-referencing and deleting those old instances during compilation (in Was my DescriptorSet recycled from a descriptor pool, preserving the old Implementation object and its Descriptor references? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
Without reviewing the code and what is happening in various threads it's not possible to suggest exactly is wrong and what to do about it. Broadly speaking, from the Vulkan debug error it would look like the DescriptorSet is still being used by another thread other than the one you are doing the compile from, so it's really not ready to be reused. It's possible to have several frames worth of command bufffers recorded and submitted to a Vulkan queue and awaiting execution on the GPU, if you are reusing the DescriptorSet while the Vulkan objects associated with them are being actively referenced by a command buffer then this will cause this error. The solution for this type of issue would be delaying reuse until the Descriptor and associated Descriptors have all completed rendering. |
Beta Was this translation helpful? Give feedback.
-
I encountered this sort of thing in vsgCs. The reference counting mechanism isn't quite sufficient to protect against recycling of resources that are still being used. When a tile is deleted in vsgCs, it is put on a list of objects to be deleted "several" frames later. |
Beta Was this translation helpful? Give feedback.
-
@robertosfield gave the answer about the number of frames necessary needed to hold the objects before their resuse. I don't understand your concern about the compiler and this issue; the objects are still deleted and returned to VSG via the ref_ptr refcount mechanism, which is atomic. |
Beta Was this translation helpful? Give feedback.
-
While I haven't spent the time on the design side, I think something as simple as a circular buffer to cache objects that are to be deleted. Psuedo code class DeleteManager
{
std::vector<vsg::ref_ptr<vsg::Objects>> deleteCache;
size_t currentFrame = 0;
DeleteManager(size_t numFramesToCache)
{
for(size_t i=0; i < cnumFramesToCache; ++i) cache.push_back(Objets::create());
}
void advance()
{
currentFrame = (currentFrame+1) % (cache.size());
cache[currentFrame]->clear();
}
void sheduleDelete(ref_ptr<vsg::Object> objectToDelete)
{
cache[currentFrame]->addChild(object);
}
}; Something like this might be added to vsg::Viewer like the CompileManager has been. One would also want to make sure it's thread safe, and potentially you could move the actual delete to a dedicated delete thread. |
Beta Was this translation helpful? Give feedback.
Without reviewing the code and what is happening in various threads it's not possible to suggest exactly is wrong and what to do about it.
Broadly speaking, from the Vulkan debug error it would look like the DescriptorSet is still being used by another thread other than the one you are doing the compile from, so it's really not ready to be reused. It's possible to have several frames worth of command bufffers recorded and submitted to a Vulkan queue and awaiting execution on the GPU, if you are reusing the DescriptorSet while the Vulkan objects associated with them are being actively referenced by a command buffer then this will cause this error.
The solution for this type of issue would …