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/d3d12 | |
| 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/d3d12')
| -rw-r--r-- | tools/gfx/d3d12/d3d12-helper-functions.cpp | 21 | ||||
| -rw-r--r-- | tools/gfx/d3d12/d3d12-helper-functions.h | 3 |
2 files changed, 24 insertions, 0 deletions
diff --git a/tools/gfx/d3d12/d3d12-helper-functions.cpp b/tools/gfx/d3d12/d3d12-helper-functions.cpp index 5f9102d0c..34efa8401 100644 --- a/tools/gfx/d3d12/d3d12-helper-functions.cpp +++ b/tools/gfx/d3d12/d3d12-helper-functions.cpp @@ -613,6 +613,27 @@ void translatePostBuildInfoDescs( } // namespace d3d12 +Result SLANG_MCALL getD3D12Adapters(List<AdapterInfo>& outAdapters) +{ + List<ComPtr<IDXGIAdapter>> dxgiAdapters; + DeviceCheckFlags flags = DeviceCheckFlag::UseHardwareDevice; + SLANG_RETURN_ON_FAIL(D3DUtil::findAdapters(flags, UnownedStringSlice(), dxgiAdapters)); + + outAdapters.clear(); + for (const auto& dxgiAdapter : dxgiAdapters) + { + DXGI_ADAPTER_DESC desc; + dxgiAdapter->GetDesc(&desc); + AdapterInfo info = {}; + auto name = String::fromWString(desc.Description); + memcpy(info.name, name.getBuffer(), Math::Min(name.getLength(), (Index)sizeof(AdapterInfo::name) - 1)); + info.vendorID = desc.VendorId; + info.deviceID = desc.DeviceId; + outAdapters.add(info); + } + return SLANG_OK; +} + Result SLANG_MCALL createD3D12Device(const IDevice::Desc* desc, IDevice** outDevice) { RefPtr<d3d12::DeviceImpl> result = new d3d12::DeviceImpl(); diff --git a/tools/gfx/d3d12/d3d12-helper-functions.h b/tools/gfx/d3d12/d3d12-helper-functions.h index 97f75a654..52b587529 100644 --- a/tools/gfx/d3d12/d3d12-helper-functions.h +++ b/tools/gfx/d3d12/d3d12-helper-functions.h @@ -6,6 +6,7 @@ #include "d3d12-shader-object-layout.h" #include "d3d12-submitter.h" #include "../../../source/core/slang-short-list.h" +#include "../../../source/core/slang-list.h" #ifndef __ID3D12GraphicsCommandList1_FWD_DEFINED__ // If can't find a definition of CommandList1, just use an empty definition @@ -84,6 +85,8 @@ void translatePostBuildInfoDescs( } // namespace d3d12 +Result SLANG_MCALL getD3D12Adapters(List<AdapterInfo>& outAdapters); + Result SLANG_MCALL createD3D12Device(const IDevice::Desc* desc, IDevice** outDevice); } // namespace gfx |
