Questions tagged [metalkit]

Use this tag for questions MetalKit, a framework that provides functions and classes intended to reduce the effort required to create a Metal application. Consider using a more specific tag such as [mtkview] or [mtktextureloader].

MetalKit is a framework that first appeared in iOS 9 and OS X El Capitan. It provides functions and classes intended to reduce the effort required to create a Metal application.

The following functions are the three key areas MetalKit provides:

  • Texture Loading enables your application to load textures from various sources easily. Loading of textures can be achieved in an asynchronous way with only a few lines of code. For more information, please see the MTKTextureLoader Class Reference.
  • Model Handling enables Metal-specific functionality to easily interface with Model I/O assets; these highly-optimized functions and objects make up of a collection that enables efficient data transfer between Metal buffers and Model I/O.
  • View Management provides a standard implementation of a Metal view and an optional drawing delegate, which reduce greatly the amount of code needed to generate graphics rendering in Metal app. For more information, please see the MTKView Class Reference and MTKViewDelegate Protocol Reference.

This tag is appropriate for general questions about MetalKit. Specific questions about any of the aformentioned functions should use a more specific tag instead, such as or .

400 questions
8
votes
1 answer

Metal makeComputeCommandEncoder assertion failure

I am trying to setup and execute a compute kernel and submit it's output to MTKView to draw. But I get the following crash: -[MTLDebugCommandBuffer computeCommandEncoder]:889: failed assertion `encoding in progress' What is wrong with the code…
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
7
votes
0 answers

Show depth data with ARKit and MetalKit

I am total beginner in Swift & iOS, and I am trying to: Visualise the depth map on the phone screen, instead of the actual video recording. Save both the RGB and depth data stream. I am currently stuck on the first one. I am using ARKit4 with…
Valeria
  • 1,508
  • 4
  • 20
  • 44
7
votes
1 answer

Is there any way to export Point Cloud data from LiDAR iOS14?

I am new for Metal and ARkit. I started learning about Lidar and scene’s depth data to visualize the shape. Below is the link for the point cloud sample code provided by Apple…
AnilG
  • 101
  • 1
  • 3
7
votes
1 answer

what the purpose of declaring a variable with "const constant"?

In Metal shader, What is the purpose of declaring a variable like const constant Vertex *vertexArray [[buffer(0)]] (with const constant I mean)? why constant alone is not enough? also, what is the difference between constant and const ? Also in the…
zeus
  • 12,173
  • 9
  • 63
  • 184
7
votes
2 answers

How do you synchronize a Metal Performance Shader with an MTLBlitCommandEncoder?

I'm trying to better understand the synchronization requirements when working with Metal Performance Shaders and an MTLBlitCommandEncoder. I have an MTLCommandBuffer that is set up as follows: Use MTLBlitCommandEncoder to copy a region of Texture…
kennyc
  • 5,490
  • 5
  • 34
  • 57
7
votes
1 answer

Is drawing to an MTKView or CAMetalLayer required to take place on the main thread?

It's well known that updating the user interface in AppKit or UIKit is required to take place on the main thread. Does Metal have the same requirement when it comes to presenting a drawable? In a layer-hosted NSView that I've been playing around…
kennyc
  • 5,490
  • 5
  • 34
  • 57
7
votes
3 answers

UIImage created from MTKView results in color/opacity differences

When I capture the contents of an MTKView into a UIImage, the resulting image looks qualitatively different, as shown below: The code I use to generate the UIImage is as follows: let kciOptions = [kCIContextWorkingColorSpace: CGColorSpace(name:…
Plutovman
  • 677
  • 5
  • 22
7
votes
1 answer

Connection between [[stage_in]], MTLVertexDescriptor and MTKMesh

What is the connection between: Using [[stage_in]] in a Metal Shader Using MTLVertexDescriptor Using MTKMesh For example Is it possible to use [[stage_in]] without using MTLVertexDescriptor? Is it possible to use MTLVertexDescriptor without…
hyperknot
  • 13,454
  • 24
  • 98
  • 153
7
votes
1 answer

CVMetalTextureCacheCreateTextureFromImage always return null

I'm trying to render I420 (YCbCr planner) via MetalKit most of examples are using the CMSampleBuffer which from Camera, but my goal is using a given I420 bytes. I do something like this: let data = NSMutableData(contentsOfURL:…
PatrickSCLin
  • 1,419
  • 3
  • 17
  • 45
6
votes
0 answers

SwiftUI CPU High Usage on Real-Time ForEach View Updating (macOS)

So I have a view and I am computing the amplitude of an audio file and then passing it to a view to graph it and it changes in real-time. The problem is that the graph gets so laggy after few seconds and CPU usage gets maximized and literally…
arata
  • 859
  • 1
  • 8
  • 23
6
votes
1 answer

Convert OpenCL/CUDA to Metal

I'm about to convert some GPU kernels of my project from OpenCL/Cuda to Metal in order to run my application on Apple devices. Currently, my project was written completely in C/C++. After doing some research, I think I need to get my hand dirty with…
dk1111
  • 188
  • 1
  • 5
6
votes
0 answers

How do you work with really large images in Metal?

TL;DR: In macOS 10.13, an MTLTexture has a maximum width and height of 16,384. What strategies can you use to be able to process and display images larger than 16,384 pixels using Metal? In a photo viewer that I'm currently working on, I've moved…
kennyc
  • 5,490
  • 5
  • 34
  • 57
6
votes
0 answers

How to change MTKView current drawable size

Apple documentation says the MTKView current drawable default size is derived from the current view’s size, in native pixels. Is there any way to make MTKView current drawable half of the device's screen size?
6
votes
2 answers

Why are there two brackets [ in the c++ vertex functions?

I am watching the introduction video's from Apple about Metal and MetalKit. The sample code for the shaders has these double brackets like [[buffer(0)]] arguments. Why are there two brackets? Does it mean anything or is it just to indicate that…
user965972
  • 2,489
  • 2
  • 23
  • 39
6
votes
0 answers

Water flow From Bottom to Top using Metal Kit iOS

I am creating an application, in which water will flow from bottom to top. i did many changes using source from https://github.com/FlexMonkey/ParticleLab Please find video on link below, this is look like Milk, but i am trying to make it as real…
Saood
  • 273
  • 1
  • 3
  • 17
1
2
3
26 27