mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 18:10:11 +01:00
nvk: Add a dedicated_image to nvk_device_memory
Also refactor the dedicated image handling a tiny bit to make the next bit easier. Reviewed-by: Mel Henning <mhenning@darkrefraction.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38702>
This commit is contained in:
parent
9bd51ce508
commit
02b4647a1c
2 changed files with 13 additions and 8 deletions
|
|
@ -133,6 +133,11 @@ nvk_AllocateMemory(VkDevice device,
|
||||||
struct nvk_device_memory *mem;
|
struct nvk_device_memory *mem;
|
||||||
VkResult result = VK_SUCCESS;
|
VkResult result = VK_SUCCESS;
|
||||||
|
|
||||||
|
mem = vk_device_memory_create(&dev->vk, pAllocateInfo,
|
||||||
|
pAllocator, sizeof(*mem));
|
||||||
|
if (!mem)
|
||||||
|
return vk_error(dev, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||||
|
|
||||||
const VkImportMemoryFdInfoKHR *fd_info =
|
const VkImportMemoryFdInfoKHR *fd_info =
|
||||||
vk_find_struct_const(pAllocateInfo->pNext, IMPORT_MEMORY_FD_INFO_KHR);
|
vk_find_struct_const(pAllocateInfo->pNext, IMPORT_MEMORY_FD_INFO_KHR);
|
||||||
const VkExportMemoryAllocateInfo *export_info =
|
const VkExportMemoryAllocateInfo *export_info =
|
||||||
|
|
@ -153,10 +158,12 @@ nvk_AllocateMemory(VkDevice device,
|
||||||
uint32_t alignment = pdev->nvkmd->bind_align_B;
|
uint32_t alignment = pdev->nvkmd->bind_align_B;
|
||||||
|
|
||||||
uint8_t pte_kind = 0, tile_mode = 0;
|
uint8_t pte_kind = 0, tile_mode = 0;
|
||||||
if (dedicated_info != NULL) {
|
if (dedicated_info != NULL && dedicated_info->image != VK_NULL_HANDLE) {
|
||||||
VK_FROM_HANDLE(nvk_image, image, dedicated_info->image);
|
VK_FROM_HANDLE(nvk_image, image, dedicated_info->image);
|
||||||
if (image != NULL &&
|
|
||||||
image->vk.tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
|
mem->dedicated_image = image;
|
||||||
|
|
||||||
|
if (image->vk.tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
|
||||||
/* This image might be shared with GL so we need to set the BO flags
|
/* This image might be shared with GL so we need to set the BO flags
|
||||||
* such that GL can bind and use it.
|
* such that GL can bind and use it.
|
||||||
*/
|
*/
|
||||||
|
|
@ -170,11 +177,6 @@ nvk_AllocateMemory(VkDevice device,
|
||||||
const uint64_t aligned_size =
|
const uint64_t aligned_size =
|
||||||
align64(pAllocateInfo->allocationSize, alignment);
|
align64(pAllocateInfo->allocationSize, alignment);
|
||||||
|
|
||||||
mem = vk_device_memory_create(&dev->vk, pAllocateInfo,
|
|
||||||
pAllocator, sizeof(*mem));
|
|
||||||
if (!mem)
|
|
||||||
return vk_error(dev, VK_ERROR_OUT_OF_HOST_MEMORY);
|
|
||||||
|
|
||||||
const bool is_import = fd_info && fd_info->handleType;
|
const bool is_import = fd_info && fd_info->handleType;
|
||||||
if (is_import) {
|
if (is_import) {
|
||||||
assert(fd_info->handleType ==
|
assert(fd_info->handleType ==
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,14 @@
|
||||||
|
|
||||||
#include "util/list.h"
|
#include "util/list.h"
|
||||||
|
|
||||||
|
struct nvk_image;
|
||||||
struct nvkmd_mem;
|
struct nvkmd_mem;
|
||||||
|
|
||||||
struct nvk_device_memory {
|
struct nvk_device_memory {
|
||||||
struct vk_device_memory vk;
|
struct vk_device_memory vk;
|
||||||
|
|
||||||
|
struct nvk_image *dedicated_image;
|
||||||
|
|
||||||
struct nvkmd_mem *mem;
|
struct nvkmd_mem *mem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue