Questions tagged [metal]

0

votes
0

answer
5

Views

How to retrieve an environment texture (MTLTexture) cubeMap and change to Spherical Harmonics

I would like to save the auto-generated environment texture from an ARWorldTrackingConfiguration, and then load that same texture later into a different tracking configuration to be added to a model. How is this done? I have looked through everything I could find online and looked through Apple's do...
A.M.
0

votes
2

answer
91

Views

What (and why) is the most safe way to use a internal hardware watchdog in a bare-metal embedded app with a static cooperative scheduler?

I've already used internal hardware watchdogs in several OS-less embedded applications (with static cooperative schedulers). What I do is: I look for the slowest periodic and lowest priority task I set the watchdog timeout to something more than the period of the slowest task then I kick the dog at...
Guillaume D
1

votes
0

answer
8

Views

How do I reference an arbitrary id<MTLTexture> for use in a SCNTechnique?

TL;DR: How does one reference a 'not on disk' sampler2D symbol and pass it to an SCNTechnique? My technique works if I reference an image from my bundle, but if I dont, I cannot find a way to pass in an existing id to the sampler symbol my technique has set up. Long: I have a valid working SCNTechni...
vade
1

votes
1

answer
36

Views

Linear interpolation for vertices to achieve faceted appearance in Metal

I was trying to make an artistic look with Metal. The effect to achieve is to render a faceted teapot based on triangle primitives, instead of a smooth and mellow teapot. I am not sure how I can do this. I know I should tell Metal to calculate pixels inside a triangle as if the triangle is planar, i...
jackxujh
1

votes
0

answer
76

Views

GPU-accelerating a time-intensive function with Metal

I have a function that takes 1-3 minutes to run because it's doing some heavy lifting inside of a C++ library. The function returns a I have an ObjC wrapper around the library and a Swift extension like such: extension MyCoreLib { func runTheLongFunction() -> String { let device = MTLCreateSystemDef...
Zack Shapiro
0

votes
0

answer
5

Views

MTKView Drawing Performance

What I am Trying to Do I am trying to show filters on a camera feed by using a Metal view: MTKView. I am closely following the method of Apple's sample code - Enhancing Live Video by Leveraging TrueDepth Camera Data (link). What I Have So Far Following code works great (mainly interpreted from abov...
Gizmodo
1

votes
0

answer
34

Views

Why does Metal constant with h suffix produce bad byte range results?

I have run into a very strange problem in my Metal shader that has to do with a byte value in the range (0, 255). This byte value is represented as a ushort that is converted to a half precision by code like (x / 255.0h). What is strange is that this literal constant divide seems to be optimized inc...
MoDJ
1

votes
0

answer
158

Views

The processing speed between swift and objective-c in Metal

I have written a demo base on apple official document in swift. And I found the usage of CPU is lower in Objective-c than in swift. Does it mean Objective-c is much effective than swift while handling metal app? I'm confused because many people says that swift is faster than Objective-c in general....
Dove Zarchary
1

votes
1

answer
207

Views

Swift include metal shader into library [Using swift package manager]

I've always worked with Xcode projects but now I'm starting a project that I want in the future run on other platforms, so I'm using Swift Package Manager to generate the project, but I'm facing an issue, my library need to include a metal shader file (also a openGL shader file), but I'm clueless on...
norman784
1

votes
1

answer
348

Views

Mipmap sampler in Metal compute kernel (not vertex or fragment shader)

I have a source texture (480x480) that was created with mipmapped set to true (error checking removed to simply this post), and a dest texture (100x100): // source texture var textureDescriptor = MTLTextureDescriptor.texture2DDescriptor(pixelFormat: MTLPixelFormat.r8Unorm, width: Int(480), height: I...
Labeno
1

votes
1

answer
252

Views

Metal shader output data (GPGPU)

I'm trying to implement some image detection algorithms on ios and I need some data preparation that should work as shader (Metal) so it should pass output array with result data. Small example: SWIFT ... // Create buffer var resultBuffer = device.makeBuffer(length: SIZE * MemoryLayout.size, option...
Sergey Grigorchuk
1

votes
0

answer
151

Views

AVPlayerItem.seek(to: cmTime, toleranceBefore:, toleranceAfter:) to get specific video frames?

This week I've had a miserable time trying to get video frames from a Quicktime movie and display them in a Metal texture. It has been far harder than I anticipated. I just want to show frame 0, and then step back and forth through the video frames with the arrow keys. After failing with the AVPla...
bsabiston
1

votes
0

answer
374

Views

No rendertargets set in RenderPassDescriptor

