mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JBR-8737 Vulkan: Respect nonCoherentAtomSize in allocator
This commit is contained in:
committed by
Alexey Ushakov
parent
f14bfe0de9
commit
c874bfb819
@@ -165,9 +165,11 @@ VKMemoryRequirements VKAllocator_ImageRequirements(VKAllocator* allocator, VkIma
|
||||
return r;
|
||||
}
|
||||
|
||||
void VKAllocator_PadToAlignment(VKMemoryRequirements* requirements) {
|
||||
void VKAllocator_PadToAlignment(VKAllocator* allocator, VKMemoryRequirements* requirements) {
|
||||
assert(allocator != NULL);
|
||||
assert(requirements != NULL);
|
||||
VkMemoryRequirements* t = &requirements->requirements.memoryRequirements;
|
||||
if (t->alignment < allocator->device->nonCoherentAtomSize) t->alignment = allocator->device->nonCoherentAtomSize;
|
||||
t->size = ((t->size + t->alignment - 1) / t->alignment) * t->alignment;
|
||||
requirements->dedicatedRequirements.requiresDedicatedAllocation = VK_FALSE;
|
||||
requirements->dedicatedRequirements.prefersDedicatedAllocation = VK_FALSE;
|
||||
|
||||
@@ -62,7 +62,7 @@ VKMemoryRequirements VKAllocator_ImageRequirements(VKAllocator* allocator, VkIma
|
||||
* This also resets dedicated requirement flags, as for dedicated allocations size must
|
||||
* be strictly equal to the one returned by resource memory requirements.
|
||||
*/
|
||||
void VKAllocator_PadToAlignment(VKMemoryRequirements* requirements);
|
||||
void VKAllocator_PadToAlignment(VKAllocator* allocator, VKMemoryRequirements* requirements);
|
||||
|
||||
/**
|
||||
* Find memory type with properties not less than requiredProperties and not more than allowedProperties,
|
||||
|
||||
@@ -67,7 +67,7 @@ VKMemory VKBuffer_CreateBuffers(VKDevice* device, VkBufferUsageFlags usageFlags,
|
||||
// Check memory requirements. We aim to create maxBufferCount buffers,
|
||||
// but due to implementation-specific alignment requirements this number can be lower (unlikely though).
|
||||
VKMemoryRequirements requirements = VKAllocator_BufferRequirements(alloc, buffers[0].handle);
|
||||
VKAllocator_PadToAlignment(&requirements); // Align for array-like allocation.
|
||||
VKAllocator_PadToAlignment(alloc, &requirements); // Align for array-like allocation.
|
||||
VkDeviceSize realBufferSize = requirements.requirements.memoryRequirements.size;
|
||||
if (pageSize == 0) pageSize = (*bufferCount) * realBufferSize;
|
||||
uint32_t realBufferCount = pageSize / realBufferSize;
|
||||
|
||||
@@ -257,6 +257,7 @@ void VKDevice_CheckAndAdd(VKEnv* vk, VkPhysicalDevice physicalDevice) {
|
||||
ARRAY_PUSH_BACK(vk->devices) = (VKDevice) {
|
||||
.name = deviceName,
|
||||
.type = deviceProperties2.properties.deviceType,
|
||||
.nonCoherentAtomSize = deviceProperties2.properties.limits.nonCoherentAtomSize,
|
||||
.handle = VK_NULL_HANDLE,
|
||||
.physicalDevice = physicalDevice,
|
||||
.queueFamily = queueFamily,
|
||||
|
||||
@@ -48,6 +48,7 @@ struct VKDevice {
|
||||
VkPhysicalDevice physicalDevice;
|
||||
char* name;
|
||||
VkPhysicalDeviceType type;
|
||||
VkDeviceSize nonCoherentAtomSize;
|
||||
uint32_t queueFamily;
|
||||
ARRAY(pchar) enabledLayers;
|
||||
ARRAY(pchar) enabledExtensions;
|
||||
|
||||
Reference in New Issue
Block a user