mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-21 07:19:30 -07:00
Making sure copyTextureToTexture can run, even though the WebGPU project still relies on endPass
This commit is contained in:
@@ -72,6 +72,7 @@ export default async (canvas, config) => {
|
|||||||
|
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
let start = NaN;
|
let start = NaN;
|
||||||
|
let outputs;
|
||||||
|
|
||||||
const renderLoop = (now) => {
|
const renderLoop = (now) => {
|
||||||
if (isNaN(start)) {
|
if (isNaN(start)) {
|
||||||
@@ -81,10 +82,11 @@ export default async (canvas, config) => {
|
|||||||
const devicePixelRatio = window.devicePixelRatio ?? 1;
|
const devicePixelRatio = window.devicePixelRatio ?? 1;
|
||||||
const canvasWidth = canvas.clientWidth * devicePixelRatio;
|
const canvasWidth = canvas.clientWidth * devicePixelRatio;
|
||||||
const canvasHeight = canvas.clientHeight * devicePixelRatio;
|
const canvasHeight = canvas.clientHeight * devicePixelRatio;
|
||||||
|
const canvasSize = [canvasWidth, canvasHeight];
|
||||||
if (canvas.width !== canvasWidth || canvas.height !== canvasHeight) {
|
if (canvas.width !== canvasWidth || canvas.height !== canvasHeight) {
|
||||||
canvas.width = canvasWidth;
|
canvas.width = canvasWidth;
|
||||||
canvas.height = canvasHeight;
|
canvas.height = canvasHeight;
|
||||||
pipeline.build([canvasWidth, canvasHeight]);
|
outputs = pipeline.build(canvasSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
device.queue.writeBuffer(timeBuffer, 0, timeUniforms.toBuffer({ seconds: (now - start) / 1000, frames }));
|
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();
|
const encoder = device.createCommandEncoder();
|
||||||
pipeline.run(encoder);
|
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.
|
// 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()]);
|
device.queue.submit([encoder.finish()]);
|
||||||
requestAnimationFrame(renderLoop);
|
requestAnimationFrame(renderLoop);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user