Skip to content

Commit

Permalink
Upped image resolution to 1280x1280, added frame time metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
FlexMonkey committed Jan 19, 2015
1 parent ee97343 commit cb2816b
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions MetalParticles/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ class ViewController: UIViewController
let bitmapInfo = CGBitmapInfo(CGBitmapInfo.ByteOrder32Big.rawValue | CGImageAlphaInfo.PremultipliedLast.rawValue)
let renderingIntent = kCGRenderingIntentDefault

let imageSide: UInt = 640
let imageSize = CGSize(width: Int(640), height: Int(640))
let imageByteCount = Int(640 * 640 * 4)
let imageSide: UInt = 1280
let imageSize = CGSize(width: Int(1280), height: Int(1280))
let imageByteCount = Int(1280 * 1280 * 4)

let bytesPerPixel = UInt(4)
let bitsPerComponent = UInt(8)
let bitsPerPixel:UInt = 32
let rgbColorSpace = CGColorSpaceCreateDeviceRGB()

let bytesPerRow = UInt(4 * 640)
let providerLength = Int(640 * 640 * 4) * sizeof(UInt8)
var imageBytes = [UInt8](count: Int(640 * 640 * 4), repeatedValue: 0)
let bytesPerRow = UInt(4 * 1280)
let providerLength = Int(1280 * 1280 * 4) * sizeof(UInt8)
var imageBytes = [UInt8](count: Int(1280 * 1280 * 4), repeatedValue: 0)

var kernelFunction: MTLFunction!
var pipelineState: MTLComputePipelineState!
Expand All @@ -42,7 +42,7 @@ class ViewController: UIViewController
var region: MTLRegion!
var textureA: MTLTexture!
var textureB: MTLTexture! //
let blankBitmapRawData = [UInt8](count: Int(640 * 640 * 4), repeatedValue: 0)
let blankBitmapRawData = [UInt8](count: Int(1280 * 1280 * 4), repeatedValue: 0)

var image:UIImage!
var errorFlag:Bool = false
Expand All @@ -56,7 +56,9 @@ class ViewController: UIViewController
let particleCount: Int = 250_000
var particles = [Particle]()

var gravityWell = CGPoint(x: 320, y: 320)
var gravityWell = CGPoint(x: 640, y: 640)

var frameStartTime = CFAbsoluteTimeGetCurrent()

override func viewDidLoad()
{
Expand Down Expand Up @@ -174,18 +176,21 @@ class ViewController: UIViewController
run()
}
}

final func run()
{
println("frametime:" + NSString(format: "%.6f", CFAbsoluteTimeGetCurrent() - frameStartTime))
frameStartTime = CFAbsoluteTimeGetCurrent()

Async.background()
{
self.applyShader()
}
.main
{
self.imageView.image = self.image
{
self.applyShader()
}
.main
{
self.imageView.image = self.image

self.run();
self.run();
}
}

Expand Down

0 comments on commit cb2816b

Please sign in to comment.