forked from MoonsideGames/Refresh
Fix heap iteration (#22)
Fixes an issue where certain memory heaps could potentially be overlooked. Reviewed-on: MoonsideGames/Refresh#22anisotropy
parent
f49c0ab190
commit
5568ce4949
|
@ -2156,22 +2156,22 @@ static uint8_t VULKAN_INTERNAL_FindMemoryType(
|
||||||
uint32_t typeFilter,
|
uint32_t typeFilter,
|
||||||
VkMemoryPropertyFlags requiredProperties,
|
VkMemoryPropertyFlags requiredProperties,
|
||||||
VkMemoryPropertyFlags ignoredProperties,
|
VkMemoryPropertyFlags ignoredProperties,
|
||||||
uint32_t *result
|
uint32_t *memoryTypeIndex
|
||||||
) {
|
) {
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
for (i = 0; i < renderer->memoryProperties.memoryTypeCount; i += 1)
|
for (i = *memoryTypeIndex; i < renderer->memoryProperties.memoryTypeCount; i += 1)
|
||||||
{
|
{
|
||||||
if ( (typeFilter & (1 << i)) &&
|
if ( (typeFilter & (1 << i)) &&
|
||||||
(renderer->memoryProperties.memoryTypes[i].propertyFlags & requiredProperties) == requiredProperties &&
|
(renderer->memoryProperties.memoryTypes[i].propertyFlags & requiredProperties) == requiredProperties &&
|
||||||
(renderer->memoryProperties.memoryTypes[i].propertyFlags & ignoredProperties) == 0 )
|
(renderer->memoryProperties.memoryTypes[i].propertyFlags & ignoredProperties) == 0 )
|
||||||
{
|
{
|
||||||
*result = i;
|
*memoryTypeIndex = i;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Refresh_LogError("Failed to find memory properties %X, required %X, ignored %X", requiredProperties, ignoredProperties, typeFilter);
|
Refresh_LogError("Failed to find memory properties %X, required %X, ignored %X", typeFilter, requiredProperties, ignoredProperties);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2513,7 +2513,7 @@ static uint8_t VULKAN_INTERNAL_FindAvailableBufferMemory(
|
||||||
VkDeviceSize *pOffset,
|
VkDeviceSize *pOffset,
|
||||||
VkDeviceSize *pSize
|
VkDeviceSize *pSize
|
||||||
) {
|
) {
|
||||||
uint32_t memoryTypeIndex;
|
uint32_t memoryTypeIndex = 0;
|
||||||
VkMemoryDedicatedRequirementsKHR dedicatedRequirements =
|
VkMemoryDedicatedRequirementsKHR dedicatedRequirements =
|
||||||
{
|
{
|
||||||
VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR,
|
VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR,
|
||||||
|
@ -2524,28 +2524,37 @@ static uint8_t VULKAN_INTERNAL_FindAvailableBufferMemory(
|
||||||
VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR,
|
VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR,
|
||||||
&dedicatedRequirements
|
&dedicatedRequirements
|
||||||
};
|
};
|
||||||
|
uint8_t findResult = 0;
|
||||||
|
|
||||||
if (!VULKAN_INTERNAL_FindBufferMemoryRequirements(
|
while (VULKAN_INTERNAL_FindBufferMemoryRequirements(
|
||||||
renderer,
|
renderer,
|
||||||
buffer,
|
buffer,
|
||||||
&memoryRequirements,
|
&memoryRequirements,
|
||||||
&memoryTypeIndex
|
&memoryTypeIndex
|
||||||
)) {
|
)) {
|
||||||
Refresh_LogError("Failed to acquire buffer memory requirements!");
|
findResult = VULKAN_INTERNAL_FindAvailableMemory(
|
||||||
return 0;
|
renderer,
|
||||||
|
memoryTypeIndex,
|
||||||
|
&memoryRequirements,
|
||||||
|
&dedicatedRequirements,
|
||||||
|
buffer,
|
||||||
|
VK_NULL_HANDLE,
|
||||||
|
pMemoryAllocation,
|
||||||
|
pOffset,
|
||||||
|
pSize
|
||||||
|
);
|
||||||
|
|
||||||
|
if (findResult == 1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memoryTypeIndex += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return VULKAN_INTERNAL_FindAvailableMemory(
|
return findResult;
|
||||||
renderer,
|
|
||||||
memoryTypeIndex,
|
|
||||||
&memoryRequirements,
|
|
||||||
&dedicatedRequirements,
|
|
||||||
buffer,
|
|
||||||
VK_NULL_HANDLE,
|
|
||||||
pMemoryAllocation,
|
|
||||||
pOffset,
|
|
||||||
pSize
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t VULKAN_INTERNAL_FindAvailableTextureMemory(
|
static uint8_t VULKAN_INTERNAL_FindAvailableTextureMemory(
|
||||||
|
@ -2556,7 +2565,7 @@ static uint8_t VULKAN_INTERNAL_FindAvailableTextureMemory(
|
||||||
VkDeviceSize *pOffset,
|
VkDeviceSize *pOffset,
|
||||||
VkDeviceSize *pSize
|
VkDeviceSize *pSize
|
||||||
) {
|
) {
|
||||||
uint32_t memoryTypeIndex;
|
uint32_t memoryTypeIndex = 0;
|
||||||
VkMemoryPropertyFlags requiredMemoryPropertyFlags;
|
VkMemoryPropertyFlags requiredMemoryPropertyFlags;
|
||||||
VkMemoryPropertyFlags ignoredMemoryPropertyFlags;
|
VkMemoryPropertyFlags ignoredMemoryPropertyFlags;
|
||||||
VkMemoryDedicatedRequirementsKHR dedicatedRequirements =
|
VkMemoryDedicatedRequirementsKHR dedicatedRequirements =
|
||||||
|
@ -2569,6 +2578,7 @@ static uint8_t VULKAN_INTERNAL_FindAvailableTextureMemory(
|
||||||
VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR,
|
VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR,
|
||||||
&dedicatedRequirements
|
&dedicatedRequirements
|
||||||
};
|
};
|
||||||
|
uint8_t findResult = 0;
|
||||||
|
|
||||||
if (cpuAllocation)
|
if (cpuAllocation)
|
||||||
{
|
{
|
||||||
|
@ -2581,7 +2591,7 @@ static uint8_t VULKAN_INTERNAL_FindAvailableTextureMemory(
|
||||||
ignoredMemoryPropertyFlags = 0;
|
ignoredMemoryPropertyFlags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!VULKAN_INTERNAL_FindImageMemoryRequirements(
|
while (VULKAN_INTERNAL_FindImageMemoryRequirements(
|
||||||
renderer,
|
renderer,
|
||||||
image,
|
image,
|
||||||
requiredMemoryPropertyFlags,
|
requiredMemoryPropertyFlags,
|
||||||
|
@ -2589,21 +2599,29 @@ static uint8_t VULKAN_INTERNAL_FindAvailableTextureMemory(
|
||||||
&memoryRequirements,
|
&memoryRequirements,
|
||||||
&memoryTypeIndex
|
&memoryTypeIndex
|
||||||
)) {
|
)) {
|
||||||
Refresh_LogError("Failed to acquire image memory requirements!");
|
findResult = VULKAN_INTERNAL_FindAvailableMemory(
|
||||||
return 0;
|
renderer,
|
||||||
|
memoryTypeIndex,
|
||||||
|
&memoryRequirements,
|
||||||
|
&dedicatedRequirements,
|
||||||
|
VK_NULL_HANDLE,
|
||||||
|
image,
|
||||||
|
pMemoryAllocation,
|
||||||
|
pOffset,
|
||||||
|
pSize
|
||||||
|
);
|
||||||
|
|
||||||
|
if (findResult == 1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memoryTypeIndex += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return VULKAN_INTERNAL_FindAvailableMemory(
|
return findResult;
|
||||||
renderer,
|
|
||||||
memoryTypeIndex,
|
|
||||||
&memoryRequirements,
|
|
||||||
&dedicatedRequirements,
|
|
||||||
VK_NULL_HANDLE,
|
|
||||||
image,
|
|
||||||
pMemoryAllocation,
|
|
||||||
pOffset,
|
|
||||||
pSize
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Memory Barriers */
|
/* Memory Barriers */
|
||||||
|
|
Loading…
Reference in New Issue