Fix: Wrong Cycles NanoVDB memory alignment on Windows

This was not a problem in practice so far, but will be with upcoming changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/132908
This commit is contained in:
Brecht Van Lommel
2025-06-20 16:26:33 +02:00
parent 8111152c67
commit 8cf031ba95
3 changed files with 4 additions and 2 deletions

View File

@@ -103,7 +103,7 @@ void CPUDevice::mem_alloc(device_memory &mem)
}
if (mem.type == MEM_DEVICE_ONLY) {
size_t alignment = MIN_ALIGNMENT_CPU_DATA_TYPES;
size_t alignment = MIN_ALIGNMENT_DEVICE_MEMORY;
void *data = util_aligned_malloc(mem.memory_size(), alignment);
mem.device_pointer = (device_ptr)data;
}

View File

@@ -513,7 +513,7 @@ void *Device::get_guiding_device() const
void *Device::host_alloc(const MemoryType /*type*/, const size_t size)
{
return util_aligned_malloc(size, MIN_ALIGNMENT_CPU_DATA_TYPES);
return util_aligned_malloc(size, MIN_ALIGNMENT_DEVICE_MEMORY);
}
void Device::host_free(const MemoryType /*type*/, void *host_pointer, const size_t size)

View File

@@ -10,6 +10,8 @@ CCL_NAMESPACE_BEGIN
/* Minimum alignment needed by all CPU native data types (SSE, AVX). */
#define MIN_ALIGNMENT_CPU_DATA_TYPES 16 // NOLINT
/* NanoVDB needs at least 32 byte alignment. */
#define MIN_ALIGNMENT_DEVICE_MEMORY 32 // NOLINT
/* Allocate block of size bytes at least aligned to a given value. */
void *util_aligned_malloc(const size_t size, const int alignment);