Skip to content

Commit

Permalink
Use less encoders
Browse files Browse the repository at this point in the history
  • Loading branch information
STREGA committed Oct 4, 2023
1 parent 5c79107 commit 9c7060b
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,7 @@ class MetalRenderTarget: RenderTargetBackend {
func willBeginFrame(_ frame: UInt) {
self.isFirstPass = true
self.commandBuffer = Game.shared.renderer.commandQueue.makeCommandBuffer()!
}

func didEndFrame(_ frame: UInt) {
if let drawable = metalView?.currentDrawable {
commandBuffer.present(drawable)
}
self.commandBuffer.commit()
}

func willBeginContent(matrices: Matrices?, viewport: GameMath.Rect?) {

if self.isFirstPass {
self.isFirstPass = false
self.commandEncoder = commandBuffer.makeRenderCommandEncoder(
Expand All @@ -103,6 +94,17 @@ class MetalRenderTarget: RenderTargetBackend {
descriptor: renderPassDescriptor
)
}
}

func didEndFrame(_ frame: UInt) {
self.commandEncoder.endEncoding()
if let drawable = metalView?.currentDrawable {
commandBuffer.present(drawable)
}
self.commandBuffer.commit()
}

func willBeginContent(matrices: Matrices?, viewport: GameMath.Rect?) {
if let viewport {
let mtlViewport = MTLViewport(
originX: Double(viewport.position.x),
Expand All @@ -117,7 +119,7 @@ class MetalRenderTarget: RenderTargetBackend {
}

func didEndContent() {
self.commandEncoder.endEncoding()

}

@inline(__always)
Expand Down

0 comments on commit 9c7060b

Please sign in to comment.