Questions tagged [mtlbuffer]

A memory allocation in iOS and macOS, for storing unformatted data that is accessible to the GPU.

29 questions
31
votes
1 answer

Using a MTLTexture as the environment map of a SCNScene

I want to set a MTLTexture object as the environment map of a scene, as it seems to be possible according to the documentation. I can set the environment map to be a UIImage with the following code: let roomImage = UIImage(named:…
halileohalilei
  • 2,220
  • 2
  • 25
  • 52
4
votes
1 answer

How to pass dynamic sized super large array to Metal Argument buffers?

I have a large array with more than 1 million struct instance. The size is actually dynamic. It works fine with MTLBuffer, it appears to be a pointer in Metal shader, and I don't have to write some hardcoded size or length. The problem is, I don't…
iaomw
  • 720
  • 6
  • 21
2
votes
1 answer

Reading contents from a generic MTLBuffer?

Within my app, I have a MTLBuffer which is being instantiated using a generic type. In one particular case, the buffer will hold values as related to particles in a point cloud, and is defined as such; struct ParticleUniforms { simd_float3…
ZbadhabitZ
  • 2,753
  • 1
  • 25
  • 45
2
votes
1 answer

How To Set Up Byte Alignment From a MTLBuffer to a 2D MTLTexture?

I have an array of float values that represents a 2D image (think from a CCD) that I ultimately want to render into a MTLView. This is on macOS, but I'd like to be able to apply the same to iOS at some point. I initially create an MTLBuffer with the…
Demitri
  • 13,134
  • 4
  • 40
  • 41
2
votes
1 answer

MTLBuffer with MTLStorageModePrivate mode

I'm relatively new to the Metal, and I have a pretty straight-forward question. I simply can not init MTLBuffer with MTLStorageModePrivate option: id privateBuff = [device newBufferWithLength:dataLength…
Eugene Alexeev
  • 1,152
  • 12
  • 32
2
votes
2 answers

how to display MTKView with rgba16Float MTLPixelFormat

I have an MTKView set to use MTLPixelFormat.rgba16Float. I'm having display issues which can be best described with the following graphic: So the intended UIColor becomes washed out, but only while it is being displayed in MTKView. When I convert…
Plutovman
  • 677
  • 5
  • 22
2
votes
1 answer

Metal newBufferWithBytes usage

I have a basic question about allocating new Metal device buffers. Most of the sample codes I see create MTLBuffer at setup time and do not modify it. But I wonder if the vertex data is changing at every render call, is it okay to every time create…
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
2
votes
1 answer

Changing values of MTLBuffer after created

I would like to be able to define a MTLBuffer and populate data directly to the buffer (or as efficiently as possible). If I do the following, the values used in the shader are 1.0 and 2.0 (for X and Y respectively), not 3.0 and 4.0 which are set…
Jeshua Lacock
  • 5,730
  • 1
  • 28
  • 58
1
vote
1 answer

Need for CPU-GPU sync if write and read happens on different memory pages of MTLBuffer?

I am using an MTLBuffer in Metal that I created by allocating several memory pages (using vm_allocate) with device.makeBuffer(bytesNoCopy:length:options:deallocator:). I write the buffer with CPU and the GPU only reads it. I know that generally I…
Céline
  • 185
  • 7
1
vote
1 answer

Draw portion of MTLBuffer?

I am rendering point fragments from a buffer with this call: renderEncoder.drawPrimitives(type: .point, vertexStart: 0, vertexCount: 1, instanceCount:…
Jeshua Lacock
  • 5,730
  • 1
  • 28
  • 58
1
vote
1 answer

Is necessary to recreate MTLBuffer, MTLTexture or other metal resources when the app is brought to foreground?

I'm refactoring the render layer of cocos2d-x, and the new engine will use Metal on iOS. In the original version, cocos2dx would recreate all buffers and textures when the app was brought to foreground after a long time stayed in the…
realxie
  • 109
  • 3
1
vote
1 answer

access particular set of pixels MTLTexture in metal

I created an MTLTexture using UIImage data as follows. var texture = metalView.currentDrawable!.texture let uiImg = createImageFromCurrentDrawable() guard let device = metalView.device else { fatalError("Device not created. Run on a…
1
vote
2 answers

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{ …
1
vote
1 answer

MTLTexture from MTLBuffer issue

I have results of compute shader stored in MTLBuffer. Each element of MTLBuffer is a UInt16. I am trying to pass the results to a fragment shader that displays the result by interpreting the elements of MTLBuffer as color intensity between 0 to 255.…
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
1
vote
2 answers

MTLBuffer allocation + CPU/GPU synchronisation

I am using a metal performance shader(MPSImageHistogram) to compute something in an MTLBuffer that I grab, perform computations, and then display via MTKView. The MTLBuffer output from the shader is small (~4K bytes). So I am allocating a new…
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
1
2