Skip to content

Commit faf6f98

Browse files
authored
Update test.html
1 parent 8450c33 commit faf6f98

File tree

1 file changed

+32
-51
lines changed

1 file changed

+32
-51
lines changed

webgpu/test.html

Lines changed: 32 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
} else {
177177
o = double_fractal(o, FragCoord.xy);
178178
}
179-
return o + .02;
179+
return o;
180180
}`;
181181

182182
const canvas = document.getElementById('canvas')
@@ -228,6 +228,7 @@
228228
size: 4 * 2,
229229
usage: GPUConst.BufferUsage.UNIFORM | GPUConst.BufferUsage.COPY_DST,
230230
});
231+
231232
//Create bind groups
232233
const uniformsBindGroup = device.createBindGroup({
233234
layout: pipeline.getBindGroupLayout(0),
@@ -246,58 +247,38 @@
246247
uniformsArrayBuffer[0] = canvas.width;
247248
uniformsArrayBuffer[1] = canvas.height;
248249

249-
let screenshotCount = 0;
250-
window.doScreenshot = false;
251-
const link = document.createElement("a");
250+
//function frame(t) {
251+
const commandEncoder = device.createCommandEncoder();
252+
const textureView = context.getCurrentTexture().createView();
252253

253-
function frame(t) {
254-
255-
const commandEncoder = device.createCommandEncoder();
256-
const textureView = context.getCurrentTexture().createView();
257-
258-
const renderPassDescriptor = {
259-
colorAttachments: [
260-
{
261-
view: textureView,
262-
loadValue: { r: 0., g: 0., b: 0., a: 1. },
263-
storeOp: 'store',
264-
},
265-
],
266-
};
267-
268-
device.queue.writeBuffer(
269-
uniformsBuffer,
270-
0,
271-
uniformsArrayBuffer.buffer,
272-
uniformsArrayBuffer.byteOffset,
273-
uniformsArrayBuffer.byteLength
274-
);
254+
const renderPassDescriptor = {
255+
colorAttachments: [
256+
{
257+
view: textureView,
258+
loadValue: { r: 0., g: 0., b: 0., a: 1. },
259+
storeOp: 'store',
260+
},
261+
],
262+
};
275263

276-
const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
277-
passEncoder.setPipeline(pipeline);
278-
passEncoder.setBindGroup(0, uniformsBindGroup);
279-
passEncoder.draw(6, 1, 0, 0);
280-
passEncoder.endPass();
281-
282-
device.queue.submit([commandEncoder.finish()]);
283-
284-
screenshotCount++;
285-
if (window.doScreenshot) {
286-
canvas.toBlob(
287-
(blob) => {
288-
link.download = "Screenshot a" + Date.now() + ".png";
289-
link.href = URL.createObjectURL(blob);
290-
link.dispatchEvent(new MouseEvent("click"));
291-
},
292-
"image/png",
293-
1
294-
);
295-
window.doScreenshot = false;
296-
}
297-
//requestAnimationFrame(frame);
298-
}
299-
requestAnimationFrame(frame);
264+
device.queue.writeBuffer(
265+
uniformsBuffer,
266+
0,
267+
uniformsArrayBuffer.buffer,
268+
uniformsArrayBuffer.byteOffset,
269+
uniformsArrayBuffer.byteLength
270+
);
271+
272+
const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
273+
passEncoder.setPipeline(pipeline);
274+
passEncoder.setBindGroup(0, uniformsBindGroup);
275+
passEncoder.draw(6, 1, 0, 0);
276+
passEncoder.endPass();
277+
278+
device.queue.submit([commandEncoder.finish()]);
279+
//} requestAnimationFrame(frame);
280+
300281
})();
301282
</script>
302283
</body>
303-
</html>
284+
</html>

0 commit comments

Comments
 (0)