The signal SIGABRT error: validateRenderPassDescriptor:611: failed assertion `No rendertargets set in RenderPassDescriptor.' This is how I set up the MTLRenderPassDescriptor: guard let currenDrawable: CAMetalDrawable = self.currentDrawable else { return } let renderPassDescriptor = MTLRenderPassDesc...
Hexagons
1

votes
1

answer
325

Views

Metal vs GLSL CoreImage performance

In WWDC session 510, Apple engineers present support for coding CIKernel in Metal and claim it should work faster. I've made together a test project which implements motion blur in both metal and glsl (code is similar to the one from 510 session). Sometimes metal kernel is faster, sometimes glsl k...
Dannie P
1

votes
0

answer
120

Views

Why FPS Gauge in Xcode not usable for non-OpenGL ES or non-Metal App

Xcode's FPS Gauge and GPU Report seems only usable for code directly using OpenGL ES and Metal(This pic is captured using non-OpenGL ES or non-Metal demo). In my understanding, Even Core Graphics and Core Animation are built on OpenGL ES and Metal. Android can use dumpsys gfxinfo to get information...
keywind
1

votes
1

answer
586

Views

Load Balancing Applications in Kubernetes Bare-Metal

I've been looking at setting up an Ingress controller for a bare-metal Kubernetes cluster. I started looking at Ingress controllers, but these seem to only work well for HTTP services that are reachable via port 80 or 443. If you need to expose a TCP or UDP service on an arbitrary port, it seems pos...
Ross Peoples
1

votes
0

answer
162

Views

iOS: drawbacks of disabling Metal API Validation in order to fix pipeline failed assertion?

Adding a SKEmitterNode to a SceneKit Scene via a SpriteKit overlay generates the following exception: -[MTLDebugRenderCommandEncoder validateFramebufferWithRenderPipelineState:]:1196: failed assertion `For color attachment 0, the render pipeline's pixelFormat (MTLPixelFormatRGBA8Unorm_sRGB) does not...
Crashalot
1

votes
1

answer
273

Views

iOS Metal API draw 3d texture inside the volume

So, I'm trying to render a cube with 3d texture. Texture contains 3 slices of 3 diferent colors, red green and blue. Each slice consists of 4 pixels with the same color. Works fine. https://imgur.com/a/a5oXi private func makeTexture() { let width = 2 let height = 2 let depth = 3 let byteSize = 4 let...
Yura Sorokin
1

votes
0

answer
196

Views

CIImage says `Cannot render image (with an input Metal texture) using a metal context.`

