MTKView stands for MetalKit View, a class provided by MetalKit designed to render Metal. Use this tag alongside [metal] or [metalkit] for questions about the usage or behavior of this class.
Questions tagged [mtkview]
30 questions
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
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
6
votes
0 answers
How to change MTKView current drawable size
Apple documentation says the MTKView current drawable default size is derived from the current view’s size, in native pixels. Is there any way to make MTKView current drawable half of the device's screen size?

Kasun Palihakkara
- 321
- 3
- 22
4
votes
2 answers
MTKView delegate stops responding to - (void)drawInMTKView:(nonnull MTKView *)view calls
I have an MTKView in a window managed by a window controller. When I first instantiate the window controller and window, the MTKView calls my delegate's two calls and drawInMTKView is called at the preferred rate:
- (void)drawInMTKView:(nonnull…

blackirishman
- 903
- 1
- 10
- 23
2
votes
1 answer
Change storage mode of MTKView's depth texture
In the Metal's profiler I get this suggestion:
"Texture:0x12880c010 "MTKView Depth"" has storage mode 'Private' but was a transient render target accessed exclusively by the GPU
Consider changing the storage mode to 'Memoryless'.
This texture is…

Roman Gaditskii
- 135
- 6
2
votes
0 answers
Able to render to texture but can not present to MTKView on relative old devices
I have a drawing app using Metal, that works well on newer iPhones and iPads. However, on older devices like the 6th and 7th generation iPad, the screen shows up as blank transparent view.
I checked the code that handles the drawing, and it seems…

Brew Master
- 457
- 3
- 13
2
votes
1 answer
MTKView display HDR10 CIImage
I need to display CVPixelBuffers in HDR10 (kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange / BT2020 PQ color space) using MTKView. I have the following code to display but it produces distorted images, and I can not be sure if it is displaying 10…

Deepak Sharma
- 5,577
- 7
- 55
- 131
2
votes
1 answer
MTKView : Type of expression is ambiguous without more context on commandBuffer.present
I am getting compile time error while setting drawable on command buffer object.
Following is my function which is being called from draw method of MTKView subclass.
fileprivate func executeMetalShader() {
guard let pipelineState =…

Afsar edrisy
- 1,985
- 12
- 28
2
votes
1 answer
MTKView refresh issue
I am compositing an array of UIImages via an MTKView, and I am seeing refresh issues that only manifest themselves during the composite phase, but which go away as soon as I interact with the app. In other words, the composites are working as…

Plutovman
- 677
- 5
- 22
2
votes
1 answer
iOS MTKView (Metal Kit view) draws image without proper scale
I don't understand why MTKView doesn't use device's scale.
I have a retina device: 2x scale, MTKView.bounds of 400x200, and CIImage size of 800x400, but it draws only left bottom quarter of the image.
Strangely drawableSize returns bounds size…

Borzh
- 5,069
- 2
- 48
- 64
1
vote
1 answer
HDR image display in MTKView/CAMetalLayer
I am looking to display HDR images on iOS using CAMetalLayer/MTKView. I see CALayers such as AVCaptureVideoPreviewLayer or AVPlayerLayer have the capability to display HDR content. However, it appears these layers might be using EDR APIs to achieve…

Deepak Sharma
- 5,577
- 7
- 55
- 131
1
vote
3 answers
How to calculate the frame timestep/deltatime in an MTKView?
I want to get the time since the last frame (known as the timestep or deltatime) in the draw method of MTKView. I expect to see values of approximately 0.017 assuming 60 frames per second consistently. The value should rise to about 0.03 if…

user16217248
- 3,119
- 19
- 19
- 37
1
vote
0 answers
Converting RGBA32Float MTLTextures to NSImage
I've tried a bunch of techniques like using CIImage or copying the data into a buffer of uint_32ts, but they have all had their issues. The simplest I have found so far is:
extension MTLTexture {
func toImage() -> NSImage? {
…

kelkamon
- 11
- 2
1
vote
1 answer
MTKView Transparency
I can't make my MTKView clear its background. I've set the view's and its layer's isOpaque to false, background color to clear and tried multiple solutions found on google/stackoverflow (most in the code below like loadAction and clearColor of color…

cboe
- 469
- 1
- 9
- 25
1
vote
0 answers
Draw a text inside MTKView
I started to work on a project that the old colleges used metal to draw a graph. I am looking for a fast solution to add a label inside this MTKView.
Here is what I have so far:
for coordinate in coordinates {
let circleVertice = CircleVertex(x:…

Peter hes
- 101
- 6