Making sure copyTextureToTexture can run, even though the WebGPU project still relies on endPass

This commit is contained in:
Rezmason
2022-08-09 22:25:35 -07:00
parent e024f4bd4d
commit fc6821f4db

View File

@@ -72,6 +72,7 @@ export default async (canvas, config) => {
let frames = 0;
let start = NaN;
let outputs;
const renderLoop = (now) => {
if (isNaN(start)) {
@@ -81,10 +82,11 @@ export default async (canvas, config) => {
const devicePixelRatio = window.devicePixelRatio ?? 1;
const canvasWidth = canvas.clientWidth * devicePixelRatio;
const canvasHeight = canvas.clientHeight * devicePixelRatio;
const canvasSize = [canvasWidth, canvasHeight];
if (canvas.width !== canvasWidth || canvas.height !== canvasHeight) {
canvas.width = canvasWidth;
canvas.height = canvasHeight;
pipeline.build([canvasWidth, canvasHeight]);
outputs = pipeline.build(canvasSize);
}
device.queue.writeBuffer(timeBuffer, 0, timeUniforms.toBuffer({ seconds: (now - start) / 1000, frames }));
@@ -93,7 +95,7 @@ export default async (canvas, config) => {
const encoder = device.createCommandEncoder();
pipeline.run(encoder);
// Eventually, when WebGPU allows it, we'll remove the endPass and just copy from our pipeline's output to the canvas texture.
// encoder.copyTextureToTexture({ texture: output.primary }, { texture: canvasContext.getCurrentTexture() }, canvasSize);
// encoder.copyTextureToTexture({ texture: outputs?.primary }, { texture: canvasContext.getCurrentTexture() }, canvasSize);
device.queue.submit([encoder.finish()]);
requestAnimationFrame(renderLoop);
};