gpujs / gpu.js

GPU Accelerated JavaScript
https://gpu.rocks
MIT License
15.1k stars 654 forks source link

Error: Could not find a KernelValue for function #619

Closed sacredvoid closed 4 years ago

sacredvoid commented 4 years ago

A GIF or MEME to give some spice of the internet

What is wrong?

I'm trying to optimise a 'for loop' where I normalise the Y buffer values, and append the Y, U, V together. It runs into this error:

Uncaught (in promise) Error: Could not find a KernelValue for function Mat$type() { if (arguments.length !== 0) { throwBindingError('function Mat.type called with ' + arguments.length + ' arguments, expected 0 args!'); } var thisWired = classParam.toWireType(null, this); var rv = invoker(fn, thisWired); var ret = retType.fromWireType(rv); return ret; } at lookupKernelValueType (gpu-browser.min.js:14) at Function.lookupKernelValueType (gpu-browser.min.js:14) at WebGL2Kernel.setupArguments (gpu-browser.min.js:14) at WebGL2Kernel.build (gpu-browser.min.js:14) at WebGL2Kernel.t (gpu-browser.min.js:14) at n (gpu-browser.min.js:14) at Object.predictModel (processor.js:165)

Where does it happen?

In processor.js when I'm trying to run this: const gpu = new GPU(); const kernel_normalize = gpu.createKernel(function (yuv,y_buffer,u_buffer,v_buffer,pixels) { for(let i=0; i<pixels; i++){ if(y[i] <0 ) y[i]=0; if(y[i] >1 ) y[i]=1; yuv[this.thread.x *3] = y_buffer[this.thread.x] * 255; yuv[this.thread.y *3+1] = u_buffer.data[this.thread.y]; yuv[this.thread.z *3+1] = v_buffer.data[this.thread.z]; } }).setOutput([upscaled_numPixels*3]); YUV_upscaled_array=kernel_normalize(YUV_upscaled_array,Y_upscaled_array,U_upscaled_mat,V_upscaled_mat,upscaled_numPixels); I'm not familiar with threading, so could you help me out here?

How do we replicate the issue?

I don't think that would be needed, newbie issue.

How important is this (1-5)?

4

Expected behavior (i.e. solution)

I think I should have got my Upscaled array of size upscaled_numPixels*3.

Other Comments

I'm trying to take input from the video tag using getImageData (to a canvas) and process it, and put it back into another canvas. Input size is 180x320, output is 720x1280.