|
|
|
@@ -30,9 +30,9 @@ void Serialiser::Serialise(const char *name, ImageRegionState &el)
|
|
|
|
|
{
|
|
|
|
|
ScopedContext scope(this, name, "ImageRegionState", 0, true);
|
|
|
|
|
|
|
|
|
|
Serialise("range", el.range);
|
|
|
|
|
Serialise("prevstate", el.prevstate);
|
|
|
|
|
Serialise("state", el.state);
|
|
|
|
|
Serialise("range", el.subresourceRange);
|
|
|
|
|
Serialise("prevstate", el.oldLayout);
|
|
|
|
|
Serialise("state", el.newLayout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VulkanResourceManager::SerialisableResource(ResourceId id, VkResourceRecord *record)
|
|
|
|
@@ -79,24 +79,24 @@ void VulkanResourceManager::RecordTransitions(vector< pair<ResourceId, ImageRegi
|
|
|
|
|
if(it->first < id) continue;
|
|
|
|
|
if(it->first != id) break;
|
|
|
|
|
|
|
|
|
|
if(it->second.range.aspectMask & t.subresourceRange.aspectMask)
|
|
|
|
|
if(it->second.subresourceRange.aspectMask & t.subresourceRange.aspectMask)
|
|
|
|
|
{
|
|
|
|
|
// we've found a range that completely matches our region, doesn't matter if that's
|
|
|
|
|
// a whole image and the transition is the whole image, or it's one subresource.
|
|
|
|
|
// note that for images with only one array/mip slice (e.g. render targets) we'll never
|
|
|
|
|
// really have to worry about the else{} branch
|
|
|
|
|
if(it->second.range.baseMipLevel == t.subresourceRange.baseMipLevel &&
|
|
|
|
|
it->second.range.mipLevels == nummips &&
|
|
|
|
|
it->second.range.baseArrayLayer == t.subresourceRange.baseArrayLayer &&
|
|
|
|
|
it->second.range.arraySize == numslices)
|
|
|
|
|
if(it->second.subresourceRange.baseMipLevel == t.subresourceRange.baseMipLevel &&
|
|
|
|
|
it->second.subresourceRange.mipLevels == nummips &&
|
|
|
|
|
it->second.subresourceRange.baseArrayLayer == t.subresourceRange.baseArrayLayer &&
|
|
|
|
|
it->second.subresourceRange.arraySize == numslices)
|
|
|
|
|
{
|
|
|
|
|
// verify
|
|
|
|
|
//RDCASSERT(it->second.state == t.oldState);
|
|
|
|
|
//RDCASSERT(it->second.state == t.oldLayout);
|
|
|
|
|
|
|
|
|
|
// apply it (prevstate is from the start of all transitions, so only set once)
|
|
|
|
|
if(it->second.prevstate == UNTRANSITIONED_IMG_STATE)
|
|
|
|
|
it->second.prevstate = t.oldLayout;
|
|
|
|
|
it->second.state = t.newLayout;
|
|
|
|
|
if(it->second.oldLayout == UNTRANSITIONED_IMG_STATE)
|
|
|
|
|
it->second.oldLayout = t.oldLayout;
|
|
|
|
|
it->second.newLayout = t.newLayout;
|
|
|
|
|
|
|
|
|
|
done = true;
|
|
|
|
|
break;
|
|
|
|
@@ -113,17 +113,17 @@ void VulkanResourceManager::RecordTransitions(vector< pair<ResourceId, ImageRegi
|
|
|
|
|
// range could be sparse, but that's OK as we only break out of the loop once we go past the whole
|
|
|
|
|
// aspect. Any subresources that don't match the range, after the split, will fail to meet any
|
|
|
|
|
// of the handled cases, so we'll just continue processing.
|
|
|
|
|
if(it->second.range.mipLevels == 1 &&
|
|
|
|
|
it->second.range.arraySize == 1 &&
|
|
|
|
|
it->second.range.baseMipLevel >= t.subresourceRange.baseMipLevel &&
|
|
|
|
|
it->second.range.baseMipLevel < t.subresourceRange.baseMipLevel+nummips &&
|
|
|
|
|
it->second.range.baseArrayLayer >= t.subresourceRange.baseArrayLayer &&
|
|
|
|
|
it->second.range.baseArrayLayer < t.subresourceRange.baseArrayLayer+numslices)
|
|
|
|
|
if(it->second.subresourceRange.mipLevels == 1 &&
|
|
|
|
|
it->second.subresourceRange.arraySize == 1 &&
|
|
|
|
|
it->second.subresourceRange.baseMipLevel >= t.subresourceRange.baseMipLevel &&
|
|
|
|
|
it->second.subresourceRange.baseMipLevel < t.subresourceRange.baseMipLevel+nummips &&
|
|
|
|
|
it->second.subresourceRange.baseArrayLayer >= t.subresourceRange.baseArrayLayer &&
|
|
|
|
|
it->second.subresourceRange.baseArrayLayer < t.subresourceRange.baseArrayLayer+numslices)
|
|
|
|
|
{
|
|
|
|
|
// apply it (prevstate is from the start of all transitions, so only set once)
|
|
|
|
|
if(it->second.prevstate == UNTRANSITIONED_IMG_STATE)
|
|
|
|
|
it->second.prevstate = t.oldLayout;
|
|
|
|
|
it->second.state = t.newLayout;
|
|
|
|
|
if(it->second.oldLayout == UNTRANSITIONED_IMG_STATE)
|
|
|
|
|
it->second.oldLayout = t.oldLayout;
|
|
|
|
|
it->second.newLayout = t.newLayout;
|
|
|
|
|
|
|
|
|
|
// continue as there might be more, but we're done
|
|
|
|
|
done = true;
|
|
|
|
@@ -134,14 +134,14 @@ void VulkanResourceManager::RecordTransitions(vector< pair<ResourceId, ImageRegi
|
|
|
|
|
// case, so we know that the transition doesn't cover the whole range.
|
|
|
|
|
// Also, if we've already done the split this case won't be hit and we'll either fall into
|
|
|
|
|
// the case above, or we'll finish as we've covered the whole transition.
|
|
|
|
|
else if(it->second.range.mipLevels > 1 || it->second.range.arraySize > 1)
|
|
|
|
|
else if(it->second.subresourceRange.mipLevels > 1 || it->second.subresourceRange.arraySize > 1)
|
|
|
|
|
{
|
|
|
|
|
pair<ResourceId, ImageRegionState> existing = *it;
|
|
|
|
|
|
|
|
|
|
// remember where we were in the array, as after this iterators will be
|
|
|
|
|
// invalidated.
|
|
|
|
|
size_t offs = it - trans.begin();
|
|
|
|
|
size_t count = it->second.range.mipLevels * it->second.range.arraySize;
|
|
|
|
|
size_t count = it->second.subresourceRange.mipLevels * it->second.subresourceRange.arraySize;
|
|
|
|
|
|
|
|
|
|
// only insert count-1 as we want count entries total - one per subresource
|
|
|
|
|
trans.insert(it, count-1, existing);
|
|
|
|
@@ -152,12 +152,12 @@ void VulkanResourceManager::RecordTransitions(vector< pair<ResourceId, ImageRegi
|
|
|
|
|
|
|
|
|
|
for(size_t i=0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
it->second.range.mipLevels = 1;
|
|
|
|
|
it->second.range.arraySize = 1;
|
|
|
|
|
it->second.subresourceRange.mipLevels = 1;
|
|
|
|
|
it->second.subresourceRange.arraySize = 1;
|
|
|
|
|
|
|
|
|
|
// slice-major
|
|
|
|
|
it->second.range.baseArrayLayer = uint32_t(i / existing.second.range.mipLevels);
|
|
|
|
|
it->second.range.baseMipLevel = uint32_t(i % existing.second.range.mipLevels);
|
|
|
|
|
it->second.subresourceRange.baseArrayLayer = uint32_t(i / existing.second.subresourceRange.mipLevels);
|
|
|
|
|
it->second.subresourceRange.baseMipLevel = uint32_t(i % existing.second.subresourceRange.mipLevels);
|
|
|
|
|
it++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -166,15 +166,15 @@ void VulkanResourceManager::RecordTransitions(vector< pair<ResourceId, ImageRegi
|
|
|
|
|
|
|
|
|
|
// the loop will continue after this point and look at the next subresources
|
|
|
|
|
// so we need to check to see if the first subresource lies in the range here
|
|
|
|
|
if(it->second.range.baseMipLevel >= t.subresourceRange.baseMipLevel &&
|
|
|
|
|
it->second.range.baseMipLevel < t.subresourceRange.baseMipLevel+nummips &&
|
|
|
|
|
it->second.range.baseArrayLayer >= t.subresourceRange.baseArrayLayer &&
|
|
|
|
|
it->second.range.baseArrayLayer < t.subresourceRange.baseArrayLayer+numslices)
|
|
|
|
|
if(it->second.subresourceRange.baseMipLevel >= t.subresourceRange.baseMipLevel &&
|
|
|
|
|
it->second.subresourceRange.baseMipLevel < t.subresourceRange.baseMipLevel+nummips &&
|
|
|
|
|
it->second.subresourceRange.baseArrayLayer >= t.subresourceRange.baseArrayLayer &&
|
|
|
|
|
it->second.subresourceRange.baseArrayLayer < t.subresourceRange.baseArrayLayer+numslices)
|
|
|
|
|
{
|
|
|
|
|
// apply it (prevstate is from the start of all transitions, so only set once)
|
|
|
|
|
if(it->second.prevstate == UNTRANSITIONED_IMG_STATE)
|
|
|
|
|
it->second.prevstate = t.oldLayout;
|
|
|
|
|
it->second.state = t.newLayout;
|
|
|
|
|
if(it->second.oldLayout == UNTRANSITIONED_IMG_STATE)
|
|
|
|
|
it->second.oldLayout = t.oldLayout;
|
|
|
|
|
it->second.newLayout = t.newLayout;
|
|
|
|
|
|
|
|
|
|
// continue as there might be more, but we're done
|
|
|
|
|
done = true;
|
|
|
|
@@ -187,7 +187,7 @@ void VulkanResourceManager::RecordTransitions(vector< pair<ResourceId, ImageRegi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if we've gone past where the new subresource range would sit
|
|
|
|
|
if(it->second.range.aspectMask > t.subresourceRange.aspectMask)
|
|
|
|
|
if(it->second.subresourceRange.aspectMask > t.subresourceRange.aspectMask)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// otherwise continue to try and find the subresource range
|
|
|
|
@@ -213,8 +213,8 @@ void VulkanResourceManager::MergeTransitions(vector< pair<ResourceId, ImageRegio
|
|
|
|
|
ResourceId id = srctrans[ti].first;
|
|
|
|
|
const ImageRegionState &t = srctrans[ti].second;
|
|
|
|
|
|
|
|
|
|
uint32_t nummips = t.range.mipLevels;
|
|
|
|
|
uint32_t numslices = t.range.arraySize;
|
|
|
|
|
uint32_t nummips = t.subresourceRange.mipLevels;
|
|
|
|
|
uint32_t numslices = t.subresourceRange.arraySize;
|
|
|
|
|
|
|
|
|
|
bool done = false;
|
|
|
|
|
|
|
|
|
@@ -230,24 +230,24 @@ void VulkanResourceManager::MergeTransitions(vector< pair<ResourceId, ImageRegio
|
|
|
|
|
if(it->first < id) continue;
|
|
|
|
|
if(it->first != id) break;
|
|
|
|
|
|
|
|
|
|
if(it->second.range.aspectMask & t.range.aspectMask)
|
|
|
|
|
if(it->second.subresourceRange.aspectMask & t.subresourceRange.aspectMask)
|
|
|
|
|
{
|
|
|
|
|
// we've found a range that completely matches our region, doesn't matter if that's
|
|
|
|
|
// a whole image and the transition is the whole image, or it's one subresource.
|
|
|
|
|
// note that for images with only one array/mip slice (e.g. render targets) we'll never
|
|
|
|
|
// really have to worry about the else{} branch
|
|
|
|
|
if(it->second.range.baseMipLevel == t.range.baseMipLevel &&
|
|
|
|
|
it->second.range.mipLevels == nummips &&
|
|
|
|
|
it->second.range.baseArrayLayer == t.range.baseArrayLayer &&
|
|
|
|
|
it->second.range.arraySize == numslices)
|
|
|
|
|
if(it->second.subresourceRange.baseMipLevel == t.subresourceRange.baseMipLevel &&
|
|
|
|
|
it->second.subresourceRange.mipLevels == nummips &&
|
|
|
|
|
it->second.subresourceRange.baseArrayLayer == t.subresourceRange.baseArrayLayer &&
|
|
|
|
|
it->second.subresourceRange.arraySize == numslices)
|
|
|
|
|
{
|
|
|
|
|
// verify
|
|
|
|
|
//RDCASSERT(it->second.state == t.prevstate);
|
|
|
|
|
|
|
|
|
|
// apply it (prevstate is from the start of all transitions, so only set once)
|
|
|
|
|
if(it->second.prevstate == UNTRANSITIONED_IMG_STATE)
|
|
|
|
|
it->second.prevstate = t.prevstate;
|
|
|
|
|
it->second.state = t.state;
|
|
|
|
|
if(it->second.oldLayout == UNTRANSITIONED_IMG_STATE)
|
|
|
|
|
it->second.oldLayout = t.oldLayout;
|
|
|
|
|
it->second.newLayout = t.newLayout;
|
|
|
|
|
|
|
|
|
|
done = true;
|
|
|
|
|
break;
|
|
|
|
@@ -264,17 +264,17 @@ void VulkanResourceManager::MergeTransitions(vector< pair<ResourceId, ImageRegio
|
|
|
|
|
// range could be sparse, but that's OK as we only break out of the loop once we go past the whole
|
|
|
|
|
// aspect. Any subresources that don't match the range, after the split, will fail to meet any
|
|
|
|
|
// of the handled cases, so we'll just continue processing.
|
|
|
|
|
if(it->second.range.mipLevels == 1 &&
|
|
|
|
|
it->second.range.arraySize == 1 &&
|
|
|
|
|
it->second.range.baseMipLevel >= t.range.baseMipLevel &&
|
|
|
|
|
it->second.range.baseMipLevel < t.range.baseMipLevel+nummips &&
|
|
|
|
|
it->second.range.baseArrayLayer >= t.range.baseArrayLayer &&
|
|
|
|
|
it->second.range.baseArrayLayer < t.range.baseArrayLayer+numslices)
|
|
|
|
|
if(it->second.subresourceRange.mipLevels == 1 &&
|
|
|
|
|
it->second.subresourceRange.arraySize == 1 &&
|
|
|
|
|
it->second.subresourceRange.baseMipLevel >= t.subresourceRange.baseMipLevel &&
|
|
|
|
|
it->second.subresourceRange.baseMipLevel < t.subresourceRange.baseMipLevel+nummips &&
|
|
|
|
|
it->second.subresourceRange.baseArrayLayer >= t.subresourceRange.baseArrayLayer &&
|
|
|
|
|
it->second.subresourceRange.baseArrayLayer < t.subresourceRange.baseArrayLayer+numslices)
|
|
|
|
|
{
|
|
|
|
|
// apply it (prevstate is from the start of all transitions, so only set once)
|
|
|
|
|
if(it->second.prevstate == UNTRANSITIONED_IMG_STATE)
|
|
|
|
|
it->second.prevstate = t.prevstate;
|
|
|
|
|
it->second.state = t.state;
|
|
|
|
|
if(it->second.oldLayout == UNTRANSITIONED_IMG_STATE)
|
|
|
|
|
it->second.oldLayout = t.oldLayout;
|
|
|
|
|
it->second.newLayout = t.newLayout;
|
|
|
|
|
|
|
|
|
|
// continue as there might be more, but we're done
|
|
|
|
|
done = true;
|
|
|
|
@@ -285,14 +285,14 @@ void VulkanResourceManager::MergeTransitions(vector< pair<ResourceId, ImageRegio
|
|
|
|
|
// case, so we know that the transition doesn't cover the whole range.
|
|
|
|
|
// Also, if we've already done the split this case won't be hit and we'll either fall into
|
|
|
|
|
// the case above, or we'll finish as we've covered the whole transition.
|
|
|
|
|
else if(it->second.range.mipLevels > 1 || it->second.range.arraySize > 1)
|
|
|
|
|
else if(it->second.subresourceRange.mipLevels > 1 || it->second.subresourceRange.arraySize > 1)
|
|
|
|
|
{
|
|
|
|
|
pair<ResourceId, ImageRegionState> existing = *it;
|
|
|
|
|
|
|
|
|
|
// remember where we were in the array, as after this iterators will be
|
|
|
|
|
// invalidated.
|
|
|
|
|
size_t offs = it - dsttrans.begin();
|
|
|
|
|
size_t count = it->second.range.mipLevels * it->second.range.arraySize;
|
|
|
|
|
size_t count = it->second.subresourceRange.mipLevels * it->second.subresourceRange.arraySize;
|
|
|
|
|
|
|
|
|
|
// only insert count-1 as we want count entries total - one per subresource
|
|
|
|
|
dsttrans.insert(it, count-1, existing);
|
|
|
|
@@ -303,12 +303,12 @@ void VulkanResourceManager::MergeTransitions(vector< pair<ResourceId, ImageRegio
|
|
|
|
|
|
|
|
|
|
for(size_t i=0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
it->second.range.mipLevels = 1;
|
|
|
|
|
it->second.range.arraySize = 1;
|
|
|
|
|
it->second.subresourceRange.mipLevels = 1;
|
|
|
|
|
it->second.subresourceRange.arraySize = 1;
|
|
|
|
|
|
|
|
|
|
// slice-major
|
|
|
|
|
it->second.range.baseArrayLayer = uint32_t(i / existing.second.range.mipLevels);
|
|
|
|
|
it->second.range.baseMipLevel = uint32_t(i % existing.second.range.mipLevels);
|
|
|
|
|
it->second.subresourceRange.baseArrayLayer = uint32_t(i / existing.second.subresourceRange.mipLevels);
|
|
|
|
|
it->second.subresourceRange.baseMipLevel = uint32_t(i % existing.second.subresourceRange.mipLevels);
|
|
|
|
|
it++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -317,15 +317,15 @@ void VulkanResourceManager::MergeTransitions(vector< pair<ResourceId, ImageRegio
|
|
|
|
|
|
|
|
|
|
// the loop will continue after this point and look at the next subresources
|
|
|
|
|
// so we need to check to see if the first subresource lies in the range here
|
|
|
|
|
if(it->second.range.baseMipLevel >= t.range.baseMipLevel &&
|
|
|
|
|
it->second.range.baseMipLevel < t.range.baseMipLevel+nummips &&
|
|
|
|
|
it->second.range.baseArrayLayer >= t.range.baseArrayLayer &&
|
|
|
|
|
it->second.range.baseArrayLayer < t.range.baseArrayLayer+numslices)
|
|
|
|
|
if(it->second.subresourceRange.baseMipLevel >= t.subresourceRange.baseMipLevel &&
|
|
|
|
|
it->second.subresourceRange.baseMipLevel < t.subresourceRange.baseMipLevel+nummips &&
|
|
|
|
|
it->second.subresourceRange.baseArrayLayer >= t.subresourceRange.baseArrayLayer &&
|
|
|
|
|
it->second.subresourceRange.baseArrayLayer < t.subresourceRange.baseArrayLayer+numslices)
|
|
|
|
|
{
|
|
|
|
|
// apply it (prevstate is from the start of all transitions, so only set once)
|
|
|
|
|
if(it->second.prevstate == UNTRANSITIONED_IMG_STATE)
|
|
|
|
|
it->second.prevstate = t.prevstate;
|
|
|
|
|
it->second.state = t.state;
|
|
|
|
|
if(it->second.oldLayout == UNTRANSITIONED_IMG_STATE)
|
|
|
|
|
it->second.oldLayout = t.oldLayout;
|
|
|
|
|
it->second.newLayout = t.newLayout;
|
|
|
|
|
|
|
|
|
|
// continue as there might be more, but we're done
|
|
|
|
|
done = true;
|
|
|
|
@@ -338,7 +338,7 @@ void VulkanResourceManager::MergeTransitions(vector< pair<ResourceId, ImageRegio
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if we've gone past where the new subresource range would sit
|
|
|
|
|
if(it->second.range.aspectMask > t.range.aspectMask)
|
|
|
|
|
if(it->second.subresourceRange.aspectMask > t.subresourceRange.aspectMask)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// otherwise continue to try and find the subresource range
|
|
|
|
@@ -348,7 +348,7 @@ void VulkanResourceManager::MergeTransitions(vector< pair<ResourceId, ImageRegio
|
|
|
|
|
|
|
|
|
|
// we don't have an existing transition for this memory region, insert into place. it points to
|
|
|
|
|
// where it should be inserted
|
|
|
|
|
dsttrans.insert(it, std::make_pair(id, ImageRegionState(t.range, t.prevstate, t.state)));
|
|
|
|
|
dsttrans.insert(it, std::make_pair(id, ImageRegionState(t.subresourceRange, t.oldLayout, t.newLayout)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRDBG("Post-merge, there are %u transitions", (uint32_t)dsttrans.size());
|
|
|
|
@@ -393,8 +393,8 @@ void VulkanResourceManager::SerialiseImageStates(map<ResourceId, ImageLayouts> &
|
|
|
|
|
t.destQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
|
|
|
|
t.image = Unwrap(GetCurrentHandle<VkImage>(liveid));
|
|
|
|
|
t.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
|
|
|
|
t.newLayout = state.state;
|
|
|
|
|
t.subresourceRange = state.range;
|
|
|
|
|
t.newLayout = state.newLayout;
|
|
|
|
|
t.subresourceRange = state.subresourceRange;
|
|
|
|
|
transitions.push_back(t);
|
|
|
|
|
vec.push_back(std::make_pair(liveid, state));
|
|
|
|
|
}
|
|
|
|
@@ -406,7 +406,7 @@ void VulkanResourceManager::SerialiseImageStates(map<ResourceId, ImageLayouts> &
|
|
|
|
|
ApplyTransitions(vec, states);
|
|
|
|
|
|
|
|
|
|
for(size_t i=0; i < vec.size(); i++)
|
|
|
|
|
transitions[i].oldLayout = vec[i].second.prevstate;
|
|
|
|
|
transitions[i].oldLayout = vec[i].second.oldLayout;
|
|
|
|
|
|
|
|
|
|
// erase any do-nothing transitions
|
|
|
|
|
for(auto it=transitions.begin(); it != transitions.end();)
|
|
|
|
@@ -437,8 +437,8 @@ void VulkanResourceManager::ApplyTransitions(vector< pair<ResourceId, ImageRegio
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t nummips = t.range.mipLevels;
|
|
|
|
|
uint32_t numslices = t.range.arraySize;
|
|
|
|
|
uint32_t nummips = t.subresourceRange.mipLevels;
|
|
|
|
|
uint32_t numslices = t.subresourceRange.arraySize;
|
|
|
|
|
if(nummips == VK_REMAINING_MIP_LEVELS) nummips = states[id].mipLevels;
|
|
|
|
|
if(numslices == VK_REMAINING_ARRAY_LAYERS) numslices = states[id].arraySize;
|
|
|
|
|
|
|
|
|
@@ -446,13 +446,13 @@ void VulkanResourceManager::ApplyTransitions(vector< pair<ResourceId, ImageRegio
|
|
|
|
|
if(nummips == 0) nummips = 1;
|
|
|
|
|
if(numslices == 0) numslices = 1;
|
|
|
|
|
|
|
|
|
|
if(t.prevstate == t.state) continue;
|
|
|
|
|
if(t.oldLayout == t.newLayout) continue;
|
|
|
|
|
|
|
|
|
|
TRDBG("Transition of %s (%u->%u, %u->%u) from %s to %s",
|
|
|
|
|
ToStr::Get(t.range.aspect).c_str(),
|
|
|
|
|
t.range.baseMipLevel, t.range.mipLevels,
|
|
|
|
|
t.range.baseArrayLayer, t.range.arraySize,
|
|
|
|
|
ToStr::Get(t.prevstate).c_str(), ToStr::Get(t.state).c_str());
|
|
|
|
|
ToStr::Get(t.subresourceRange.aspect).c_str(),
|
|
|
|
|
t.subresourceRange.baseMipLevel, t.subresourceRange.mipLevels,
|
|
|
|
|
t.subresourceRange.baseArrayLayer, t.subresourceRange.arraySize,
|
|
|
|
|
ToStr::Get(t.oldLayout).c_str(), ToStr::Get(t.newLayout).c_str());
|
|
|
|
|
|
|
|
|
|
bool done = false;
|
|
|
|
|
|
|
|
|
@@ -462,34 +462,34 @@ void VulkanResourceManager::ApplyTransitions(vector< pair<ResourceId, ImageRegio
|
|
|
|
|
for(; it != stit->second.subresourceStates.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
TRDBG(".. state %s (%u->%u, %u->%u) from %s to %s",
|
|
|
|
|
ToStr::Get(it->range.aspect).c_str(),
|
|
|
|
|
ToStr::Get(it->subresourceRange.aspect).c_str(),
|
|
|
|
|
it->range.baseMipLevel, it->range.mipLevels,
|
|
|
|
|
it->range.baseArrayLayer, it->range.arraySize,
|
|
|
|
|
ToStr::Get(it->prevstate).c_str(), ToStr::Get(it->state).c_str());
|
|
|
|
|
ToStr::Get(it->oldLayout).c_str(), ToStr::Get(it->newLayout).c_str());
|
|
|
|
|
|
|
|
|
|
// image transitions are handled by initially inserting one subresource range for each aspect,
|
|
|
|
|
// and whenever we need more fine-grained detail we split it immediately for one range for
|
|
|
|
|
// each subresource in that aspect. Thereafter if a transition comes in that covers multiple
|
|
|
|
|
// subresources, we transition all matching ranges.
|
|
|
|
|
|
|
|
|
|
if(it->range.aspectMask & t.range.aspectMask)
|
|
|
|
|
if(it->subresourceRange.aspectMask & t.subresourceRange.aspectMask)
|
|
|
|
|
{
|
|
|
|
|
// we've found a range that completely matches our region, doesn't matter if that's
|
|
|
|
|
// a whole image and the transition is the whole image, or it's one subresource.
|
|
|
|
|
// note that for images with only one array/mip slice (e.g. render targets) we'll never
|
|
|
|
|
// really have to worry about the else{} branch
|
|
|
|
|
if(it->range.baseMipLevel == t.range.baseMipLevel &&
|
|
|
|
|
it->range.mipLevels == nummips &&
|
|
|
|
|
it->range.baseArrayLayer == t.range.baseArrayLayer &&
|
|
|
|
|
it->range.arraySize == numslices)
|
|
|
|
|
if(it->subresourceRange.baseMipLevel == t.subresourceRange.baseMipLevel &&
|
|
|
|
|
it->subresourceRange.mipLevels == nummips &&
|
|
|
|
|
it->subresourceRange.baseArrayLayer == t.subresourceRange.baseArrayLayer &&
|
|
|
|
|
it->subresourceRange.arraySize == numslices)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
RDCASSERT(t.prevstate == UNTRANSITIONED_IMG_STATE || it->state == UNTRANSITIONED_IMG_STATE || // renderdoc untracked/ignored
|
|
|
|
|
it->state == t.prevstate || // valid transition
|
|
|
|
|
t.prevstate == VK_IMAGE_LAYOUT_UNDEFINED); // can transition from UNDEFINED to any state
|
|
|
|
|
*/
|
|
|
|
|
t.prevstate = it->state;
|
|
|
|
|
it->state = t.state;
|
|
|
|
|
t.oldLayout = it->newLayout;
|
|
|
|
|
it->newLayout = t.newLayout;
|
|
|
|
|
|
|
|
|
|
done = true;
|
|
|
|
|
break;
|
|
|
|
@@ -506,17 +506,17 @@ void VulkanResourceManager::ApplyTransitions(vector< pair<ResourceId, ImageRegio
|
|
|
|
|
// range could be sparse, but that's OK as we only break out of the loop once we go past the whole
|
|
|
|
|
// aspect. Any subresources that don't match the range, after the split, will fail to meet any
|
|
|
|
|
// of the handled cases, so we'll just continue processing.
|
|
|
|
|
if(it->range.mipLevels == 1 &&
|
|
|
|
|
it->range.arraySize == 1 &&
|
|
|
|
|
it->range.baseMipLevel >= t.range.baseMipLevel &&
|
|
|
|
|
it->range.baseMipLevel < t.range.baseMipLevel+nummips &&
|
|
|
|
|
it->range.baseArrayLayer >= t.range.baseArrayLayer &&
|
|
|
|
|
it->range.baseArrayLayer < t.range.baseArrayLayer+numslices)
|
|
|
|
|
if(it->subresourceRange.mipLevels == 1 &&
|
|
|
|
|
it->subresourceRange.arraySize == 1 &&
|
|
|
|
|
it->subresourceRange.baseMipLevel >= t.subresourceRange.baseMipLevel &&
|
|
|
|
|
it->subresourceRange.baseMipLevel < t.subresourceRange.baseMipLevel+nummips &&
|
|
|
|
|
it->subresourceRange.baseArrayLayer >= t.subresourceRange.baseArrayLayer &&
|
|
|
|
|
it->subresourceRange.baseArrayLayer < t.subresourceRange.baseArrayLayer+numslices)
|
|
|
|
|
{
|
|
|
|
|
// apply it (prevstate is from the start of all transitions, so only set once)
|
|
|
|
|
if(it->prevstate == UNTRANSITIONED_IMG_STATE)
|
|
|
|
|
it->prevstate = t.prevstate;
|
|
|
|
|
it->state = t.state;
|
|
|
|
|
if(it->oldLayout == UNTRANSITIONED_IMG_STATE)
|
|
|
|
|
it->oldLayout = t.oldLayout;
|
|
|
|
|
it->newLayout = t.newLayout;
|
|
|
|
|
|
|
|
|
|
// continue as there might be more, but we're done
|
|
|
|
|
done = true;
|
|
|
|
@@ -527,14 +527,14 @@ void VulkanResourceManager::ApplyTransitions(vector< pair<ResourceId, ImageRegio
|
|
|
|
|
// case, so we know that the transition doesn't cover the whole range.
|
|
|
|
|
// Also, if we've already done the split this case won't be hit and we'll either fall into
|
|
|
|
|
// the case above, or we'll finish as we've covered the whole transition.
|
|
|
|
|
else if(it->range.mipLevels > 1 || it->range.arraySize > 1)
|
|
|
|
|
else if(it->subresourceRange.mipLevels > 1 || it->subresourceRange.arraySize > 1)
|
|
|
|
|
{
|
|
|
|
|
ImageRegionState existing = *it;
|
|
|
|
|
|
|
|
|
|
// remember where we were in the array, as after this iterators will be
|
|
|
|
|
// invalidated.
|
|
|
|
|
size_t offs = it - stit->second.subresourceStates.begin();
|
|
|
|
|
size_t count = it->range.mipLevels * it->range.arraySize;
|
|
|
|
|
size_t count = it->subresourceRange.mipLevels * it->subresourceRange.arraySize;
|
|
|
|
|
|
|
|
|
|
// only insert count-1 as we want count entries total - one per subresource
|
|
|
|
|
stit->second.subresourceStates.insert(it, count-1, existing);
|
|
|
|
@@ -545,12 +545,12 @@ void VulkanResourceManager::ApplyTransitions(vector< pair<ResourceId, ImageRegio
|
|
|
|
|
|
|
|
|
|
for(size_t i=0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
it->range.mipLevels = 1;
|
|
|
|
|
it->range.arraySize = 1;
|
|
|
|
|
it->subresourceRange.mipLevels = 1;
|
|
|
|
|
it->subresourceRange.arraySize = 1;
|
|
|
|
|
|
|
|
|
|
// slice-major
|
|
|
|
|
it->range.baseArrayLayer = uint32_t(i / existing.range.mipLevels);
|
|
|
|
|
it->range.baseMipLevel = uint32_t(i % existing.range.mipLevels);
|
|
|
|
|
it->subresourceRange.baseArrayLayer = uint32_t(i / existing.subresourceRange.mipLevels);
|
|
|
|
|
it->subresourceRange.baseMipLevel = uint32_t(i % existing.subresourceRange.mipLevels);
|
|
|
|
|
it++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -559,15 +559,15 @@ void VulkanResourceManager::ApplyTransitions(vector< pair<ResourceId, ImageRegio
|
|
|
|
|
|
|
|
|
|
// the loop will continue after this point and look at the next subresources
|
|
|
|
|
// so we need to check to see if the first subresource lies in the range here
|
|
|
|
|
if(it->range.baseMipLevel >= t.range.baseMipLevel &&
|
|
|
|
|
it->range.baseMipLevel < t.range.baseMipLevel+nummips &&
|
|
|
|
|
it->range.baseArrayLayer >= t.range.baseArrayLayer &&
|
|
|
|
|
it->range.baseArrayLayer < t.range.baseArrayLayer+numslices)
|
|
|
|
|
if(it->subresourceRange.baseMipLevel >= t.subresourceRange.baseMipLevel &&
|
|
|
|
|
it->subresourceRange.baseMipLevel < t.subresourceRange.baseMipLevel+nummips &&
|
|
|
|
|
it->subresourceRange.baseArrayLayer >= t.subresourceRange.baseArrayLayer &&
|
|
|
|
|
it->subresourceRange.baseArrayLayer < t.subresourceRange.baseArrayLayer+numslices)
|
|
|
|
|
{
|
|
|
|
|
// apply it (prevstate is from the start of all transitions, so only set once)
|
|
|
|
|
if(it->prevstate == UNTRANSITIONED_IMG_STATE)
|
|
|
|
|
it->prevstate = t.prevstate;
|
|
|
|
|
it->state = t.state;
|
|
|
|
|
if(it->oldLayout == UNTRANSITIONED_IMG_STATE)
|
|
|
|
|
it->oldLayout = t.oldLayout;
|
|
|
|
|
it->newLayout = t.newLayout;
|
|
|
|
|
|
|
|
|
|
// continue as there might be more, but we're done
|
|
|
|
|
done = true;
|
|
|
|
@@ -580,7 +580,7 @@ void VulkanResourceManager::ApplyTransitions(vector< pair<ResourceId, ImageRegio
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if we've gone past where the new subresource range would sit
|
|
|
|
|
if(it->range.aspectMask > t.range.aspectMask)
|
|
|
|
|
if(it->subresourceRange.aspectMask > t.subresourceRange.aspectMask)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// otherwise continue to try and find the subresource range
|
|
|
|
|