-1

I am drawing in an MTKView using

  override func draw(_ rect: CGRect) {
      var pixelBuffer: CVPixelBuffer?

      syncQueue.sync {
         pixelBuffer = internalPixelBuffer
      }

      guard let drawable = currentDrawable,
         let currentRenderPassDescriptor = currentRenderPassDescriptor,
         let previewPixelBuffer = pixelBuffer else {
            return
      }
      ...

   }

The thing is I don't if it is possible to set loadAction and clear color of this render pass descriptor. Is the default clear color set to black?

Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131

2 Answers2

2

You may modify the render pass descriptor, if you like. Or, you don't have to use it at all. You can set up your own descriptor from scratch.

The descriptor is initially set up to match the properties of the MTKView. So, the clear color of the descriptor comes from the clearColor property of the view. That property does default to black so, in some sense, yes, the default clear color of the descriptor would be black.

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
  • I am facing an issue with default descriptor. Sometimes, there is a glitch and I see half of the previous frame still being dram in the next draw cycle. Could renderpassdescriptor be the cause? – Deepak Sharma Aug 05 '19 at 15:57
0

Yes it is, you can check it like this:

let clearColor = currentRenderPassDescriptor.colorAttachments[0].clearColor
print(clearColor)
Hamid Yusifli
  • 9,688
  • 2
  • 24
  • 48