Skip to content

Commit

Permalink
Make nogc compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaTheFoxgirl committed Mar 17, 2024
1 parent 32cb151 commit edcd01f
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"copyright": "Copyright © 2023, Hipreme",
"description": "Bindings to Apple's metal graphics API. No compiler support needed",
"dependencies": {
"objc_meta": "~>1.0.15"
"objc_meta": "~>1.1.0"
},
"configurations": [
{
Expand Down
3 changes: 3 additions & 0 deletions source/metal/blitcommandencoder.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import metal.metal;
import metal.texture;

@ObjectiveC final extern(C++):
@nogc nothrow:

///The options that enable behavior for some blit operations.
enum MTLBlitOption : NSUInteger
Expand All @@ -21,6 +22,8 @@ enum MTLBlitOption : NSUInteger
///An interface you can use to encode GPU commands that copy and modify the underlying memory of various Metal resources.
interface MTLBlitCommandEncoder : MTLCommandEncoder
{
@nogc nothrow:

///Encodes a command that fills a buffer with a constant value for each byte.
@selector("fillBuffer:range:value:")
void fillBuffer(MTLBuffer buffer, NSRange range, ubyte value);
Expand Down
13 changes: 13 additions & 0 deletions source/metal/commandbuffer.d
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import metal.rendercommandencoder;
import metal.blitcommandencoder;

@ObjectiveC final extern(C++):
@nogc nothrow:

///Options for reporting errors from a command buffer.
enum MTLCommandBufferErrorOption : NSUInteger
Expand All @@ -18,6 +19,8 @@ enum MTLCommandBufferErrorOption : NSUInteger
///A configuration that customizes the behavior for a new command buffer.
class MTLCommandBufferDescriptor
{
@nogc nothrow:

mixin ObjcExtend!NSObject;
@selector("alloc")
static MTLCommandBufferDescriptor alloc();
Expand Down Expand Up @@ -87,6 +90,8 @@ enum MTLCommandBufferError : NSUInteger
///A configuration you create to customize a blit command encoder, which affects the runtime behavior of the blit pass you encode with it.
class MTLBlitPassDescriptor
{
@nogc nothrow:

mixin ObjcExtend!NSObject;
///Creates a new blit pass descriptor with a default configuration.
@selector("blitPassDescriptor")
Expand Down Expand Up @@ -120,6 +125,8 @@ enum MTLCommandEncoderErrorState : NSInteger
///A container that provides additional information about a runtime failure a GPU encounters as it runs the commands in a command buffer.
interface MTLCommandBufferEncoderInfo
{
@nogc nothrow:

///The name of the encoder that generates the error information
@selector("label")
NSString label();
Expand Down Expand Up @@ -147,6 +154,8 @@ enum MTLFunctionLogType : NSUInteger
///The source code that logged a debug message.
interface MTLFunctionLogDebugLocation
{
@nogc nothrow:

///The name of the shader function.
@selector("functionName")
NSString functionName();
Expand Down Expand Up @@ -188,12 +197,16 @@ interface MTLFunctionLog
///A collection of logged messages, created when a Metal device runs a command buffer.
interface MTLLogContainer
{
@nogc nothrow:

mixin ObjcExtend!NSFastEnumeration;
}

///A container that stores a sequence of GPU commands that you encode into it.
interface MTLCommandBuffer
{
@nogc nothrow:

///Encodes a command into the command buffer that pauses the GPU from running subsequent passes until the event equals or exceeds a value.
@selector("encodeWaitForEvent:value:")
void encodeWaitForEvent(MTLEvent event, ulong value);
Expand Down
5 changes: 5 additions & 0 deletions source/metal/library.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import objc.meta : selector, ObjcExtend;
import metal.metal;

@ObjectiveC final extern(C++):
@nogc nothrow:
enum MTLLanguageVersion : NSUInteger
{
///Deprecated
Expand Down Expand Up @@ -37,6 +38,8 @@ enum MTLLibraryType : NSInteger

class MTLCompileOptions
{
@nogc nothrow:

mixin ObjcExtend!NSObject;
@selector("alloc")
static MTLCompileOptions alloc();
Expand Down Expand Up @@ -97,6 +100,8 @@ class MTLCompileOptions

interface MTLLibrary
{
@nogc nothrow:

///The installation name for a dynamic library.
@selector("installName")
NSString installName();
Expand Down
55 changes: 55 additions & 0 deletions source/metal/metal.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module metal.metal;

import objc.meta : selector, ObjcExtend;
@ObjectiveC final extern(C++):
@nogc nothrow:

public import objc.runtime;
import metal.library;
Expand Down Expand Up @@ -90,6 +91,7 @@ struct MTLRegion

interface MTLRenderPipelineState
{
@nogc nothrow:
void release() @selector("release");
MTLDevice device() @selector("device");
NSString label() @selector("label");
Expand Down Expand Up @@ -155,6 +157,8 @@ enum MTLStoreActionOptions : NSUInteger
///A render target that serves as the output destination for pixels generated by a render pass.
class MTLRenderPassAttachmentDescriptor
{
@nogc nothrow:

mixin ObjcExtend!NSObject;

///The texture object associated with this attachment.
Expand Down Expand Up @@ -247,6 +251,8 @@ enum MTLStoreAction: NSUInteger

class MTLRenderPassColorAttachmentDescriptor
{
@nogc nothrow:

mixin ObjcExtend!MTLRenderPassAttachmentDescriptor;
///The color to use when clearing the color attachment.
@selector("clearColor")
Expand All @@ -257,6 +263,8 @@ class MTLRenderPassColorAttachmentDescriptor

class MTLRenderPassColorAttachmentDescriptorArray
{
@nogc nothrow:

mixin ObjcExtend!NSObject;
@selector("setObject:atIndexedSubscript:")
void setObjectAtIndexedSubscript(MTLRenderPassColorAttachmentDescriptor attachment, NSUInteger attachmentIndex);
Expand Down Expand Up @@ -288,6 +296,8 @@ enum MTLMultisampleDepthResolveFilter : NSUInteger
///A depth render target that serves as the output destination for depth pixels generated by a render pass.
class MTLRenderPassDepthAttachmentDescriptor
{
@nogc nothrow:

mixin ObjcExtend!MTLRenderPassAttachmentDescriptor;
///The depth to use when clearing the depth attachment.
@selector("clearDepth")
Expand All @@ -312,6 +322,8 @@ enum MTLMultisampleStencilResolveFilter : NSUInteger

class MTLRenderPassStencilAttachmentDescriptor
{
@nogc nothrow:

mixin ObjcExtend!MTLRenderPassAttachmentDescriptor;
///The filter used for stencil multisample resolve.
@selector("stencilResolveFilter")
Expand Down Expand Up @@ -368,6 +380,8 @@ enum MTLIndexType : NSUInteger

interface MTLCounterSampleBuffer
{
@nogc nothrow:

///Transforms samples of a GPU’s counter set from the driver’s internal format to a standard Metal data structure.
@selector("resolveCounterRange:")
NSData resolveCounterRange(NSRange range);
Expand All @@ -380,6 +394,8 @@ MTLCoordinate2D MTLCoordinate2DMake(float x, float y);

interface MTLRasterizationRateMap
{
@nogc nothrow:

///The device object that created the rate map.
MTLDevice device() @selector("device");
///A string that identifies the rate map.
Expand Down Expand Up @@ -420,6 +436,8 @@ interface MTLRasterizationRateMap
///A description of where to store GPU counter information at the start and end of a render pass.
class MTLRenderPassSampleBufferAttachmentDescriptor
{
@nogc nothrow:

mixin ObjcExtend!NSObject;
///The sample buffer to write new GPU counter samples to.
@selector("sampleBuffer")
Expand Down Expand Up @@ -456,6 +474,8 @@ class MTLRenderPassSampleBufferAttachmentDescriptor

class MTLRenderPassSampleBufferAttachmentDescriptorArray
{
@nogc nothrow:

mixin ObjcExtend!NSObject;
///Returns the descriptor object for the specified sample buffer attachment.
@selector("objectAtIndexedSubscript:")
Expand All @@ -469,6 +489,8 @@ class MTLRenderPassSampleBufferAttachmentDescriptorArray
///A depth and stencil state object that specifies the depth and stencil configuration and operations used in a render pass.
interface MTLDepthStencilState
{
@nogc nothrow:

///The device from which this state object was created.
@selector("device")
MTLDevice device();
Expand All @@ -481,6 +503,8 @@ interface MTLDepthStencilState
///An object that configures new MTLDepthStencilState objects.
class MTLDepthStencilDescriptor
{
@nogc nothrow:

mixin ObjcExtend!NSObject;
@selector("alloc")
static MTLDepthStencilDescriptor alloc();
Expand Down Expand Up @@ -528,6 +552,8 @@ class MTLDepthStencilDescriptor
///A group of render targets that hold the results of a render pass.
class MTLRenderPassDescriptor
{
@nogc nothrow:

mixin ObjcExtend!NSObject;

@selector("new")
Expand Down Expand Up @@ -697,6 +723,8 @@ enum MTLBlendFactor : NSUInteger

class MTLRenderPipelineColorAttachmentDescriptor
{
@nogc nothrow:

mixin ObjcExtend!NSObject;

///The pixel format of the color attachment’s texture.
Expand Down Expand Up @@ -760,6 +788,8 @@ class MTLRenderPipelineColorAttachmentDescriptor

class MTLRenderPipelineColorAttachmentDescriptorArray
{
@nogc nothrow:

mixin ObjcExtend!NSObject;

static MTLRenderPipelineColorAttachmentDescriptorArray alloc() @selector("alloc");
Expand All @@ -783,6 +813,8 @@ class MTLRenderPipelineColorAttachmentDescriptorArray

class MTLRenderPipelineDescriptor
{
@nogc nothrow:

mixin ObjcExtend!NSObject;
alias ini = initialize;

Expand Down Expand Up @@ -823,6 +855,7 @@ interface MTLIOCommandQueue

class MTLIOCommandQueueDescriptor
{
@nogc nothrow:
mixin ObjcExtend!NSObject;
}

Expand All @@ -842,6 +875,8 @@ enum MTLRenderStages : NSUInteger
///An object that can capture, track, and manage resource dependencies across command encoders.
interface MTLFence
{
@nogc nothrow:

mixin ObjcExtend!NSObject;

///The device object that created the fence.
Expand Down Expand Up @@ -900,6 +935,8 @@ enum MTLArgumentBuffersTier : NSUInteger
///The main Metal interface to a GPU that apps use to draw graphics and run computations in parallel.
interface MTLDevice
{
@nogc nothrow:

mixin ObjcExtend!NSObject;

///The full name of the GPU device.
Expand Down Expand Up @@ -983,6 +1020,8 @@ alias MTLDrawablePresentedHandler = extern(C) void function(MTLDrawable);
///A displayable resource that can be rendered or written to.
interface MTLDrawable
{
@nogc nothrow:

mixin ObjcExtend!NSObject;

///A positive integer that identifies the drawable.
Expand Down Expand Up @@ -1018,6 +1057,8 @@ extern(C) NSArrayD!MTLDevice MTLCopyAllDevices();
///An instance you use to create, submit, and schedule command buffers to a specific GPU device to run the commands within those buffers.
interface MTLCommandQueue
{
@nogc nothrow:

mixin ObjcExtend!NSObject;

///Returns a command buffer from the command queue that you configure with a descriptor.
Expand Down Expand Up @@ -1047,6 +1088,8 @@ interface MTLCommandQueue
///A Metal drawable associated with a Core Animation layer.
interface CAMetalDrawable : MTLDrawable
{
@nogc nothrow:

mixin ObjcExtend!NSObject;

///A Metal texture object that contains the drawable’s contents.
Expand All @@ -1060,6 +1103,8 @@ interface CAMetalDrawable : MTLDrawable
///An allocation of memory that is accessible to a GPU.
interface MTLResource
{
@nogc nothrow:

mixin ObjcExtend!NSObject;

///The device object that created the resource.
Expand All @@ -1076,6 +1121,8 @@ interface MTLResource
///An encoder that writes GPU commands into a command buffer.
interface MTLCommandEncoder
{
@nogc nothrow:

mixin ObjcExtend!NSObject;

///Declares that all command generation from the encoder is completed.
Expand Down Expand Up @@ -1109,6 +1156,8 @@ interface MTLCommandEncoder

interface MTLBuffer
{
@nogc nothrow:

mixin ObjcExtend!NSObject;

///Creates a texture that shares its storage with the buffer.
Expand Down Expand Up @@ -1141,6 +1190,8 @@ interface MTLBuffer
///An object you use to synchronize access to Metal resources.
interface MTLEvent
{
@nogc nothrow:

///The device object that created the event.
@selector("device")
MTLDevice device();
Expand All @@ -1152,11 +1203,15 @@ interface MTLEvent

class CALayer
{
@nogc nothrow:

mixin ObjcExtend!NSObject;
}

class CAMetalLayer
{
@nogc nothrow:

mixin ObjcExtend!CALayer;
@selector("pixelFormat")
MTLPixelFormat pixelFormat();
Expand Down
3 changes: 3 additions & 0 deletions source/metal/metalkit.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ module metal.metalkit;
import metal.metal;
import objc.meta : selector;
@ObjectiveC final extern(C++):
@nogc nothrow:

class MTKView
{
@nogc nothrow:

///Creates a render pass descriptor to draw into the current drawable.
@selector("currentRenderPassDescriptor")
MTLRenderPassDescriptor currentRenderPassDescriptor();
Expand Down
1 change: 1 addition & 0 deletions source/metal/pixelformat.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module metal.pixelformat;
import objc.runtime;
@nogc nothrow:

enum MTLPixelFormat : NSUInteger
{
Expand Down
Loading

0 comments on commit edcd01f

Please sign in to comment.