mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-13 05:20:45 +00:00
Add ComposeFrameRefsDisjoint
Previously, the ref type of the a VkDeviceMemory or VkImage resource was calculated as the max of the ref types of the subresources. This reliance on the ordering of the `FrameRefType` enum values is fragile-- in particular, this makes it more difficult to add new `FrameRefType` alternatives. Now, the ref type of composite resources are calculated using `ComposeFrameRefsDisjoint` instead of `max`. Change-Id: Id5db68b6756555cdc6b068d28f1b72cb827f3d1e
This commit is contained in:
committed by
Baldur Karlsson
parent
c2db43aff5
commit
7edd6c0ab5
@@ -117,12 +117,6 @@ FrameRefType ComposeFrameRefsUnordered(FrameRefType first, FrameRefType second)
|
||||
RDCASSERT(eFrameRef_Minimum <= first && first <= eFrameRef_Maximum);
|
||||
RDCASSERT(eFrameRef_Minimum <= second && second <= eFrameRef_Maximum);
|
||||
|
||||
// The order of the reference types is irrelevant, so put them in a
|
||||
// consistent order (`first >= second`) to reduce the number of cases to
|
||||
// consider.
|
||||
if(first < second)
|
||||
std::swap(first, second);
|
||||
|
||||
if(first == eFrameRef_Read &&
|
||||
(second == eFrameRef_PartialWrite || second == eFrameRef_CompleteWrite))
|
||||
// The resource is referenced both read and write/clear;
|
||||
@@ -141,6 +135,11 @@ FrameRefType ComposeFrameRefsUnordered(FrameRefType first, FrameRefType second)
|
||||
return first;
|
||||
}
|
||||
|
||||
FrameRefType ComposeFrameRefsDisjoint(FrameRefType x, FrameRefType y)
|
||||
{
|
||||
return RDCMAX(x, y);
|
||||
}
|
||||
|
||||
bool IsDirtyFrameRef(FrameRefType refType)
|
||||
{
|
||||
return (refType != eFrameRef_None && refType != eFrameRef_Read);
|
||||
|
||||
@@ -111,6 +111,11 @@ FrameRefType ComposeFrameRefs(FrameRefType first, FrameRefType second);
|
||||
// reset for replay.
|
||||
FrameRefType ComposeFrameRefsUnordered(FrameRefType first, FrameRefType second);
|
||||
|
||||
// Compose frame refs for disjoint subresources.
|
||||
// This is used to compute the overall frame ref for images/memory from the
|
||||
// frame refs of their subresources.
|
||||
FrameRefType ComposeFrameRefsDisjoint(FrameRefType x, FrameRefType y);
|
||||
|
||||
bool IsDirtyFrameRef(FrameRefType refType);
|
||||
|
||||
// Captures the possible initialization/reset requirements for resources.
|
||||
|
||||
@@ -781,8 +781,7 @@ void VulkanResourceManager::MarkImageFrameReferenced(ResourceId img, const Image
|
||||
const ImageRange &range, FrameRefType refType)
|
||||
{
|
||||
FrameRefType maxRef = MarkImageReferenced(m_ImgFrameRefs, img, imageInfo, range, refType);
|
||||
MarkResourceFrameReferenced(
|
||||
img, maxRef, [](FrameRefType x, FrameRefType y) -> FrameRefType { return std::max(x, y); });
|
||||
MarkResourceFrameReferenced(img, maxRef, ComposeFrameRefsDisjoint);
|
||||
}
|
||||
|
||||
void VulkanResourceManager::MarkMemoryFrameReferenced(ResourceId mem, VkDeviceSize offset,
|
||||
@@ -791,8 +790,7 @@ void VulkanResourceManager::MarkMemoryFrameReferenced(ResourceId mem, VkDeviceSi
|
||||
SCOPED_LOCK(m_Lock);
|
||||
|
||||
FrameRefType maxRef = MarkMemoryReferenced(m_MemFrameRefs, mem, offset, size, refType);
|
||||
MarkResourceFrameReferenced(
|
||||
mem, maxRef, [](FrameRefType x, FrameRefType y) -> FrameRefType { return std::max(x, y); });
|
||||
MarkResourceFrameReferenced(mem, maxRef, ComposeFrameRefsDisjoint);
|
||||
}
|
||||
|
||||
void VulkanResourceManager::MergeReferencedImages(std::map<ResourceId, ImgRefs> &imgRefs)
|
||||
|
||||
@@ -3114,8 +3114,7 @@ void VkResourceRecord::MarkImageFrameReferenced(VkResourceRecord *img, const Ima
|
||||
|
||||
// maintain the reference type of the image itself as the maximum reference type of any
|
||||
// subresource
|
||||
MarkResourceFrameReferenced(
|
||||
id, maxRef, [](FrameRefType x, FrameRefType y) -> FrameRefType { return std::max(x, y); });
|
||||
MarkResourceFrameReferenced(id, maxRef, ComposeFrameRefsDisjoint);
|
||||
}
|
||||
|
||||
void VkResourceRecord::MarkImageViewFrameReferenced(VkResourceRecord *view, const ImageRange &range,
|
||||
@@ -3148,8 +3147,7 @@ void VkResourceRecord::MarkImageViewFrameReferenced(VkResourceRecord *view, cons
|
||||
|
||||
// maintain the reference type of the image itself as the maximum reference type of any
|
||||
// subresource
|
||||
MarkResourceFrameReferenced(
|
||||
img, maxRef, [](FrameRefType x, FrameRefType y) -> FrameRefType { return std::max(x, y); });
|
||||
MarkResourceFrameReferenced(img, maxRef, ComposeFrameRefsDisjoint);
|
||||
}
|
||||
|
||||
void VkResourceRecord::MarkMemoryFrameReferenced(ResourceId mem, VkDeviceSize offset,
|
||||
@@ -3158,8 +3156,7 @@ void VkResourceRecord::MarkMemoryFrameReferenced(ResourceId mem, VkDeviceSize of
|
||||
if(refType != eFrameRef_Read && refType != eFrameRef_None)
|
||||
cmdInfo->dirtied.insert(mem);
|
||||
FrameRefType maxRef = MarkMemoryReferenced(cmdInfo->memFrameRefs, mem, offset, size, refType);
|
||||
MarkResourceFrameReferenced(
|
||||
mem, maxRef, [](FrameRefType x, FrameRefType y) -> FrameRefType { return std::max(x, y); });
|
||||
MarkResourceFrameReferenced(mem, maxRef, ComposeFrameRefsDisjoint);
|
||||
}
|
||||
|
||||
void VkResourceRecord::MarkBufferFrameReferenced(VkResourceRecord *buf, VkDeviceSize offset,
|
||||
|
||||
@@ -1281,7 +1281,7 @@ FrameRefType ImgRefs::Update(ImageRange range, FrameRefType refType, Compose com
|
||||
{
|
||||
int index = (aspectIndex * splitLevelCount + level) * splitLayerCount + layer;
|
||||
rangeRefs[index] = comp(rangeRefs[index], refType);
|
||||
maxRefType = RDCMAX(maxRefType, rangeRefs[index]);
|
||||
maxRefType = ComposeFrameRefsDisjoint(maxRefType, rangeRefs[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1310,7 +1310,7 @@ FrameRefType ImgRefs::Merge(const ImgRefs &other, Compose comp)
|
||||
{
|
||||
int index = SubresourceIndex(aspectIndex, level, layer);
|
||||
rangeRefs[index] = comp(rangeRefs[index], other.SubresourceRef(aspectIndex, level, layer));
|
||||
maxRefType = RDCMAX(maxRefType, rangeRefs[index]);
|
||||
maxRefType = ComposeFrameRefsDisjoint(maxRefType, rangeRefs[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1346,7 +1346,7 @@ FrameRefType MemRefs::Update(VkDeviceSize offset, VkDeviceSize size, FrameRefTyp
|
||||
rangeRefs.update(offset, offset + size, refType,
|
||||
[&maxRefType, comp](FrameRefType oldRef, FrameRefType newRef) -> FrameRefType {
|
||||
FrameRefType ref = comp(oldRef, newRef);
|
||||
maxRefType = std::max(maxRefType, ref);
|
||||
maxRefType = ComposeFrameRefsDisjoint(maxRefType, ref);
|
||||
return ref;
|
||||
});
|
||||
return maxRefType;
|
||||
@@ -1359,7 +1359,7 @@ FrameRefType MemRefs::Merge(MemRefs &other, Compose comp)
|
||||
rangeRefs.merge(other.rangeRefs,
|
||||
[&maxRefType, comp](FrameRefType oldRef, FrameRefType newRef) -> FrameRefType {
|
||||
FrameRefType ref = comp(oldRef, newRef);
|
||||
maxRefType = std::max(maxRefType, ref);
|
||||
maxRefType = ComposeFrameRefsDisjoint(maxRefType, ref);
|
||||
return ref;
|
||||
});
|
||||
return maxRefType;
|
||||
@@ -1494,7 +1494,7 @@ public:
|
||||
FrameRefType maxRef = MarkImageReferenced(descInfo->bindImgRefs, view->baseResource,
|
||||
view->resInfo->imageInfo, imgRange, refType);
|
||||
|
||||
p.second = std::max(p.second, maxRef);
|
||||
p.second = ComposeFrameRefsDisjoint(p.second, maxRef);
|
||||
}
|
||||
|
||||
void AddMemFrameRef(ResourceId mem, VkDeviceSize offset, VkDeviceSize size, FrameRefType refType)
|
||||
@@ -1517,7 +1517,7 @@ public:
|
||||
}
|
||||
FrameRefType maxRef = MarkMemoryReferenced(descInfo->bindMemRefs, mem, offset, size, refType,
|
||||
ComposeFrameRefsUnordered);
|
||||
p.second = std::max(p.second, maxRef);
|
||||
p.second = ComposeFrameRefsDisjoint(p.second, maxRef);
|
||||
}
|
||||
|
||||
void RemoveBindFrameRef(ResourceId id)
|
||||
|
||||
Reference in New Issue
Block a user