mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-27 04:11:05 +00:00
Change descriptor set lock to spinlock
* We don't expect contention on this, the only time it will contend is when actively capturing a frame between updates and submits reading the descriptor contents, so we penalise that case while making the background case faster - since a spinlock is 'free' to take when there's no contention.
This commit is contained in:
@@ -119,4 +119,4 @@ private:
|
||||
#define SCOPED_READLOCK(rw) Threading::ScopedReadLock CONCAT(scopedlock, __LINE__)(rw);
|
||||
#define SCOPED_WRITELOCK(rw) Threading::ScopedWriteLock CONCAT(scopedlock, __LINE__)(rw);
|
||||
|
||||
#define SCOPED_SPINLOCK(cs) Threading::SpinLock CONCAT(scopedlock, __LINE__)(cs);
|
||||
#define SCOPED_SPINLOCK(cs) Threading::ScopedSpinLock CONCAT(scopedlock, __LINE__)(cs);
|
||||
|
||||
@@ -1060,7 +1060,7 @@ void DescriptorSetSlotImageInfo::SetFrom(const VkDescriptorImageInfo &imInfo, bo
|
||||
void DescriptorSetSlot::RemoveBindRefs(std::set<ResourceId> &ids, VulkanResourceManager *rm,
|
||||
VkResourceRecord *record)
|
||||
{
|
||||
SCOPED_LOCK(record->descInfo->refLock);
|
||||
SCOPED_SPINLOCK(record->descInfo->refLock);
|
||||
|
||||
if(texelBufferView != ResourceId())
|
||||
{
|
||||
@@ -1109,7 +1109,7 @@ void DescriptorSetSlot::AddBindRefs(std::set<ResourceId> &ids, VkResourceRecord
|
||||
VkResourceRecord *imgView, VkResourceRecord *buffer,
|
||||
VkResourceRecord *descSetRecord, FrameRefType ref)
|
||||
{
|
||||
SCOPED_LOCK(descSetRecord->descInfo->refLock);
|
||||
SCOPED_SPINLOCK(descSetRecord->descInfo->refLock);
|
||||
|
||||
if(bufView)
|
||||
{
|
||||
@@ -1157,7 +1157,7 @@ void DescriptorSetSlot::AddBindRefs(std::set<ResourceId> &ids, VulkanResourceMan
|
||||
void DescriptorSetData::UpdateBackgroundRefCache(VulkanResourceManager *resourceManager,
|
||||
const std::set<ResourceId> &ids)
|
||||
{
|
||||
SCOPED_LOCK(refLock);
|
||||
SCOPED_SPINLOCK(refLock);
|
||||
|
||||
rdcpair<ResourceId, FrameRefType> *cacheit = backgroundFrameRefs.begin();
|
||||
for(auto refit = ids.begin(); refit != ids.end(); ++refit)
|
||||
|
||||
@@ -1055,7 +1055,7 @@ struct DescriptorSetData
|
||||
BindingStorage data;
|
||||
|
||||
// lock protecting bindFrameRefs and bindMemRefs
|
||||
Threading::CriticalSection refLock;
|
||||
Threading::SpinLock refLock;
|
||||
|
||||
// contains the framerefs (ref counted) for the bound resources
|
||||
// in the binding slots. Updated when updating descriptor sets
|
||||
|
||||
@@ -1125,7 +1125,7 @@ void WrappedVulkan::vkUpdateDescriptorSets(VkDevice device, uint32_t writeCount,
|
||||
|
||||
VkResourceRecord *setrecord = GetRecord(pDescriptorCopies[i].srcSet);
|
||||
|
||||
SCOPED_LOCK(setrecord->descInfo->refLock);
|
||||
SCOPED_SPINLOCK(setrecord->descInfo->refLock);
|
||||
|
||||
for(auto refit = setrecord->descInfo->bindFrameRefs.begin();
|
||||
refit != setrecord->descInfo->bindFrameRefs.end(); ++refit)
|
||||
|
||||
@@ -875,7 +875,7 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount,
|
||||
|
||||
VkResourceRecord *setrecord = GetRecord(*it);
|
||||
|
||||
SCOPED_LOCK(setrecord->descInfo->refLock);
|
||||
SCOPED_SPINLOCK(setrecord->descInfo->refLock);
|
||||
|
||||
for(auto refit = setrecord->descInfo->bindFrameRefs.begin();
|
||||
refit != setrecord->descInfo->bindFrameRefs.end(); ++refit)
|
||||
@@ -963,7 +963,7 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount,
|
||||
{
|
||||
VkResourceRecord *setrecord = GetRecord(*it);
|
||||
|
||||
SCOPED_LOCK(setrecord->descInfo->refLock);
|
||||
SCOPED_SPINLOCK(setrecord->descInfo->refLock);
|
||||
|
||||
GetResourceManager()->MarkBackgroundFrameReferenced(
|
||||
setrecord->descInfo->backgroundFrameRefs);
|
||||
|
||||
Reference in New Issue
Block a user