Comparing version 0.2.2 to 0.2.3
@@ -15,3 +15,3 @@ const GpuEz = {}; | ||
GpuEz.returnTypeDims = Object.assign({}, ...Object.entries(GpuEz.returnTypes).map(([k, v]) => ({[v]: k}))); | ||
GpuEz.returnTypeDims = Object.assign({}, ...Object.entries(GpuEz.returnTypes).map(([k, v]) => ({[v]: +k}))); | ||
@@ -26,2 +26,7 @@ GpuEz.preKernelFuncs = { | ||
GpuEz.getArgType = function getArgType(vec, dim) { | ||
if (!dim) return vec > 1 ? `Array(${vec})` : 'Float'; | ||
return vec > 1 ? `Array${dim}D(${vec})` : 'Array' | ||
} | ||
GpuEz.getPreKernel = function getPreKernel(put, dim, type) { | ||
@@ -43,3 +48,3 @@ const pre = GpuEz.preKernels; | ||
pipeline: !!put, immutable: true, dynamicOutput: true, dynamicArguments: true, | ||
returnType: type, argumentTypes: {arr: vec > 1 ? `Array${nDim}D(${vec})` : 'Array'} | ||
returnType: type, argumentTypes: {arr: GpuEz.getArgType(vec, nDim)} | ||
}; | ||
@@ -96,3 +101,4 @@ | ||
const argNames = argEnts.map(arg => arg[1]); | ||
const argVecs = argEnts.map(arg => arg[2]); | ||
const argVecs = argEnts.map(arg => arg[2] | 0); | ||
const argDims = argEnts.map(arg => arg[3] | 0); | ||
const argMacro = argEnts.map(GpuEz.argEntsMacro).join(''); | ||
@@ -102,2 +108,10 @@ | ||
const argumentTypes = {}; | ||
for (let i = 0; i < argEnts.length; i++) { | ||
const vec = argVecs[i]; | ||
const nDim = argDims[i]; | ||
argumentTypes[argNames[i]] = GpuEz.getArgType(vec, nDim); | ||
} | ||
const kernelSettings = [ | ||
@@ -119,2 +133,3 @@ Function( | ||
returnType: GpuEz.returnTypes[vec] || GpuEz.returnTypes[1], | ||
argumentTypes, | ||
debug: !!debug | ||
@@ -132,8 +147,4 @@ } | ||
for (let i = 0; i < args.length; i++) if (args[i] instanceof Array || args[i] instanceof Float32Array) { | ||
temps.push( | ||
args[i] = GpuEz.arrayToTex( | ||
args[i], | ||
GpuEz.returnTypes[argVecs[i]] || GpuEz.returnTypes[1] | ||
) | ||
); | ||
temps.push(args[i] = GpuEz.arrayToTex(args[i], | ||
GpuEz.returnTypes[argVecs[i]] || GpuEz.returnTypes[1])); | ||
} | ||
@@ -144,3 +155,3 @@ const [${argNames}] = args; | ||
const res = kernel(...args); | ||
for (const tex of temps) tex.delete(); | ||
for (const tex of temps) if (tex.delete) tex.delete(); | ||
return res; | ||
@@ -203,2 +214,3 @@ })`); | ||
const dim = GpuEz.getArrayDim(arr, vec); | ||
if (!dim.length) return arr; | ||
@@ -205,0 +217,0 @@ const kernel = GpuEz.getPreKernel(true, dim.length, vecType); |
{ | ||
"name": "gpu-ez", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Easy GLSL parallel computing on GPU.JS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
636583
17114
2