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
11
votes
2 answers

newComputePipelineStateWithFunction failed

I am trying to let a neural net run on metal. The basic idea is that of data duplication. Each gpu thread runs one version of the net for random data points. I have written other shaders that work fine. I also tried my code in a c++ command line…
R Menke
  • 8,183
  • 4
  • 35
  • 63
11
votes
2 answers

Getting started with Metal

I'm an Objective-C / Swift software developer (in training) currently with an application in the App Store. But I have recently really been interested in Metal, Apple's new alternative to OpenGL. But I'm not exactly sure how to begin... Apple's…
jaller200
  • 548
  • 5
  • 15
11
votes
5 answers

Is there any possibility of using C++ directly with Metal API

As Metal Language is also based on C++11, and C++ would seem to be a perfect fit which is a proven performance language, i am looking to altogether bypass Objective-C / Swift. I would love to remain in C++ arena. Is there a possibility?
Bilal Ahsan
  • 172
  • 1
  • 1
  • 9
11
votes
2 answers

How do I pass a Float uniform to iOS Metal shader using Swift?

I want to pass a float to my metal shader. I cannot figure out how. Here is my shader: vertex float4 model_vertex(unsigned int iid[[instance_id]] constant float angle) { float number = float(iid) / 64.0; return…
Hallgrim
  • 15,143
  • 10
  • 46
  • 54
10
votes
1 answer

SwiftUI updates reduce FPS of metal window

I'm experimenting with SwiftUI and Metal. I've got 2 windows, one with various lists and controls and the other a Metal window. I had the slider data updating the Metal window but when I moved the slider the FPS dropped from 60 to around 25. I…
Leigh
  • 188
  • 2
  • 13
10
votes
1 answer

What is the coordinate system used in metal?

In metal what coordinate system to use inside shader (in and out)? and when we render to texture is it the same? with the z buffer also? Are there any inconsistencies? finally what are the difference between metal, opengl and directX ?
zeus
  • 12,173
  • 9
  • 63
  • 184
10
votes
1 answer

How to use multisampling with an MTKView?

I'm trying to get multisampling working with MTKView. I have an MTKView with a delegate. I set the view's sampleCount property to 4. I create a pipeline state descriptor with the rasterSampleCount set to 4, and use that to make a render pipeline…
user1118321
  • 25,567
  • 4
  • 55
  • 86
10
votes
2 answers

Alpha / Transparency & MTKView?

I have a Metal fragment shader that returns some transparent colors with an alpha channel and I'd like to reveal a UIView under the MTKView, but they only background result I get is black and "error…
Heestand XYZ
  • 1,993
  • 3
  • 19
  • 40
10
votes
1 answer

Programmatic generation of MDLMesh objects using initWithVertexBuffers

If you're using iOS Metal, and you have custom programmatic object models, and (like me) your models stopped working with the advent of Metal2 and iOS 11, then you've probably started looking into how to programmatically generate an MDLMesh. Apple…
Mike Roberts
  • 231
  • 2
  • 9
10
votes
1 answer

How to precompile PBR shaders for SceneKit?

I've noticed that if you have an empty scene and then load a 3D model in it with physically based lighting, there is a small bit of jank as the object appears. If I then add a different object in after that, that stuttering does not occur. Looking…
pushmatrix
  • 726
  • 1
  • 9
  • 23
10
votes
3 answers

Resizing MTKView scales old content before redraw

I'm using a MTKView to draw Metal content. It's configured as follows: mtkView = MTKView(frame: self.view.frame, device: device) mtkView.colorPixelFormat = .bgra8Unorm mtkView.delegate = self mtkView.sampleCount = 4 mtkView.isPaused =…
Remco Poelstra
  • 859
  • 6
  • 20
10
votes
2 answers

Metal 'texture' not found

With every Implementation of Metal based ImageView I'm facing the same problem let targetTexture = currentDrawable?.texture else{ return } Value of type 'MTLDrawable' has no member 'texture' Seems like apple has changed some metal api here is the…
10
votes
2 answers

MetalKit - Drawable.texture assertion error

I am new to MetalKit and trying to convert this tutorial from playground back to OSX app: import MetalKit public class MetalView: MTKView { var queue: MTLCommandQueue! = nil var cps: MTLComputePipelineState! = nil required public…
sooon
  • 4,718
  • 8
  • 63
  • 116
10
votes
1 answer

How to create a MTLTexture backed by a CVPixelBuffer

What's the correct way to generate a MTLTexture backed by a CVPixelBuffer? I have the following code, but it seems to leak: func PixelBufferToMTLTexture(pixelBuffer:CVPixelBuffer) -> MTLTexture { var texture:MTLTexture! let width =…
Chris
  • 2,739
  • 4
  • 29
  • 57
10
votes
1 answer

Multisampling/jagged edges in Metal (iOS)

I'm currently trying to draw a graphic that will be animated using Metal in Swift. I have successfully drawn a single frame of my graphic. The graphic is simple, as you can see from this image. What I can't figure out is how to multisample the…
Jeff Becker
  • 125
  • 2
  • 8