(args)
| 347 | } |
| 348 | |
| 349 | setupArguments(args) { |
| 350 | this.kernelArguments = []; |
| 351 | this.argumentTextureCount = 0; |
| 352 | const needsArgumentTypes = this.argumentTypes === null; |
| 353 | // TODO: remove |
| 354 | if (needsArgumentTypes) { |
| 355 | this.argumentTypes = []; |
| 356 | } |
| 357 | this.argumentSizes = []; |
| 358 | this.argumentBitRatios = []; |
| 359 | // TODO: end remove |
| 360 | |
| 361 | if (args.length < this.argumentNames.length) { |
| 362 | throw new Error('not enough arguments for kernel'); |
| 363 | } else if (args.length > this.argumentNames.length) { |
| 364 | throw new Error('too many arguments for kernel'); |
| 365 | } |
| 366 | |
| 367 | const { context: gl } = this; |
| 368 | let textureIndexes = 0; |
| 369 | |
| 370 | const onRequestTexture = () => { |
| 371 | return this.createTexture(); |
| 372 | }; |
| 373 | const onRequestIndex = () => { |
| 374 | return this.constantTextureCount + textureIndexes++; |
| 375 | }; |
| 376 | const onUpdateValueMismatch = (constructor) => { |
| 377 | this.switchKernels({ |
| 378 | type: 'argumentMismatch', |
| 379 | needed: constructor |
| 380 | }); |
| 381 | }; |
| 382 | const onRequestContextHandle = () => { |
| 383 | return gl.TEXTURE0 + this.constantTextureCount + this.argumentTextureCount++; |
| 384 | }; |
| 385 | |
| 386 | for (let index = 0; index < args.length; index++) { |
| 387 | const value = args[index]; |
| 388 | const name = this.argumentNames[index]; |
| 389 | let type; |
| 390 | if (needsArgumentTypes) { |
| 391 | type = utils.getVariableType(value, this.strictIntegers); |
| 392 | this.argumentTypes.push(type); |
| 393 | } else { |
| 394 | type = this.argumentTypes[index]; |
| 395 | } |
| 396 | const KernelValue = this.constructor.lookupKernelValueType(type, this.dynamicArguments ? 'dynamic' : 'static', this.precision, args[index]); |
| 397 | if (KernelValue === null) { |
| 398 | return this.requestFallback(args); |
| 399 | } |
| 400 | const kernelArgument = new KernelValue(value, { |
| 401 | name, |
| 402 | type, |
| 403 | tactic: this.tactic, |
| 404 | origin: 'user', |
| 405 | context: gl, |
| 406 | checkContext: this.checkContext, |
no test coverage detected