Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Sources/GPUImage/MetalRendering.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ extension MTLCommandBuffer {

renderEncoder.endEncoding()
}

func copyTexture(from:Texture,fromSize:Size,to:Texture){
guard let blitEncoder = self.makeBlitCommandEncoder() else {
fatalError("Could not create render encoder")
}
blitEncoder.copy(from: from.texture, sourceSlice: 0, sourceLevel: 0, sourceOrigin: MTLOrigin(x: 0, y: 0, z: 0), sourceSize: MTLSize(width: Int(round(fromSize.width)), height: Int(round(fromSize.height)), depth: 1), to: to.texture, destinationSlice: 0, destinationLevel: 0, destinationOrigin: .init(x: 0, y: 0, z: 0))
blitEncoder.endEncoding();
}
func renderQuad(
pipelineState: MTLRenderPipelineState, uniformSettings: ShaderUniformSettings? = nil,
inputTextures: [UInt: Texture], useNormalizedTextureCoordinates: Bool = true,
Expand Down
9 changes: 8 additions & 1 deletion Sources/GPUImage/MovieOutput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,14 @@ public class MovieOutput: ImageConsumer, AudioEncodingTarget {
commandBuffer?.commit()
commandBuffer?.waitUntilCompleted()
} else {
outputTexture = texture
let commandBuffer = sharedMetalRenderingDevice.commandQueue.makeCommandBuffer()
outputTexture = Texture(
device: sharedMetalRenderingDevice.device, orientation: .portrait,
width: Int(round(self.size.width)), height: Int(round(self.size.height)),
timingStyle: texture.timingStyle)
commandBuffer?.copyTexture(from: texture, fromSize: self.size, to: outputTexture)
commandBuffer?.commit()
commandBuffer?.waitUntilCompleted()
}

let region = MTLRegionMake2D(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ViewController: UIViewController {
super.viewDidLoad()

do {
camera = try Camera(sessionPreset: .vga640x480)
camera = try Camera(sessionPreset: .hd4K3840x2160)
camera.runBenchmark = true
filter = SaturationAdjustment()
camera --> filter --> renderView
Expand All @@ -40,7 +40,7 @@ class ViewController: UIViewController {
}

movieOutput = try MovieOutput(
URL: fileURL, size: Size(width: 480, height: 640), liveVideo: true)
URL: fileURL, size: Size(width: 2160, height: 3840), liveVideo: true)
// camera.audioEncodingTarget = movieOutput
filter --> movieOutput!
movieOutput!.startRecording()
Expand Down