Skip to content

Commit

Permalink
Fixing vendor-specific/tied memory property flag detection
Browse files Browse the repository at this point in the history
  • Loading branch information
toomuchvoltage committed Sep 16, 2023
1 parent 5eaa1e1 commit d9fca6e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/loadtests/vkloadtests/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Texture::Texture(VulkanContext& vkctx,
if (useSubAlloc == UseSuballocator::Yes)
{
VkInstance vkInst = vkctx.instance;
VMA_CALLBACKS::InitVMA(vdi.physicalDevice, vdi.device, vkInst);
VMA_CALLBACKS::InitVMA(vdi.physicalDevice, vdi.device, vkInst, vdi.deviceMemoryProperties);

ktxresult = ktxTexture_VkUploadEx_WithSuballocator(kTexture, &vdi, &texture,
static_cast<VkImageTiling>(tiling),
Expand Down
8 changes: 6 additions & 2 deletions tests/loadtests/vkloadtests/VulkanLoadTestSample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ namespace VMA_CALLBACKS
{
VmaAllocator vmaAllocator;
std::mt19937_64 mt64;
VkPhysicalDeviceMemoryProperties cachedDevMemProps;

void InitVMA(VkPhysicalDevice& physicalDevice, VkDevice& device, VkInstance& instance)
void InitVMA(VkPhysicalDevice& physicalDevice, VkDevice& device, VkInstance& instance, VkPhysicalDeviceMemoryProperties& devMemProps)
{
cachedDevMemProps = devMemProps;

VmaVulkanFunctions vulkanFunctions = {};
vulkanFunctions.vkGetInstanceProcAddr = &vkGetInstanceProcAddr;
vulkanFunctions.vkGetDeviceProcAddr = &vkGetDeviceProcAddr;
Expand Down Expand Up @@ -75,7 +78,8 @@ namespace VMA_CALLBACKS
{
uint64_t allocId = mt64();
VmaAllocationCreateInfo pCreateInfo = {};
if (allocInfo->memoryTypeIndex == 8)
if ((cachedDevMemProps.memoryTypes[allocInfo->memoryTypeIndex].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) ||
(cachedDevMemProps.memoryTypes[allocInfo->memoryTypeIndex].propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT))
{
pCreateInfo.usage = VMA_MEMORY_USAGE_CPU_TO_GPU;
pCreateInfo.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT;
Expand Down
2 changes: 1 addition & 1 deletion tests/loadtests/vkloadtests/VulkanLoadTestSample.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace VMA_CALLBACKS
{
void InitVMA(VkPhysicalDevice& physicalDevice, VkDevice& device, VkInstance& instance);
void InitVMA(VkPhysicalDevice& physicalDevice, VkDevice& device, VkInstance& instance, VkPhysicalDeviceMemoryProperties& devMemProps);
void DestroyVMA();
uint64_t AllocMemCWrapper(VkMemoryAllocateInfo* allocInfo, VkMemoryRequirements* memReq, uint64_t* numPages);
VkResult BindBufferMemoryCWrapper(VkBuffer buffer, uint64_t allocId);
Expand Down

0 comments on commit d9fca6e

Please sign in to comment.