From 8ea3854d94eb1ff213be716a38493d601784810b Mon Sep 17 00:00:00 2001 From: skallweitNV <64953474+skallweitNV@users.noreply.github.com> Date: Thu, 6 Jun 2024 18:08:38 +0200 Subject: work on gfx metal backend (#4287) * implement sampler state * implement input layout * implement fence object * buffer implementation * texture implementation * cleanup * add adapter enumeration * supported formats and allocation info * work on device and implement readBufferResource * skeleton for transient resource heap * initial work on command queue / buffers / encoders * fix uploading initial buffer data * implement buffer resource view * string utility functions * wip query pool implementation * cleanup * swapchain * wip * remove plain buffer view * extend gfxGetDeviceTypeName with metal * basic support for resource binding with compute shaders * needed for metal bindings * replace assert(0) with SLANG_UNIMPLEMENTED_X --- tools/gfx/render.cpp | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'tools/gfx/render.cpp') diff --git a/tools/gfx/render.cpp b/tools/gfx/render.cpp index f6e32fef8..0dd1e5bf5 100644 --- a/tools/gfx/render.cpp +++ b/tools/gfx/render.cpp @@ -20,6 +20,7 @@ Result SLANG_MCALL createCPUDevice(const IDevice::Desc* desc, IDevice** outDevic Result SLANG_MCALL getD3D11Adapters(List& outAdapters); Result SLANG_MCALL getD3D12Adapters(List& outAdapters); Result SLANG_MCALL getVKAdapters(List& outAdapters); +Result SLANG_MCALL getMetalAdapters(List& outAdapters); Result SLANG_MCALL getCUDAAdapters(List& outAdapters); Result SLANG_MCALL reportD3DLiveObjects(); @@ -274,6 +275,14 @@ extern "C" case DeviceType::CUDA: SLANG_RETURN_ON_FAIL(getCUDAAdapters(adapters)); break; +#endif +#if SLANG_APPLE_FAMILY + case DeviceType::Vulkan: + SLANG_RETURN_ON_FAIL(getVKAdapters(adapters)); + break; + case DeviceType::Metal: + SLANG_RETURN_ON_FAIL(getMetalAdapters(adapters)); + break; #endif case DeviceType::CPU: return SLANG_E_NOT_IMPLEMENTED; @@ -330,21 +339,38 @@ extern "C" } break; #elif SLANG_APPLE_FAMILY - case DeviceType::Default: + case DeviceType::Vulkan: + { + return createVKDevice(desc, outDevice); + } case DeviceType::Metal: { return createMetalDevice(desc, outDevice); } - case DeviceType::Vulkan: + case DeviceType::Default: { - return createVKDevice(desc, outDevice); + IDevice::Desc newDesc = *desc; + newDesc.deviceType = DeviceType::Metal; + if (_createDevice(&newDesc, outDevice) == SLANG_OK) + return SLANG_OK; + newDesc.deviceType = DeviceType::Vulkan; + if (_createDevice(&newDesc, outDevice) == SLANG_OK) + return SLANG_OK; + return SLANG_FAIL; } #elif SLANG_LINUX_FAMILY && !defined(__CYGWIN__) - case DeviceType::Default: case DeviceType::Vulkan: { return createVKDevice(desc, outDevice); } + case DeviceType::Default: + { + IDevice::Desc newDesc = *desc; + newDesc.deviceType = DeviceType::Vulkan; + if (_createDevice(&newDesc, outDevice) == SLANG_OK) + return SLANG_OK; + return SLANG_FAIL; + } #endif case DeviceType::CUDA: { @@ -415,6 +441,8 @@ extern "C" return "OpenGL"; case gfx::DeviceType::Vulkan: return "Vulkan"; + case gfx::DeviceType::Metal: + return "Metal"; case gfx::DeviceType::CPU: return "CPU"; case gfx::DeviceType::CUDA: -- cgit v1.2.3