Socket
Socket
Sign inDemoInstall

@antv/g-webgpu-engine

Package Overview
Dependencies
Maintainers
26
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g-webgpu-engine - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

12

CHANGELOG.md

@@ -6,2 +6,14 @@ # Change Log

# [0.4.0](https://github.com/xiaoiver/GWebGPUEngine/compare/v0.3.0...v0.4.0) (2020-06-24)
### Features
* 支持在 WebWorker 中运行 [#23](https://github.com/xiaoiver/GWebGPUEngine/issues/23) ([1e87b0f](https://github.com/xiaoiver/GWebGPUEngine/commit/1e87b0f0702a9082c8cdfba834532f23dd72700c))
* 支持转译 WSL [#25](https://github.com/xiaoiver/GWebGPUEngine/issues/25) ([00b4502](https://github.com/xiaoiver/GWebGPUEngine/commit/00b4502b70ca085b38988756caf3e33936d3a732))
# [0.2.0](https://github.com/xiaoiver/GWebGPUEngine/compare/v0.1.2...v0.2.0) (2020-06-12)

@@ -8,0 +20,0 @@

3

es/webgl/index.js

@@ -144,3 +144,4 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";

regl({
container: _this.canvas,
// @ts-ignore
canvas: _this.canvas,
attributes: {

@@ -147,0 +148,0 @@ alpha: true,

@@ -21,3 +21,4 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";

*/
// tslint:disable-next-line:no-submodule-imports
import { isSafari } from '@antv/g-webgpu-core'; // tslint:disable-next-line:no-submodule-imports
import * as WebGPUConstants from '@webgpu/types/dist/constants';

@@ -138,3 +139,10 @@ import { injectable } from 'inversify';

this.commandBuffers[2] = this.computeEncoder.finish();
this.device.defaultQueue.submit(this.commandBuffers);
if (isSafari) {
// @ts-ignore
this.device.getQueue().submit(this.commandBuffers);
} else {
this.device.defaultQueue.submit(this.commandBuffers);
}
this.tempBuffers.forEach(function (buffer) {

@@ -316,3 +324,3 @@ return buffer.destroy();

var _compileComputePipelineStageDescriptor = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(computeCode, context) {
var shaderVersion, computeShader;
var computeShader, shaderVersion;
return _regeneratorRuntime.wrap(function _callee4$(_context4) {

@@ -322,12 +330,26 @@ while (1) {

case 0:
if (!isSafari) {
_context4.next = 4;
break;
}
computeShader = computeCode;
_context4.next = 8;
break;
case 4:
shaderVersion = '#version 450\n';
_context4.next = 3;
_context4.next = 7;
return this.compileShaderToSpirV(computeCode, 'compute', shaderVersion);
case 3:
case 7:
computeShader = _context4.sent;
case 8:
return _context4.abrupt("return", {
computeStage: {
module: this.device.createShaderModule({
code: computeShader
code: computeShader,
// @ts-ignore
isWHLSL: isSafari
}),

@@ -338,3 +360,3 @@ entryPoint: 'main'

case 5:
case 9:
case "end":

@@ -384,3 +406,11 @@ return _context4.stop();

var dataBuffer = this.createBuffer(view, WebGPUConstants.BufferUsage.Vertex | WebGPUConstants.BufferUsage.CopyDst | WebGPUConstants.BufferUsage.CopySrc | usage);
var dataBuffer;
if (isSafari) {
dataBuffer = this.createBuffer(view, WebGPUConstants.BufferUsage.Vertex | WebGPUConstants.BufferUsage.CopyDst | WebGPUConstants.BufferUsage.MapRead | usage);
} else {
// 如果添加了 MapRead,Chrome 会报错
dataBuffer = this.createBuffer(view, WebGPUConstants.BufferUsage.Vertex | WebGPUConstants.BufferUsage.CopyDst | WebGPUConstants.BufferUsage.CopySrc | usage);
}
return dataBuffer;

@@ -540,3 +570,3 @@ }

var _readData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(context) {
var output, length, typedArrayConstructor, gpuBuffer, byteCount, gpuReadBuffer, arraybuffer;
var output, length, typedArrayConstructor, gpuBuffer, arraybuffer, byteCount, gpuReadBuffer;
return _regeneratorRuntime.wrap(function _callee5$(_context5) {

@@ -549,3 +579,3 @@ while (1) {

if (!output) {
_context5.next = 15;
_context5.next = 21;
break;

@@ -557,6 +587,20 @@ }

if (!gpuBuffer) {
_context5.next = 15;
_context5.next = 21;
break;
}
if (!isSafari) {
_context5.next = 10;
break;
}
_context5.next = 7;
return gpuBuffer.mapReadAsync();
case 7:
arraybuffer = _context5.sent;
_context5.next = 20;
break;
case 10:
byteCount = length * typedArrayConstructor.BYTES_PER_ELEMENT;

@@ -575,15 +619,17 @@ gpuReadBuffer = this.device.createBuffer({

this.uploadEncoder = this.device.createCommandEncoder(this.uploadEncoderDescriptor);
_context5.next = 12;
_context5.next = 18;
return gpuReadBuffer.mapReadAsync();
case 12:
case 18:
arraybuffer = _context5.sent;
// destroy read buffer later
this.tempBuffers.push(gpuReadBuffer);
case 20:
return _context5.abrupt("return", new typedArrayConstructor(arraybuffer));
case 15:
case 21:
return _context5.abrupt("return", new Float32Array());
case 16:
case 22:
case "end":

@@ -687,3 +733,3 @@ return _context5.stop();

value: function initContextAndSwapChain() {
this.context = this.canvas.getContext('gpupresent');
this.context = this.canvas.getContext(isSafari ? 'gpu' : 'gpupresent');
this.swapChain = this.context.configureSwapChain({

@@ -722,3 +768,4 @@ device: this.device,

this.mainColorAttachments = [{
attachment: this.mainTexture.createView(),
attachment: isSafari ? // @ts-ignore
this.mainTexture.createDefaultView() : this.mainTexture.createView(),
loadValue: [0, 0, 0, 1],

@@ -729,3 +776,4 @@ storeOp: WebGPUConstants.StoreOp.Store

this.mainColorAttachments = [{
attachment: this.swapChain.getCurrentTexture().createView(),
attachment: isSafari ? // @ts-ignore
this.swapChain.getCurrentTexture().createDefaultView() : this.swapChain.getCurrentTexture().createView(),
loadValue: [0, 0, 0, 1],

@@ -742,3 +790,3 @@ storeOp: WebGPUConstants.StoreOp.Store

dimension: WebGPUConstants.TextureDimension.E2d,
format: WebGPUConstants.TextureFormat.Depth24PlusStencil8,
format: isSafari ? 'depth32float-stencil8' : WebGPUConstants.TextureFormat.Depth24PlusStencil8,
usage: WebGPUConstants.TextureUsage.OutputAttachment

@@ -749,7 +797,9 @@ };

this.depthTexture.destroy();
}
} // @ts-ignore
this.depthTexture = this.device.createTexture(depthTextureDescriptor);
this.mainDepthAttachment = {
attachment: this.depthTexture.createView(),
attachment: isSafari ? // @ts-ignore
this.depthTexture.createDefaultView() : this.depthTexture.createView(),
depthLoadValue: this.clearDepthValue,

@@ -779,5 +829,7 @@ depthStoreOp: WebGPUConstants.StoreOp.Store,

if (this.options.antialiasing) {
this.mainColorAttachments[0].resolveTarget = this.swapChain.getCurrentTexture().createView();
this.mainColorAttachments[0].resolveTarget = isSafari ? // @ts-ignore
this.swapChain.getCurrentTexture().createDefaultView() : this.swapChain.getCurrentTexture().createView();
} else {
this.mainColorAttachments[0].attachment = this.swapChain.getCurrentTexture().createView();
this.mainColorAttachments[0].attachment = isSafari ? // @ts-ignore
this.swapChain.getCurrentTexture().createDefaultView() : this.swapChain.getCurrentTexture().createView();
}

@@ -840,3 +892,5 @@

module: this.device.createShaderModule({
code: vertexShader
code: vertexShader,
// @ts-ignore
isWHLSL: isSafari
}),

@@ -847,3 +901,5 @@ entryPoint: 'main'

module: this.device.createShaderModule({
code: fragmentShader
code: fragmentShader,
// @ts-ignore
isWHLSL: isSafari
}),

@@ -850,0 +906,0 @@ entryPoint: 'main'

@@ -159,3 +159,4 @@ "use strict";

(0, _regl.default)({
container: _this.canvas,
// @ts-ignore
canvas: _this.canvas,
attributes: {

@@ -162,0 +163,0 @@ alpha: true,

@@ -26,2 +26,4 @@ "use strict";

var _gWebgpuCore = require("@antv/g-webgpu-core");
var WebGPUConstants = _interopRequireWildcard(require("@webgpu/types/dist/constants"));

@@ -150,3 +152,10 @@

this.commandBuffers[2] = this.computeEncoder.finish();
this.device.defaultQueue.submit(this.commandBuffers);
if (_gWebgpuCore.isSafari) {
// @ts-ignore
this.device.getQueue().submit(this.commandBuffers);
} else {
this.device.defaultQueue.submit(this.commandBuffers);
}
this.tempBuffers.forEach(function (buffer) {

@@ -328,3 +337,3 @@ return buffer.destroy();

var _compileComputePipelineStageDescriptor = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(computeCode, context) {
var shaderVersion, computeShader;
var computeShader, shaderVersion;
return _regenerator.default.wrap(function _callee4$(_context4) {

@@ -334,12 +343,26 @@ while (1) {

case 0:
if (!_gWebgpuCore.isSafari) {
_context4.next = 4;
break;
}
computeShader = computeCode;
_context4.next = 8;
break;
case 4:
shaderVersion = '#version 450\n';
_context4.next = 3;
_context4.next = 7;
return this.compileShaderToSpirV(computeCode, 'compute', shaderVersion);
case 3:
case 7:
computeShader = _context4.sent;
case 8:
return _context4.abrupt("return", {
computeStage: {
module: this.device.createShaderModule({
code: computeShader
code: computeShader,
// @ts-ignore
isWHLSL: _gWebgpuCore.isSafari
}),

@@ -350,3 +373,3 @@ entryPoint: 'main'

case 5:
case 9:
case "end":

@@ -396,3 +419,11 @@ return _context4.stop();

var dataBuffer = this.createBuffer(view, WebGPUConstants.BufferUsage.Vertex | WebGPUConstants.BufferUsage.CopyDst | WebGPUConstants.BufferUsage.CopySrc | usage);
var dataBuffer;
if (_gWebgpuCore.isSafari) {
dataBuffer = this.createBuffer(view, WebGPUConstants.BufferUsage.Vertex | WebGPUConstants.BufferUsage.CopyDst | WebGPUConstants.BufferUsage.MapRead | usage);
} else {
// 如果添加了 MapRead,Chrome 会报错
dataBuffer = this.createBuffer(view, WebGPUConstants.BufferUsage.Vertex | WebGPUConstants.BufferUsage.CopyDst | WebGPUConstants.BufferUsage.CopySrc | usage);
}
return dataBuffer;

@@ -552,3 +583,3 @@ }

var _readData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(context) {
var output, length, typedArrayConstructor, gpuBuffer, byteCount, gpuReadBuffer, arraybuffer;
var output, length, typedArrayConstructor, gpuBuffer, arraybuffer, byteCount, gpuReadBuffer;
return _regenerator.default.wrap(function _callee5$(_context5) {

@@ -561,3 +592,3 @@ while (1) {

if (!output) {
_context5.next = 15;
_context5.next = 21;
break;

@@ -569,6 +600,20 @@ }

if (!gpuBuffer) {
_context5.next = 15;
_context5.next = 21;
break;
}
if (!_gWebgpuCore.isSafari) {
_context5.next = 10;
break;
}
_context5.next = 7;
return gpuBuffer.mapReadAsync();
case 7:
arraybuffer = _context5.sent;
_context5.next = 20;
break;
case 10:
byteCount = length * typedArrayConstructor.BYTES_PER_ELEMENT;

@@ -587,15 +632,17 @@ gpuReadBuffer = this.device.createBuffer({

this.uploadEncoder = this.device.createCommandEncoder(this.uploadEncoderDescriptor);
_context5.next = 12;
_context5.next = 18;
return gpuReadBuffer.mapReadAsync();
case 12:
case 18:
arraybuffer = _context5.sent;
// destroy read buffer later
this.tempBuffers.push(gpuReadBuffer);
case 20:
return _context5.abrupt("return", new typedArrayConstructor(arraybuffer));
case 15:
case 21:
return _context5.abrupt("return", new Float32Array());
case 16:
case 22:
case "end":

@@ -699,3 +746,3 @@ return _context5.stop();

value: function initContextAndSwapChain() {
this.context = this.canvas.getContext('gpupresent');
this.context = this.canvas.getContext(_gWebgpuCore.isSafari ? 'gpu' : 'gpupresent');
this.swapChain = this.context.configureSwapChain({

@@ -734,3 +781,4 @@ device: this.device,

this.mainColorAttachments = [{
attachment: this.mainTexture.createView(),
attachment: _gWebgpuCore.isSafari ? // @ts-ignore
this.mainTexture.createDefaultView() : this.mainTexture.createView(),
loadValue: [0, 0, 0, 1],

@@ -741,3 +789,4 @@ storeOp: WebGPUConstants.StoreOp.Store

this.mainColorAttachments = [{
attachment: this.swapChain.getCurrentTexture().createView(),
attachment: _gWebgpuCore.isSafari ? // @ts-ignore
this.swapChain.getCurrentTexture().createDefaultView() : this.swapChain.getCurrentTexture().createView(),
loadValue: [0, 0, 0, 1],

@@ -754,3 +803,3 @@ storeOp: WebGPUConstants.StoreOp.Store

dimension: WebGPUConstants.TextureDimension.E2d,
format: WebGPUConstants.TextureFormat.Depth24PlusStencil8,
format: _gWebgpuCore.isSafari ? 'depth32float-stencil8' : WebGPUConstants.TextureFormat.Depth24PlusStencil8,
usage: WebGPUConstants.TextureUsage.OutputAttachment

@@ -761,7 +810,9 @@ };

this.depthTexture.destroy();
}
} // @ts-ignore
this.depthTexture = this.device.createTexture(depthTextureDescriptor);
this.mainDepthAttachment = {
attachment: this.depthTexture.createView(),
attachment: _gWebgpuCore.isSafari ? // @ts-ignore
this.depthTexture.createDefaultView() : this.depthTexture.createView(),
depthLoadValue: this.clearDepthValue,

@@ -791,5 +842,7 @@ depthStoreOp: WebGPUConstants.StoreOp.Store,

if (this.options.antialiasing) {
this.mainColorAttachments[0].resolveTarget = this.swapChain.getCurrentTexture().createView();
this.mainColorAttachments[0].resolveTarget = _gWebgpuCore.isSafari ? // @ts-ignore
this.swapChain.getCurrentTexture().createDefaultView() : this.swapChain.getCurrentTexture().createView();
} else {
this.mainColorAttachments[0].attachment = this.swapChain.getCurrentTexture().createView();
this.mainColorAttachments[0].attachment = _gWebgpuCore.isSafari ? // @ts-ignore
this.swapChain.getCurrentTexture().createDefaultView() : this.swapChain.getCurrentTexture().createView();
}

@@ -852,3 +905,5 @@

module: this.device.createShaderModule({
code: vertexShader
code: vertexShader,
// @ts-ignore
isWHLSL: _gWebgpuCore.isSafari
}),

@@ -859,3 +914,5 @@ entryPoint: 'main'

module: this.device.createShaderModule({
code: fragmentShader
code: fragmentShader,
// @ts-ignore
isWHLSL: _gWebgpuCore.isSafari
}),

@@ -862,0 +919,0 @@ entryPoint: 'main'

{
"name": "@antv/g-webgpu-engine",
"version": "0.3.0",
"version": "0.4.0",
"description": "",

@@ -25,4 +25,4 @@ "main": "lib/index.js",

"dependencies": {
"@antv/g-webgpu-compiler": "^0.3.0",
"@antv/g-webgpu-core": "^0.3.0",
"@antv/g-webgpu-compiler": "^0.4.0",
"@antv/g-webgpu-core": "^0.4.0",
"@webgpu/glslang": "^0.0.15",

@@ -47,3 +47,3 @@ "@webgpu/types": "^0.0.22",

},
"gitHead": "c91fd340ae86a05d8b1009ad7447888530b26834"
"gitHead": "562ae1b577219c3f465bce0e9e0b58d44ffef65f"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc