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

Function handleCastingFloatsWithNativeFunctions

test/internal/casting.js:61–79  ·  view source on GitHub ↗
(mode)

Source from the content-addressed store, hash-verified

59
60
61function handleCastingFloatsWithNativeFunctions(mode) {
62 const gpu = new GPU({ mode });
63 gpu.addNativeFunction('add', `
64 float add(float value1, float value2) {
65 return value1 + value2;
66 }
67 `);
68 const kernel = gpu.createKernel(function(value1, value2) {
69 return add(value1, value2);
70 }, {
71 argumentTypes: ['Integer', 'Integer'],
72 output: [1],
73 strictIntegers: true,
74 });
75 const result = kernel(1, 2);
76 assert.deepEqual(Array.from(result), [3]);
77 assert.deepEqual(kernel.argumentTypes, ['Integer', 'Integer']);
78 gpu.destroy();
79}
80
81(GPU.isWebGLSupported ? test : skip)('handle casting floats with native functions webgl', () => {
82 handleCastingFloatsWithNativeFunctions('webgl');

Callers 1

casting.jsFile · 0.85

Calls 5

addNativeFunctionMethod · 0.95
createKernelMethod · 0.95
destroyMethod · 0.95
kernelFunction · 0.85
addFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…