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

Method validateSettings

src/backend/cpu/kernel.js:87–110  ·  view source on GitHub ↗

* @desc Validate settings related to Kernel, such as dimensions size, and auto output support. * @param {IArguments} args

(args)

Source from the content-addressed store, hash-verified

85 * @param {IArguments} args
86 */
87 validateSettings(args) {
88 if (!this.output || this.output.length === 0) {
89 if (args.length !== 1) {
90 throw new Error('Auto output only supported for kernels with only one input');
91 }
92
93 const argType = utils.getVariableType(args[0], this.strictIntegers);
94 if (argType === 'Array') {
95 this.output = utils.getDimensions(argType);
96 } else if (argType === 'NumberTexture' || argType === 'ArrayTexture(4)') {
97 this.output = args[0].output;
98 } else {
99 throw new Error('Auto output not supported for input type: ' + argType);
100 }
101 }
102
103 if (this.graphical) {
104 if (this.output.length !== 2) {
105 throw new Error('Output must have 2 dimensions on graphical mode');
106 }
107 }
108
109 this.checkOutput();
110 }
111
112 translateSource() {
113 this.leadingReturnStatement = this.output.length > 1 ? 'resultX[x] = ' : 'result[x] = ';

Callers 1

buildMethod · 0.95

Calls 2

getVariableTypeMethod · 0.80
checkOutputMethod · 0.80

Tested by

no test coverage detected