mirror of
https://github.com/gpujs/gpu.js.git
synced 2026-01-18 16:04:10 +00:00
feat: Consolidate subKernels rendering code as part of the renderStrategy fix: remove tabs, replace with spaces fix: make FunctionBuilder.fromKernel typing static fix: Add missing FunctionBuilder.getPrototypeString definition fix: Move building logic to kernelRunShortcut as well as exec method
96 lines
2.7 KiB
JavaScript
96 lines
2.7 KiB
JavaScript
const { assert, skip, test, module: describe } = require('qunit');
|
|
const { GPU } = require('../../src');
|
|
|
|
describe('issue #279');
|
|
|
|
const WIDTH = 600;
|
|
const HEIGHT = 400;
|
|
function wrongCanvasSizeOptimized(mode) {
|
|
const gpu = new GPU({ mode });
|
|
|
|
const initMatrix = gpu.createKernel(function(value) {
|
|
return value;
|
|
})
|
|
.setOptimizeFloatMemory(true)
|
|
.setOutput([WIDTH, HEIGHT]);
|
|
|
|
const render = gpu.createKernel(function(matrix) {
|
|
const i = matrix[this.thread.y][this.thread.x];
|
|
this.color(i, i, i, 1);
|
|
})
|
|
.setOutput([WIDTH, HEIGHT])
|
|
.setGraphical(true);
|
|
|
|
const matrix = initMatrix(0.5);
|
|
render(matrix);
|
|
const canvas = render.canvas;
|
|
assert.equal(canvas.width, WIDTH);
|
|
assert.equal(canvas.height, HEIGHT);
|
|
gpu.destroy();
|
|
}
|
|
|
|
(GPU.isCanvasSupported ? test : skip)('Issue #279 wrong canvas size optimized - cpu', () => {
|
|
wrongCanvasSizeOptimized('cpu');
|
|
});
|
|
|
|
test('Issue #279 wrong canvas size optimized - gpu', () => {
|
|
wrongCanvasSizeOptimized('gpu');
|
|
});
|
|
|
|
(GPU.isWebGLSupported ? test : skip)('Issue #279 wrong canvas size optimized - webgl', () => {
|
|
wrongCanvasSizeOptimized('webgl');
|
|
});
|
|
|
|
(GPU.isWebGL2Supported ? test : skip)('Issue #279 wrong canvas size optimized - webgl2', () => {
|
|
wrongCanvasSizeOptimized('webgl2');
|
|
});
|
|
|
|
(GPU.isHeadlessGLSupported ? test : skip)('Issue #279 wrong canvas size optimized - headlessgl', () => {
|
|
wrongCanvasSizeOptimized('headlessgl');
|
|
});
|
|
|
|
|
|
function wrongCanvasSizeUnoptimized(mode) {
|
|
const gpu = new GPU({ mode });
|
|
|
|
const initMatrix = gpu.createKernel(function(value) {
|
|
return value;
|
|
})
|
|
.setOptimizeFloatMemory(false)
|
|
.setOutput([WIDTH, HEIGHT]);
|
|
|
|
const render = gpu.createKernel(function(matrix) {
|
|
const i = matrix[this.thread.y][this.thread.x];
|
|
this.color(i, i, i, 1);
|
|
})
|
|
.setOutput([WIDTH, HEIGHT])
|
|
.setGraphical(true);
|
|
|
|
const matrix = initMatrix(0.5);
|
|
render(matrix);
|
|
const canvas = render.canvas;
|
|
assert.equal(canvas.width, WIDTH);
|
|
assert.equal(canvas.height, HEIGHT);
|
|
gpu.destroy();
|
|
}
|
|
|
|
(GPU.isCanvasSupported ? test : skip)('Issue #279 wrong canvas size unoptimized - cpu', () => {
|
|
wrongCanvasSizeUnoptimized('cpu');
|
|
});
|
|
|
|
test('Issue #279 wrong canvas size unoptimized - gpu', () => {
|
|
wrongCanvasSizeUnoptimized('gpu');
|
|
});
|
|
|
|
(GPU.isWebGLSupported ? test : skip)('Issue #279 wrong canvas size unoptimized - webgl', () => {
|
|
wrongCanvasSizeUnoptimized('webgl');
|
|
});
|
|
|
|
(GPU.isWebGL2Supported ? test : skip)('Issue #279 wrong canvas size unoptimized - webgl2', () => {
|
|
wrongCanvasSizeUnoptimized('webgl2');
|
|
});
|
|
|
|
(GPU.isHeadlessGLSupported ? test : skip)('Issue #279 wrong canvas size unoptimized - headlessgl', () => {
|
|
wrongCanvasSizeUnoptimized('headlessgl');
|
|
});
|