Metal 2D Array Texture submission broken

This is a copy of the issue submitted at https://github.com/ValveSoftware/openvr/issues/1088, but maybe other devs here will have knowledge on the subject.


I am using OpenVR 1.2.10 (non-beta) and SteamVR 1.3.19 on a 2016 MBP with AMD Radeon 580 eGPU.


Problem: When submitting 2D array textures, headset displays left eye texture index for both eyes.


------



OpenVR is supposed to allow for optimized 2D array texture submission on macOS since last year, but it is not working correctly for me.


I have successfully created and rendered my scene to a type2DArray Metal texture. To better observe the difference between the eyes, I'm only updating the projection transform for one of them.



fileprivate func updateCameras() {
  //stereoRenderer.leftEye.transform = SCNMatrix4Invert(SCNMatrix4Mult(leftEyePosition, hmdPose))
  //stereoRenderer.leftEye.camera?.projectionTransform = leftEyeProjection
  stereoRenderer.rightEye.transform = SCNMatrix4Invert(SCNMatrix4Mult(rightEyePosition, hmdPose))
  stereoRenderer.rightEye.camera?.projectionTransform = rightEyeProjection
}



The resulting texture looks as I'd expect when debugging, with each index corresponding to left and right eye.


However, after submitting the texture to compositor:



+(void)submitTexture:(id)texture {
  vr::Texture_t textureDesc[2];
  vr::VRTextureBounds_t textureBounds[2];
  for (int i = 0; i<2; ++i) {
  textureDesc[i].handle = reinterpret_cast<void*>(intptr_t(texture));
  textureDesc[i].eType = vr::ETextureType::TextureType_Metal;
  textureDesc[i].eColorSpace = vr::EColorSpace::ColorSpace_Linear;
  textureBounds[i] = { .uMin = 0.0f, .uMax = 1.0f, .vMin = 0.0f, .vMax = 1.0f };
  }
  vr::VRCompositor()->Submit(vr::Eye_Left, &textureDesc[0], &textureBounds[0]);
  vr::VRCompositor()->Submit(vr::Eye_Right, &textureDesc[1], &textureBounds[1]);
}



The problem is that all that I'm receiving in the headset (HTC Vive) is the same left eye texture displayed for both eyes. I can't display the trace for the submit either. All of the IVRCompositor entries just yield a blank view.


The textures have been allocated using:


   func makeVRSampleTexture(eyeSize: CGSize, hmdMode: Bool) -> MTLTexture? {
        let descriptor = MTLTextureDescriptor()
        descriptor.textureType = .type2DMultisampleArray
        descriptor.width = Int(eyeSize.width)
        descriptor.height = Int(eyeSize.height)
        descriptor.pixelFormat = .bgra8Unorm_srgb
        descriptor.arrayLength = 2
        descriptor.sampleCount = 4
        descriptor.storageMode = .private
        descriptor.usage = [.renderTarget]
        return makeTexture(descriptor: descriptor)
    }
   
    func makeVRTexture(eyeSize: CGSize, hmdMode: Bool) -> MTLTexture? {
        let descriptor = MTLTextureDescriptor()
        descriptor.textureType = .type2DArray
        descriptor.width = Int(eyeSize.width)
        descriptor.height = Int(eyeSize.height)
        descriptor.pixelFormat = .bgra8Unorm_srgb
        descriptor.arrayLength = 2
        descriptor.storageMode = .private
        if hmdMode {
            descriptor.usage = [.renderTarget]
            return makeSharedTexture(descriptor: descriptor)
        } else {
            descriptor.usage = [.renderTarget, .shaderRead]
            return makeTexture(descriptor: descriptor)
        }
    }


Where the sampleTexture is used as a render target, and other one as a resolve target.


The Github issue posted at the start of the post has images related to the topic.