mirror of
https://github.com/gpujs/gpu.js.git
synced 2026-01-18 16:04:10 +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
91 lines
2.5 KiB
JavaScript
91 lines
2.5 KiB
JavaScript
const { assert, skip, test, module: describe, only } = require('qunit');
|
|
const { webGLKernelValueMaps } = require('../../../../../src');
|
|
|
|
describe('internal: WebGLKernelValueDynamicMemoryOptimizedNumberTexture');
|
|
|
|
test('.updateValue() checks too large height', () => {
|
|
const mockKernel = {
|
|
constructor: {
|
|
features: { maxTextureSize: 1 },
|
|
},
|
|
validate: true,
|
|
};
|
|
const v = new webGLKernelValueMaps.unsigned.dynamic.MemoryOptimizedNumberTexture({ size: [1, 1] }, {
|
|
kernel: mockKernel,
|
|
name: 'test',
|
|
type: 'MemoryOptimizedNumberTexture',
|
|
origin: 'user',
|
|
tactic: 'speed',
|
|
onRequestContextHandle: () => 1,
|
|
onRequestTexture: () => null,
|
|
onRequestIndex: () => 1
|
|
});
|
|
|
|
assert.throws(() => {
|
|
v.updateValue({ size: [1, 2] });
|
|
}, new Error('Argument height of 2 larger than maximum size of 1 for your GPU'));
|
|
});
|
|
|
|
test('.updateValue() checks too large width', () => {
|
|
const mockKernel = {
|
|
constructor: {
|
|
features: { maxTextureSize: 1 },
|
|
},
|
|
validate: true,
|
|
};
|
|
|
|
const v = new webGLKernelValueMaps.unsigned.dynamic.MemoryOptimizedNumberTexture({ size: [1, 1] }, {
|
|
kernel: mockKernel,
|
|
name: 'test',
|
|
type: 'MemoryOptimizedNumberTexture',
|
|
origin: 'user',
|
|
tactic: 'speed',
|
|
onRequestContextHandle: () => 1,
|
|
onRequestTexture: () => null,
|
|
onRequestIndex: () => 1
|
|
});
|
|
assert.throws(() => {
|
|
v.updateValue({
|
|
size: [2,1]
|
|
})
|
|
}, new Error('Argument width of 2 larger than maximum size of 1 for your GPU'));
|
|
});
|
|
|
|
test('.updateValue() checks ok height & width', () => {
|
|
const mockKernel = {
|
|
constructor: {
|
|
features: { maxTextureSize: 2 },
|
|
},
|
|
validate: true,
|
|
setUniform3iv: () => {},
|
|
setUniform2iv: () => {},
|
|
setUniform1i: () => {},
|
|
outputTexture: {}
|
|
};
|
|
const mockContext = {
|
|
activeTexture: () => {},
|
|
bindTexture: () => {},
|
|
texParameteri: () => {},
|
|
pixelStorei: () => {},
|
|
texImage2D: () => {},
|
|
};
|
|
const v = new webGLKernelValueMaps.unsigned.dynamic.MemoryOptimizedNumberTexture({ size: [2,2], context: mockContext }, {
|
|
kernel: mockKernel,
|
|
name: 'test',
|
|
type: 'MemoryOptimizedNumberTexture',
|
|
origin: 'user',
|
|
tactic: 'speed',
|
|
context: mockContext,
|
|
onRequestContextHandle: () => 1,
|
|
onRequestTexture: () => null,
|
|
onRequestIndex: () => 1
|
|
});
|
|
v.updateValue({
|
|
size: [1,1],
|
|
context: mockContext,
|
|
texture: {}
|
|
});
|
|
|
|
assert.equal(v.constructor.name, 'WebGLKernelValueDynamicMemoryOptimizedNumberTexture');
|
|
});
|