I am attempting to convert a MTLTexture to a CGImage by adding an extension function to MTLTexture objects inside of my macOS playground. The current function looks like this: extension MTLTexture { func toImage() -> CGImage? { let context = CIContext() let texture = self let cImg = CIImage(mtlTextu...
J.Doe
1

votes
0

answer
39

Views

Displaying a MTLTexture in a macOS playground by converting it to CImage or other working format

I am having trouble converting a MTLTexture into a format that can easily be displayed inside of a macOS playground. There are a variety of solutions I have found however none of them are updated to Swift 4 and after I update them I have found no success with them. Additionally all of the better mai...
J.Doe
1

votes
0

answer
111

Views

Metal shaders: converting non-position fragment shader arguments to windows/pixel coords?

In my Metal app I need to do some distance comparisons between the fragment position and a baseline, which I pass in from the vertex shader. The fragment position comes to the fragment shader in window, or pixel, coordinates. I guess this is because the argument is marked [[stage-in]], or maybe be...
bsabiston
1

votes
1

answer
111

Views

How to specify TextureUsage for Textures created with CVMetalTextureCache

I need to create textures from CVPixelBuffers so I'm using the CVMetalTextureCache to generate them. I would like to use those textures as a render target, but I haven't find the way to specify the MTLTextureUsage. TextureAttributes argument is marked as 'reserved for future use' if there is no way...
vtruant
1

votes
0

answer
77

Views

Bare metal OS can't use locals

I just started to get into OS development, emulating a raspi2 (cortex a7) with qemu. Right now I'm stuck because I can't use local variables when the cpu is in user mode. here's what my main program looks like #include uint32_t function_with_locals() { uint32_t l1 = 5; uint32_t l2 = 3; return l1 -...
NBWL
1

votes
0

answer
88

Views

Core Image filter intermittently crashes when running in a NSOperation

I have a simple Core Image filter running in a NSOperation. It works most of the time, but, every now and then it will crash (the rest of the code never crashes that doesn't use Core Image). When it crashes, it always has the same backtrace pointing to MetalTools-[MTLDebugComputeCommandEncoder setSa...
Jeshua Lacock
1

votes
0

answer
1.3k

Views

Execution of the command buffer was aborted due to an error during execution

I've been stuck on this for a while; this isn't a particularly expensive shader (at least, based on my very limited experience with Metal), yet I still get this message for the first few frames: Execution of the command buffer was aborted due to an error during execution. Caused GPU Hang Error (IOAF...
Philip S
1

votes
0

answer
43

Views

Metal fragment shader bound resource acting erratically on macOS

This problem has been stumping me, and I can't figure it out. I've got a few different shaders which use the same resource, a structure with a bunch of lighting values. The first shader to use it works fine -- the second one does not. Seems like it might be getting zeroes. The third shader to us...
bsabiston
1

votes
0

answer
199

Views

Edge detection overlay with lines

I need to overlay the edges detected in live video preview with a color of my choice (as is done in Lightroom CC app when you adjust focus). What's the easiest way to draw those lines in real time using Metal or CoreImage? I can use Sobel edge detection to detect the edges using Metal Performance Sh...
Deepak Sharma
1

votes
0

answer
110

Views

Updating mesh vertex positions per frame (from CPU) in SceneKit

I have custom shader that deforms geometry of SCNNode, however the geometry is not mutated on CPU side which causes issues when trying to interact with the deformed model. A custom blit shader needs to be implemented with an additional MTLBuffer that will copy the deformed vertices back to CPU. Can...
Astemir Eleev
1

votes
1

answer
84

Views

What kind of keypoints are detected by MPSImageFindKeypoints?

Apple documentation mentions a Metal kernel called MPSImageFindKeypoints but there is no information about what kind of features is that. From the parameters, it looks similar to FAST keypoints. By which algorithm is this kernel powered? Are those features the ones that ARKit uses? (Accessible via r...
tomas789
1

votes
0

answer
86

Views

SAMA5D36 xplained board USB not connecting

I'm flashing code for usb cdc serial SAMA5D36 xplained board. All configurations are happening but the USB is not getting connected. I think its because of the Vbus pin is not getting high and the device is getting disconnected. Can you help me with this why its happening and a solution for this iss...
1

votes
0

answer
281

Views

How to render MTLTexture generated by SCNRenderer?

Currently I have 3D scene with some object. I want to render it to 2D texture (for example MTLTexture). After that I want to show this rendered texture on screen like an image (for example in MTKView or SKScene) in realtime and simultaneously write it in the movie. For now I have SCNRenderer and off...
Joker
1

votes
0

answer
113

Views

Metal Alpha value of Color not changing

fragment half4 fragment_shader(VertexOut vIn [[stage_in]]){ return half4(1,1,0.75,0.0); } In the Sample Drawing Triangle program for each vertices I am passing this fragment Shader. Since Alpha is Zero There shouldnot be any output. Changing Alpha Not Working Output not changing with Alpha Change
1

votes
0

answer
530

Views

Getting error message “[CAMetalLayerDrawable texture] should not be called after already presenting this drawable. Get a nextDrawable instead.”

I just need to render multiple objects simultaneously. But I am getting an error as mention. Here I am passing multiple objects to my render func. var sceneObject:Array = [objectToDraw,temObjectToDraw] for scene in sceneObject{ scene .render(commandQueue: commandQueue, pipelineState: pipelineState,...
user8028778
1

votes
1

answer
38

Views

Can I add secondary gpu to baremetal server

Can I add secondary or another GPU to bare metal server, I tried to get the price details to confirm the same but getting following error slcli order place --verify --billing monthly --complex-type SoftLayer_Container_Product_Order_Hardware_Server DUAL_E52600_V4_12_DRIVES DALLAS12 REBOOT_KVM_OV...
Ahamad
1

votes
0

answer
32

Views

Is there a glColorMask equivalent in SceneKit?

Is there a way to only write certain components of the color into the image buffer in SceneKit like with glColorMask in OpenGL? I tried the SCNMaterial's property .colorBufferWriteMask, but no luck.
user973224
1

votes
1

answer
129

Views

Metal depth stencil not working

I have a MetalKit project on MacOS where everything works as expected except for the depth stencil. Because I could only find examples of the depth stencil for iOS I'm following those. The snippet below is being called immediately after the render pipeline was created but the return value from newDe...
GenericPtr
1

votes
0

answer
87

Views

drawing Circle/SemiCircle in Metal

I am new to metal. I want to draw a semi circle. Any ideas or suggestions to draw a semi circle. I tried using tesselation float u = patch_coord.x; float v = patch_coord.y; float w = patch_coord.z; float x = u * patchIn.control_points[0].position.x + v * patchIn.control_points[1].position.x + w * p...
Ruban4Axis
1

votes
1

answer
179

Views

How to reduce video processing time on iOS?

I am currently using AVComposition and CIFilter for apply filter and AVExportSession to export that video but this is taking to much time like 30 seconds for processing 45 seconds video. I have also tried to used MtalPetal with SDAVAssetExportSession but still its taking time. I have also tried GPUI...
Surjeet Rajput
1

votes
0

answer
77

Views

Using OpenCV rotation and translation in iOS Metal to draw AR cube

I am new to playing the AR, computer vision and graphics. I am trying to use make a AR experience using OpenCV and Metal in iOS. Rotation and Translation was retrieved by SolvePnP and passed to Metal to draw the cube pose. However, there are a few problems: The cube jump out of the view as soon as t...
cuth
1

votes
1

answer
225

Views

What is the main difference between float4 and half4 in fragment shader function?

I try to set render pipeline and MTKView color attachment pixel format of MTLPixelFormatRGBA16Float. However, it seem same with MTLPixelFormatBGRA8Unorm_sRGB. I just want to make the render color range higher(HDR). Is the return type of the fragment function important? What should I set to realize...
BigFatTom

View additional questions