[all] Remove old compute shader code
This commit is contained in:
parent
ddc0938ae4
commit
a49c370ceb
4 changed files with 0 additions and 117 deletions
|
@ -113,14 +113,8 @@ public class Field {
|
|||
// MARK: - Metal Configuration
|
||||
|
||||
private var device: MTLDevice?
|
||||
// private var sampleComputeState: MTLComputePipelineState?
|
||||
public private(set) var parametersBuffer: MTLBuffer?
|
||||
public private(set) var ballBuffer: MTLBuffer?
|
||||
// public private(set) var sampleTexture: MTLTexture?
|
||||
|
||||
// private var threadgroupCount = MTLSize()
|
||||
// TODO: It might be possible to (more dynamically) right-size this.
|
||||
// private var threadgroupSize = MTLSize(width: 16, height: 16, depth: 1)
|
||||
|
||||
/// Create the Metal buffer containing basic parameters of the simulation.
|
||||
private func populateParametersBuffer() {
|
||||
|
@ -176,29 +170,6 @@ public class Field {
|
|||
}
|
||||
}
|
||||
|
||||
/// Create a Metal texture to hold sample values created by the sampling compute shader.
|
||||
/// @param device The Metal device to use to create the texture.
|
||||
/// @return A new texture.
|
||||
// private func makeSampleTextureIfNeeded(withDevice device: MTLDevice) -> MTLTexture? {
|
||||
// if sampleTexture == nil {
|
||||
// let desc = MTLTextureDescriptor()
|
||||
// desc.pixelFormat = .r16Float
|
||||
// desc.width = Int(size.width)
|
||||
// desc.height = Int(size.height)
|
||||
// desc.usage = [.shaderWrite, .shaderRead]
|
||||
// sampleTexture = device.makeTexture(descriptor: desc)
|
||||
// }
|
||||
// return sampleTexture
|
||||
// }
|
||||
|
||||
/// Update the threadgroup divisions based on the size of the field.
|
||||
/// @param size The size of the field.
|
||||
// private func updateThreadgroupSizes(withFieldSize size: CGSize) {
|
||||
// let width = Int(size.width)
|
||||
// let height = Int(size.height)
|
||||
// threadgroupCount = MTLSize(width: width + threadgroupSize.width - 1, height: height + threadgroupSize.height - 1, depth: 1)
|
||||
// }
|
||||
|
||||
private func write<T>(value: inout T, to ptr: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer {
|
||||
let sizeOfType = MemoryLayout<T>.stride
|
||||
ptr.copyBytes(from: &value, count: sizeOfType)
|
||||
|
@ -211,40 +182,7 @@ public class Field {
|
|||
}
|
||||
NSLog("Setting up Metal")
|
||||
self.device = device
|
||||
// sampleComputeState = try computePipelineStateForSamplingKernel(withDevice: device)
|
||||
populateParametersBuffer()
|
||||
populateBallBuffer()
|
||||
}
|
||||
|
||||
// public func computePipelineStateForSamplingKernel(withDevice device: MTLDevice) throws -> MTLComputePipelineState? {
|
||||
// let bundle = Bundle(for: type(of: self))
|
||||
// let library = try device.makeDefaultLibrary(bundle: bundle)
|
||||
// guard let samplingKernel = library.makeFunction(name: "sampleFieldKernel") else {
|
||||
// throw MetaballsError.metalError("Unable to create sampling kernel function")
|
||||
// }
|
||||
// let state = try device.makeComputePipelineState(function: samplingKernel)
|
||||
// return state
|
||||
// }
|
||||
|
||||
// public func computeEncoderForSamplingKernel(withDevice device: MTLDevice, commandBuffer buffer: MTLCommandBuffer) throws -> MTLComputeCommandEncoder {
|
||||
// guard let parametersBuffer = makeParametersBufferIfNeeded(withDevice: device),
|
||||
// let ballBuffer = makeBallBufferIfNeeded(withDevice: device),
|
||||
// let sampleTexture = makeSampleTextureIfNeeded(withDevice: device),
|
||||
// let state = sampleComputeState
|
||||
// else {
|
||||
// throw MetaballsError.metalError("Missing Metal buffers or compute state")
|
||||
// }
|
||||
//
|
||||
// let encoder = buffer.makeComputeCommandEncoder()
|
||||
// encoder.setComputePipelineState(state)
|
||||
// encoder.setBuffer(parametersBuffer, offset: 0, at: 0)
|
||||
// encoder.setBuffer(ballBuffer, offset: 0, at: 1)
|
||||
// encoder.setTexture(sampleTexture, at: 0)
|
||||
// encoder.dispatchThreadgroups(threadgroupCount, threadsPerThreadgroup: threadgroupSize)
|
||||
// encoder.endEncoding()
|
||||
//
|
||||
// updateParametersBuffer()
|
||||
//
|
||||
// return encoder
|
||||
// }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue