Skip to content

Commit

Permalink
Simplify MacOS AMD GPU workaround
Browse files Browse the repository at this point in the history
Just append the VK_MEMORY_PROPERTY_HOST_COHERENT_BIT requirement
  • Loading branch information
Kethen committed Dec 9, 2024
1 parent ff1e765 commit bcdc7be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions Common/GPU/Vulkan/VulkanMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ VulkanPushPool::VulkanPushPool(VulkanContext *vulkan, const char *name, size_t o
RegisterGPUMemoryManager(this);

#if PPSSPP_PLATFORM(MAC) && PPSSPP_ARCH(AMD64)
allocation_extra_flags_ = 0;
if (vulkan_->GetPhysicalDeviceProperties().properties.vendorID != VULKAN_VENDOR_INTEL) {
// ref https://github.com/KhronosGroup/MoltenVK/issues/960
INFO_LOG(Log::G3D, "MoltenVK with dedicated gpu, allocating buffers with VMA_MEMORY_USAGE_CPU_ONLY");
allocation_usage_ = VMA_MEMORY_USAGE_CPU_ONLY; // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT in vma type index
} else {
allocation_usage_ = VMA_MEMORY_USAGE_CPU_TO_GPU;
INFO_LOG(Log::G3D, "MoltenVK with dedicated gpu, adding VK_MEMORY_PROPERTY_HOST_COHERENT_BIT");
allocation_extra_flags_ = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
}
#endif

Expand Down Expand Up @@ -79,10 +78,9 @@ VulkanPushPool::Block VulkanPushPool::CreateBlock(size_t size) {
b.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
VmaAllocationCreateInfo allocCreateInfo{};

#if PPSSPP_PLATFORM(MAC) && PPSSPP_ARCH(AMD64)
allocCreateInfo.usage = allocation_usage_;
#else
allocCreateInfo.usage = VMA_MEMORY_USAGE_CPU_TO_GPU;
#if PPSSPP_PLATFORM(MAC) && PPSSPP_ARCH(AMD64)
allocCreateInfo.requiredFlags = allocation_extra_flags_;
#endif
VmaAllocationInfo allocInfo{};

Expand Down
2 changes: 1 addition & 1 deletion Common/GPU/Vulkan/VulkanMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ class VulkanPushPool : public GPUMemoryManager {
int curBlockIndex_ = -1;
const char *name_;
#if PPSSPP_PLATFORM(MAC) && PPSSPP_ARCH(AMD64)
VmaMemoryUsage allocation_usage_;
VkMemoryPropertyFlags allocation_extra_flags_;
#endif
};

0 comments on commit bcdc7be

Please sign in to comment.