diff options
| author | skallweitNV <64953474+skallweitNV@users.noreply.github.com> | 2024-06-06 18:08:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-06 09:08:38 -0700 |
| commit | 8ea3854d94eb1ff213be716a38493d601784810b (patch) | |
| tree | 071be96574be4afa54afe0a1fe0d66f10eb2cd80 /tools/gfx/render.cpp | |
| parent | 40d48bf1742cf21cc1ad3dd00d11fb04f37e512f (diff) | |
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
Diffstat (limited to 'tools/gfx/render.cpp')
| -rw-r--r-- | tools/gfx/render.cpp | 36 |
1 files changed, 32 insertions, 4 deletions
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<AdapterInfo>& outAdapters); Result SLANG_MCALL getD3D12Adapters(List<AdapterInfo>& outAdapters); Result SLANG_MCALL getVKAdapters(List<AdapterInfo>& outAdapters); +Result SLANG_MCALL getMetalAdapters(List<AdapterInfo>& outAdapters); Result SLANG_MCALL getCUDAAdapters(List<AdapterInfo>& outAdapters); Result SLANG_MCALL reportD3DLiveObjects(); @@ -275,6 +276,14 @@ extern "C" 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; default: @@ -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: |
