4#include <RGL/Types.hpp>
5#include <RGL/Device.hpp>
6#include "MTLObjCCompatLayer.hpp"
12 struct DeviceMTL :
public IDevice,
public std::enable_shared_from_this<DeviceMTL>{
13 OBJC_ID(MTLDevice) device =
nullptr;
14 OBJC_ID(MTLLibrary) defaultLibrary =
nullptr;
15 OBJC_ID(MTLCommandQueue) uploadQueue =
nullptr;
16 OBJC_ID(MTLArgumentEncoder) globalTextureEncoder =
nullptr;
17 OBJC_ID(MTLArgumentEncoder) globalBufferEncoder =
nullptr;
18 OBJC_ID(MTLBuffer) globalTextureBuffer =
nullptr;
19 OBJC_ID(MTLBuffer) globalBufferBuffer =
nullptr;
21 DeviceMTL(
decltype(device) device);
22 std::string GetBrandString() final;
24 RGLSwapchainPtr CreateSwapchain(RGLSurfacePtr, RGLCommandQueuePtr presentQueue,
int,
int) final;
26 RGLPipelineLayoutPtr CreatePipelineLayout(const PipelineLayoutDescriptor&) final;
27 RGLRenderPipelinePtr CreateRenderPipeline(const RenderPipelineDescriptor&) final;
28 RGLComputePipelinePtr CreateComputePipeline(const struct ComputePipelineDescriptor&) final;
30 RGLShaderLibraryPtr CreateShaderLibraryFromName(const std::
string_view& name) final;
31 RGLShaderLibraryPtr CreateDefaultShaderLibrary() final;
32 RGLShaderLibraryPtr CreateShaderLibraryFromBytes(const std::span<const uint8_t>) final;
33 RGLShaderLibraryPtr CreateShaderLibrarySourceCode(const std::
string_view, const FromSourceConfig& config) final;
34 RGLShaderLibraryPtr CreateShaderLibraryFromPath(const std::filesystem::path&) final;
36 RGLBufferPtr CreateBuffer(const BufferConfig&) final;
37 RGLTexturePtr CreateTextureWithData(const TextureConfig&, const TextureUploadData&) final;
38 RGLTexturePtr CreateTexture(const TextureConfig&) final;
39 RGLSamplerPtr CreateSampler(const SamplerConfig&) final;
41 RGLCommandQueuePtr CreateCommandQueue(QueueType type) final;
43 TextureView GetGlobalBindlessTextureHeap() const final;
45 DeviceData GetDeviceData() final;
47 RGLFencePtr CreateFence(
bool preSignaled) final;
48 void BlockUntilIdle() final;
50 size_t GetTotalVRAM() const final;
51 size_t GetCurrentVRAMInUse() const final;
53 FreeList<uint32_t, 2048> textureFreelist;
54 FreeList<uint32_t, 65536> bufferFreelist;
56 virtual ~DeviceMTL(){}
59 RGLDevicePtr CreateDefaultDeviceMTL();