graphics
[VulkanVR] Quest Backbuffer Read Fails: RenderGraph Fix
Solution
Unity 2022.3.x - Unity 6.3.x
Published Mon, Mar 9
Reading the color backbuffer on a VR HMD with Vulkan using RenderGraph.ImportTexture or RenderGraph.ImportBackbuffer can result in NullReferenceException during Blitter.BlitTexture or an invalid texture handle. This occurs when directly accessing the camera color texture on Meta Quest hardware, particularly when requiresIntermediateTexture is not enabled.
Quick-Fix
The foveated rendering OpenXR feature can interfere with framebuffer fetching on Meta Quest 3 with Vulkan. Disabling this feature or using a copy pass approach resolves rendering issues.
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.RenderGraphModule;
public class BackbufferPassManager
{
private class PassData
{
public TextureHandle _Source;
public TextureHandle _Destination;
}
public void AddPass(RenderGraph renderGraph, TextureHandle source, TextureHandle destA, TextureHandle destB, Vector4 scaleBias)
{
renderGraph.AddCopyPass(source, destA, "CopyFrameBufferPass");
using (var builder = renderGraph.AddRasterRenderPass<PassData>("CopyFrameBufferPass2", out var passData))
{
passData._Source = destA;
passData._Destination = destB;
builder.UseTexture(passData._Source, AccessFlags.Read);
builder.SetRenderAttachment(passData._Destination, 0, AccessFlags.WriteAll);
builder.AllowPassCulling(false);
builder.SetRenderFunc((PassData currentPassData, RasterGraphContext context) =>
{
Blitter.BlitTexture(context.cmd, currentPassData._Source, scaleBias, 0, true);
});
}
}
}
Related Posts Haven't quite found a solution to your problem? We think these posts might help you.
[OpenXR] Boost Meta Quest VR Frame Rates[URP] Adaptive Probe Volume Compute Shader Init Fix[URP] Unlock 60 FPS: Renderer Performance & Draw Call Reduction
Content inspired by a Unity discussion post.