VisionOS Metal Sample issue with clearColor

Hi everyone,

This happens with Xcode 15.3 (15E204a) and visionOS 1.1.2 (21O231).

To reproduce this issue, simply create a new VisionOS app with Metal (see below).

Then simply change the following piece of code in Renderer.swift:

func renderFrame() {
        [...]
        // Set the clear color red channel to 1.0 instead of 0.0.
        renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 0.0)
        [...]
}

On the simulator it works as expected while on device it will show a black background with red jagged edges (see below).

Replies

It seems that a (not ideal) workaround is to do the following:

renderPassDescriptor.depthAttachment.clearDepth = 1.0  // instead of 0.0

and

depthStateDescriptor.depthCompareFunction = .always // instead of MTLCompareFunction.greater