Questions tagged [metal]

Metal is a proprietary framework for GPU-accelerated advanced 3D graphics rendering and data-parallel computation workloads. Made by Apple.

Metal is a proprietary framework for GPU-accelerated advanced 3D graphics rendering and data-parallel computation workloads. Made by Apple.

Metal provides the lowest-overhead access to the GPU, enabling you to maximize the graphics and compute potential of your apps on iOS, OS X, and tvOS. With a streamlined API, precompiled shaders, and support for efficient multi-threading, Metal can take your game or graphics app to the next level of performance and capability.


OpenGL Vs Metal

OpenGL vs Metal

Red: The game
Blue: is GPU use


Metal is specifically designed to exploit modern architectural considerations, such as multiprocessing and shared memory, to make it easy to parallelize the creation of GPU commands. This design philosophy extends to the tools used to build iOS apps.

From https://developer.apple.com/metal/.

2141 questions
12
votes
5 answers

How to use UnsafeMutableRawPointer to fill an array?

I have a Metal texture, I want to access its data from Swift by making it a float4 array (so that I can access each pixel 4 color components). I discovered this method of MTLTexture : getBytes(UnsafeMutableRawPointer, bytesPerRow: Int,…
Pop Flamingo
  • 3,023
  • 2
  • 26
  • 64
12
votes
2 answers

Metal - `include` or `import` function

Is it possible to import or include metal file into another metal file? Say I have a metal file with all the math functions and I will only include or import it if it is needed in my metal project. Is it possible? I tried: #include "sdf.metal" and…
sooon
  • 4,718
  • 8
  • 63
  • 116
12
votes
3 answers

Compute sum of array values in parallel with metal swift

I am trying to compute sum of large array in parallel with metal swift. Is there a god way to do it? My plane was that I divide my array to sub arrays, compute sum of one sub arrays in parallel and then when parallel computation is finished compute…
Marko Zadravec
  • 8,298
  • 10
  • 55
  • 97
12
votes
2 answers

Multiple models in Metal. How?

This is an absolute beginner question. Background: I’m not really a game developer, but I’m trying to learn the basics of low-level 3D programming, because it’s a fun and interesting topic. I’ve picked Apple’s Metal as the graphics framework. I know…
Tamas Czinege
  • 118,853
  • 40
  • 150
  • 176
12
votes
1 answer

using the pure Metal-API alongside with SceneKit or SpriteKit

I have a SKView and a MTKView running in one application and everything is working well so far. The only thing is, that both views are poorly visually integrated. They are just side by side. But I would like to have the pure metal rendering inside…
Oliver
  • 167
  • 1
  • 7
12
votes
2 answers

iOS Metal compute pipeline slower than CPU implementation for search task

I made simple experiment, by implementing naive char search algorithm searching 1.000.000 rows of 50 characters each (50 mil char map) on both CPU and GPU (using iOS8 Metal compute pipeline). CPU implementation uses simple loop, Metal implementation…
Lukasz
  • 19,816
  • 17
  • 83
  • 139
11
votes
1 answer

Texture ARMeshGeometry from ARKit Camera frame?

This question somewhat builds on this post, wherein the idea is to take the ARMeshGeometry from an iOS device with LiDAR scanner, calculate the texture coordinates, and apply the sampled camera frame as the texture for a given mesh, hereby allowing…
ZbadhabitZ
  • 2,753
  • 1
  • 25
  • 45
11
votes
1 answer

Alpha Blending in Metal Not Giving The Expected Results

I'm having trouble rendering semitransparent sprites in Metal. I have read this question, and this question, and this one, and this thread on Apple's forums, and several more, but can't quite get it to work, so please read on before marking this…
Nicolas Miari
  • 16,006
  • 8
  • 81
  • 189
11
votes
4 answers

iOS12 is causing an error on Metal Command Buffer execution, render is glitchy or doesn't occur

We have an app that uses Metal to render. This app works correctly on devices running iOS11. When using the same app on devices running iOS12, we started getting glitches and sometimes hangs in the rendering. We also tried recompiling for iOS12 and…
11
votes
3 answers

CVMetalTextureCacheCreateTextureFromImage returns -6660 on macOS 10.13

I'm recording the screen from my iPhone device to my Mac. As a preview layer, I am collecting sample buffers directly from an AVCaptureVideoDataOutput, from which I'm creating textures and rendering them with Metal. The problem I'm having is that…
Marko Hlebar
  • 1,973
  • 17
  • 18
11
votes
1 answer

Is it safe to feed unaligned buffers to MTLBuffer?

When trying to use Metal to rapidly draw pixel buffers to the screen from memory, we create MTLBuffer objects using MTLDevice.makeBuffer(bytesNoCopy:..) to allow the GPU to directly read the pixels from memory without having to copy it. Shared…
ldoogy
  • 2,819
  • 1
  • 24
  • 38
11
votes
2 answers

Metal Shader with SceneKit SCNProgram

I'm looking for just a working Metal shader that works in SceneKit with SCNProgram. Can someone show me the correct method declarations/how to hook this up? let program = SCNProgram() program.vertexFunctionName =…
Chris
  • 2,739
  • 4
  • 29
  • 57
11
votes
2 answers

Metal Shading Language - (Console) Output?

Can I debug my metal-shading-language code using console output (like print in Swift)? If yes, how? If no, are there any other ways to output variables from my .metal file? (Maybe by passing data from the .metal file to my .swift file using the…
ediheld
  • 233
  • 3
  • 13
11
votes
1 answer

How to debug metal kernel of ios in Xcode?

I have written metal kernel (.metal) in shader language. But it's not working as I expected so I thought about debugging and I am following Metal Tips and Techniques for debugging. I have called the insertDebugCaptureBoundary method of…
Mohan
  • 1,871
  • 21
  • 34
11
votes
1 answer

Inconsistent SceneKit framerate

I'm seeing very inconsistent frame rates in the SceneKit starter project. Sometimes it runs constantly at 60 fps (12ms rendering, 6ms metal flush), and sometimes it runs constantly at 40 fps (20ms rendering, 6ms metal flush), no more, no less. The…
Xzya
  • 337
  • 7
  • 16