space-game/src/core/xr-webgpu/xrGpuEntryPoint.ts
Michael Mainguy 0bb27691fe
All checks were successful
Build / build (push) Successful in 1m42s
Add WebGPU XR rendering pipeline via XRGPUBinding
Create a parallel WebGPU XR path that uses XRGPUBinding and
XRProjectionLayer instead of the WebGL-only XRWebGLLayer, while
preserving the existing WebGL XR path as the default fallback.

New files in src/core/xr-webgpu/:
- xrGpuTypes.ts: TypeScript declarations for XRGPUBinding spec types
- xrGpuSessionSetup.ts: GPUDevice access and session init helpers
- xrGpuTextureProvider.ts: Per-frame GPUTexture swap via hwTex.set()
- xrGpuLayerWrapper.ts: WebXRLayerWrapper subclass for projection layers
- xrGpuRenderTarget.ts: WebXRRenderTarget using XRGPUBinding
- xrGpuEntryPoint.ts: Public API for availability check and creation

Modified xrEntryHandler.ts to conditionally route through WebGPU or
WebGL XR entry based on XRGPUBinding availability.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 08:29:31 -06:00

29 lines
949 B
TypeScript

/**
* Public API for WebGPU XR support.
* Consumed by xrEntryHandler.ts to conditionally use the WebGPU XR path.
*/
import { WebGPUEngine } from "@babylonjs/core";
import type { AbstractEngine, Scene, WebXRSessionManager } from "@babylonjs/core";
import { XRGPURenderTarget } from "./xrGpuRenderTarget";
import { buildWebGPUSessionInit } from "./xrGpuSessionSetup";
import "./xrGpuTypes"; // ensure global XRGPUBinding augmentation is loaded
export function isWebGPUXRAvailable(engine: AbstractEngine): boolean {
return (
engine instanceof WebGPUEngine &&
typeof globalThis.XRGPUBinding !== 'undefined'
);
}
export function createWebGPURenderTarget(
sessionManager: WebXRSessionManager,
engine: WebGPUEngine,
scene: Scene
): XRGPURenderTarget {
return new XRGPURenderTarget(sessionManager, engine, scene);
}
export function getWebGPUSessionInit(): XRSessionInit {
return buildWebGPUSessionInit();
}