webgpu-samples icon indicating copy to clipboard operation
webgpu-samples copied to clipboard

Update canvas size configuration

Open austinEng opened this issue 3 years ago • 1 comments

The WebGPU API has changed such that now instead of passing the configured canvas size to GPUCanvasContext.configure({ size: .. }), the texture size is determined from the canvas.width and canvas.height` attributes.

This means, to achieve the same behavior as with the older API, we need to make the canvas width/height window.devicePixelRatio * 600x600 if the devicePixelRatio > 1, and then size it back to 600x600 using CSS style attributes (somewhere in SampleLayout.tsx). Then, instead of computing the presentationSize in various samples, use the canvas.width and canvas.height attributes to make additional textures that match the canvas's width/height.

austinEng avatar Jul 08 '22 18:07 austinEng

@onsummer I checked the API specification, and this is the new behavior that we need to update the samples to use.

austinEng avatar Jul 08 '22 18:07 austinEng