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/d3d11 | |
| 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/d3d11')
| -rw-r--r-- | tools/gfx/d3d11/d3d11-helper-functions.cpp | 21 | ||||
| -rw-r--r-- | tools/gfx/d3d11/d3d11-helper-functions.h | 3 |
2 files changed, 24 insertions, 0 deletions
diff --git a/tools/gfx/d3d11/d3d11-helper-functions.cpp b/tools/gfx/d3d11/d3d11-helper-functions.cpp index c797979ce..93065077a 100644 --- a/tools/gfx/d3d11/d3d11-helper-functions.cpp +++ b/tools/gfx/d3d11/d3d11-helper-functions.cpp @@ -345,6 +345,27 @@ namespace d3d11 } } // namespace d3d11 +Result SLANG_MCALL getD3D11Adapters(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 createD3D11Device(const IDevice::Desc* desc, IDevice** outDevice) { RefPtr<d3d11::DeviceImpl> result = new d3d11::DeviceImpl(); diff --git a/tools/gfx/d3d11/d3d11-helper-functions.h b/tools/gfx/d3d11/d3d11-helper-functions.h index 266ba0973..9f115d88d 100644 --- a/tools/gfx/d3d11/d3d11-helper-functions.h +++ b/tools/gfx/d3d11/d3d11-helper-functions.h @@ -3,6 +3,7 @@ #include "slang-gfx.h" #include "d3d11-base.h" +#include "../../../source/core/slang-list.h" namespace gfx { @@ -281,6 +282,8 @@ namespace d3d11 D3D11_SHADER_RESOURCE_VIEW_DESC& descOut); } // namespace d3d11 +Result SLANG_MCALL getD3D11Adapters(List<AdapterInfo>& outAdapters); + Result SLANG_MCALL createD3D11Device(const IDevice::Desc* desc, IDevice** outDevice); } // namespace gfx |
