Add locking around access to descriptor set references

* With VK_EXT_descriptor_indexing descriptor sets can be updated while a
  submission is going on, leading to potentially parallel access to the
  references.
This commit is contained in:
baldurk
2019-04-03 15:09:06 +01:00
parent 4ff4a7910e
commit 9e4a64e1eb
4 changed files with 13 additions and 0 deletions
+4
View File
@@ -831,6 +831,8 @@ bool IsValid(const VkWriteDescriptorSet &write, uint32_t arrayElement)
void DescriptorSetSlot::RemoveBindRefs(VkResourceRecord *record)
{
SCOPED_LOCK(record->descInfo->refLock);
if(texelBufferView != VK_NULL_HANDLE)
{
record->RemoveBindFrameRef(GetResID(texelBufferView));
@@ -874,6 +876,8 @@ void DescriptorSetSlot::RemoveBindRefs(VkResourceRecord *record)
void DescriptorSetSlot::AddBindRefs(VkResourceRecord *record, FrameRefType ref)
{
SCOPED_LOCK(record->descInfo->refLock);
if(texelBufferView != VK_NULL_HANDLE)
{
VkResourceRecord *bufView = GetRecord(texelBufferView);
+3
View File
@@ -957,6 +957,9 @@ struct DescriptorSetData
// create from the layout.
vector<DescriptorSetSlot *> descBindings;
// lock protecting bindFrameRefs and bindMemRefs
Threading::CriticalSection refLock;
// contains the framerefs (ref counted) for the bound resources
// in the binding slots. Updated when updating descriptor sets
// and then applied in a block on descriptor set bind.
@@ -956,6 +956,8 @@ void WrappedVulkan::vkUpdateDescriptorSets(VkDevice device, uint32_t writeCount,
VkResourceRecord *setrecord = GetRecord(pDescriptorCopies[i].srcSet);
SCOPED_LOCK(setrecord->descInfo->refLock);
for(auto refit = setrecord->descInfo->bindFrameRefs.begin();
refit != setrecord->descInfo->bindFrameRefs.end(); ++refit)
{
@@ -827,6 +827,8 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount,
{
VkResourceRecord *setrecord = GetRecord(*it);
SCOPED_LOCK(setrecord->descInfo->refLock);
const std::map<ResourceId, pair<uint32_t, FrameRefType>> &frameRefs =
setrecord->descInfo->bindFrameRefs;
@@ -865,6 +867,8 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount,
VkResourceRecord *setrecord = GetRecord(*it);
SCOPED_LOCK(setrecord->descInfo->refLock);
for(auto refit = setrecord->descInfo->bindFrameRefs.begin();
refit != setrecord->descInfo->bindFrameRefs.end(); ++refit)
{