From 3380ece4a1003a068377e0a9c884d6e177a23d63 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 15 Feb 2022 15:16:48 +0000 Subject: [PATCH] Add utility calls for creating buffers from slices --- core/sys/darwin/Metal/MetalClasses.odin | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/sys/darwin/Metal/MetalClasses.odin b/core/sys/darwin/Metal/MetalClasses.odin index 2686ce2ae..e5b6d0849 100644 --- a/core/sys/darwin/Metal/MetalClasses.odin +++ b/core/sys/darwin/Metal/MetalClasses.odin @@ -1,6 +1,7 @@ package objc_Metal import NS "core:sys/darwin/Foundation" +import "core:mem" //////////////////////////////////////////////////////////////////////////////// @@ -6465,6 +6466,16 @@ Device_newBufferWithBytes :: #force_inline proc(self: ^Device, bytes: []byte, op Device_newBufferWithBytesNoCopy :: #force_inline proc(self: ^Device, bytes: []byte, options: ResourceOptions, deallocator: rawptr) -> ^Buffer { return msgSend(^Buffer, self, "newBufferWithBytesNoCopy:length:options:deallocator:", raw_data(bytes), NS.UInteger(len(bytes)), options, deallocator) } + +@(objc_type=Device, objc_name="newBufferWithSlice") +Device_newBufferWithSlice :: #force_inline proc(self: ^Device, slice: $S/[]$E, options: ResourceOptions) -> ^Buffer { + return Device_newBufferWithBytes(self, mem.slice_to_bytes(slice), options) +} +@(objc_type=Device, objc_name="newBufferWithSliceNoCopy") +Device_newBufferWithSliceNoCopy :: #force_inline proc(self: ^Device, slice: $S/[]$E, options: ResourceOptions, deallocator: rawptr) -> ^Buffer { + return Device_newBufferWithBytesNotCopy(self, mem.slice_to_bytes(slice), options, deallocator) +} + @(objc_type=Device, objc_name="newBuffer") Device_newBuffer :: #force_inline proc(self: ^Device, length: NS.UInteger, options: ResourceOptions) -> ^Buffer { return msgSend(^Buffer, self, "newBufferWithLength:options:", length, options) @@ -7263,7 +7274,7 @@ IndirectRenderCommand_drawPatches :: #force_inline proc(self: ^IndirectRenderCom msgSend(nil, self, "drawPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:instanceCount:baseInstance:tessellationFactorBuffer:tessellationFactorBufferOffset:tessellationFactorBufferInstanceStride:", numberOfPatchControlPoints, patchStart, patchCount, patchIndexBuffer, patchIndexBufferOffset, instanceCount, baseInstance, buffer, offset, instanceStride) } @(objc_type=IndirectRenderCommand, objc_name="drawPrimitives") -IndirectRenderCommand_drawPrimitives :: #force_inline proc(self: ^IndirectRenderCommand, primitiveType: PrimitiveType, vertexStart: NS.UInteger, vertexCount: NS.UInteger, instanceCount: NS.UInteger = 0, baseInstance: NS.UInteger = 0) { +IndirectRenderCommand_drawPrimitives :: #force_inline proc(self: ^IndirectRenderCommand, primitiveType: PrimitiveType, vertexStart: NS.UInteger, vertexCount: NS.UInteger, instanceCount: NS.UInteger, baseInstance: NS.UInteger = 0) { msgSend(nil, self, "drawPrimitives:vertexStart:vertexCount:instanceCount:baseInstance:", primitiveType, vertexStart, vertexCount, instanceCount, baseInstance) } @(objc_type=IndirectRenderCommand, objc_name="reset")