MCPcopy Index your code
hub / github.com/gpujs/gpu.js / wrongCanvasSizeOptimized

Function wrongCanvasSizeOptimized

test/issues/279-wrong-canvas-size.js:8–30  ·  view source on GitHub ↗
(mode)

Source from the content-addressed store, hash-verified

6const WIDTH = 600;
7const HEIGHT = 400;
8function wrongCanvasSizeOptimized(mode) {
9 const gpu = new GPU({ mode });
10
11 const initMatrix = gpu.createKernel(function(value) {
12 return value;
13 })
14 .setOptimizeFloatMemory(true)
15 .setOutput([WIDTH, HEIGHT]);
16
17 const render = gpu.createKernel(function(matrix) {
18 const i = matrix[this.thread.y][this.thread.x];
19 this.color(i, i, i, 1);
20 })
21 .setOutput([WIDTH, HEIGHT])
22 .setGraphical(true);
23
24 const matrix = initMatrix(0.5);
25 render(matrix);
26 const canvas = render.canvas;
27 assert.equal(canvas.width, WIDTH);
28 assert.equal(canvas.height, HEIGHT);
29 gpu.destroy();
30}
31
32(GPU.isCanvasSupported ? test : skip)('Issue #279 wrong canvas size optimized - cpu', () => {
33 wrongCanvasSizeOptimized('cpu');

Callers 1

Calls 6

createKernelMethod · 0.95
destroyMethod · 0.95
setGraphicalMethod · 0.80
colorMethod · 0.65
setOutputMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…