From 86099fb7ee178b7dbd3abe90cc03f155041edc47 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Thu, 15 Feb 2024 20:13:26 -0800 Subject: [PATCH] remove ignored memory property flags --- src/Refresh_Driver_Vulkan.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/src/Refresh_Driver_Vulkan.c b/src/Refresh_Driver_Vulkan.c index b4f2f83..749d564 100644 --- a/src/Refresh_Driver_Vulkan.c +++ b/src/Refresh_Driver_Vulkan.c @@ -2365,7 +2365,6 @@ static uint8_t VULKAN_INTERNAL_FindMemoryType( VulkanRenderer *renderer, uint32_t typeFilter, VkMemoryPropertyFlags requiredProperties, - VkMemoryPropertyFlags ignoredProperties, uint32_t *memoryTypeIndex ) { uint32_t i; @@ -2373,8 +2372,7 @@ static uint8_t VULKAN_INTERNAL_FindMemoryType( for (i = *memoryTypeIndex; i < renderer->memoryProperties.memoryTypeCount; i += 1) { if ( (typeFilter & (1 << i)) && - (renderer->memoryProperties.memoryTypes[i].propertyFlags & requiredProperties) == requiredProperties && - (renderer->memoryProperties.memoryTypes[i].propertyFlags & ignoredProperties) == 0 ) + (renderer->memoryProperties.memoryTypes[i].propertyFlags & requiredProperties) == requiredProperties) { *memoryTypeIndex = i; return 1; @@ -2388,7 +2386,6 @@ static uint8_t VULKAN_INTERNAL_FindBufferMemoryRequirements( VulkanRenderer *renderer, VkBuffer buffer, VkMemoryPropertyFlags requiredMemoryProperties, - VkMemoryPropertyFlags ignoredMemoryProperties, VkMemoryRequirements2KHR *pMemoryRequirements, uint32_t *pMemoryTypeIndex ) { @@ -2408,7 +2405,6 @@ static uint8_t VULKAN_INTERNAL_FindBufferMemoryRequirements( renderer, pMemoryRequirements->memoryRequirements.memoryTypeBits, requiredMemoryProperties, - ignoredMemoryProperties, pMemoryTypeIndex ); } @@ -2417,7 +2413,6 @@ static uint8_t VULKAN_INTERNAL_FindImageMemoryRequirements( VulkanRenderer *renderer, VkImage image, VkMemoryPropertyFlags requiredMemoryPropertyFlags, - VkMemoryPropertyFlags ignoredMemoryPropertyFlags, VkMemoryRequirements2KHR *pMemoryRequirements, uint32_t *pMemoryTypeIndex ) { @@ -2437,7 +2432,6 @@ static uint8_t VULKAN_INTERNAL_FindImageMemoryRequirements( renderer, pMemoryRequirements->memoryRequirements.memoryTypeBits, requiredMemoryPropertyFlags, - ignoredMemoryPropertyFlags, pMemoryTypeIndex ); } @@ -2859,22 +2853,19 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForImage( uint8_t bindResult = 0; uint32_t memoryTypeIndex = 0; VkMemoryPropertyFlags requiredMemoryPropertyFlags; - VkMemoryPropertyFlags ignoredMemoryPropertyFlags; VkMemoryRequirements2KHR memoryRequirements = { VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR, NULL }; - /* Prefer GPU allocation */ + /* Prefer GPU allocation for textures */ requiredMemoryPropertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; - ignoredMemoryPropertyFlags = 0; while (VULKAN_INTERNAL_FindImageMemoryRequirements( renderer, image, requiredMemoryPropertyFlags, - ignoredMemoryPropertyFlags, &memoryRequirements, &memoryTypeIndex )) { @@ -2904,7 +2895,6 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForImage( { memoryTypeIndex = 0; requiredMemoryPropertyFlags = 0; - ignoredMemoryPropertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; if (isRenderTarget) { @@ -2917,7 +2907,6 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForImage( renderer, image, requiredMemoryPropertyFlags, - ignoredMemoryPropertyFlags, &memoryRequirements, &memoryTypeIndex )) { @@ -2958,7 +2947,6 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForBuffer( uint8_t bindResult = 0; uint32_t memoryTypeIndex = 0; VkMemoryPropertyFlags requiredMemoryPropertyFlags = 0; - VkMemoryPropertyFlags ignoredMemoryPropertyFlags = 0; VkMemoryRequirements2KHR memoryRequirements = { 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_COHERENT_BIT; } - else - { - ignoredMemoryPropertyFlags = - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; - } if (preferDeviceLocal) { requiredMemoryPropertyFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; } - ignoredMemoryPropertyFlags = 0; while (VULKAN_INTERNAL_FindBufferMemoryRequirements( renderer, buffer, requiredMemoryPropertyFlags, - ignoredMemoryPropertyFlags, &memoryRequirements, &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) { memoryTypeIndex = 0; + requiredMemoryPropertyFlags = 0; - requiredMemoryPropertyFlags = - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | - VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; + if (requireHostVisible) + { + requiredMemoryPropertyFlags = + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; + } /* Follow-up for the warning logged by FindMemoryType */ if (!renderer->unifiedMemoryWarning) @@ -3033,7 +3018,6 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForBuffer( renderer, buffer, requiredMemoryPropertyFlags, - ignoredMemoryPropertyFlags, &memoryRequirements, &memoryTypeIndex )) {