A memory allocation in iOS and macOS, for storing unformatted data that is accessible to the GPU.
Questions tagged [mtlbuffer]
29 questions
1
vote
0 answers
Convert audio CMSampleBuffer to MTLBuffer
What is the most efficient way to convert audio CMSampleBuffer buffers to MTLBuffer buffers? I would also like to efficiently as possible convert MTLBuffer buffers back to CMSampleBuffer buffers.
Do I need to first convert audio CMSampleBuffer to…

Jeshua Lacock
- 5,730
- 1
- 28
- 58
0
votes
1 answer
How do I specify a deallocator for memory allocated with mem_align in Swift?
I am creating paged aligned memory with memory_align, then I create a MTLBuffer from that with no copy. The GPU then blits data into that MTLBuffer. When that completes, I wrap that same memory in Data with Data.init(bytesNoCopy:count:deallocator:)…

T.J.
- 3,942
- 2
- 32
- 40
0
votes
0 answers
How to correctly use mmap() and newBufferWithBytesNoCopy together?
While generating a texture from an MTLBuffer created from mmap() via newBufferWithBytesNoCopy, if the number of pages requested by the len argument to mmap is larger than the number of pages of size of the file, the mmap call succeeds, and the…

user16217248
- 3,119
- 19
- 19
- 37
0
votes
0 answers
Block passed to deallocator for newBufferWithBytesNoCopy is never called/used
I have the following inside the main function. I have ensured earlier that CONTENT_SIZE is page aligned.
if (!(Queue = [Device = MTLCreateSystemDefaultDevice() newCommandQueue])) // Set global variables
return EXIT_FAILURE;
{
const…

user16217248
- 3,119
- 19
- 19
- 37
0
votes
2 answers
How to draw a line with variable endpoints with Metal on macOS?
I need to draw a line (light-source/light-target) with Metal on macOS within a 60 FPS animation while the two endpoints coordinates of the line change on each frame.
Actually I can properly draw a static line with Metal using a MTLBuffer containing…

Leonardo
- 751
- 8
- 15
0
votes
0 answers
Can I dereference and assign a value to a pointer in Metal Shader
I would like to dereference a pointer and assign it a value in a Metal Shader (Kernel), like so (simple example);
kernel void test_kernel()
{
device uint64_t* ptr;
*ptr = 1;
}
When I run this I get the following error;
Execution of the…

fuzzy_motion
- 11
- 2
0
votes
1 answer
Issue creating MTLBuffer from MTLTexture used as inputs in CoreML Custom Layer for GPU execution
I am trying to create a CoreML Custom layer that runs on the GPU, using Objective-C for CoreML setup and Metal for GPU programming.
I have created the CoreML model with the custom layer and can successfully execute on the GPU, I wish to create an…
0
votes
1 answer
Why is this Metal code not producing the correct triangle geometry?
I am following a Metal tutorial by Metal By Example and converting the code to Swift.
I am running the second example, and for some reason, this code is not working.
import UIKit
import Metal
import MetalKit
import simd
class MBEMetalView:…

Evan Escobar
- 93
- 8
0
votes
1 answer
MTKView blend issues when re-using currentDrawable.texture in draw() loop
I am working on a metal-backed painting application in which I divide the drawing of a stroke in two steps: the first step draws the leading edge of a stroke to screen and captures the entire to an MTLTexture via:
metalTextureComposite =…

Plutovman
- 677
- 5
- 22
0
votes
0 answers
MTKView texture correct color build-up
I am working on a metal-backed drawing application where brushstrokes are drawn on an MTKView by stamping a textured square repeatedly along a path. I am having color-accumulation issues as illustrated with the picture below:
For alpha values [0.5…

Plutovman
- 677
- 5
- 22
0
votes
0 answers
Sending SetFragment Texture Onetime in Metal IOS
I am drawing quad and attaching texture where my finger touches in screen. the texture i am using is same. but after some time of finger touch FPS goes down to 5 to 10. If I debug
We can see in the image the setFragmentTexture Command going…

Ruban4Axis
- 821
- 6
- 27
0
votes
1 answer
Rotation around z- axis through arbitary (x,y) point in metal
I have a plane with four vertices. It can be rotate around z-axis (0, 0,1).(achieve using model matrix in metal).Model matrix is changed base on rotation gesture.
So what I need to do is rotate plane around z-axis through arbitrary (x,y) where x,y…

Kasun Palihakkara
- 321
- 3
- 22
0
votes
0 answers
Metal Texture updating in a very weird way
I am in the process of trying to write a Monte Carlo Path tracer using Metal. I have the entire pipeline working (almost) correctly. I have some weird banding issues, but that seems like it has more to do with my path tracing logic than with…

JoeVictor
- 1,806
- 1
- 17
- 38
0
votes
2 answers
Swift 3 / Xcode 9. MTLBuffer 'didModifyRange' is unavailable
I'm trying to tell a MTLBuffer that the range has changed but the compiler won't let me do that:
vertexBuffer?.didModifyRange(NSMakeRange(0,MemoryLayout.stride*nbVerts))
it just says: 'didModifyRange' is unavailable
why is that?
thanks

user1822451
- 101
- 1
- 5