Merge pull request #19710 from Kethen/macos_amd_workaround

Work around metal buffer bug on MacOS + AMD GPU
This commit is contained in:
Henrik Rydgård 2024-12-09 14:39:34 +01:00 committed by GitHub
commit a5a3401bae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 4 deletions

View file

@ -343,10 +343,6 @@ static VulkanLibraryHandle VulkanLoadLibrary(std::string *errorString) {
return nullptr;
#elif PPSSPP_PLATFORM(UWP)
return nullptr;
#elif PPSSPP_PLATFORM(MAC) && PPSSPP_ARCH(AMD64)
// Disable Vulkan on Mac/x86. Too many configurations that don't work with MoltenVK
// for whatever reason.
return nullptr;
#elif PPSSPP_PLATFORM(WINDOWS)
return LoadLibrary(L"vulkan-1.dll");
#else

View file

@ -38,6 +38,16 @@ static const double PUSH_GARBAGE_COLLECTION_DELAY = 10.0;
VulkanPushPool::VulkanPushPool(VulkanContext *vulkan, const char *name, size_t originalBlockSize, VkBufferUsageFlags usage)
: vulkan_(vulkan), name_(name), originalBlockSize_(originalBlockSize), usage_(usage) {
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, adding VK_MEMORY_PROPERTY_HOST_COHERENT_BIT");
allocation_extra_flags_ = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
}
#endif
for (int i = 0; i < VulkanContext::MAX_INFLIGHT_FRAMES; i++) {
blocks_.push_back(CreateBlock(originalBlockSize));
blocks_.back().original = true;
@ -67,7 +77,11 @@ VulkanPushPool::Block VulkanPushPool::CreateBlock(size_t size) {
b.usage = usage_;
b.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
VmaAllocationCreateInfo allocCreateInfo{};
allocCreateInfo.usage = VMA_MEMORY_USAGE_CPU_TO_GPU;
#if PPSSPP_PLATFORM(MAC) && PPSSPP_ARCH(AMD64)
allocCreateInfo.requiredFlags = allocation_extra_flags_;
#endif
VmaAllocationInfo allocInfo{};
VkResult result = vmaCreateBuffer(vulkan_->Allocator(), &b, &allocCreateInfo, &block.buffer, &block.allocation, &allocInfo);

View file

@ -93,4 +93,7 @@ private:
VkBufferUsageFlags usage_;
int curBlockIndex_ = -1;
const char *name_;
#if PPSSPP_PLATFORM(MAC) && PPSSPP_ARCH(AMD64)
VkMemoryPropertyFlags allocation_extra_flags_;
#endif
};