mirror of
https://github.com/gpujs/gpu.js.git
synced 2025-12-08 20:35:56 +00:00
...it kind of snowballed from some needs Fixes #521 - If `tactic` is not set, check precision allowed from WebGL, and automatically change based off needs, otherwise use value from `tactic`. Fixes #535 - Internally check if texture from argument is the same as output, if so, clone this texture, and then clean it up after the kernel runs. Fixes #536 - Normalize all declarations to non-destructured, and then parse Fixes #537 - Change logic Fixes #538 - Found the GL script that would work, and reduced the methods to use it Fixes #539 - Found a better way of testing random, and this gives me an error for 1 in 10 runs, acceptable Some refactoring for less duplicate code and documentation
53 lines
1.4 KiB
HTML
53 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>GPU.js Internal Variable Precision</title>
|
|
</head>
|
|
<body>
|
|
<h2>GPU.js Internal variable precision: <span id="ivp"></span></h2>
|
|
</body>
|
|
<script src="../dist/gpu-browser.min.js"></script>
|
|
<script>
|
|
const ivp = document.getElementById('ivp');
|
|
const gpu = new GPU();
|
|
const startSize = 10;
|
|
const fullSize = window.innerWidth;
|
|
const kernel = gpu.createKernel(function() {
|
|
const x = this.thread.x / this.output.x;
|
|
const y = this.thread.y / this.output.y;
|
|
this.color(x, y, y, 1);
|
|
}, {
|
|
graphical: true,
|
|
dynamicOutput: true,
|
|
precision: 'unsigned'
|
|
});
|
|
document.body.appendChild(kernel.canvas);
|
|
|
|
let currentSize = startSize;
|
|
// const expected = 0;
|
|
// let tore = false;
|
|
function render() {
|
|
if (currentSize < fullSize) {
|
|
kernel.setOutput([
|
|
++currentSize,
|
|
currentSize
|
|
]);
|
|
kernel();
|
|
// const pixels = kernel.getPixels();
|
|
// if (tore || pixels[kernel.canvas.width * 4] !== expected) {
|
|
// tore = true;
|
|
// if (!confirm(`canvas tore at ${currentSize}x${currentSize}, continue?`)) {
|
|
// return;
|
|
// }
|
|
// }
|
|
ivp.textContent = kernel.getVariablePrecisionString();
|
|
requestAnimationFrame(render);
|
|
} else {
|
|
alert('reached the width of the window without tearing');
|
|
}
|
|
}
|
|
requestAnimationFrame(render);
|
|
</script>
|
|
</html>
|