mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 12:56:06 +00:00
Extend the VRAM setting to Vulkan memory-budget reports for DXVK and D3D12 while preserving real heap capacity and allocation results, removing the hard rejection that caused game crashes in FIT and Discord tests.
33 lines
1.1 KiB
C
33 lines
1.1 KiB
C
#ifndef VRAMCAP_BUDGET_H
|
|
#define VRAMCAP_BUDGET_H
|
|
|
|
#include <stdint.h>
|
|
#include <vulkan/vulkan.h>
|
|
|
|
static inline uint64_t vramcap_parse_mb(const char *text) {
|
|
if (!text || !*text) return 0;
|
|
uint64_t value = 0, limit = UINT64_MAX >> 20;
|
|
for (; *text; text++) {
|
|
if (*text < '0' || *text > '9') return 0;
|
|
unsigned digit = (unsigned)(*text - '0');
|
|
if (value > (limit - digit) / 10) return 0;
|
|
value = value * 10 + digit;
|
|
}
|
|
return value << 20;
|
|
}
|
|
|
|
static inline VkDeviceSize vramcap_clamp(VkDeviceSize value, uint64_t cap) {
|
|
return cap && value > cap ? cap : value;
|
|
}
|
|
|
|
static inline void vramcap_budget(const VkPhysicalDeviceMemoryProperties *p,
|
|
VkPhysicalDeviceMemoryBudgetPropertiesEXT *budget, uint64_t cap) {
|
|
for (uint32_t i = 0; i < p->memoryHeapCount && i < VK_MAX_MEMORY_HEAPS; i++)
|
|
if (p->memoryHeaps[i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) {
|
|
budget->heapBudget[i] = vramcap_clamp(budget->heapBudget[i], cap);
|
|
budget->heapBudget[i] = vramcap_clamp(budget->heapBudget[i], p->memoryHeaps[i].size);
|
|
}
|
|
}
|
|
|
|
#endif
|