diff options
| author | Simon Kallweit <simon.kallweit@gmail.com> | 2024-05-27 06:03:13 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-27 15:03:13 +0200 |
| commit | d9443d670ef8413971fe7c3f02368b60a7fc5904 (patch) | |
| tree | 001e763846b23814b0e4960991fc457d7b580a0f /tools/gfx/metal/metal-command-queue.cpp | |
| parent | 4f1cbf6f4d561320b8e3c73b871cc95dd13c6207 (diff) | |
[gfx] metal backend skeleton (#4223)
* add metal-cpp submodule
* add metal-cpp cmake target
* gfx metal backend skeleton
* add premake support
* add foundation framework
* add metal-cpp include to premake
* update vs project file
---------
Co-authored-by: Simon Kallweit <skallweit@nvidia.com>
Co-authored-by: Jay Kwak <82421531+jkwak-work@users.noreply.github.com>
Diffstat (limited to 'tools/gfx/metal/metal-command-queue.cpp')
| -rw-r--r-- | tools/gfx/metal/metal-command-queue.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/tools/gfx/metal/metal-command-queue.cpp b/tools/gfx/metal/metal-command-queue.cpp new file mode 100644 index 000000000..c8b36ff1e --- /dev/null +++ b/tools/gfx/metal/metal-command-queue.cpp @@ -0,0 +1,75 @@ +// metal-command-queue.cpp +#include "metal-command-queue.h" + +#include "metal-command-buffer.h" +#include "metal-fence.h" + +namespace gfx +{ + +using namespace Slang; + +namespace metal +{ + +ICommandQueue* CommandQueueImpl::getInterface(const Guid& guid) +{ + if (guid == GfxGUID::IID_ISlangUnknown || guid == GfxGUID::IID_ICommandQueue) + return static_cast<ICommandQueue*>(this); + return nullptr; +} + +CommandQueueImpl::~CommandQueueImpl() +{ +} + +void CommandQueueImpl::init(DeviceImpl* renderer) +{ + m_renderer = renderer; + + MTL::Device* device = m_renderer->m_device; + m_commandQueue = device->newCommandQueue(8); +} + +void CommandQueueImpl::waitOnHost() +{ +} + +Result CommandQueueImpl::getNativeHandle(InteropHandle* outHandle) +{ + outHandle->api = InteropHandleAPI::Metal; + outHandle->handleValue = reinterpret_cast<intptr_t>(m_commandQueue); + return SLANG_OK; +} + +const CommandQueueImpl::Desc& CommandQueueImpl::getDesc() { return m_desc; } + +Result CommandQueueImpl::waitForFenceValuesOnDevice( + GfxCount fenceCount, IFence** fences, uint64_t* waitValues) +{ + return SLANG_E_NOT_IMPLEMENTED; +} + +void CommandQueueImpl::queueSubmitImpl( + uint32_t count, ICommandBuffer* const* commandBuffers, IFence* fence, uint64_t valueToSignal) +{ + for (uint32_t i = 0; i < count; ++i) + { + CommandBufferImpl* cmdBufImpl = static_cast<CommandBufferImpl*>(commandBuffers[i]); + cmdBufImpl->m_commandBuffer->presentDrawable(m_renderer->m_drawable); + cmdBufImpl->m_commandBuffer->commit(); + } +} + +void CommandQueueImpl::executeCommandBuffers( + GfxCount count, ICommandBuffer* const* commandBuffers, IFence* fence, uint64_t valueToSignal) +{ + if (count == 0 && fence == nullptr) + { + return; + } + queueSubmitImpl(count, commandBuffers, fence, valueToSignal); +} + +} // namespace metal +} // namespace gfx |
