diff --git a/README.md b/README.md index 78cfd09..8049886 100644 --- a/README.md +++ b/README.md @@ -169,3 +169,13 @@ dispatch.commit() - em_float3 (simd_float3) - em_float4 (simd_float4) - EMMetalTexture (MTLTexture 2D) + +### Custom Pipelines + +```.swift +let dispatch = EMMetalDispatch() +dispatch.custom { commandBuffer in + // do something with commandBuffer +} +dispatch.commit() +``` diff --git a/Sources/EasyMetalShader/Pipelines/EMMetalDispatch.swift b/Sources/EasyMetalShader/Pipelines/EMMetalDispatch.swift index 79494f7..b40fb09 100644 --- a/Sources/EasyMetalShader/Pipelines/EMMetalDispatch.swift +++ b/Sources/EasyMetalShader/Pipelines/EMMetalDispatch.swift @@ -16,6 +16,10 @@ public class EMMetalDispatch { commandBuffer = ShaderCore.commandQueue.makeCommandBuffer()! } + public func custom(_ process: @escaping (MTLCommandBuffer) -> ()) { + process(commandBuffer) + } + public func compute(_ process: @escaping (MTLComputeCommandEncoder) -> ()) { let encoder = commandBuffer.makeComputeCommandEncoder()! process(encoder)