nvk: Dedicated allocations override internal
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:

committed by
Marge Bot

parent
702326d013
commit
7f0c06e130
@@ -3,6 +3,7 @@
|
||||
#include "nouveau_bo.h"
|
||||
|
||||
#include "nvk_device.h"
|
||||
#include "nvk_image.h"
|
||||
#include "nvk_physical_device.h"
|
||||
#include "nv_push.h"
|
||||
|
||||
@@ -191,10 +192,31 @@ nvk_AllocateMemory(VkDevice device,
|
||||
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;
|
||||
|
@@ -8,12 +8,15 @@
|
||||
#include "util/list.h"
|
||||
|
||||
struct nvk_device;
|
||||
struct nvk_image_plane;
|
||||
|
||||
struct nvk_device_memory {
|
||||
struct vk_device_memory vk;
|
||||
|
||||
struct list_head link;
|
||||
|
||||
struct nvk_image_plane *dedicated_image_plane;
|
||||
|
||||
struct nouveau_ws_bo *bo;
|
||||
|
||||
void *map;
|
||||
|
@@ -409,15 +409,8 @@ nvk_image_plane_alloc_internal(struct nvk_device *dev,
|
||||
.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
|
||||
@@ -610,7 +603,14 @@ nvk_image_plane_bind(struct nvk_image_plane *plane,
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user