Skip to content

fix llvm 5 compile #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: radv-wip-steamvr
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/amd/common/ac_llvm_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,21 @@ void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes)
llvm::Argument *A = llvm::unwrap<llvm::Argument>(val);
llvm::AttrBuilder B;
B.addDereferenceableAttr(bytes);
#if HAVE_LLVM >= 0x0500
A->addAttr(llvm::AttributeList::get(A->getContext(), A->getArgNo() + 1, B));
#else
A->addAttr(llvm::AttributeSet::get(A->getContext(), A->getArgNo() + 1, B));
#endif
}

bool ac_is_sgpr_param(LLVMValueRef arg)
{
llvm::Argument *A = llvm::unwrap<llvm::Argument>(arg);
#if HAVE_LLVM >= 0x0500
llvm::AttributeList AS = A->getParent()->getAttributes();
#else
llvm::AttributeSet AS = A->getParent()->getAttributes();
#endif
unsigned ArgNo = A->getArgNo();
return AS.hasAttribute(ArgNo + 1, llvm::Attribute::ByVal) ||
AS.hasAttribute(ArgNo + 1, llvm::Attribute::InReg);
Expand Down
93 changes: 80 additions & 13 deletions src/amd/vulkan/radv_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ static const VkExtensionProperties instance_extensions[] = {
.specVersion = 5,
},
#endif
{
.extensionName = VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
.specVersion = 1,
},
{
.extensionName = VK_KHX_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME,
.specVersion = 1,
},
{
.extensionName = VK_KHX_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME,
.specVersion = 1,
},
};

static const VkExtensionProperties common_device_extensions[] = {
Expand Down Expand Up @@ -115,6 +127,18 @@ static const VkExtensionProperties common_device_extensions[] = {
.extensionName = VK_NV_DEDICATED_ALLOCATION_EXTENSION_NAME,
.specVersion = 1,
},
{
.extensionName = VK_KHX_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME,
.specVersion = 1,
},
{
.extensionName = VK_KHX_EXTERNAL_MEMORY_EXTENSION_NAME,
.specVersion = 1,
},
{
.extensionName = VK_KHX_EXTERNAL_MEMORY_FD_EXTENSION_NAME,
.specVersion = 1,
},
};

static VkResult
Expand Down Expand Up @@ -255,7 +279,6 @@ radv_physical_device_finish(struct radv_physical_device *device)
close(device->local_fd);
}


static void *
default_alloc_func(void *pUserData, size_t size, size_t align,
VkSystemAllocationScope allocationScope)
Expand Down Expand Up @@ -1694,7 +1717,7 @@ VkResult radv_AllocateMemory(
VkResult result;
enum radeon_bo_domain domain;
uint32_t flags = 0;
const VkDedicatedAllocationMemoryAllocateInfoNV *dedicate_info = NULL;

assert(pAllocateInfo->sType == VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO);

if (pAllocateInfo->allocationSize == 0) {
Expand All @@ -1703,15 +1726,10 @@ VkResult radv_AllocateMemory(
return VK_SUCCESS;
}

vk_foreach_struct(ext, pAllocateInfo->pNext) {
switch (ext->sType) {
case VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV:
dedicate_info = (const VkDedicatedAllocationMemoryAllocateInfoNV *)ext;
break;
default:
break;
}
}
const VkImportMemoryFdInfoKHX *import_info =
vk_find_struct_const(pAllocateInfo->pNext, IMPORT_MEMORY_FD_INFO_KHX);
const VkDedicatedAllocationMemoryAllocateInfoNV *dedicate_info =
vk_find_struct_const(pAllocateInfo->pNext, DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV);

mem = vk_alloc2(&device->alloc, pAllocator, sizeof(*mem), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
Expand All @@ -1726,6 +1744,17 @@ VkResult radv_AllocateMemory(
mem->buffer = NULL;
}

if (import_info) {
assert(import_info->handleType ==
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHX);
mem->bo = device->ws->buffer_from_fd(device->ws, import_info->fd,
NULL, NULL);
if (!mem->bo)
goto fail;
else
goto out_success;
}

uint64_t alloc_size = align_u64(pAllocateInfo->allocationSize, 4096);
if (pAllocateInfo->memoryTypeIndex == RADV_MEM_TYPE_GTT_WRITE_COMBINE ||
pAllocateInfo->memoryTypeIndex == RADV_MEM_TYPE_GTT_CACHED)
Expand All @@ -1749,7 +1778,7 @@ VkResult radv_AllocateMemory(
goto fail;
}
mem->type_index = pAllocateInfo->memoryTypeIndex;

out_success:
*pMem = radv_device_memory_to_handle(mem);

return VK_SUCCESS;
Expand Down Expand Up @@ -2695,7 +2724,6 @@ void radv_DestroySampler(
vk_free2(&device->alloc, pAllocator, sampler);
}


/* vk_icd.h does not declare this function, so we declare it here to
* suppress Wmissing-prototypes.
*/
Expand Down Expand Up @@ -2739,3 +2767,42 @@ vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *pSupportedVersion)
*pSupportedVersion = MIN2(*pSupportedVersion, 3u);
return VK_SUCCESS;
}

VkResult radv_GetMemoryFdKHX(VkDevice _device,
VkDeviceMemory _memory,
VkExternalMemoryHandleTypeFlagsKHX handleType,
int *pFD)
{
RADV_FROM_HANDLE(radv_device, device, _device);
RADV_FROM_HANDLE(radv_device_memory, memory, _memory);

/* We support only one handle type. */
assert(handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHX);

bool ret = radv_get_memory_fd(device, memory, pFD);
if (ret == false)
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
return VK_SUCCESS;
}

VkResult radv_GetMemoryFdPropertiesKHX(VkDevice _device,
VkExternalMemoryHandleTypeFlagBitsKHX handleType,
int fd,
VkMemoryFdPropertiesKHX *pMemoryFdProperties)
{
/* The valid usage section for this function says:
*
* "handleType must not be one of the handle types defined as opaque."
*
* Since we only handle opaque handles for now, there are no FD properties.
*/
return VK_ERROR_INVALID_EXTERNAL_HANDLE_KHX;
}

VkResult radv_GetSemaphoreFdKHX(VkDevice device,
VkSemaphore semaphore,
VkExternalSemaphoreHandleTypeFlagsKHX handleType,
int *pFd)
{
return VK_SUCCESS;
}
6 changes: 6 additions & 0 deletions src/amd/vulkan/radv_entrypoints_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
'VK_KHR_wayland_surface',
'VK_KHR_xcb_surface',
'VK_KHR_xlib_surface',
'VK_KHX_external_memory_capabilities',
'VK_KHX_external_memory',
'VK_KHX_external_memory_fd',
'VK_KHX_external_semaphore_capabilities',
'VK_KHX_external_semaphore',
'VK_KHX_external_semaphore_fd'
]

# We generate a static hash table for entry point lookup
Expand Down
Loading