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
0
votes
0 answers

Using MPSGraph.reductionSum on a specific axis

I have the following function: let mtlDevice = MTLCreateSystemDefaultDevice()! let device = MPSGraphDevice(mtlDevice: mtlDevice) let inputData: [UInt32] = [0, 45, 0, 0, 45, 81, 0, 54, 0, 0, 54, 81, 1, 45, 0, 1, 45, 81, 1, 54, 0, 1, 54, 81, 7, 63,…
konsolas
  • 1,041
  • 11
  • 24
0
votes
0 answers

Metal: Instance a Fragment Function?

I’m a beginner to MSL, I’ve written a pair of vertex and fragment shaders. The fragment shader takes a material argument to implement phong lighting. I then learned about instancing and modified my vertex function with the instance_id tag, but it…
bockyboh
  • 11
  • 1
  • 2
0
votes
0 answers

Crash when set CAMetalLayer.presentsWithTransaction=true in background thread

When set metalLayer.presentsWithTransaction = true, and when I call nextDrawable.present() in bg thread (our rendering thread is not main thread), the app sometimes will crash with: *** Terminating app due to uncaught exception…
luckysmg
  • 187
  • 1
  • 9
0
votes
0 answers

iOS MetalKit: Loop through array in MSL

This seems to be a silly question, but I can't find a good way to loop through an array and currently, I have to pass a buffer that contains the element count to my kernel function. kernel void test_func(constant const int2* array [[ buffer(0) ]], …
Son Nguyen
  • 1,124
  • 2
  • 10
  • 24
0
votes
0 answers

Problems when capturing video using AVCaptureVideoDataOutput and AVCaptureAudioDataOutput

fellow developers! I am working on an application for photo and video shooting with the ability to apply filters of the Core Image to frames right during shooting. Rendering and displaying frames using MTKView/Metal. Everything seems to work well,…
diclonius9
  • 69
  • 4
0
votes
0 answers

Error installing tensor flow-metal plugin

I followed the instruction to install the tensorflow-metal plugin, but when I ran the verification example found on the website I am getting these errors 2023-01-07 16:51:14.262420: I…
shark
  • 1
  • 1
0
votes
0 answers

Negating `function_constant()` call for conditionally omitting struct fields in Metal shading language

so it appears that Apple Metal got away with preprocessor directives, opting to use function constants for optionally enabling / disabling parts of shader code. I can conditionally enable certain struct fields, like so: constant bool…
Georgi B. Nikolov
  • 976
  • 2
  • 13
  • 24
0
votes
1 answer

CAMetalLayer.nextDrawable takes much time, even more than 8ms

CAMetalLayer.nextDrawable() should not be a very time-comsuming method.But sometimes it often takes much time, even more than 8ms Copy the code below Follow the comment guide in viewDidLoad See the log print class TestVC: UIViewController { …
luckysmg
  • 187
  • 1
  • 9
0
votes
0 answers

Recommended way to merge layers of textures in Metal?

Say I have a tree of graphics objects, and each one renders itself into a 'layer' – a Metal texture. Then as a final step I want to merge all these layers into one final output image, to display to screen. My first idea on how to do this is to run a…
Rob N
  • 15,024
  • 17
  • 92
  • 165
0
votes
1 answer

PyTorch memory leak reference cycle in for loop

I am facing a memory leak when iteratively updating tensors in PyTorch on my Mac M1 GPU using the PyTorch mps interface. The following is a minimal reproducible example that replicates the behavior: import torch def leak_example(p1, device): …
hrrrrrr5602
  • 103
  • 6
0
votes
1 answer

How can I write a using a struct to a MTLBuffer?

I have an array of 3 MTLBuffers. They are created and then reused. They are managed with semaphores to avoid conflicts. I need to write to them using a struct I created. I'm having trouble binding to the MTLBuffer and assign my struct format to it.…
T.J.
  • 3,942
  • 2
  • 32
  • 40
0
votes
1 answer

Trouble getting started with Metal shader compilation

I'm having trouble getting started with Metal's shader compilation. How to make a MTLLibrary that can link to a MTLDynamicLibrary (or MTLLinkedFunctions), in particular a library that declares extern functions that are to be resolved at runtime when…
Joseph Johnston
  • 533
  • 1
  • 3
  • 14
0
votes
0 answers

Transparency issue with Scenekit renderer on arkit

I have an odd behaviour in certain conditions when I have two geometries one above the other and the first one at least has alpha value != 0. I am using a program for the SCNMaterial, program is in metal and does simple stuff, color out is of the…
czane
  • 392
  • 1
  • 6
  • 18
0
votes
1 answer

How to Handle Apple Metal Texture RGB instead of RGBA

I'm working on an Apple Metal project in C++, and I was trying to implement things from learnopengl.com like the model loader. One part that I'm having trouble on is loading the textures correctly. In the code, I do: MTL::Texture*…
JPerez01
  • 91
  • 2
  • 10
0
votes
1 answer

Is it possible to declare and initialize a texture inside a .metal file?

I was just wondering, instead of creating a texture, initializing data to it via blit command encoder if it is private or by using MTLTexture replace if it not private, and passing it to GPU using setFragmentTexture, can I have the texture already…
user16217248
  • 3,119
  • 19
  • 19
  • 37
1 2 3
99
100