MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / importExternalSemaphore

Function importExternalSemaphore

Source/Falcor/Utils/CudaUtils.cpp:144–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144cudaExternalSemaphore_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
178void destroyExternalSemaphore(cudaExternalSemaphore_t extSem)
179{

Callers 1

ExternalSemaphoreMethod · 0.85

Calls 3

getSharedApiHandleMethod · 0.45
getTypeMethod · 0.45
getDeviceMethod · 0.45

Tested by

no test coverage detected