diff options
| author | skallweitNV <64953474+skallweitNV@users.noreply.github.com> | 2022-11-03 16:58:49 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-03 11:58:49 -0400 |
| commit | 8f9d58416934cbf850f0f01e5fefbdfe1b02d4d6 (patch) | |
| tree | 3d376e772dcaeb7d0ef55d091fe49e33a6f57fb1 /tools/gfx/cuda/cuda-helper-functions.cpp | |
| parent | 203b5d7a5014d7f140345567e065cbf57b57b819 (diff) | |
Add gfxGetAdapters function (currently implemented for D3D12/Vulkan) (#2486)
* Add gfxGetAdapters function (currently implemented for D3D12/Vulkan)
* Extend to handle DirectX11 and CUDA
* Use blob to return adapter list and add AdapterList helper
* Replace strncpy with memcpy
Co-authored-by: jsmall-nvidia <jsmall@nvidia.com>
Diffstat (limited to 'tools/gfx/cuda/cuda-helper-functions.cpp')
| -rw-r--r-- | tools/gfx/cuda/cuda-helper-functions.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/gfx/cuda/cuda-helper-functions.cpp b/tools/gfx/cuda/cuda-helper-functions.cpp index 6325d9fc6..702caf253 100644 --- a/tools/gfx/cuda/cuda-helper-functions.cpp +++ b/tools/gfx/cuda/cuda-helper-functions.cpp @@ -72,6 +72,22 @@ void _optixLogCallback(unsigned int level, const char* tag, const char* message, # endif } // namespace cuda +Result SLANG_MCALL getCUDAAdapters(List<AdapterInfo>& outAdapters) +{ + int count; + cudaGetDeviceCount(&count); + for (int i = 0; i < count; i++) + { + cudaDeviceProp prop; + cudaGetDeviceProperties(&prop, i); + AdapterInfo info = {}; + memcpy(info.name, prop.name, Math::Min(strlen(prop.name), sizeof(AdapterInfo::name) - 1)); + outAdapters.add(info); + } + + return SLANG_OK; +} + Result SLANG_MCALL createCUDADevice(const IDevice::Desc* desc, IDevice** outDevice) { RefPtr<cuda::DeviceImpl> result = new cuda::DeviceImpl(); @@ -80,6 +96,13 @@ returnComPtr(outDevice, result); return SLANG_OK; } #else + +Result SLANG_MCALL getCUDAAdapters(List<AdapterInfo>& outAdapters) +{ + SLANG_UNUSED(outAdapters); + return SLANG_FAIL; +} + Result SLANG_MCALL createCUDADevice(const IDevice::Desc* desc, IDevice** outDevice) { SLANG_UNUSED(desc); |
