mirror of
https://github.com/GayPizzaSpecifications/voxelotl-engine.git
synced 2025-08-03 21:21:34 +00:00
split core renderer stuff into metal subfolder
This commit is contained in:
23
Sources/Voxelotl/Renderer/Metal/PipelineOptions.swift
Normal file
23
Sources/Voxelotl/Renderer/Metal/PipelineOptions.swift
Normal file
@ -0,0 +1,23 @@
|
||||
import Metal
|
||||
|
||||
internal struct PipelineOptions: Hashable {
|
||||
let colorFormat: MTLPixelFormat, depthFormat: MTLPixelFormat
|
||||
let shader: Shader
|
||||
let blendFunc: BlendFunc
|
||||
}
|
||||
|
||||
internal extension PipelineOptions {
|
||||
func createPipeline(_ device: MTLDevice) throws -> MTLRenderPipelineState {
|
||||
let pipeDescription = MTLRenderPipelineDescriptor()
|
||||
pipeDescription.vertexFunction = self.shader.vertexProgram
|
||||
pipeDescription.fragmentFunction = self.shader.fragmentProgram
|
||||
pipeDescription.colorAttachments[0].pixelFormat = self.colorFormat
|
||||
self.blendFunc.setBlend(colorAttachment: &pipeDescription.colorAttachments[0])
|
||||
pipeDescription.depthAttachmentPixelFormat = self.depthFormat
|
||||
do {
|
||||
return try device.makeRenderPipelineState(descriptor: pipeDescription)
|
||||
} catch {
|
||||
throw RendererError.initFailure("Failed to create pipeline state: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user