summaryrefslogtreecommitdiffstats
path: root/tools/gfx/metal/metal-command-buffer.cpp
diff options
context:
space:
mode:
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