metal

device.newDefaultLibrary() returns nil

。_饼干妹妹 提交于 2020-01-07 06:25:25
问题 After I installed XCode 6 GM, application, compiled by it started to return nil at Metal Framework device.newDefaultLibrary() call. What's the problem? 回答1: Update your device to iOS 8 GM and it will stop failing. 回答2: Try use - (nullable id )newDefaultLibraryWithBundle:(NSBundle *)bundle error:(__autoreleasing NSError **)error 来源: https://stackoverflow.com/questions/25757157/device-newdefaultlibrary-returns-nil

device.newDefaultLibrary() returns nil

天涯浪子 提交于 2020-01-07 06:25:07
问题 After I installed XCode 6 GM, application, compiled by it started to return nil at Metal Framework device.newDefaultLibrary() call. What's the problem? 回答1: Update your device to iOS 8 GM and it will stop failing. 回答2: Try use - (nullable id )newDefaultLibraryWithBundle:(NSBundle *)bundle error:(__autoreleasing NSError **)error 来源: https://stackoverflow.com/questions/25757157/device-newdefaultlibrary-returns-nil

Custom Variable Declarations Using Metal With Scene Kit Shader Modifiers

假如想象 提交于 2020-01-05 04:58:53
问题 I am having difficulty passing uniforms to Scene Kit's shader modifiers. This seems to work fine when using OpenGL but not when using Metal. I have used SCNProgram successfully before but wanted to take advantage of SceneKit's tessellator instead of setting up compute shaders for tessellation. But I want to use the code I have already written in Metal rather than using OpenGL. There is unfortunately not a great deal of examples of how to do this. This Swift Playground illustrates how to do

How Metal distribute the image block to each thread group?

北城以北 提交于 2020-01-05 03:07:15
问题 For example, if I want to do a grayscale transformation, I need to set up my threadsPerGroup and thread group in the following way. NSUInteger maxTotalThreadsPerThreadgroup = [self.computePipelineState maxTotalThreadsPerThreadgroup]; MTLSize threadgroupCounts = MTLSizeMake(threadExecutionWidth * 2, threadExecutionWidth * 2, 1); MTLSize threadsPerThreadGroup = MTLSizeMake([self.texutre width] / threadgroupCounts.width + 1, [self.texutre height] / threadgroupCounts.height + 1, 1); I know the

CAMetalLayer drawable texture is weird on some devices

懵懂的女人 提交于 2020-01-04 02:32:22
问题 I am using the below code to get and append a pixel buffer from a metal layer. On some non specific devices the output looks like below and the drawable textures pixelFormat is .invalid static func make(with currentDrawable: CAMetalDrawable, usingBuffer pool: CVPixelBufferPool) -> (CVPixelBuffer?, UIImage) { let destinationTexture = currentDrawable.texture var pixelBuffer: CVPixelBuffer? _ = CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, pool, &pixelBuffer) if let pixelBuffer =

How to chain filters in Metal for iOS?

谁说我不能喝 提交于 2020-01-03 15:26:29
问题 I completed this tutorial by Simon Gladman (@flexmonkey) to capture images from AVFoundation and apply a filter to the output. However, I'm struggling to find a way to replace the blur filter with my own compute shader. In other words, I need to concatenate my custom shader after the YCbCrColorConversion filter mentioned there. let commandBuffer = commandQueue.makeCommandBuffer() let commandEncoder = commandBuffer.makeComputeCommandEncoder() // pipelineState has compiled YCbCrColorConversion

Save ARFaceGeometry to OBJ file

夙愿已清 提交于 2020-01-02 11:03:10
问题 In an iOS ARKit app, I've been trying to save the ARFaceGeometry data to an OBJ file. I followed the explanation here: How to make a 3D model from AVDepthData?. However, the OBJ isn't created correctly. Here's what I have: func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) { guard let faceAnchor = anchor as? ARFaceAnchor else { return } currentFaceAnchor = faceAnchor // If this is the first time with this anchor, get the controller to create content. //

How to use texture2d_array array in metal?

拈花ヽ惹草 提交于 2020-01-02 11:03:10
问题 I have been trying to use texture2d_array for my application of live filters in metal. But I'm not getting the proper result. Im creating the texture array like this, Code: Class MetalTextureArray . class MetalTextureArray { private(set) var arrayTexture: MTLTexture private var width: Int private var height: Int init(_ width: Int, _ height: Int, _ arrayLength: Int, _ device: MTLDevice) { self.width = width self.height = height let textureDescriptor = MTLTextureDescriptor() textureDescriptor

Metal Custom CIFilter different return value

你离开我真会死。 提交于 2020-01-02 08:15:21
问题 I'm writing CIFilter, but result pixel colors are different than returned values from metal function. kernel.metal #include <CoreImage/CoreImage.h> extern "C" { namespace coreimage { float4 foo(sample_t rgb){ return float4(0.3f, 0.5f, 0.7f, 1.0f); } } MetalFilter.swift import CoreImage class MetalFilter: CIFilter { private let kernel: CIColorKernel var inputImage: CIImage? override init() { let url = Bundle.main.url(forResource: "default", withExtension: "metallib")! let data = try! Data

Explaining the different types in Metal and SIMD

柔情痞子 提交于 2020-01-02 05:22:08
问题 When working with Metal, I find there's a bewildering number of types and it's not always clear to me which type I should be using in which context. In Apple's Metal Shading Language Specification, there's a pretty clear table of which types are supported within a Metal shader file. However, there's plenty of sample code available that seems to use additional types that are part of SIMD. On the macOS (Objective-C) side of things, the Metal types are not available but the SIMD ones are and I'm