#include "nouveau_bo.h"
#include "nvk_device.h"
+#include "nvk_image.h"
#include "nvk_physical_device.h"
#include "nv_push.h"
struct nvk_device_memory *mem;
VkResult result;
- result = nvk_allocate_memory(dev, pAllocateInfo, NULL, pAllocator, &mem);
+ const VkMemoryDedicatedAllocateInfo *dedicated_info =
+ vk_find_struct_const(pAllocateInfo->pNext,
+ MEMORY_DEDICATED_ALLOCATE_INFO);
+
+ struct nvk_image_plane *dedicated_image_plane = NULL;
+ struct nvk_memory_tiling_info tile_info, *p_tile_info = NULL;
+ if (dedicated_info && dedicated_info->image != VK_NULL_HANDLE) {
+ VK_FROM_HANDLE(nvk_image, image, dedicated_info->image);
+ if (image->plane_count == 1 && image->planes[0].nil.pte_kind) {
+ dedicated_image_plane = &image->planes[0];
+ tile_info = (struct nvk_memory_tiling_info) {
+ .tile_mode = image->planes[0].nil.tile_mode,
+ .pte_kind = image->planes[0].nil.pte_kind,
+ };
+ p_tile_info = &tile_info;
+ }
+ }
+
+ result = nvk_allocate_memory(dev, pAllocateInfo, p_tile_info,
+ pAllocator, &mem);
if (result != VK_SUCCESS)
return result;
+ mem->dedicated_image_plane = dedicated_image_plane;
+
*pMem = nvk_device_memory_to_handle(mem);
return VK_SUCCESS;
.tile_mode = plane->nil.tile_mode,
.pte_kind = plane->nil.pte_kind,
};
- VkResult result = nvk_allocate_memory(dev, &alloc_info, &tile_info,
- pAllocator, &plane->internal);
- if (result != VK_SUCCESS)
- return result;
-
- plane->mem = plane->internal;
- plane->offset = 0;
-
- return VK_SUCCESS;
+ return nvk_allocate_memory(dev, &alloc_info, &tile_info,
+ pAllocator, &plane->internal);
}
VKAPI_ATTR VkResult VKAPI_CALL
uint64_t *offset_B)
{
*offset_B = ALIGN_POT(*offset_B, plane->nil.align_B);
- if (plane->internal == NULL) {
+ if (mem->dedicated_image_plane == plane) {
+ assert(*offset_B == 0);
+ plane->mem = mem;
+ plane->offset = 0;
+ } else if (plane->internal != NULL) {
+ plane->mem = plane->internal;
+ plane->offset = 0;
+ } else {
plane->mem = mem;
plane->offset = *offset_B;
}