WebXR screen mirroring

When we resolve a multi-sampled buffer to a single-sampled, we do this, which perhaps might work in your case? Is your source or destination buffer multi-sampled?

 gl.bindFramebuffer(gl.READ_FRAMEBUFFER, src);
        gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, dst);
        gl.blitFramebuffer(0, 0, target.width, target.height,
                           0, 0, target.width, target.height,
                           gl.COLOR_BUFFER_BIT,
                           gl.NEAREST);

Actually I think both buffers should be multisampled as Iā€™m blitting from webglLayer.framebuffer to the canvas (null) and have antialiasing enabled in the editor.
However the blit errors with this:
GL_INVALID_OPERATION: Invalid operation on multisampled framebuffer

gd.gl.bindFramebuffer(gd.gl.READ_FRAMEBUFFER, webglLayer.framebuffer);
gd.gl.bindFramebuffer(gd.gl.DRAW_FRAMEBUFFER, null);
gd.gl.blitFramebuffer(0, heightOffset, gd.width / 2, gd.height - heightOffset, 0, 0, gd.width, gd.height, gd.gl.COLOR_BUFFER_BIT, gd.gl.NEAREST);
gd.gl.bindFramebuffer(gd.gl.FRAMEBUFFER, webglLayer.framebuffer);

Not sure you can blit to a multi-sampled buffer. You might need to blit to a single sampled, and then render it (using quad) to a multi-samipled.

After further testing this seems to work with the new engine version 1.66.2.
I guess this PR fixed it.
Thanks!

1 Like