@antv/g-webgpu-engine
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -39,3 +39,5 @@ /// <reference types="@webgpu/types" /> | ||
init(canvas: HTMLCanvasElement, options?: IWebGPUEngineOptions): Promise<void>; | ||
isFloatSupported(): any; | ||
compileComputePipelineStageDescriptor(computeCode: string, context: GLSLContext): Promise<Pick<GPUComputePipelineDescriptor, 'computeStage'>>; | ||
confirmInput(contextName: string, textureName: string, referContextName: string): void; | ||
dispatch(context: GLSLContext): void; | ||
@@ -42,0 +44,0 @@ readData(context: GLSLContext): Promise<Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array>; |
@@ -188,2 +188,9 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; | ||
}, { | ||
key: "isFloatSupported", | ||
value: function isFloatSupported() { | ||
// @see https://github.com/antvis/GWebGPUEngine/issues/26 | ||
// @ts-ignore | ||
return this.gl.limits.readFloat; | ||
} | ||
}, { | ||
key: "compileComputePipelineStageDescriptor", | ||
@@ -203,3 +210,5 @@ value: function () { | ||
// @ts-ignore | ||
cache = {}; | ||
cache = { | ||
textureCache: {} | ||
}; | ||
} | ||
@@ -261,6 +270,5 @@ | ||
} | ||
} // @ts-ignore | ||
} | ||
uniforms[name] = _this2.gl.texture({ | ||
var uniformTexture = _this2.gl.texture({ | ||
width: width, | ||
@@ -270,4 +278,11 @@ height: width, | ||
type: 'float' | ||
}); // @ts-ignore | ||
}); | ||
cache.textureCache[name] = uniformTexture; // 需要动态获取,有可能在运行时通过 setBinding 关联到另一个计算程序的输出 | ||
// @ts-ignore | ||
uniforms[name] = context.maxIteration > 1 && context.needPingpong ? cache.textureCache[name] : function () { | ||
return cache.textureCache[name]; | ||
}; // @ts-ignore | ||
uniforms["".concat(name, "Size")] = [width, width]; | ||
@@ -290,5 +305,5 @@ } else { | ||
uniforms.u_OutputTexelCount = outputTexelCount; // 大于一次认为需要 pingpong | ||
uniforms.u_OutputTexelCount = outputTexelCount; // 大于一次且 输入输出均为自身的 认为需要 pingpong | ||
if (context.maxIteration > 1) { | ||
if (context.maxIteration > 1 && context.needPingpong) { | ||
// @ts-ignore | ||
@@ -357,2 +372,13 @@ cache.texInput = uniforms[outputTextureName]; // @ts-ignore | ||
}, { | ||
key: "confirmInput", | ||
value: function confirmInput(contextName, textureName, referContextName) { | ||
var cache = this.contextCache[contextName]; | ||
var referCache = this.contextCache[referContextName]; | ||
if (cache && referCache) { | ||
// 需要 pingpong 的都有 texInput | ||
cache.textureCache[textureName] = referCache.texInput || referCache.texOutput; | ||
} | ||
} | ||
}, { | ||
key: "dispatch", | ||
@@ -370,3 +396,3 @@ value: function dispatch(context) { | ||
if (context.maxIteration > 1) { | ||
if (context.maxIteration > 1 && context.needPingpong) { | ||
var tmp = cache.texOutput; | ||
@@ -373,0 +399,0 @@ cache.texOutput = cache.texInput; |
@@ -46,2 +46,3 @@ /// <reference types="@webgpu/types" /> | ||
private readonly computeEncoderDescriptor; | ||
isFloatSupported(): boolean; | ||
getDevice(): GPUDevice; | ||
@@ -105,2 +106,3 @@ getSwapChain(): GPUSwapChain; | ||
dispatch(context: GLSLContext): void; | ||
confirmInput(contextName: string, textureName: string, referContextName: string): void; | ||
private createBuffer; | ||
@@ -107,0 +109,0 @@ private initGlslang; |
@@ -68,2 +68,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
_createClass(WebGPUEngine, [{ | ||
key: "isFloatSupported", | ||
value: function isFloatSupported() { | ||
return true; | ||
} | ||
}, { | ||
key: "getDevice", | ||
@@ -556,4 +561,7 @@ value: function getDevice() { | ||
this.commandBuffers[0] = this.uploadEncoder.finish(); | ||
this.device.defaultQueue.submit(this.commandBuffers); | ||
this.commandBuffers[0] = this.uploadEncoder.finish(); // filter undefined buffers | ||
this.device.defaultQueue.submit(this.commandBuffers.filter(function (b) { | ||
return b; | ||
})); | ||
this.uploadEncoder = this.device.createCommandEncoder(this.uploadEncoderDescriptor); | ||
@@ -613,2 +621,6 @@ _context5.next = 12; | ||
}, { | ||
key: "confirmInput", | ||
value: function confirmInput(contextName, textureName, referContextName) {// | ||
} | ||
}, { | ||
key: "createBuffer", | ||
@@ -615,0 +627,0 @@ value: function createBuffer(view, flags) { |
@@ -203,2 +203,9 @@ "use strict"; | ||
}, { | ||
key: "isFloatSupported", | ||
value: function isFloatSupported() { | ||
// @see https://github.com/antvis/GWebGPUEngine/issues/26 | ||
// @ts-ignore | ||
return this.gl.limits.readFloat; | ||
} | ||
}, { | ||
key: "compileComputePipelineStageDescriptor", | ||
@@ -218,3 +225,5 @@ value: function () { | ||
// @ts-ignore | ||
cache = {}; | ||
cache = { | ||
textureCache: {} | ||
}; | ||
} | ||
@@ -276,6 +285,5 @@ | ||
} | ||
} // @ts-ignore | ||
} | ||
uniforms[name] = _this2.gl.texture({ | ||
var uniformTexture = _this2.gl.texture({ | ||
width: width, | ||
@@ -285,4 +293,11 @@ height: width, | ||
type: 'float' | ||
}); // @ts-ignore | ||
}); | ||
cache.textureCache[name] = uniformTexture; // 需要动态获取,有可能在运行时通过 setBinding 关联到另一个计算程序的输出 | ||
// @ts-ignore | ||
uniforms[name] = context.maxIteration > 1 && context.needPingpong ? cache.textureCache[name] : function () { | ||
return cache.textureCache[name]; | ||
}; // @ts-ignore | ||
uniforms["".concat(name, "Size")] = [width, width]; | ||
@@ -305,5 +320,5 @@ } else { | ||
uniforms.u_OutputTexelCount = outputTexelCount; // 大于一次认为需要 pingpong | ||
uniforms.u_OutputTexelCount = outputTexelCount; // 大于一次且 输入输出均为自身的 认为需要 pingpong | ||
if (context.maxIteration > 1) { | ||
if (context.maxIteration > 1 && context.needPingpong) { | ||
// @ts-ignore | ||
@@ -372,2 +387,13 @@ cache.texInput = uniforms[outputTextureName]; // @ts-ignore | ||
}, { | ||
key: "confirmInput", | ||
value: function confirmInput(contextName, textureName, referContextName) { | ||
var cache = this.contextCache[contextName]; | ||
var referCache = this.contextCache[referContextName]; | ||
if (cache && referCache) { | ||
// 需要 pingpong 的都有 texInput | ||
cache.textureCache[textureName] = referCache.texInput || referCache.texOutput; | ||
} | ||
} | ||
}, { | ||
key: "dispatch", | ||
@@ -385,3 +411,3 @@ value: function dispatch(context) { | ||
if (context.maxIteration > 1) { | ||
if (context.maxIteration > 1 && context.needPingpong) { | ||
var tmp = cache.texOutput; | ||
@@ -388,0 +414,0 @@ cache.texOutput = cache.texInput; |
@@ -80,2 +80,7 @@ "use strict"; | ||
(0, _createClass2.default)(WebGPUEngine, [{ | ||
key: "isFloatSupported", | ||
value: function isFloatSupported() { | ||
return true; | ||
} | ||
}, { | ||
key: "getDevice", | ||
@@ -568,4 +573,7 @@ value: function getDevice() { | ||
this.commandBuffers[0] = this.uploadEncoder.finish(); | ||
this.device.defaultQueue.submit(this.commandBuffers); | ||
this.commandBuffers[0] = this.uploadEncoder.finish(); // filter undefined buffers | ||
this.device.defaultQueue.submit(this.commandBuffers.filter(function (b) { | ||
return b; | ||
})); | ||
this.uploadEncoder = this.device.createCommandEncoder(this.uploadEncoderDescriptor); | ||
@@ -625,2 +633,6 @@ _context5.next = 12; | ||
}, { | ||
key: "confirmInput", | ||
value: function confirmInput(contextName, textureName, referContextName) {// | ||
} | ||
}, { | ||
key: "createBuffer", | ||
@@ -627,0 +639,0 @@ value: function createBuffer(view, flags) { |
{ | ||
"name": "@antv/g-webgpu-engine", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "", | ||
@@ -25,4 +25,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@antv/g-webgpu-compiler": "^0.2.0", | ||
"@antv/g-webgpu-core": "^0.2.0", | ||
"@antv/g-webgpu-compiler": "^0.3.0", | ||
"@antv/g-webgpu-core": "^0.3.0", | ||
"@webgpu/glslang": "^0.0.15", | ||
@@ -47,3 +47,3 @@ "@webgpu/types": "^0.0.22", | ||
}, | ||
"gitHead": "74fb112a31addaaee0498dce8339e6f240934e82" | ||
"gitHead": "c91fd340ae86a05d8b1009ad7447888530b26834" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
278127
2886
+ Added@antv/g-webgpu-compiler@0.3.0(transitive)
+ Added@antv/g-webgpu-core@0.3.0(transitive)
- Removed@antv/g-webgpu-compiler@0.2.0(transitive)
- Removed@antv/g-webgpu-core@0.2.0(transitive)
Updated@antv/g-webgpu-core@^0.3.0