Force WebGPU

Hello!

I’d like to test webGPU with PlayCanvas but no matter what I do, I’m stuck with WebGL 2.0

I switched my project to V2. I’ve enabled WebGPU in the rendering settings. I’m using the latest version of Chrome and this is how I start PC:

		const gfxOptions = {
			//deviceTypes: ['webgl2'],
			deviceTypes: ['webgpu'],
			glslangUrl: this.assetRoot+'glslang.js',
			twgslUrl: this.assetRoot+'twgsl.js'
		};

		const device = pc.createGraphicsDevice(this.canvas.current, gfxOptions);

		this.pcApp = new pc.Application(this.canvas.current, {
					mouse: new pc.Mouse(this.canvas.current),
					keyboard: new pc.Keyboard(window),
					fillMode: pc.FILLMODE_FILL_WINDOW,
					graphicDevice: device,
					graphicsDeviceOptions: this.settings.CONTEXT_OPTIONS,
					touch: pc.platform.touch ? new pc.TouchDevice(window) : null,
					scriptPrefix: this.assetRoot,
					assetPrefix: this.assetRoot
				});

What am I missing please?

Do these examples work for you n WebGPU mode? PlayCanvas Examples

Are you hosting your project on https?

Yes. When I open those, WebGPU does work.

I guess step into createGraphicsDevice function and see what happens

OK. Where can I find the non-minified version of PC 2.7.4 please?

here https://code.playcanvas.com/playcanvas-2.7.4.dbg.js

Thanks!
I fixed it. I didn’t realize that createGraphicsDevice was returning a Promise. The fixed version is:

		const gfxOptions = {
			//deviceTypes: ['webgl2'],
			deviceTypes: ['webgpu'],
			glslangUrl: this.assetRoot+'glslang.js',
			twgslUrl: this.assetRoot+'twgsl.js',
		};

		const device = pc.createGraphicsDevice(this.canvas.current, gfxOptions);
		device.then( device => {

		this.pcApp = new pc.Application(this.canvas.current, {
					mouse: new pc.Mouse(this.canvas.current),
					keyboard: new pc.Keyboard(window),
					fillMode: pc.FILLMODE_FILL_WINDOW,
					graphicsDevice: device,
					graphicsDeviceOptions: this.settings.CONTEXT_OPTIONS,
					touch: pc.platform.touch ? new pc.TouchDevice(window) : null,
					scriptPrefix: this.assetRoot,
					assetPrefix: this.assetRoot
				});
3 Likes