Skip to content

Commit

Permalink
custom pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
yukiny0811 committed Jan 9, 2024
1 parent 27d3386 commit 069fb55
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
```
4 changes: 4 additions & 0 deletions Sources/EasyMetalShader/Pipelines/EMMetalDispatch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 069fb55

Please sign in to comment.