gpu.js/test/internal/backend/web-gl2/kernel-value/dynamic-html-image-array.js
Robert Plummer cd0b417c67 fix: #552 remove incorrect texture size checks
fix: texture.renderRawOutput to use existing framebuffer, or make it so it can be deleted
fix: glKernelString to handle the framebuffer from texture.renderRawOutput
fix: WebGLKernelArray.checkSize so display error for all three scenarios
  1. width too big
  2. height too big
  3. width and height too big
2020-01-08 07:13:37 -05:00

91 lines
2.4 KiB
JavaScript

const { assert, skip, test, module: describe, only } = require('qunit');
const { webGL2KernelValueMaps } = require('../../../../../src');
describe('internal: WebGL2KernelValueDynamicHTMLImage');
test('.updateValue() checks too large height', () => {
const mockKernel = {
constructor: {
features: { maxTextureSize: 1 },
},
validate: true,
};
const v = new webGL2KernelValueMaps.unsigned.dynamic.HTMLImageArray([{ width: 1, height: 1 }], {
kernel: mockKernel,
name: 'test',
type: 'HTMLImage',
origin: 'user',
tactic: 'speed',
onRequestContextHandle: () => 1,
onRequestTexture: () => null,
onRequestIndex: () => 1
});
assert.throws(() => {
v.updateValue([{ width: 1, height: 2 }]);
}, new Error('Argument texture 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 webGL2KernelValueMaps.unsigned.dynamic.HTMLImageArray([{ width: 1, height: 1 }], {
kernel: mockKernel,
name: 'test',
type: 'HTMLImageArray',
origin: 'user',
tactic: 'speed',
onRequestContextHandle: () => 1,
onRequestTexture: () => null,
onRequestIndex: () => 1
});
assert.throws(() => {
v.updateValue([{
height: 1,
width: 2,
}])
}, new Error('Argument texture 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: () => {},
};
const mockContext = {
activeTexture: () => {},
bindTexture: () => {},
texParameteri: () => {},
pixelStorei: () => {},
texImage3D: () => {},
texSubImage3D: () => {},
};
const v = new webGL2KernelValueMaps.unsigned.dynamic.HTMLImageArray([{ width: 2, height: 2 }], {
kernel: mockKernel,
name: 'test',
type: 'HTMLImageArray',
origin: 'user',
tactic: 'speed',
context: mockContext,
onRequestContextHandle: () => 1,
onRequestTexture: () => null,
onRequestIndex: () => 1
});
v.updateValue([{
height: 1,
width: 1,
}]);
assert.equal(v.constructor.name, 'WebGL2KernelValueDynamicHTMLImageArray');
});