1717#include " HelperDeviceMemoryAllocator.h"
1818#include " CommandQueueMTL.h"
1919#include " SwapChainMTL.h"
20+ #include " FenceMTL.h"
21+ #include " DescriptorPoolMTL.h"
2022
2123
2224Result CreateDeviceMTL (const DeviceCreationDesc& desc, DeviceBase*& device) {
@@ -70,9 +72,13 @@ static Result NRI_CALL CreateCommandBuffer(CommandAllocator& commandAllocator, C
7072 return ((CommandAllocatorMTL&)commandAllocator).CreateCommandBuffer (commandBuffer);
7173}
7274
75+
76+ static Result NRI_CALL CreateDescriptorPool (Device& device, const DescriptorPoolDesc& descriptorPoolDesc, DescriptorPool*& descriptorPool) {
77+ return ((DeviceMTL&)device).CreateImplementation <DescriptorPoolMTL>(descriptorPool, descriptorPoolDesc);
78+ }
79+
7380static void NRI_CALL ResetCommandAllocator (CommandAllocator& commandAllocator) {
74- // ((CommandAllocatorVK&)commandAllocator).Reset();
75-
81+ ((CommandAllocatorMTL&)commandAllocator).Reset ();
7682}
7783
7884static void NRI_CALL SetCommandBufferDebugName (CommandBuffer& commandBuffer, const char * name) {
@@ -219,6 +225,11 @@ static void NRI_CALL CmdResolveTexture(CommandBuffer& commandBuffer, Texture& ds
219225 // ((CommandBufferMTL&)commandBuffer).ResolveTexture(dstTexture, dstRegionDesc, srcTexture, srcRegionDesc);
220226}
221227
228+
229+ static void NRI_CALL Wait (Fence& fence, uint64_t value) {
230+ ((FenceMTL&)fence).Wait (value);
231+ }
232+
222233static void NRI_CALL CmdCopyBuffer (CommandBuffer& commandBuffer, Buffer& dstBuffer, uint64_t dstOffset, const Buffer& srcBuffer, uint64_t srcOffset, uint64_t size) {
223234 ((CommandBufferMTL&)commandBuffer).CopyBuffer (dstBuffer, dstOffset, srcBuffer, srcOffset, size);
224235}
@@ -265,31 +276,46 @@ static Result NRI_CALL CreateTexture(Device& device, const TextureDesc& textureD
265276 return ((DeviceMTL&)device).CreateImplementation <TextureMTL>(texture, textureDesc);
266277}
267278
279+ static Result NRI_CALL CreateCommandAllocator (const CommandQueue& commandQueue, CommandAllocator*& commandAllocator) {
280+ DeviceMTL& device = ((CommandQueueMTL&)commandQueue).GetDevice ();
281+ return device.CreateImplementation <CommandAllocatorMTL>(commandAllocator, commandQueue);
282+ }
268283
269- // static Result NRI_CALL CreateBufferView(const BufferViewDesc& bufferViewDesc, Descriptor*& bufferView) {
270- // DeviceMTL& device = ((const BufferMTL*)bufferViewDesc.buffer)->GetDevice();
271- // return device.CreateImplementation<DescriptorMTL>(bufferView, bufferViewDesc);
272- // }
273- //
274- // static Result NRI_CALL CreateTexture1DView(const Texture1DViewDesc& textureViewDesc, Descriptor*& textureView) {
275- // DeviceMTL& device = ((const TextureMTL*)textureViewDesc.texture)->GetDevice();
276- // return device.CreateImplementation<DescriptorMTL>(textureView, textureViewDesc);
277- // }
278- //
279- // static Result NRI_CALL CreateTexture2DView(const Texture2DViewDesc& textureViewDesc, Descriptor*& textureView) {
280- // DeviceMTL& device = ((const TextureMTL*)textureViewDesc.texture)->GetDevice();
281- // return device.CreateImplementation<DescriptorMTL>(textureView, textureViewDesc);
282- // }
283- //
284- // static Result NRI_CALL CreateTexture3DView(const Texture3DViewDesc& textureViewDesc, Descriptor*& textureView) {
285- // DeviceMTL& device = ((const TextureMTL*)textureViewDesc.texture)->GetDevice();
286- // return device.CreateImplementation<DescriptorMTL>(textureView, textureViewDesc);
287- // }
284+ static Result NRI_CALL CreateBufferView (const BufferViewDesc& bufferViewDesc, Descriptor*& bufferView) {
285+ DeviceMTL& device = ((const BufferMTL*)bufferViewDesc.buffer )->GetDevice ();
286+ return device.CreateImplementation <DescriptorMTL>(bufferView, bufferViewDesc);
287+ }
288288
289+ static Result NRI_CALL CreateBuffer (Device& device, const BufferDesc& bufferDesc, Buffer*& buffer) {
290+ return ((DeviceMTL&)device).CreateImplementation <BufferMTL>(buffer, bufferDesc);
291+ }
289292
290- // static void NRI_CALL QueueSubmit(CommandQueue& commandQueue, const QueueSubmitDesc& workSubmissionDesc) {
291- // ((CommandQueueMTL&)commandQueue).Submit(workSubmissionDesc, nullptr);
292- // }
293+ static Result NRI_CALL CreateTexture1DView (const Texture1DViewDesc& textureViewDesc, Descriptor*& textureView) {
294+ DeviceMTL& device = ((const TextureMTL*)textureViewDesc.texture )->GetDevice ();
295+ return device.CreateImplementation <DescriptorMTL>(textureView, textureViewDesc);
296+ }
297+
298+ static Result NRI_CALL CreateTexture2DView (const Texture2DViewDesc& textureViewDesc, Descriptor*& textureView) {
299+ DeviceMTL& device = ((const TextureMTL*)textureViewDesc.texture )->GetDevice ();
300+ return device.CreateImplementation <DescriptorMTL>(textureView, textureViewDesc);
301+ }
302+
303+ static Result NRI_CALL CreateTexture3DView (const Texture3DViewDesc& textureViewDesc, Descriptor*& textureView) {
304+ DeviceMTL& device = ((const TextureMTL*)textureViewDesc.texture )->GetDevice ();
305+ return device.CreateImplementation <DescriptorMTL>(textureView, textureViewDesc);
306+ }
307+
308+ static Result NRI_CALL CreateSampler (Device& device, const SamplerDesc& samplerDesc, Descriptor*& sampler) {
309+ return ((DeviceMTL&)device).CreateImplementation <DescriptorMTL>(sampler, samplerDesc);
310+ }
311+
312+ static Result NRI_CALL CreatePipelineLayout (Device& device, const PipelineLayoutDesc& pipelineLayoutDesc, PipelineLayout*& pipelineLayout) {
313+ return ((DeviceMTL&)device).CreateImplementation <PipelineLayoutMTL>(pipelineLayout, pipelineLayoutDesc);
314+ }
315+
316+ static void NRI_CALL QueueSubmit (CommandQueue& commandQueue, const QueueSubmitDesc& workSubmissionDesc) {
317+ ((CommandQueueMTL&)commandQueue).Submit (workSubmissionDesc, nullptr );
318+ }
293319
294320
295321static void NRI_CALL DestroyCommandBuffer (CommandBuffer& commandBuffer) {
@@ -389,8 +415,11 @@ static Result NRI_CALL CreateComputePipeline(Device& device, const ComputePipeli
389415
390416
391417static Result NRI_CALL AllocateDescriptorSets (DescriptorPool& descriptorPool, const PipelineLayout& pipelineLayout, uint32_t setIndex, DescriptorSet** descriptorSets, uint32_t instanceNum, uint32_t variableDescriptorNum) {
392- return Result::SUCCESS;
393- // return ((DescriptorPoolMTL&)descriptorPool).AllocateDescriptorSets(pipelineLayout, setIndex, descriptorSets, instanceNum, variableDescriptorNum);
418+ return ((DescriptorPoolMTL&)descriptorPool).AllocateDescriptorSets (pipelineLayout, setIndex, descriptorSets, instanceNum, variableDescriptorNum);
419+ }
420+
421+ static void NRI_CALL ResetDescriptorPool (DescriptorPool& descriptorPool) {
422+ ((DescriptorPoolMTL&)descriptorPool).Reset ();
394423}
395424
396425
@@ -408,20 +437,19 @@ static void NRI_CALL SetDescriptorDebugName(Descriptor& descriptor, const char*
408437 table.GetBufferMemoryDesc = ::GetBufferMemoryDesc;
409438 table.GetTextureMemoryDesc = ::GetTextureMemoryDesc;
410439 table.GetCommandQueue = ::GetCommandQueue;
411- // table.CreateCommandAllocator = ::CreateCommandAllocator;
440+ table.CreateCommandAllocator = ::CreateCommandAllocator;
412441 table.CreateCommandBuffer = ::CreateCommandBuffer;
413- // table.CreateDescriptorPool = ::CreateDescriptorPool;
414- // table.CreateBuffer = ::CreateBuffer;
442+ table.CreateDescriptorPool = ::CreateDescriptorPool;
443+ table.CreateBuffer = ::CreateBuffer;
415444 table.CreateTexture = ::CreateTexture;
416- // table.CreateBufferView = ::CreateBufferView;
417- // table.CreateTexture1DView = ::CreateTexture1DView;
418- // table.CreateTexture2DView = ::CreateTexture2DView;
419- // table.CreateTexture3DView = ::CreateTexture3DView;
420- // table.CreateSampler = ::CreateSampler;
421- // table.CreatePipelineLayout = ::CreatePipelineLayout;
445+ table.CreateBufferView = ::CreateBufferView;
446+ table.CreateTexture1DView = ::CreateTexture1DView;
447+ table.CreateTexture2DView = ::CreateTexture2DView;
448+ table.CreateTexture3DView = ::CreateTexture3DView;
449+ table.CreateSampler = ::CreateSampler;
450+ table.CreatePipelineLayout = ::CreatePipelineLayout;
422451 table.CreateGraphicsPipeline = ::CreateGraphicsPipeline;
423452 table.CreateComputePipeline = ::CreateComputePipeline;
424-
425453// table.CreateQueryPool = ::CreateQueryPool;
426454// table.CreateFence = ::CreateFence;
427455 table.DestroyCommandAllocator = ::DestroyCommandAllocator;
@@ -479,14 +507,14 @@ static void NRI_CALL SetDescriptorDebugName(Descriptor& descriptor, const char*
479507 table.CmdBeginAnnotation = ::CmdBeginAnnotation;
480508 table.CmdEndAnnotation = ::CmdEndAnnotation;
481509 table.EndCommandBuffer = ::EndCommandBuffer;
482- // table.QueueSubmit = ::QueueSubmit;
483- // table.Wait = ::Wait;
510+ table.QueueSubmit = ::QueueSubmit;
511+ table.Wait = ::Wait;
484512// table.GetFenceValue = ::GetFenceValue;
485513// table.UpdateDescriptorRanges = ::UpdateDescriptorRanges;
486514// table.UpdateDynamicConstantBuffers = ::UpdateDynamicConstantBuffers;
487515// table.CopyDescriptorSet = ::CopyDescriptorSet;
488516 table.AllocateDescriptorSets = ::AllocateDescriptorSets;
489- // table.ResetDescriptorPool = ::ResetDescriptorPool;
517+ table.ResetDescriptorPool = ::ResetDescriptorPool;
490518 table.ResetCommandAllocator = ::ResetCommandAllocator;
491519 table.MapBuffer = ::MapBuffer;
492520 table.UnmapBuffer = ::UnmapBuffer;
0 commit comments