| 142 | } |
| 143 | |
| 144 | cudaExternalSemaphore_t importExternalSemaphore(const Fence* fence) |
| 145 | { |
| 146 | FALCOR_CHECK(fence, "'fence' is nullptr."); |
| 147 | FALCOR_CHECK(fence->getDesc().shared, "'fence' must be created with shared=true."); |
| 148 | SharedFenceApiHandle sharedHandle = fence->getSharedApiHandle(); |
| 149 | FALCOR_CHECK(sharedHandle, "Fence shared handle creation failed."); |
| 150 | |
| 151 | cudaExternalSemaphoreHandleDesc desc = {}; |
| 152 | switch (fence->getDevice()->getType()) |
| 153 | { |
| 154 | #if FALCOR_WINDOWS |
| 155 | case Device::Type::D3D12: |
| 156 | desc.type = cudaExternalSemaphoreHandleTypeD3D12Fence; |
| 157 | desc.handle.win32.handle = sharedHandle; |
| 158 | break; |
| 159 | case Device::Type::Vulkan: |
| 160 | desc.type = cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32; |
| 161 | desc.handle.win32.handle = sharedHandle; |
| 162 | break; |
| 163 | #elif FALCOR_LINUX |
| 164 | case Device::Type::Vulkan: |
| 165 | desc.type = cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd; |
| 166 | desc.handle.fd = (int)reinterpret_cast<intptr_t>(sharedHandle); |
| 167 | break; |
| 168 | #endif |
| 169 | default: |
| 170 | FALCOR_THROW("Unsupported device type '{}'.", fence->getDevice()->getType()); |
| 171 | } |
| 172 | |
| 173 | cudaExternalSemaphore_t extSem; |
| 174 | FALCOR_CUDA_CHECK(cudaImportExternalSemaphore(&extSem, &desc)); |
| 175 | return extSem; |
| 176 | } |
| 177 | |
| 178 | void destroyExternalSemaphore(cudaExternalSemaphore_t extSem) |
| 179 | { |
no test coverage detected