summaryrefslogtreecommitdiff
path: root/tools/gfx/render.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/gfx/render.cpp')
-rw-r--r--tools/gfx/render.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/tools/gfx/render.cpp b/tools/gfx/render.cpp
index b19824671..84f537705 100644
--- a/tools/gfx/render.cpp
+++ b/tools/gfx/render.cpp
@@ -1,6 +1,7 @@
// render.cpp
#include "renderer-shared.h"
#include "../../source/core/slang-math.h"
+#include "../../source/core/slang-blob.h"
#include "open-gl/render-gl.h"
#include "debug-layer/debug-device.h"
@@ -15,6 +16,11 @@ Result SLANG_MCALL createVKDevice(const IDevice::Desc* desc, IDevice** outDevice
Result SLANG_MCALL createCUDADevice(const IDevice::Desc* desc, IDevice** outDevice);
Result SLANG_MCALL createCPUDevice(const IDevice::Desc* desc, IDevice** outDevice);
+Result SLANG_MCALL getD3D11Adapters(List<AdapterInfo>& outAdapters);
+Result SLANG_MCALL getD3D12Adapters(List<AdapterInfo>& outAdapters);
+Result SLANG_MCALL getVKAdapters(List<AdapterInfo>& outAdapters);
+Result SLANG_MCALL getCUDAAdapters(List<AdapterInfo>& outAdapters);
+
static bool debugLayerEnabled = false;
bool isGfxDebugLayerEnabled() { return debugLayerEnabled; }
@@ -233,6 +239,48 @@ extern "C"
return SLANG_OK;
}
+ SLANG_GFX_API SlangResult SLANG_MCALL gfxGetAdapters(DeviceType type, ISlangBlob** outAdaptersBlob)
+ {
+ List<AdapterInfo> adapters;
+
+ switch (type)
+ {
+#if SLANG_WINDOWS_FAMILY
+ case DeviceType::DirectX11:
+ SLANG_RETURN_ON_FAIL(getD3D11Adapters(adapters));
+ break;
+ case DeviceType::DirectX12:
+ SLANG_RETURN_ON_FAIL(getD3D12Adapters(adapters));
+ break;
+ case DeviceType::OpenGl:
+ return SLANG_E_NOT_IMPLEMENTED;
+ case DeviceType::Vulkan:
+ SLANG_RETURN_ON_FAIL(getVKAdapters(adapters));
+ break;
+ case DeviceType::CUDA:
+ SLANG_RETURN_ON_FAIL(getCUDAAdapters(adapters));
+ break;
+#elif SLANG_LINUX_FAMILY && !defined(__CYGWIN__)
+ case DeviceType::Vulkan:
+ SLANG_RETURN_ON_FAIL(getVKAdapters(adapters));
+ break;
+ case DeviceType::CUDA:
+ SLANG_RETURN_ON_FAIL(getCUDAAdapters(adapters));
+ break;
+#endif
+ case DeviceType::CPU:
+ return SLANG_E_NOT_IMPLEMENTED;
+ default:
+ return SLANG_E_INVALID_ARG;
+ }
+
+ auto adaptersBlob = RawBlob::create(adapters.getBuffer(), adapters.getCount() * sizeof(AdapterInfo));
+ if (outAdaptersBlob)
+ returnComPtr(outAdaptersBlob, adaptersBlob);
+
+ return SLANG_OK;
+ }
+
SlangResult _createDevice(const IDevice::Desc* desc, IDevice** outDevice)
{
switch (desc->deviceType)