summaryrefslogtreecommitdiffstats
path: root/tools/gfx/metal/metal-command-buffer.cpp
diff options
context:
space:
mode:
authorSimon Kallweit <simon.kallweit@gmail.com>2024-05-27 06:03:13 -0700
committerGitHub <noreply@github.com>2024-05-27 15:03:13 +0200
commitd9443d670ef8413971fe7c3f02368b60a7fc5904 (patch)
tree001e763846b23814b0e4960991fc457d7b580a0f /tools/gfx/metal/metal-command-buffer.cpp
parent4f1cbf6f4d561320b8e3c73b871cc95dd13c6207 (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-buffer.cpp')
-rw-r--r--tools/gfx/metal/metal-command-buffer.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/tools/gfx/metal/metal-command-buffer.cpp b/tools/gfx/metal/metal-command-buffer.cpp
new file mode 100644
index 000000000..08caa03dd
--- /dev/null
+++ b/tools/gfx/metal/metal-command-buffer.cpp
@@ -0,0 +1,86 @@
+// metal-command-buffer.cpp
+#include "metal-command-buffer.h"
+
+#include "metal-device.h"
+#include "metal-command-encoder.h"
+#include "metal-shader-object.h"
+#include "metal-command-queue.h"
+
+namespace gfx
+{
+
+using namespace Slang;
+
+namespace metal
+{
+
+ICommandBuffer* CommandBufferImpl::getInterface(const Guid& guid)
+{
+ if (guid == GfxGUID::IID_ISlangUnknown || guid == GfxGUID::IID_ICommandBuffer)
+ return static_cast<ICommandBuffer*>(this);
+ return nullptr;
+}
+
+void CommandBufferImpl::comFree() { }
+
+Result CommandBufferImpl::init(DeviceImpl* renderer, TransientResourceHeapImpl* transientHeap)
+{
+ m_renderer = renderer;
+ m_commandBuffer = m_renderer->m_commandQueue->commandBuffer();
+ return SLANG_OK;
+}
+
+void CommandBufferImpl::encodeRenderCommands(
+ IRenderPassLayout* renderPass, IFramebuffer* framebuffer, IRenderCommandEncoder** outEncoder)
+{
+ if (!m_renderCommandEncoder)
+ {
+ m_renderCommandEncoder = new RenderCommandEncoder;
+ m_renderCommandEncoder->init(this);
+ }
+ m_renderCommandEncoder->beginPass(renderPass, framebuffer);
+ *outEncoder = m_renderCommandEncoder;
+}
+
+void CommandBufferImpl::encodeComputeCommands(IComputeCommandEncoder** outEncoder)
+{
+ if (!m_computeCommandEncoder)
+ {
+ m_computeCommandEncoder = new ComputeCommandEncoder;
+ m_computeCommandEncoder->init(this);
+ }
+ *outEncoder = m_computeCommandEncoder;
+}
+
+void CommandBufferImpl::encodeResourceCommands(IResourceCommandEncoder** outEncoder)
+{
+ if (!m_resourceCommandEncoder)
+ {
+ m_resourceCommandEncoder = new ResourceCommandEncoder;
+ m_resourceCommandEncoder->init(this);
+ }
+ *outEncoder = m_resourceCommandEncoder;
+}
+
+void CommandBufferImpl::encodeRayTracingCommands(IRayTracingCommandEncoder** outEncoder)
+{
+ if (!m_rayTracingCommandEncoder)
+ {
+ m_rayTracingCommandEncoder = new RayTracingCommandEncoder;
+ m_rayTracingCommandEncoder->init(this);
+ }
+ *outEncoder = m_rayTracingCommandEncoder;
+}
+
+void CommandBufferImpl::close()
+{
+ //m_commandBuffer->commit();
+}
+
+Result CommandBufferImpl::getNativeHandle(InteropHandle* outHandle)
+{
+ return SLANG_E_NOT_IMPLEMENTED;
+}
+
+} // namespace metal
+} // namespace gfx