Ensure invalid memory indices in the remap table aren't used. Refs #627

This commit is contained in:
baldurk
2017-05-29 15:08:58 +01:00
parent 158bc4d583
commit ba1e6f1e82
2 changed files with 7 additions and 6 deletions
+3 -2
View File
@@ -88,11 +88,12 @@ uint32_t WrappedVulkan::PhysicalDeviceData::GetMemoryIndex(uint32_t resourceRequ
void WrappedVulkan::RemapMemoryIndices(VkPhysicalDeviceMemoryProperties *memProps,
uint32_t **memIdxMap)
{
uint32_t *memmap = new uint32_t[32];
uint32_t *memmap = new uint32_t[VK_MAX_MEMORY_TYPES];
*memIdxMap = memmap;
m_MemIdxMaps.push_back(memmap);
RDCEraseMem(memmap, sizeof(uint32_t) * 32);
for(size_t i = 0; i < VK_MAX_MEMORY_TYPES; i++)
memmap[i] = ~0U;
// basic idea here:
// We want to discourage coherent memory maps as much as possible while capturing,
@@ -137,8 +137,8 @@ void WrappedVulkan::vkGetBufferMemoryRequirements(VkDevice device, VkBuffer buff
// for each of our fake memory indices, check if the real
// memory type it points to is set - if so, set our fake bit
for(uint32_t i = 0; i < VK_MAX_MEMORY_TYPES; i++)
if(bits & (1 << memIdxMap[i]))
pMemoryRequirements->memoryTypeBits |= (1 << i);
if(memIdxMap[i] < 32U && (bits & (1U << memIdxMap[i])))
pMemoryRequirements->memoryTypeBits |= (1U << i);
}
void WrappedVulkan::vkGetImageMemoryRequirements(VkDevice device, VkImage image,
@@ -158,8 +158,8 @@ void WrappedVulkan::vkGetImageMemoryRequirements(VkDevice device, VkImage image,
// for each of our fake memory indices, check if the real
// memory type it points to is set - if so, set our fake bit
for(uint32_t i = 0; i < VK_MAX_MEMORY_TYPES; i++)
if(bits & (1 << memIdxMap[i]))
pMemoryRequirements->memoryTypeBits |= (1 << i);
if(memIdxMap[i] < 32U && (bits & (1U << memIdxMap[i])))
pMemoryRequirements->memoryTypeBits |= (1U << i);
}
void WrappedVulkan::vkGetImageSparseMemoryRequirements(