Hi,
Im trying to import a Vulkan semaphore for using by CUDA on windows platform, but always get cudaErrorInvalidValue error.
Considering I have already a HANDLE for the Vulkan semaphore object, the Cuda side is at DLL1 as follows:
void test_createCudaImportSemaphor(HANDLE handle)
{
cudaExternalSemaphoreHandleDesc externalSemaphoreHandleDesc;
externalSemaphoreHandleDesc.flags = 0;
externalSemaphoreHandleDesc.type = cudaExternalSemaphoreHandleTypeOpaqueWin32;
externalSemaphoreHandleDesc.handle.win32.handle = handle;
cudaExternalSemaphore_t cudaExternalSemaphore;
cudaError_t err = cudaImportExternalSemaphore(&cudaExternalSemaphore, &externalSemaphoreHandleDesc);
////////////////////////////////////////////////
// err= 1 (cudaErrorInvalidValue ) why ????
////////////////////////////////////////////////
// destory
err = cudaDestroyExternalSemaphore(cudaExternalSemaphore);
}
The Vulkan side that creates the semaphore exist in DLL2 as follows:
void test_exportVulkanSemphoreToCuda(vk::Device device)
{
// create semaphore that can be exported (windows platform)
vk::ExportSemaphoreWin32HandleInfoKHR exportSemaphoreWin32HandleInfoKHR;
WindowsSecurityAttributes cWinSecurityAttributes; // taken from cuda samples 02_graphics
exportSemaphoreWin32HandleInfoKHR.pAttributes = &cWinSecurityAttributes;
exportSemaphoreWin32HandleInfoKHR.dwAccess = DXGI_SHARED_RESOURCE_READ | DXGI_SHARED_RESOURCE_WRITE;
vk::ExportSemaphoreCreateInfo exportSemaphoreCreateInfo;
exportSemaphoreCreateInfo.pNext = &exportSemaphoreWin32HandleInfoKHR;
exportSemaphoreCreateInfo.handleTypes = vk::ExternalSemaphoreHandleTypeFlagBits::eOpaqueWin32;
vk::SemaphoreCreateInfo semaphoreCreateInfo;
semaphoreCreateInfo.pNext = &exportSemaphoreCreateInfo;
vk::UniqueSemaphore upSemaphore = device.createSemaphoreUnique(semaphoreCreateInfo);
// get semaphore windows handle
vk::SemaphoreGetWin32HandleInfoKHR semaphoreGetWin32HandleInfoKHR = {};
semaphoreGetWin32HandleInfoKHR.semaphore = upSemaphore.get();
semaphoreGetWin32HandleInfoKHR.handleType = vk::ExternalSemaphoreHandleTypeFlagBits::eOpaqueWin32;
HANDLE handle = device.getSemaphoreWin32HandleKHR(semaphoreGetWin32HandleInfoKHR);
test_createCudaImportSemaphor(handle);
CloseHandle(handle);
}
I can’t figure out what is the problem
Thanks