| 318 | } |
| 319 | |
| 320 | OIDN_API OIDNDevice oidnNewDeviceByUUID(const void* uuid) |
| 321 | { |
| 322 | Ref<Device> device = nullptr; |
| 323 | |
| 324 | OIDN_TRY |
| 325 | OIDN_INIT_CONTEXT(ctx, DeviceType::Default); |
| 326 | |
| 327 | if (uuid == nullptr) |
| 328 | throw Exception(Error::InvalidArgument, "UUID pointer is null"); |
| 329 | |
| 330 | // Find the physical device with the specified UUID |
| 331 | const int numDevices = ctx.getNumPhysicalDevices(); |
| 332 | int foundID = -1; |
| 333 | |
| 334 | for (int i = 0; i < numDevices; ++i) |
| 335 | { |
| 336 | const auto& physicalDevice = ctx.getPhysicalDevice(i); |
| 337 | if (physicalDevice->uuidSupported && |
| 338 | memcmp(uuid, physicalDevice->uuid.bytes, sizeof(physicalDevice->uuid.bytes)) == 0) |
| 339 | { |
| 340 | foundID = i; |
| 341 | break; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | if (foundID < 0) |
| 346 | throw Exception(Error::InvalidArgument, "no physical device found with specified UUID"); |
| 347 | |
| 348 | device = ctx.newDevice(foundID); |
| 349 | OIDN_CATCH |
| 350 | |
| 351 | return reinterpret_cast<OIDNDevice>(device.detach()); |
| 352 | } |
| 353 | |
| 354 | OIDN_API OIDNDevice oidnNewDeviceByLUID(const void* luid) |
| 355 | { |
nothing calls this directly
no test coverage detected