remove ignored memory property flags

pull/50/head
cosmonaut 2024-02-15 20:13:26 -08:00
parent 95ac1d06fb
commit 86099fb7ee
1 changed files with 10 additions and 26 deletions

View File

@ -2365,7 +2365,6 @@ static uint8_t VULKAN_INTERNAL_FindMemoryType(
VulkanRenderer *renderer, VulkanRenderer *renderer,
uint32_t typeFilter, uint32_t typeFilter,
VkMemoryPropertyFlags requiredProperties, VkMemoryPropertyFlags requiredProperties,
VkMemoryPropertyFlags ignoredProperties,
uint32_t *memoryTypeIndex uint32_t *memoryTypeIndex
) { ) {
uint32_t i; uint32_t i;
@ -2373,8 +2372,7 @@ static uint8_t VULKAN_INTERNAL_FindMemoryType(
for (i = *memoryTypeIndex; 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 )
{ {
*memoryTypeIndex = i; *memoryTypeIndex = i;
return 1; return 1;
@ -2388,7 +2386,6 @@ static uint8_t VULKAN_INTERNAL_FindBufferMemoryRequirements(
VulkanRenderer *renderer, VulkanRenderer *renderer,
VkBuffer buffer, VkBuffer buffer,
VkMemoryPropertyFlags requiredMemoryProperties, VkMemoryPropertyFlags requiredMemoryProperties,
VkMemoryPropertyFlags ignoredMemoryProperties,
VkMemoryRequirements2KHR *pMemoryRequirements, VkMemoryRequirements2KHR *pMemoryRequirements,
uint32_t *pMemoryTypeIndex uint32_t *pMemoryTypeIndex
) { ) {
@ -2408,7 +2405,6 @@ static uint8_t VULKAN_INTERNAL_FindBufferMemoryRequirements(
renderer, renderer,
pMemoryRequirements->memoryRequirements.memoryTypeBits, pMemoryRequirements->memoryRequirements.memoryTypeBits,
requiredMemoryProperties, requiredMemoryProperties,
ignoredMemoryProperties,
pMemoryTypeIndex pMemoryTypeIndex
); );
} }
@ -2417,7 +2413,6 @@ static uint8_t VULKAN_INTERNAL_FindImageMemoryRequirements(
VulkanRenderer *renderer, VulkanRenderer *renderer,
VkImage image, VkImage image,
VkMemoryPropertyFlags requiredMemoryPropertyFlags, VkMemoryPropertyFlags requiredMemoryPropertyFlags,
VkMemoryPropertyFlags ignoredMemoryPropertyFlags,
VkMemoryRequirements2KHR *pMemoryRequirements, VkMemoryRequirements2KHR *pMemoryRequirements,
uint32_t *pMemoryTypeIndex uint32_t *pMemoryTypeIndex
) { ) {
@ -2437,7 +2432,6 @@ static uint8_t VULKAN_INTERNAL_FindImageMemoryRequirements(
renderer, renderer,
pMemoryRequirements->memoryRequirements.memoryTypeBits, pMemoryRequirements->memoryRequirements.memoryTypeBits,
requiredMemoryPropertyFlags, requiredMemoryPropertyFlags,
ignoredMemoryPropertyFlags,
pMemoryTypeIndex pMemoryTypeIndex
); );
} }
@ -2859,22 +2853,19 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForImage(
uint8_t bindResult = 0; uint8_t bindResult = 0;
uint32_t memoryTypeIndex = 0; uint32_t memoryTypeIndex = 0;
VkMemoryPropertyFlags requiredMemoryPropertyFlags; VkMemoryPropertyFlags requiredMemoryPropertyFlags;
VkMemoryPropertyFlags ignoredMemoryPropertyFlags;
VkMemoryRequirements2KHR memoryRequirements = VkMemoryRequirements2KHR memoryRequirements =
{ {
VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR, VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR,
NULL NULL
}; };
/* Prefer GPU allocation */ /* Prefer GPU allocation for textures */
requiredMemoryPropertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; requiredMemoryPropertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
ignoredMemoryPropertyFlags = 0;
while (VULKAN_INTERNAL_FindImageMemoryRequirements( while (VULKAN_INTERNAL_FindImageMemoryRequirements(
renderer, renderer,
image, image,
requiredMemoryPropertyFlags, requiredMemoryPropertyFlags,
ignoredMemoryPropertyFlags,
&memoryRequirements, &memoryRequirements,
&memoryTypeIndex &memoryTypeIndex
)) { )) {
@ -2904,7 +2895,6 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForImage(
{ {
memoryTypeIndex = 0; memoryTypeIndex = 0;
requiredMemoryPropertyFlags = 0; requiredMemoryPropertyFlags = 0;
ignoredMemoryPropertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
if (isRenderTarget) if (isRenderTarget)
{ {
@ -2917,7 +2907,6 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForImage(
renderer, renderer,
image, image,
requiredMemoryPropertyFlags, requiredMemoryPropertyFlags,
ignoredMemoryPropertyFlags,
&memoryRequirements, &memoryRequirements,
&memoryTypeIndex &memoryTypeIndex
)) { )) {
@ -2958,7 +2947,6 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForBuffer(
uint8_t bindResult = 0; uint8_t bindResult = 0;
uint32_t memoryTypeIndex = 0; uint32_t memoryTypeIndex = 0;
VkMemoryPropertyFlags requiredMemoryPropertyFlags = 0; VkMemoryPropertyFlags requiredMemoryPropertyFlags = 0;
VkMemoryPropertyFlags ignoredMemoryPropertyFlags = 0;
VkMemoryRequirements2KHR memoryRequirements = VkMemoryRequirements2KHR memoryRequirements =
{ {
VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR, VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR,
@ -2971,24 +2959,17 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForBuffer(
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
} }
else
{
ignoredMemoryPropertyFlags =
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
}
if (preferDeviceLocal) if (preferDeviceLocal)
{ {
requiredMemoryPropertyFlags |= requiredMemoryPropertyFlags |=
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
} }
ignoredMemoryPropertyFlags = 0;
while (VULKAN_INTERNAL_FindBufferMemoryRequirements( while (VULKAN_INTERNAL_FindBufferMemoryRequirements(
renderer, renderer,
buffer, buffer,
requiredMemoryPropertyFlags, requiredMemoryPropertyFlags,
ignoredMemoryPropertyFlags,
&memoryRequirements, &memoryRequirements,
&memoryTypeIndex &memoryTypeIndex
)) { )) {
@ -3013,14 +2994,18 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForBuffer(
} }
} }
/* Bind failed, try again if originally preferred device local */ /* Bind failed, try again without preferred flags */
if (bindResult != 1) if (bindResult != 1)
{ {
memoryTypeIndex = 0; memoryTypeIndex = 0;
requiredMemoryPropertyFlags = 0;
requiredMemoryPropertyFlags = if (requireHostVisible)
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | {
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; requiredMemoryPropertyFlags =
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
}
/* Follow-up for the warning logged by FindMemoryType */ /* Follow-up for the warning logged by FindMemoryType */
if (!renderer->unifiedMemoryWarning) if (!renderer->unifiedMemoryWarning)
@ -3033,7 +3018,6 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForBuffer(
renderer, renderer,
buffer, buffer,
requiredMemoryPropertyFlags, requiredMemoryPropertyFlags,
ignoredMemoryPropertyFlags,
&memoryRequirements, &memoryRequirements,
&memoryTypeIndex &memoryTypeIndex
)) { )) {