@antv/g-webgpu 1.7.72 → 1.7.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +4 -1
- package/dist/index.js +4 -1
- package/dist/index.umd.js +409 -286
- package/dist/index.umd.min.js +1 -1
- package/dist/pkg/glsl_wgsl_compiler.d.ts +48 -0
- package/dist/pkg/glsl_wgsl_compiler.js +223 -0
- package/dist/pkg/glsl_wgsl_compiler_bg.wasm +0 -0
- package/dist/pkg/package.json +17 -0
- package/package.json +7 -7
package/dist/index.umd.js
CHANGED
|
@@ -4140,6 +4140,9 @@
|
|
|
4140
4140
|
function bufferBindingEquals(a, b) {
|
|
4141
4141
|
return a.buffer === b.buffer && a.wordCount === b.wordCount;
|
|
4142
4142
|
}
|
|
4143
|
+
function bindingLayoutSamplerDescriptorEqual(a, b) {
|
|
4144
|
+
return a.dimension === b.dimension && a.formatKind === b.formatKind;
|
|
4145
|
+
}
|
|
4143
4146
|
function samplerBindingEquals(a, b) {
|
|
4144
4147
|
if (a === null) return b === null;
|
|
4145
4148
|
if (b === null) return false;
|
|
@@ -4148,6 +4151,8 @@
|
|
|
4148
4151
|
function bindingLayoutDescriptorEqual(a, b) {
|
|
4149
4152
|
if (a.numSamplers !== b.numSamplers) return false;
|
|
4150
4153
|
if (a.numUniformBuffers !== b.numUniformBuffers) return false;
|
|
4154
|
+
if (a.samplerEntries === undefined !== (b.samplerEntries === undefined)) return false;
|
|
4155
|
+
if (a.samplerEntries !== undefined && !arrayEqual(a.samplerEntries, b.samplerEntries, bindingLayoutSamplerDescriptorEqual)) return false;
|
|
4151
4156
|
return true;
|
|
4152
4157
|
}
|
|
4153
4158
|
function bindingsDescriptorEquals(a, b) {
|
|
@@ -4843,7 +4848,7 @@
|
|
|
4843
4848
|
}
|
|
4844
4849
|
this.buffer = this.device.createBuffer({
|
|
4845
4850
|
viewOrSize: this.currentBufferWordSize,
|
|
4846
|
-
usage: BufferUsage.UNIFORM
|
|
4851
|
+
usage: BufferUsage.UNIFORM,
|
|
4847
4852
|
hint: BufferFrequencyHint.Dynamic
|
|
4848
4853
|
});
|
|
4849
4854
|
}
|
|
@@ -5153,31 +5158,28 @@
|
|
|
5153
5158
|
RGAttachmentSlot[RGAttachmentSlot["ColorMax"] = 3] = "ColorMax";
|
|
5154
5159
|
RGAttachmentSlot[RGAttachmentSlot["DepthStencil"] = 4] = "DepthStencil";
|
|
5155
5160
|
})(RGAttachmentSlot || (RGAttachmentSlot = {}));
|
|
5156
|
-
var IdentityViewportCoords = {
|
|
5157
|
-
x: 0,
|
|
5158
|
-
y: 0,
|
|
5159
|
-
w: 1,
|
|
5160
|
-
h: 1
|
|
5161
|
-
};
|
|
5162
5161
|
var RenderGraphPass = /*#__PURE__*/function () {
|
|
5163
5162
|
function RenderGraphPass() {
|
|
5164
5163
|
// RenderTargetAttachmentSlot => renderTargetID
|
|
5165
5164
|
this.renderTargetIDs = [];
|
|
5165
|
+
this.renderTargetLevels = [];
|
|
5166
5166
|
// RenderTargetAttachmentSlot => resolveTextureID
|
|
5167
5167
|
this.resolveTextureOutputIDs = [];
|
|
5168
5168
|
// RenderTargetAttachmentSlot => Texture
|
|
5169
5169
|
this.resolveTextureOutputExternalTextures = [];
|
|
5170
|
+
this.resolveTextureOutputExternalTextureLevel = [];
|
|
5170
5171
|
// List of resolveTextureIDs that we have a reference to.
|
|
5171
5172
|
this.resolveTextureInputIDs = [];
|
|
5172
5173
|
// RGAttachmentSlot => refcount.
|
|
5173
5174
|
this.renderTargetExtraRefs = [];
|
|
5174
|
-
this.viewport = IdentityViewportCoords;
|
|
5175
5175
|
this.resolveTextureInputTextures = [];
|
|
5176
5176
|
this.renderTargets = [];
|
|
5177
5177
|
// Execution state computed by scheduling.
|
|
5178
5178
|
this.descriptor = {
|
|
5179
5179
|
colorAttachment: [],
|
|
5180
|
+
colorAttachmentLevel: [],
|
|
5180
5181
|
colorResolveTo: [],
|
|
5182
|
+
colorResolveToLevel: [],
|
|
5181
5183
|
colorStore: [],
|
|
5182
5184
|
depthStencilAttachment: null,
|
|
5183
5185
|
depthStencilResolveTo: null,
|
|
@@ -5189,8 +5191,8 @@
|
|
|
5189
5191
|
};
|
|
5190
5192
|
this.viewportX = 0;
|
|
5191
5193
|
this.viewportY = 0;
|
|
5192
|
-
this.viewportW =
|
|
5193
|
-
this.viewportH =
|
|
5194
|
+
this.viewportW = 1;
|
|
5195
|
+
this.viewportH = 1;
|
|
5194
5196
|
// Execution callback from user.
|
|
5195
5197
|
this.execFunc = null;
|
|
5196
5198
|
this.postFunc = null;
|
|
@@ -5205,12 +5207,19 @@
|
|
|
5205
5207
|
_proto.pushDebugThumbnail = function pushDebugThumbnail(attachmentSlot) {
|
|
5206
5208
|
this.debugThumbnails[attachmentSlot] = true;
|
|
5207
5209
|
};
|
|
5208
|
-
_proto.setViewport = function setViewport(
|
|
5209
|
-
this.
|
|
5210
|
+
_proto.setViewport = function setViewport(x, y, w, h) {
|
|
5211
|
+
this.viewportX = x;
|
|
5212
|
+
this.viewportY = y;
|
|
5213
|
+
this.viewportW = w;
|
|
5214
|
+
this.viewportH = h;
|
|
5210
5215
|
};
|
|
5211
|
-
_proto.attachRenderTargetID = function attachRenderTargetID(attachmentSlot, renderTargetID) {
|
|
5216
|
+
_proto.attachRenderTargetID = function attachRenderTargetID(attachmentSlot, renderTargetID, level) {
|
|
5217
|
+
if (level === void 0) {
|
|
5218
|
+
level = 0;
|
|
5219
|
+
}
|
|
5212
5220
|
assert(this.renderTargetIDs[attachmentSlot] === undefined);
|
|
5213
5221
|
this.renderTargetIDs[attachmentSlot] = renderTargetID;
|
|
5222
|
+
this.renderTargetLevels[attachmentSlot] = level;
|
|
5214
5223
|
};
|
|
5215
5224
|
_proto.attachResolveTexture = function attachResolveTexture(resolveTextureID) {
|
|
5216
5225
|
this.resolveTextureInputIDs.push(resolveTextureID);
|
|
@@ -5429,12 +5438,16 @@
|
|
|
5429
5438
|
var attachmentSlot = renderPass.renderTargetIDs.indexOf(renderTargetID);
|
|
5430
5439
|
return this.resolveRenderTargetPassAttachmentSlot(renderPass, attachmentSlot);
|
|
5431
5440
|
};
|
|
5432
|
-
_proto.resolveRenderTargetToExternalTexture = function resolveRenderTargetToExternalTexture(renderTargetID, texture) {
|
|
5441
|
+
_proto.resolveRenderTargetToExternalTexture = function resolveRenderTargetToExternalTexture(renderTargetID, texture, level) {
|
|
5442
|
+
if (level === void 0) {
|
|
5443
|
+
level = 0;
|
|
5444
|
+
}
|
|
5433
5445
|
var renderPass = this.findPassForResolveRenderTarget(renderTargetID);
|
|
5434
5446
|
var attachmentSlot = renderPass.renderTargetIDs.indexOf(renderTargetID);
|
|
5435
5447
|
// We shouldn't be resolving to a resolve texture ID in this case.
|
|
5436
5448
|
assert(renderPass.resolveTextureOutputIDs[attachmentSlot] === undefined);
|
|
5437
5449
|
renderPass.resolveTextureOutputExternalTextures[attachmentSlot] = texture;
|
|
5450
|
+
renderPass.resolveTextureOutputExternalTextureLevel[attachmentSlot] = level;
|
|
5438
5451
|
};
|
|
5439
5452
|
_proto.getRenderTargetDescription = function getRenderTargetDescription(renderTargetID) {
|
|
5440
5453
|
return assertExists(this.currentGraph.renderTargetDescriptions[renderTargetID]);
|
|
@@ -5511,6 +5524,7 @@
|
|
|
5511
5524
|
assert(!(hasResolveTextureOutputID && hasExternalTexture));
|
|
5512
5525
|
var resolveTo = null;
|
|
5513
5526
|
var store = false;
|
|
5527
|
+
var level = 0;
|
|
5514
5528
|
if (this.renderTargetOutputCount[renderTargetID] > 1) {
|
|
5515
5529
|
// A future pass is going to render to this RT, we need to store the results.
|
|
5516
5530
|
store = true;
|
|
@@ -5538,12 +5552,14 @@
|
|
|
5538
5552
|
}
|
|
5539
5553
|
} else if (hasExternalTexture) {
|
|
5540
5554
|
resolveTo = externalTexture;
|
|
5555
|
+
level = pass.resolveTextureOutputExternalTextureLevel[slot];
|
|
5541
5556
|
} else {
|
|
5542
5557
|
resolveTo = null;
|
|
5543
5558
|
}
|
|
5544
5559
|
return {
|
|
5545
5560
|
resolveTo: resolveTo,
|
|
5546
|
-
store: store
|
|
5561
|
+
store: store,
|
|
5562
|
+
level: level
|
|
5547
5563
|
};
|
|
5548
5564
|
};
|
|
5549
5565
|
_proto.schedulePass = function schedulePass(graph, pass) {
|
|
@@ -5553,10 +5569,13 @@
|
|
|
5553
5569
|
var colorRenderTarget = this.acquireRenderTargetForID(graph, colorRenderTargetID);
|
|
5554
5570
|
pass.renderTargets[slot] = colorRenderTarget;
|
|
5555
5571
|
pass.descriptor.colorAttachment[slot] = colorRenderTarget !== null ? colorRenderTarget.attachment : null;
|
|
5572
|
+
pass.descriptor.colorAttachmentLevel[slot] = pass.renderTargetLevels[slot];
|
|
5556
5573
|
var _this$determineResolv = this.determineResolveParam(graph, pass, slot),
|
|
5557
5574
|
_resolveTo = _this$determineResolv.resolveTo,
|
|
5558
|
-
_store = _this$determineResolv.store
|
|
5575
|
+
_store = _this$determineResolv.store,
|
|
5576
|
+
level = _this$determineResolv.level;
|
|
5559
5577
|
pass.descriptor.colorResolveTo[slot] = _resolveTo;
|
|
5578
|
+
pass.descriptor.colorResolveToLevel[slot] = level;
|
|
5560
5579
|
pass.descriptor.colorStore[slot] = _store;
|
|
5561
5580
|
pass.descriptor.colorClearColor[slot] = colorRenderTarget !== null && colorRenderTarget.needsClear ? graph.renderTargetDescriptions[colorRenderTargetID].colorClearColor : 'load';
|
|
5562
5581
|
}
|
|
@@ -5576,25 +5595,23 @@
|
|
|
5576
5595
|
for (var i = 0; i < pass.renderTargets.length; i++) {
|
|
5577
5596
|
var renderTarget = pass.renderTargets[i];
|
|
5578
5597
|
if (!renderTarget) continue;
|
|
5598
|
+
var width = renderTarget.width >>> pass.renderTargetLevels[i];
|
|
5599
|
+
var height = renderTarget.height >>> pass.renderTargetLevels[i];
|
|
5579
5600
|
if (rtWidth === 0) {
|
|
5580
|
-
rtWidth =
|
|
5581
|
-
rtHeight =
|
|
5601
|
+
rtWidth = width;
|
|
5602
|
+
rtHeight = height;
|
|
5582
5603
|
rtSampleCount = renderTarget.sampleCount;
|
|
5583
5604
|
}
|
|
5584
|
-
assert(
|
|
5585
|
-
assert(
|
|
5605
|
+
assert(width === rtWidth);
|
|
5606
|
+
assert(height === rtHeight);
|
|
5586
5607
|
assert(renderTarget.sampleCount === rtSampleCount);
|
|
5587
5608
|
renderTarget.needsClear = false;
|
|
5588
5609
|
}
|
|
5589
5610
|
if (rtWidth > 0 && rtHeight > 0) {
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
pass.viewportX = x;
|
|
5595
|
-
pass.viewportY = y;
|
|
5596
|
-
pass.viewportW = w;
|
|
5597
|
-
pass.viewportH = h;
|
|
5611
|
+
pass.viewportX *= rtWidth;
|
|
5612
|
+
pass.viewportY *= rtHeight;
|
|
5613
|
+
pass.viewportW *= rtWidth;
|
|
5614
|
+
pass.viewportH *= rtHeight;
|
|
5598
5615
|
}
|
|
5599
5616
|
for (var _i = 0; _i < pass.resolveTextureInputIDs.length; _i++) {
|
|
5600
5617
|
var resolveTextureID = pass.resolveTextureInputIDs[_i];
|
|
@@ -5662,9 +5679,11 @@
|
|
|
5662
5679
|
_proto.execGraph = function execGraph(graph) {
|
|
5663
5680
|
var _this = this;
|
|
5664
5681
|
this.scheduleGraph(graph);
|
|
5682
|
+
this.device.beginFrame();
|
|
5665
5683
|
graph.passes.forEach(function (pass) {
|
|
5666
5684
|
_this.execPass(pass);
|
|
5667
5685
|
});
|
|
5686
|
+
this.device.endFrame();
|
|
5668
5687
|
// Clear our transient scope state.
|
|
5669
5688
|
this.singleSampledTextureForResolveTextureID.length = 0;
|
|
5670
5689
|
};
|
|
@@ -5977,6 +5996,7 @@
|
|
|
5977
5996
|
|
|
5978
5997
|
var RenderInstFlags;
|
|
5979
5998
|
(function (RenderInstFlags) {
|
|
5999
|
+
RenderInstFlags[RenderInstFlags["None"] = 0] = "None";
|
|
5980
6000
|
RenderInstFlags[RenderInstFlags["Indexed"] = 1] = "Indexed";
|
|
5981
6001
|
RenderInstFlags[RenderInstFlags["AllowSkippingIfPipelineNotReady"] = 2] = "AllowSkippingIfPipelineNotReady";
|
|
5982
6002
|
// Mostly for error checking.
|
|
@@ -6360,7 +6380,6 @@
|
|
|
6360
6380
|
pipeline: gfxPipeline
|
|
6361
6381
|
}));
|
|
6362
6382
|
passRenderer.setBindings(0, gfxBindings, this.dynamicUniformBufferByteOffsets);
|
|
6363
|
-
// if (this.drawInstanceCount > 0) {
|
|
6364
6383
|
if (this.drawInstanceCount > 1) {
|
|
6365
6384
|
assert(!!(this.flags & RenderInstFlags.Indexed));
|
|
6366
6385
|
passRenderer.drawIndexedInstanced(this.drawCount, this.drawStart, this.drawInstanceCount);
|
|
@@ -6899,7 +6918,6 @@
|
|
|
6899
6918
|
* Render Graph builder at each frame
|
|
6900
6919
|
*/
|
|
6901
6920
|
this.builder = void 0;
|
|
6902
|
-
this.pendingDisplayObjects = [];
|
|
6903
6921
|
this.enableCapture = void 0;
|
|
6904
6922
|
this.captureOptions = void 0;
|
|
6905
6923
|
this.capturePromise = void 0;
|
|
@@ -6935,17 +6953,12 @@
|
|
|
6935
6953
|
_this.lightPool.addFog(object);
|
|
6936
6954
|
return;
|
|
6937
6955
|
}
|
|
6938
|
-
var renderable3D = new Renderable3D();
|
|
6939
|
-
// add geometry & material required by Renderable3D
|
|
6940
|
-
// object.entity.addComponent(Geometry3D);
|
|
6941
|
-
// object.entity.addComponent(Material3D);
|
|
6942
6956
|
// @ts-ignore
|
|
6943
|
-
object.renderable3D
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
} else {
|
|
6947
|
-
_this.pendingDisplayObjects.push(object);
|
|
6957
|
+
if (!object.renderable3D) {
|
|
6958
|
+
// @ts-ignore
|
|
6959
|
+
object.renderable3D = new Renderable3D();
|
|
6948
6960
|
}
|
|
6961
|
+
_this.batchManager.add(object);
|
|
6949
6962
|
};
|
|
6950
6963
|
var handleUnmounted = function handleUnmounted(e) {
|
|
6951
6964
|
var object = e.target;
|
|
@@ -6986,48 +6999,41 @@
|
|
|
6986
6999
|
_this.batchManager.updateAttribute(object, 'modelMatrix', null);
|
|
6987
7000
|
}
|
|
6988
7001
|
};
|
|
6989
|
-
renderingService.hooks.
|
|
6990
|
-
canvas
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7002
|
+
renderingService.hooks.initAsync.tapPromise(RenderGraphPlugin.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
|
|
7003
|
+
var $canvas, _this$context$config, width, height;
|
|
7004
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
7005
|
+
while (1) switch (_context.prev = _context.next) {
|
|
7006
|
+
case 0:
|
|
7007
|
+
canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
7008
|
+
canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
7009
|
+
canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
7010
|
+
canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
7011
|
+
_this.context.config.renderer.getConfig().enableDirtyRectangleRendering = false;
|
|
7012
|
+
$canvas = _this.context.contextService.getDomElement();
|
|
7013
|
+
_this$context$config = _this.context.config, width = _this$context$config.width, height = _this$context$config.height;
|
|
7014
|
+
_this.context.contextService.resize(width, height);
|
|
7015
|
+
// create swap chain and get device
|
|
7016
|
+
// @ts-ignore
|
|
7017
|
+
_context.next = 10;
|
|
7018
|
+
return _this.context.deviceContribution.createSwapChain($canvas);
|
|
7019
|
+
case 10:
|
|
7020
|
+
_this.swapChain = _context.sent;
|
|
7021
|
+
_this.device = _this.swapChain.getDevice();
|
|
7022
|
+
_this.renderHelper.setDevice(_this.device);
|
|
7023
|
+
_this.renderHelper.renderInstManager.disableSimpleMode();
|
|
7024
|
+
_this.swapChain.configureSwapChain($canvas.width, $canvas.height);
|
|
7025
|
+
canvas.addEventListener(gLite.CanvasEvent.RESIZE, function () {
|
|
7011
7026
|
_this.swapChain.configureSwapChain($canvas.width, $canvas.height);
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
// trigger rerender
|
|
7023
|
-
_this.context.renderingService.dirtify();
|
|
7024
|
-
case 12:
|
|
7025
|
-
case "end":
|
|
7026
|
-
return _context.stop();
|
|
7027
|
-
}
|
|
7028
|
-
}, _callee);
|
|
7029
|
-
}))();
|
|
7030
|
-
});
|
|
7027
|
+
});
|
|
7028
|
+
_this.batchManager.attach(_extends({
|
|
7029
|
+
device: _this.device
|
|
7030
|
+
}, context));
|
|
7031
|
+
case 17:
|
|
7032
|
+
case "end":
|
|
7033
|
+
return _context.stop();
|
|
7034
|
+
}
|
|
7035
|
+
}, _callee);
|
|
7036
|
+
})));
|
|
7031
7037
|
renderingService.hooks.destroy.tap(RenderGraphPlugin.tag, function () {
|
|
7032
7038
|
_this.renderHelper.destroy();
|
|
7033
7039
|
canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
@@ -7039,9 +7045,6 @@
|
|
|
7039
7045
|
* build frame graph at the beginning of each frame
|
|
7040
7046
|
*/
|
|
7041
7047
|
renderingService.hooks.beginFrame.tap(RenderGraphPlugin.tag, function () {
|
|
7042
|
-
if (!_this.swapChain) {
|
|
7043
|
-
return;
|
|
7044
|
-
}
|
|
7045
7048
|
var canvas = _this.swapChain.getCanvas();
|
|
7046
7049
|
var renderInstManager = _this.renderHelper.renderInstManager;
|
|
7047
7050
|
_this.builder = _this.renderHelper.renderGraph.newGraphBuilder();
|
|
@@ -7079,9 +7082,6 @@
|
|
|
7079
7082
|
_this.builder.resolveRenderTargetToExternalTexture(mainColorTargetID, _this.swapChain.getOnscreenTexture());
|
|
7080
7083
|
});
|
|
7081
7084
|
renderingService.hooks.endFrame.tap(RenderGraphPlugin.tag, function () {
|
|
7082
|
-
if (!_this.swapChain) {
|
|
7083
|
-
return;
|
|
7084
|
-
}
|
|
7085
7085
|
var renderInstManager = _this.renderHelper.renderInstManager;
|
|
7086
7086
|
// TODO: time for GPU Animation
|
|
7087
7087
|
// const timeInMilliseconds = window.performance.now();
|
|
@@ -7135,8 +7135,6 @@
|
|
|
7135
7135
|
_this.renderHelper.prepareToRender();
|
|
7136
7136
|
_this.renderHelper.renderGraph.execute();
|
|
7137
7137
|
renderInstManager.resetRenderInsts();
|
|
7138
|
-
// output to screen
|
|
7139
|
-
_this.swapChain.present();
|
|
7140
7138
|
// capture here since we don't preserve drawing buffer
|
|
7141
7139
|
if (_this.enableCapture && _this.resolveCapturePromise) {
|
|
7142
7140
|
var _this$captureOptions = _this.captureOptions,
|
|
@@ -7219,13 +7217,16 @@
|
|
|
7219
7217
|
var handleMounted = function handleMounted(e) {
|
|
7220
7218
|
var object = e.target;
|
|
7221
7219
|
// @ts-ignore
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
var pickingId = _this.pickingIdGenerator.getId(object);
|
|
7226
|
-
renderable3D.pickingId = pickingId;
|
|
7227
|
-
renderable3D.encodedPickingColor = _this.pickingIdGenerator.encodePickingColor(pickingId);
|
|
7220
|
+
if (!object.renderable3D) {
|
|
7221
|
+
// @ts-ignore
|
|
7222
|
+
object.renderable3D = new Renderable3D();
|
|
7228
7223
|
}
|
|
7224
|
+
// @ts-ignore
|
|
7225
|
+
var renderable3D = object.renderable3D;
|
|
7226
|
+
// generate picking id for later use
|
|
7227
|
+
var pickingId = _this.pickingIdGenerator.getId(object);
|
|
7228
|
+
renderable3D.pickingId = pickingId;
|
|
7229
|
+
renderable3D.encodedPickingColor = _this.pickingIdGenerator.encodePickingColor(pickingId);
|
|
7229
7230
|
};
|
|
7230
7231
|
renderingService.hooks.init.tap(PickingPlugin.tag, function () {
|
|
7231
7232
|
canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
@@ -7527,7 +7528,7 @@
|
|
|
7527
7528
|
if (this.indexBuffer) {
|
|
7528
7529
|
this.indexBuffer.destroy();
|
|
7529
7530
|
}
|
|
7530
|
-
this.indexBuffer = makeStaticDataBuffer(this.device, BufferUsage.INDEX
|
|
7531
|
+
this.indexBuffer = makeStaticDataBuffer(this.device, BufferUsage.INDEX, new Uint32Array(ArrayBuffer.isView(indices) ? indices.buffer : indices).buffer);
|
|
7531
7532
|
this.indices = indices;
|
|
7532
7533
|
return this;
|
|
7533
7534
|
};
|
|
@@ -7572,7 +7573,7 @@
|
|
|
7572
7573
|
if (this.vertexBuffers[bufferIndex]) {
|
|
7573
7574
|
this.vertexBuffers[bufferIndex].destroy();
|
|
7574
7575
|
}
|
|
7575
|
-
var buffer = makeStaticDataBuffer(this.device, BufferUsage.VERTEX
|
|
7576
|
+
var buffer = makeStaticDataBuffer(this.device, BufferUsage.VERTEX, data.buffer);
|
|
7576
7577
|
this.vertexBuffers[bufferIndex] = buffer;
|
|
7577
7578
|
return this;
|
|
7578
7579
|
};
|
|
@@ -7599,7 +7600,7 @@
|
|
|
7599
7600
|
offset = 0;
|
|
7600
7601
|
}
|
|
7601
7602
|
if (this.indexBuffer) {
|
|
7602
|
-
this.indexBuffer.setSubData(offset, ArrayBuffer.isView(indices) ? indices : new Uint32Array(indices));
|
|
7603
|
+
this.indexBuffer.setSubData(offset, new Uint8Array(ArrayBuffer.isView(indices) ? indices : new Uint32Array(indices)));
|
|
7603
7604
|
}
|
|
7604
7605
|
return this;
|
|
7605
7606
|
};
|
|
@@ -8014,6 +8015,11 @@
|
|
|
8014
8015
|
return v !== undefined;
|
|
8015
8016
|
}));
|
|
8016
8017
|
};
|
|
8018
|
+
function packUint8ToFloat(a, b) {
|
|
8019
|
+
a = clamp(Math.floor(a), 0, 255);
|
|
8020
|
+
b = clamp(Math.floor(b), 0, 255);
|
|
8021
|
+
return 256 * a + b;
|
|
8022
|
+
}
|
|
8017
8023
|
var counter = 1;
|
|
8018
8024
|
var FILL_TEXTURE_MAPPING = 'FillTextureMapping';
|
|
8019
8025
|
/**
|
|
@@ -8042,16 +8048,15 @@
|
|
|
8042
8048
|
VertexAttributeLocation[VertexAttributeLocation["MODEL_MATRIX1"] = 1] = "MODEL_MATRIX1";
|
|
8043
8049
|
VertexAttributeLocation[VertexAttributeLocation["MODEL_MATRIX2"] = 2] = "MODEL_MATRIX2";
|
|
8044
8050
|
VertexAttributeLocation[VertexAttributeLocation["MODEL_MATRIX3"] = 3] = "MODEL_MATRIX3";
|
|
8045
|
-
VertexAttributeLocation[VertexAttributeLocation["
|
|
8046
|
-
VertexAttributeLocation[VertexAttributeLocation["
|
|
8047
|
-
VertexAttributeLocation[VertexAttributeLocation["
|
|
8048
|
-
VertexAttributeLocation[VertexAttributeLocation["
|
|
8049
|
-
VertexAttributeLocation[VertexAttributeLocation["
|
|
8050
|
-
VertexAttributeLocation[VertexAttributeLocation["
|
|
8051
|
-
VertexAttributeLocation[VertexAttributeLocation["
|
|
8052
|
-
VertexAttributeLocation[VertexAttributeLocation["
|
|
8053
|
-
VertexAttributeLocation[VertexAttributeLocation["
|
|
8054
|
-
VertexAttributeLocation[VertexAttributeLocation["MAX"] = 13] = "MAX";
|
|
8051
|
+
VertexAttributeLocation[VertexAttributeLocation["PACKED_COLOR"] = 4] = "PACKED_COLOR";
|
|
8052
|
+
VertexAttributeLocation[VertexAttributeLocation["PACKED_STYLE1"] = 5] = "PACKED_STYLE1";
|
|
8053
|
+
VertexAttributeLocation[VertexAttributeLocation["PACKED_STYLE2"] = 6] = "PACKED_STYLE2";
|
|
8054
|
+
VertexAttributeLocation[VertexAttributeLocation["PICKING_COLOR"] = 7] = "PICKING_COLOR";
|
|
8055
|
+
VertexAttributeLocation[VertexAttributeLocation["POSITION"] = 8] = "POSITION";
|
|
8056
|
+
VertexAttributeLocation[VertexAttributeLocation["NORMAL"] = 9] = "NORMAL";
|
|
8057
|
+
VertexAttributeLocation[VertexAttributeLocation["UV"] = 10] = "UV";
|
|
8058
|
+
VertexAttributeLocation[VertexAttributeLocation["BARYCENTRIC"] = 11] = "BARYCENTRIC";
|
|
8059
|
+
VertexAttributeLocation[VertexAttributeLocation["MAX"] = 12] = "MAX";
|
|
8055
8060
|
})(VertexAttributeLocation || (VertexAttributeLocation = {}));
|
|
8056
8061
|
/**
|
|
8057
8062
|
* Instanced mesh
|
|
@@ -8206,16 +8211,16 @@
|
|
|
8206
8211
|
increasedLineWidthForHitTesting = _object$parsedStyle.increasedLineWidthForHitTesting;
|
|
8207
8212
|
var fillColor = [0, 0, 0, 0];
|
|
8208
8213
|
if (gLite.isCSSRGB(fill)) {
|
|
8209
|
-
fillColor = [Number(fill.r)
|
|
8214
|
+
fillColor = [Number(fill.r), Number(fill.g), Number(fill.b), Number(fill.alpha) * 255];
|
|
8210
8215
|
}
|
|
8211
8216
|
var strokeColor = [0, 0, 0, 0];
|
|
8212
8217
|
if (gLite.isCSSRGB(stroke)) {
|
|
8213
|
-
strokeColor = [Number(stroke.r)
|
|
8218
|
+
strokeColor = [Number(stroke.r), Number(stroke.g), Number(stroke.b), Number(stroke.alpha) * 255];
|
|
8214
8219
|
}
|
|
8215
8220
|
if (_this3.clipPathTarget) {
|
|
8216
8221
|
// account for target's rts
|
|
8217
8222
|
copy(modelMatrix, object.getLocalTransform());
|
|
8218
|
-
fillColor = [
|
|
8223
|
+
fillColor = [255, 255, 255, 255];
|
|
8219
8224
|
mul(modelMatrix, _this3.clipPathTarget.getWorldTransform(), modelMatrix);
|
|
8220
8225
|
} else {
|
|
8221
8226
|
copy(modelMatrix, object.getWorldTransform());
|
|
@@ -8225,7 +8230,7 @@
|
|
|
8225
8230
|
// @ts-ignore
|
|
8226
8231
|
(_object$renderable3D = object.renderable3D) === null || _object$renderable3D === void 0 ? void 0 : _object$renderable3D.encodedPickingColor) || [0, 0, 0];
|
|
8227
8232
|
packedModelMatrix.push.apply(packedModelMatrix, modelMatrix);
|
|
8228
|
-
packedFillStroke.push
|
|
8233
|
+
packedFillStroke.push(packUint8ToFloat(fillColor[0], fillColor[1]), packUint8ToFloat(fillColor[2], fillColor[3]), packUint8ToFloat(strokeColor[0], strokeColor[1]), packUint8ToFloat(strokeColor[2], strokeColor[3]));
|
|
8229
8234
|
packedStyle.push(opacity, fillOpacity, strokeOpacity, lineWidth, visibility === 'visible' ? 1 : 0, anchor[0], anchor[1], increasedLineWidthForHitTesting || 0);
|
|
8230
8235
|
packedPicking.push.apply(packedPicking, encodedPickingColor.concat([object.sortable.renderOrder * RENDER_ORDER_SCALE]));
|
|
8231
8236
|
// if (useNormal) {
|
|
@@ -8294,17 +8299,12 @@
|
|
|
8294
8299
|
});
|
|
8295
8300
|
this.geometry.setVertexBuffer({
|
|
8296
8301
|
bufferIndex: VertexAttributeBufferIndex.FILL_STROKE,
|
|
8297
|
-
byteStride: 4 *
|
|
8302
|
+
byteStride: 4 * 4,
|
|
8298
8303
|
frequency: VertexBufferFrequency.PerInstance,
|
|
8299
8304
|
attributes: [{
|
|
8300
8305
|
format: Format.F32_RGBA,
|
|
8301
8306
|
bufferByteOffset: 4 * 0,
|
|
8302
|
-
location: VertexAttributeLocation.
|
|
8303
|
-
divisor: 1
|
|
8304
|
-
}, {
|
|
8305
|
-
format: Format.F32_RGBA,
|
|
8306
|
-
bufferByteOffset: 4 * 4,
|
|
8307
|
-
location: VertexAttributeLocation.STROKE_COLOR,
|
|
8307
|
+
location: VertexAttributeLocation.PACKED_COLOR,
|
|
8308
8308
|
divisor: 1
|
|
8309
8309
|
}],
|
|
8310
8310
|
data: new Float32Array(packedFillStroke)
|
|
@@ -8504,15 +8504,15 @@
|
|
|
8504
8504
|
stroke = _object$parsedStyle2.stroke;
|
|
8505
8505
|
var fillColor = [0, 0, 0, 0];
|
|
8506
8506
|
if (gLite.isCSSRGB(fill)) {
|
|
8507
|
-
fillColor = [Number(fill.r)
|
|
8507
|
+
fillColor = [Number(fill.r), Number(fill.g), Number(fill.b), Number(fill.alpha) * 255];
|
|
8508
8508
|
}
|
|
8509
8509
|
var strokeColor = [0, 0, 0, 0];
|
|
8510
8510
|
if (gLite.isCSSRGB(stroke)) {
|
|
8511
|
-
strokeColor = [Number(stroke.r)
|
|
8511
|
+
strokeColor = [Number(stroke.r), Number(stroke.g), Number(stroke.b), Number(stroke.alpha) * 255];
|
|
8512
8512
|
}
|
|
8513
|
-
packedFillStroke.push
|
|
8513
|
+
packedFillStroke.push(packUint8ToFloat(fillColor[0], fillColor[1]), packUint8ToFloat(fillColor[2], fillColor[3]), packUint8ToFloat(strokeColor[0], strokeColor[1]), packUint8ToFloat(strokeColor[2], strokeColor[3]));
|
|
8514
8514
|
});
|
|
8515
|
-
this.geometry.updateVertexBuffer(VertexAttributeBufferIndex.FILL_STROKE, VertexAttributeLocation.
|
|
8515
|
+
this.geometry.updateVertexBuffer(VertexAttributeBufferIndex.FILL_STROKE, VertexAttributeLocation.PACKED_COLOR, startIndex, new Uint8Array(new Float32Array(packedFillStroke).buffer));
|
|
8516
8516
|
var fill = this.instance.parsedStyle.fill;
|
|
8517
8517
|
var i = this.textureMappings.findIndex(function (m) {
|
|
8518
8518
|
return m.name === FILL_TEXTURE_MAPPING;
|
|
@@ -8847,7 +8847,7 @@
|
|
|
8847
8847
|
}();
|
|
8848
8848
|
var frag = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Data;\nin vec2 v_Radius;\nin vec4 v_StylePacked3;\n\nout vec4 outputColor;\n\n/**\n * 2D signed distance field functions\n * @see http://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm\n */\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\n// @see http://www.iquilezles.org/www/articles/ellipsoids/ellipsoids.htm\nfloat sdEllipsoidApproximated(vec2 p, vec2 r) {\n float k0 = length(p / r);\n float k1 = length(p / (r * r));\n return k0 * (k0 - 1.0) / k1;\n}\n\n// @see https://www.shadertoy.com/view/4llXD7\nfloat sdRoundedBox(vec2 p, vec2 b, vec2 r) {\n vec2 q = abs(p) - b + r;\n return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r.x;\n}\n\nvoid main() {\n int shape = int(floor(v_Data.w + 0.5));\n float epsilon = 0.000001;\n\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n bool omitStroke = v_StylePacked3.z == 1.0;\n\n float antialiasblur = v_Data.z;\n float antialiased_blur = -max(0.0, antialiasblur);\n vec2 r = (v_Radius - (omitStroke ? 0.0 : u_StrokeWidth)) / v_Radius;\n\n float outer_df;\n float inner_df;\n // 'circle', 'ellipse', 'rect'\n if (shape == 0) {\n outer_df = sdCircle(v_Data.xy, 1.0);\n inner_df = sdCircle(v_Data.xy, r.x);\n } else if (shape == 1) {\n outer_df = sdEllipsoidApproximated(v_Data.xy, vec2(1.0));\n inner_df = sdEllipsoidApproximated(v_Data.xy, r);\n } else if (shape == 2) {\n outer_df = sdRoundedBox(v_Data.xy, vec2(1.0), vec2(0.0));\n inner_df = sdRoundedBox(v_Data.xy, r, vec2(0.0));\n }\n\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n\n float color_t = u_StrokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n\n vec4 diffuseColor;\n vec4 strokeColor;\n if (u_IsPicking > 0.5) {\n diffuseColor = vec4(u_PickingColor, 1.0);\n strokeColor = vec4(u_PickingColor, 1.0);\n } else {\n diffuseColor = u_Color;\n strokeColor = (u_StrokeColor == vec4(0) || omitStroke) ? vec4(0.0) : u_StrokeColor;\n }\n\n outputColor = mix(vec4(diffuseColor.rgb, diffuseColor.a * u_FillOpacity), strokeColor * u_StrokeOpacity, color_t);\n outputColor.a = outputColor.a * u_Opacity * opacity_t;\n\n if (outputColor.a < epsilon)\n discard;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n }\n}"; // eslint-disable-line
|
|
8849
8849
|
|
|
8850
|
-
var vert = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location =
|
|
8850
|
+
var vert = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec2 a_Extrude;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\nlayout(location = SIZE) in vec2 a_Size;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nout vec4 v_Data;\nout vec2 v_Radius;\nout vec4 v_StylePacked3;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n#ifdef CLIPSPACE_NEAR_ZERO\n gl_Position.z = gl_Position.z * 0.5 + 0.5;\n#endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n\n float antialiasblur = 1.0 / (a_Size.x + strokeWidth);\n\n bool omitStroke = a_StylePacked3.z == 1.0;\n vec2 radius = a_Size + vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n vec2 offset = (a_Extrude + vec2(1.0) - 2.0 * u_Anchor.xy) * radius;\n\n bool isBillboard = a_StylePacked3.w > 0.5;\n if (isBillboard) {\n vec4 mvPosition = u_ViewMatrix * u_ModelMatrix * vec4(0.0, 0.0, u_ZIndex, 1.0);\nvec2 scale;\nscale.x = length(vec3(u_ModelMatrix[0][0], u_ModelMatrix[0][1], u_ModelMatrix[0][2]));\nscale.y = length(vec3(u_ModelMatrix[1][0], u_ModelMatrix[1][1], u_ModelMatrix[1][2]));\n\n// if (sizeAttenuation < 0.5) {\n// bool isPerspective = isPerspectiveMatrix( u_ProjectionMatrix );\n// if ( isPerspective ) scale *= - mvPosition.z;\n// }\n\nvec2 alignedPosition = offset * scale;\n\nfloat rotation = 0.0;\nvec2 rotatedPosition;\nrotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\nrotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\nmvPosition.xy += rotatedPosition;\n\ngl_Position = u_ProjectionMatrix * mvPosition;\n } else {\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n \n v_Radius = radius;\n v_Data = vec4(a_Extrude, antialiasblur, a_StylePacked3.x);\n v_StylePacked3 = a_StylePacked3;\n}"; // eslint-disable-line
|
|
8851
8851
|
|
|
8852
8852
|
var SDFVertexAttributeBufferIndex;
|
|
8853
8853
|
(function (SDFVertexAttributeBufferIndex) {
|
|
@@ -8855,8 +8855,8 @@
|
|
|
8855
8855
|
})(SDFVertexAttributeBufferIndex || (SDFVertexAttributeBufferIndex = {}));
|
|
8856
8856
|
var SDFVertexAttributeLocation;
|
|
8857
8857
|
(function (SDFVertexAttributeLocation) {
|
|
8858
|
-
SDFVertexAttributeLocation[SDFVertexAttributeLocation["PACKED_STYLE3"] =
|
|
8859
|
-
SDFVertexAttributeLocation[SDFVertexAttributeLocation["SIZE"] =
|
|
8858
|
+
SDFVertexAttributeLocation[SDFVertexAttributeLocation["PACKED_STYLE3"] = 12] = "PACKED_STYLE3";
|
|
8859
|
+
SDFVertexAttributeLocation[SDFVertexAttributeLocation["SIZE"] = 13] = "SIZE";
|
|
8860
8860
|
})(SDFVertexAttributeLocation || (SDFVertexAttributeLocation = {}));
|
|
8861
8861
|
var SDF_Shape = [gLite.Shape.CIRCLE, gLite.Shape.ELLIPSE, gLite.Shape.RECT];
|
|
8862
8862
|
/**
|
|
@@ -9003,7 +9003,7 @@
|
|
|
9003
9003
|
}(Instanced);
|
|
9004
9004
|
var frag$1 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\nin vec2 v_Distance;\n\nout vec4 outputColor;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n float blur = smoothstep(0.0, v_Distance.y, 1.0 - abs(v_Distance.x));\n float u_dash_offset = v_Dash.y;\n float u_dash_array = v_Dash.z;\n float u_dash_ratio = v_Dash.w;\n\n outputColor.a = outputColor.a\n * blur\n * u_Opacity * u_StrokeOpacity\n * ceil(mod(v_Dash.x + u_dash_offset, u_dash_array) - (u_dash_array * u_dash_ratio));\n }\n}"; // eslint-disable-line
|
|
9005
9005
|
|
|
9006
|
-
var vert$1 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location =
|
|
9006
|
+
var vert$1 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = POINTA) in vec3 a_PointA;\nlayout(location = POINTB) in vec3 a_PointB;\nlayout(location = CAP) in float a_Cap;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\n\nout vec4 v_Dash;\nout vec2 v_Distance;\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n#ifdef CLIPSPACE_NEAR_ZERO\n gl_Position.z = gl_Position.z * 0.5 + 0.5;\n#endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n\n float isBillboard = a_Dash.w;\n bool isPerspective = isPerspectiveMatrix(u_ProjectionMatrix);\n\n if (isBillboard > 0.5 && isPerspective) {\n // clip space\n vec4 clip0 = project(vec4(a_PointA, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n vec4 clip1 = project(vec4(a_PointB, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n // screen space\n vec2 screen0 = u_Viewport * (0.5 * clip0.xy / clip0.w + 0.5);\n vec2 screen1 = u_Viewport * (0.5 * clip1.xy / clip1.w + 0.5);\n vec2 xBasis = normalize(screen1 - screen0);\n vec2 yBasis = vec2(-xBasis.y, xBasis.x);\n vec2 pt0 = screen0 + strokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt1 = screen1 + strokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt = mix(pt0, pt1, a_Position.z);\n vec4 clip = mix(clip0, clip1, a_Position.z);\n gl_Position = vec4(clip.w * (2.0 * pt / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n vec2 xBasis = a_PointB.xy - a_PointA.xy;\n vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));\n\n vec2 point = a_PointA.xy + xBasis * a_Position.x + yBasis * strokeWidth * a_Position.y;\n point = point - u_Anchor.xy * abs(xBasis);\n\n // round & square\n if (a_Cap > 1.0) {\n point += sign(a_Position.x - 0.5) * normalize(xBasis) * vec2(strokeWidth / 2.0);\n }\n gl_Position = project(vec4(point, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n float antialiasblur = 1.0 / strokeWidth;\n v_Distance = vec2(a_Position.y * 2.0, antialiasblur);\n v_Dash = vec4(a_Position.x, a_Dash.xyz);\n}"; // eslint-disable-line
|
|
9007
9007
|
|
|
9008
9008
|
var segmentInstanceGeometry = [0, -0.5, 0, 0, 0, 1, -0.5, 1, 1, 0, 1, 0.5, 1, 1, 1, 0, 0.5, 0, 0, 1];
|
|
9009
9009
|
var InstancedLineVertexAttributeBufferIndex;
|
|
@@ -9014,12 +9014,12 @@
|
|
|
9014
9014
|
})(InstancedLineVertexAttributeBufferIndex || (InstancedLineVertexAttributeBufferIndex = {}));
|
|
9015
9015
|
var InstancedLineVertexAttributeLocation;
|
|
9016
9016
|
(function (InstancedLineVertexAttributeLocation) {
|
|
9017
|
-
InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["POSITION"] =
|
|
9018
|
-
InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["UV"] =
|
|
9019
|
-
InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["POINTA"] =
|
|
9020
|
-
InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["POINTB"] =
|
|
9021
|
-
InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["CAP"] =
|
|
9022
|
-
InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["DASH"] =
|
|
9017
|
+
InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["POSITION"] = 8] = "POSITION";
|
|
9018
|
+
InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["UV"] = 10] = "UV";
|
|
9019
|
+
InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["POINTA"] = 9] = "POINTA";
|
|
9020
|
+
InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["POINTB"] = 11] = "POINTB";
|
|
9021
|
+
InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["CAP"] = 12] = "CAP";
|
|
9022
|
+
InstancedLineVertexAttributeLocation[InstancedLineVertexAttributeLocation["DASH"] = 13] = "DASH";
|
|
9023
9023
|
})(InstancedLineVertexAttributeLocation || (InstancedLineVertexAttributeLocation = {}));
|
|
9024
9024
|
var LineCap_MAP = {
|
|
9025
9025
|
butt: 1,
|
|
@@ -9866,7 +9866,9 @@
|
|
|
9866
9866
|
// $offscreenCanvas.height = height * dpr;
|
|
9867
9867
|
$offscreenCanvas.width = size;
|
|
9868
9868
|
$offscreenCanvas.height = size;
|
|
9869
|
-
var ctx = gLite.runtime.offscreenCanvas.getOrCreateContext(canvas
|
|
9869
|
+
var ctx = gLite.runtime.offscreenCanvas.getOrCreateContext(canvas, {
|
|
9870
|
+
willReadFrequently: true
|
|
9871
|
+
});
|
|
9870
9872
|
this.ctx = ctx;
|
|
9871
9873
|
// const ctx = (this.ctx = canvas.getContext('2d', {
|
|
9872
9874
|
// willReadFrequently: true,
|
|
@@ -10704,9 +10706,9 @@
|
|
|
10704
10706
|
};
|
|
10705
10707
|
return FillMesh;
|
|
10706
10708
|
}(Instanced);
|
|
10707
|
-
var frag$3 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n outputColor.a = outputColor.a * u_Opacity;\n }\n}"; // eslint-disable-line
|
|
10709
|
+
var frag$3 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n\n if (u_Color.x == 0.0 && u_Color.y == 0.0 && u_Color.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n outputColor.a = outputColor.a * u_Opacity;\n }\n}"; // eslint-disable-line
|
|
10708
10710
|
|
|
10709
|
-
var vert$3 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location =
|
|
10711
|
+
var vert$3 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec4 a_Size;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nbool isPerspectiveMatrix(mat4 m) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n#ifdef CLIPSPACE_NEAR_ZERO\n gl_Position.z = gl_Position.z * 0.5 + 0.5;\n#endif\n\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size.xy;\n\n bool isPerspective = isPerspectiveMatrix(u_ProjectionMatrix);\n\n bool isBillboard = a_Size.w > 0.5;\n if (isBillboard) {\n vec4 mvPosition = u_ViewMatrix * u_ModelMatrix * vec4(0.0, 0.0, u_ZIndex, 1.0);\nvec2 scale;\nscale.x = length(vec3(u_ModelMatrix[0][0], u_ModelMatrix[0][1], u_ModelMatrix[0][2]));\nscale.y = length(vec3(u_ModelMatrix[1][0], u_ModelMatrix[1][1], u_ModelMatrix[1][2]));\n\n// if (sizeAttenuation < 0.5) {\n// bool isPerspective = isPerspectiveMatrix( u_ProjectionMatrix );\n// if ( isPerspective ) scale *= - mvPosition.z;\n// }\n\nvec2 alignedPosition = offset * scale;\n\nfloat rotation = 0.0;\nvec2 rotatedPosition;\nrotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\nrotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\nmvPosition.xy += rotatedPosition;\n\ngl_Position = u_ProjectionMatrix * mvPosition;\n } else {\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n}"; // eslint-disable-line
|
|
10710
10712
|
|
|
10711
10713
|
var ImageMesh = /*#__PURE__*/function (_Instanced) {
|
|
10712
10714
|
_inheritsLoose$1(ImageMesh, _Instanced);
|
|
@@ -10804,7 +10806,7 @@
|
|
|
10804
10806
|
}(Instanced);
|
|
10805
10807
|
var frag$4 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n\nuniform sampler2D u_SDFMap;\n\n#define SDF_PX 8.0\n\nin float v_GammaScale;\n\nout vec4 outputColor;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n\n float dist = texture(SAMPLER_2D(u_SDFMap), v_Uv).a;\n\n float EDGE_GAMMA = 0.105 / u_DevicePixelRatio;\n float fontScale = u_FontSize / 24.0;\n highp float gamma = EDGE_GAMMA / (fontScale * u_GammaScale);\n lowp vec4 color = u_Color;\n lowp float buff = (256.0 - 64.0) / 256.0;\n float opacity = u_FillOpacity;\n if (u_HasStroke > 0.5 && u_StrokeWidth > 0.0) {\n color = u_StrokeColor;\n gamma = (u_StrokeBlur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_GammaScale);\n buff = (6.0 - u_StrokeWidth / fontScale / 2.0) / SDF_PX;\n opacity = u_StrokeOpacity;\n }\n\n highp float gamma_scaled = gamma * v_GammaScale;\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n opacity *= alpha * u_Opacity;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n\n if (opacity < 0.001) {\n discard;\n }\n\n outputColor = color;\n outputColor.a *= opacity;\n }\n}"; // eslint-disable-line
|
|
10806
10808
|
|
|
10807
|
-
var vert$4 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location =
|
|
10809
|
+
var vert$4 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\n\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = TEX) in vec2 a_Tex;\nlayout(location = OFFSET) in vec2 a_Offset;\n\nout vec2 v_Uv;\nout float v_GammaScale;\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n#ifdef CLIPSPACE_NEAR_ZERO\n gl_Position.z = gl_Position.z * 0.5 + 0.5;\n#endif\n\n v_Uv = a_Tex / u_SDFMapSize;\n float fontScale = u_FontSize / 24.;\n\n bool isBillboard = a_StylePacked2.y > 0.5;\n float sizeAttenuation = a_StylePacked2.z;\n vec2 offset = a_Offset * fontScale;\n\n if (isBillboard) {\n vec4 mvPosition = u_ViewMatrix * u_ModelMatrix * vec4(0.0, 0.0, u_ZIndex, 1.0);\nvec2 scale;\nscale.x = length(vec3(u_ModelMatrix[0][0], u_ModelMatrix[0][1], u_ModelMatrix[0][2]));\nscale.y = length(vec3(u_ModelMatrix[1][0], u_ModelMatrix[1][1], u_ModelMatrix[1][2]));\n\n// if (sizeAttenuation < 0.5) {\n// bool isPerspective = isPerspectiveMatrix( u_ProjectionMatrix );\n// if ( isPerspective ) scale *= - mvPosition.z;\n// }\n\nvec2 alignedPosition = offset * scale;\n\nfloat rotation = 0.0;\nvec2 rotatedPosition;\nrotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\nrotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\nmvPosition.xy += rotatedPosition;\n\ngl_Position = u_ProjectionMatrix * mvPosition;\n v_GammaScale = 1.0;\n } else {\n gl_Position = project(vec4(a_Offset * fontScale, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n v_GammaScale = gl_Position.w;\n }\n}"; // eslint-disable-line
|
|
10808
10810
|
|
|
10809
10811
|
// borrow from mapbox/src/symbol
|
|
10810
10812
|
function createImage(image, _ref, channels, data) {
|
|
@@ -11266,8 +11268,8 @@
|
|
|
11266
11268
|
})(TextVertexAttributeBufferIndex || (TextVertexAttributeBufferIndex = {}));
|
|
11267
11269
|
var TextVertexAttributeLocation;
|
|
11268
11270
|
(function (TextVertexAttributeLocation) {
|
|
11269
|
-
TextVertexAttributeLocation[TextVertexAttributeLocation["TEX"] =
|
|
11270
|
-
TextVertexAttributeLocation[TextVertexAttributeLocation["OFFSET"] =
|
|
11271
|
+
TextVertexAttributeLocation[TextVertexAttributeLocation["TEX"] = 12] = "TEX";
|
|
11272
|
+
TextVertexAttributeLocation[TextVertexAttributeLocation["OFFSET"] = 13] = "OFFSET";
|
|
11271
11273
|
})(TextVertexAttributeLocation || (TextVertexAttributeLocation = {}));
|
|
11272
11274
|
var TextUniform;
|
|
11273
11275
|
(function (TextUniform) {
|
|
@@ -11380,7 +11382,7 @@
|
|
|
11380
11382
|
this.geometry.setIndexBuffer(new Uint32Array(indices));
|
|
11381
11383
|
this.geometry.setVertexBuffer({
|
|
11382
11384
|
bufferIndex: TextVertexAttributeBufferIndex.INSTANCED,
|
|
11383
|
-
byteStride: 4 * (4 * 4 + 4 + 4 + 4 + 4
|
|
11385
|
+
byteStride: 4 * (4 * 4 + 4 + 4 + 4 + 4),
|
|
11384
11386
|
// frequency: VertexBufferFrequency.PerInstance,
|
|
11385
11387
|
frequency: VertexBufferFrequency.PerVertex,
|
|
11386
11388
|
attributes: [{
|
|
@@ -11410,30 +11412,24 @@
|
|
|
11410
11412
|
}, {
|
|
11411
11413
|
format: Format.F32_RGBA,
|
|
11412
11414
|
bufferByteOffset: 4 * 16,
|
|
11413
|
-
location: VertexAttributeLocation.
|
|
11415
|
+
location: VertexAttributeLocation.PACKED_COLOR
|
|
11414
11416
|
// byteStride: 4 * 4,
|
|
11415
11417
|
// divisor: 1,
|
|
11416
11418
|
}, {
|
|
11417
11419
|
format: Format.F32_RGBA,
|
|
11418
11420
|
bufferByteOffset: 4 * 20,
|
|
11419
|
-
location: VertexAttributeLocation.STROKE_COLOR
|
|
11420
|
-
// byteStride: 4 * 4,
|
|
11421
|
-
// divisor: 1,
|
|
11422
|
-
}, {
|
|
11423
|
-
format: Format.F32_RGBA,
|
|
11424
|
-
bufferByteOffset: 4 * 24,
|
|
11425
11421
|
location: VertexAttributeLocation.PACKED_STYLE1
|
|
11426
11422
|
// byteStride: 4 * 4,
|
|
11427
11423
|
// divisor: 1,
|
|
11428
11424
|
}, {
|
|
11429
11425
|
format: Format.F32_RGBA,
|
|
11430
|
-
bufferByteOffset: 4 *
|
|
11426
|
+
bufferByteOffset: 4 * 24,
|
|
11431
11427
|
location: VertexAttributeLocation.PACKED_STYLE2
|
|
11432
11428
|
// byteStride: 4 * 4,
|
|
11433
11429
|
// divisor: 1,
|
|
11434
11430
|
}, {
|
|
11435
11431
|
format: Format.F32_RGBA,
|
|
11436
|
-
bufferByteOffset: 4 *
|
|
11432
|
+
bufferByteOffset: 4 * 28,
|
|
11437
11433
|
location: VertexAttributeLocation.PICKING_COLOR
|
|
11438
11434
|
// byteStride: 4 * 4,
|
|
11439
11435
|
// divisor: 1,
|
|
@@ -11523,11 +11519,11 @@
|
|
|
11523
11519
|
sizeAttenuation = _object$parsedStyle4.sizeAttenuation;
|
|
11524
11520
|
var fillColor = [0, 0, 0, 0];
|
|
11525
11521
|
if (gLite.isCSSRGB(fill)) {
|
|
11526
|
-
fillColor = [Number(fill.r)
|
|
11522
|
+
fillColor = [Number(fill.r), Number(fill.g), Number(fill.b), Number(fill.alpha) * 255];
|
|
11527
11523
|
}
|
|
11528
11524
|
var strokeColor = [0, 0, 0, 0];
|
|
11529
11525
|
if (gLite.isCSSRGB(stroke)) {
|
|
11530
|
-
strokeColor = [Number(stroke.r)
|
|
11526
|
+
strokeColor = [Number(stroke.r), Number(stroke.g), Number(stroke.b), Number(stroke.alpha) * 255];
|
|
11531
11527
|
}
|
|
11532
11528
|
var encodedPickingColor = object.isInteractive() && (
|
|
11533
11529
|
// @ts-ignore
|
|
@@ -11556,27 +11552,23 @@
|
|
|
11556
11552
|
sliced[i + 14] = modelMatrix[14];
|
|
11557
11553
|
sliced[i + 15] = modelMatrix[15];
|
|
11558
11554
|
} else if (name === 'fill') {
|
|
11559
|
-
sliced[i + 16] = fillColor[0];
|
|
11560
|
-
sliced[i + 17] = fillColor[
|
|
11561
|
-
sliced[i + 18] = fillColor[2];
|
|
11562
|
-
sliced[i + 19] = fillColor[3];
|
|
11555
|
+
sliced[i + 16] = packUint8ToFloat(fillColor[0], fillColor[1]);
|
|
11556
|
+
sliced[i + 17] = packUint8ToFloat(fillColor[2], fillColor[3]);
|
|
11563
11557
|
} else if (name === 'stroke') {
|
|
11564
|
-
sliced[i +
|
|
11565
|
-
sliced[i +
|
|
11566
|
-
sliced[i + 22] = strokeColor[2];
|
|
11567
|
-
sliced[i + 23] = strokeColor[3];
|
|
11558
|
+
sliced[i + 18] = packUint8ToFloat(strokeColor[0], strokeColor[1]);
|
|
11559
|
+
sliced[i + 19] = packUint8ToFloat(strokeColor[2], strokeColor[3]);
|
|
11568
11560
|
}
|
|
11569
|
-
sliced[i +
|
|
11570
|
-
sliced[i +
|
|
11571
|
-
sliced[i +
|
|
11572
|
-
sliced[i +
|
|
11573
|
-
sliced[i +
|
|
11574
|
-
sliced[i +
|
|
11575
|
-
sliced[i +
|
|
11576
|
-
sliced[i +
|
|
11577
|
-
sliced[i +
|
|
11578
|
-
sliced[i +
|
|
11579
|
-
sliced[i +
|
|
11561
|
+
sliced[i + 20] = opacity;
|
|
11562
|
+
sliced[i + 21] = fillOpacity;
|
|
11563
|
+
sliced[i + 22] = strokeOpacity;
|
|
11564
|
+
sliced[i + 23] = lineWidth;
|
|
11565
|
+
sliced[i + 24] = visibility === 'visible' ? 1 : 0;
|
|
11566
|
+
sliced[i + 25] = isBillboard ? 1 : 0;
|
|
11567
|
+
sliced[i + 26] = sizeAttenuation ? 1 : 0;
|
|
11568
|
+
sliced[i + 27] = 0;
|
|
11569
|
+
sliced[i + 28] = encodedPickingColor[0];
|
|
11570
|
+
sliced[i + 29] = encodedPickingColor[1];
|
|
11571
|
+
sliced[i + 30] = encodedPickingColor[2];
|
|
11580
11572
|
}
|
|
11581
11573
|
_this3.geometry.updateVertexBuffer(TextVertexAttributeBufferIndex.INSTANCED, VertexAttributeLocation.MODEL_MATRIX0, start / bytes, new Uint8Array(sliced.buffer));
|
|
11582
11574
|
});
|
|
@@ -11606,11 +11598,11 @@
|
|
|
11606
11598
|
sizeAttenuation = _object$parsedStyle5.sizeAttenuation;
|
|
11607
11599
|
var fillColor = [0, 0, 0, 0];
|
|
11608
11600
|
if (gLite.isCSSRGB(fill)) {
|
|
11609
|
-
fillColor = [Number(fill.r)
|
|
11601
|
+
fillColor = [Number(fill.r), Number(fill.g), Number(fill.b), Number(fill.alpha) * 255];
|
|
11610
11602
|
}
|
|
11611
11603
|
var strokeColor = [0, 0, 0, 0];
|
|
11612
11604
|
if (gLite.isCSSRGB(stroke)) {
|
|
11613
|
-
strokeColor = [Number(stroke.r)
|
|
11605
|
+
strokeColor = [Number(stroke.r), Number(stroke.g), Number(stroke.b), Number(stroke.alpha) * 255];
|
|
11614
11606
|
}
|
|
11615
11607
|
var encodedPickingColor = object.isInteractive() && (
|
|
11616
11608
|
// @ts-ignore
|
|
@@ -11627,7 +11619,7 @@
|
|
|
11627
11619
|
// rollup will use `concat`
|
|
11628
11620
|
var temp = [];
|
|
11629
11621
|
temp.push.apply(temp, modelMatrix);
|
|
11630
|
-
var packed = [].concat(temp, fillColor, strokeColor, [opacity, fillOpacity, strokeOpacity, lineWidth, visibility === 'visible' ? 1 : 0, isBillboard ? 1 : 0, sizeAttenuation ? 1 : 0, 0], encodedPickingColor, [object.sortable.renderOrder * RENDER_ORDER_SCALE]);
|
|
11622
|
+
var packed = [].concat(temp, [packUint8ToFloat(fillColor[0], fillColor[1]), packUint8ToFloat(fillColor[2], fillColor[3]), packUint8ToFloat(strokeColor[0], strokeColor[1]), packUint8ToFloat(strokeColor[2], strokeColor[3]), opacity, fillOpacity, strokeOpacity, lineWidth, visibility === 'visible' ? 1 : 0, isBillboard ? 1 : 0, sizeAttenuation ? 1 : 0, 0], encodedPickingColor, [object.sortable.renderOrder * RENDER_ORDER_SCALE]);
|
|
11631
11623
|
// FIXME: instanced
|
|
11632
11624
|
charPackedBuffer.push.apply(charPackedBuffer, packed.concat(packed, packed, packed));
|
|
11633
11625
|
// interleaved uv & offsets
|
|
@@ -12568,7 +12560,6 @@
|
|
|
12568
12560
|
get GL () { return GL; },
|
|
12569
12561
|
get GeometryEvent () { return GeometryEvent; },
|
|
12570
12562
|
HashMap: HashMap,
|
|
12571
|
-
IdentityViewportCoords: IdentityViewportCoords,
|
|
12572
12563
|
ImageMesh: ImageMesh,
|
|
12573
12564
|
Instanced: Instanced,
|
|
12574
12565
|
InstancedLineMesh: InstancedLineMesh,
|
|
@@ -13373,6 +13364,7 @@
|
|
|
13373
13364
|
}
|
|
13374
13365
|
if (image) {
|
|
13375
13366
|
image.onload = function () {
|
|
13367
|
+
_this.imageCache[src] = image;
|
|
13376
13368
|
resolve(image);
|
|
13377
13369
|
};
|
|
13378
13370
|
image.onerror = function (ev) {
|
|
@@ -13380,7 +13372,6 @@
|
|
|
13380
13372
|
};
|
|
13381
13373
|
image.crossOrigin = 'Anonymous';
|
|
13382
13374
|
image.src = src;
|
|
13383
|
-
_this.imageCache[src] = image;
|
|
13384
13375
|
}
|
|
13385
13376
|
});
|
|
13386
13377
|
};
|
|
@@ -14198,6 +14189,16 @@
|
|
|
14198
14189
|
function translateTextureDimension(dimension) {
|
|
14199
14190
|
if (dimension === TextureDimension.n2D) return '2d';else if (dimension === TextureDimension.Cube) return '3d';else if (dimension === TextureDimension.n2DArray) return '3d';else if (dimension === TextureDimension.n3D) return '3d';else throw new Error('whoops');
|
|
14200
14191
|
}
|
|
14192
|
+
function translateBufferUsage(usage_) {
|
|
14193
|
+
var usage = 0;
|
|
14194
|
+
if (usage_ & BufferUsage.INDEX) usage |= GPUBufferUsage.INDEX;
|
|
14195
|
+
if (usage_ & BufferUsage.VERTEX) usage |= GPUBufferUsage.VERTEX;
|
|
14196
|
+
if (usage_ & BufferUsage.UNIFORM) usage |= GPUBufferUsage.UNIFORM;
|
|
14197
|
+
if (usage_ & BufferUsage.STORAGE) usage |= GPUBufferUsage.STORAGE;
|
|
14198
|
+
if (usage_ & BufferUsage.COPY_SRC) usage |= GPUBufferUsage.COPY_SRC;
|
|
14199
|
+
usage |= GPUBufferUsage.COPY_DST;
|
|
14200
|
+
return usage;
|
|
14201
|
+
}
|
|
14201
14202
|
function translateWrapMode(wrapMode) {
|
|
14202
14203
|
if (wrapMode === WrapMode.Clamp) return 'clamp-to-edge';else if (wrapMode === WrapMode.Repeat) return 'repeat';else if (wrapMode === WrapMode.Mirror) return 'mirror-repeat';else throw new Error('whoops');
|
|
14203
14204
|
}
|
|
@@ -14210,6 +14211,21 @@
|
|
|
14210
14211
|
function translateSampleType(type) {
|
|
14211
14212
|
if (type === SamplerFormatKind.Float) return 'float';else if (type === SamplerFormatKind.Depth) return 'depth';else throw new Error('whoops');
|
|
14212
14213
|
}
|
|
14214
|
+
function translateBindGroupSamplerBinding(sampler) {
|
|
14215
|
+
if (sampler.formatKind === SamplerFormatKind.Depth && sampler.comparison) {
|
|
14216
|
+
return {
|
|
14217
|
+
type: 'comparison'
|
|
14218
|
+
};
|
|
14219
|
+
} else if (sampler.formatKind === SamplerFormatKind.Float) {
|
|
14220
|
+
return {
|
|
14221
|
+
type: 'filtering'
|
|
14222
|
+
};
|
|
14223
|
+
} else {
|
|
14224
|
+
return {
|
|
14225
|
+
type: 'non-filtering'
|
|
14226
|
+
};
|
|
14227
|
+
}
|
|
14228
|
+
}
|
|
14213
14229
|
function translateViewDimension(dimension) {
|
|
14214
14230
|
if (dimension === TextureDimension.n2D) return '2d';else if (dimension === TextureDimension.n2DArray) return '2d-array';else if (dimension === TextureDimension.n3D) return '3d';else if (dimension === TextureDimension.Cube) return 'cube';else throw new Error('whoops');
|
|
14215
14231
|
}
|
|
@@ -14270,20 +14286,30 @@
|
|
|
14270
14286
|
function translateBlendMode(mode) {
|
|
14271
14287
|
if (mode === BlendMode.Add) return 'add';else if (mode === BlendMode.Subtract) return 'subtract';else if (mode === BlendMode.ReverseSubtract) return 'reverse-subtract';else throw new Error('whoops');
|
|
14272
14288
|
}
|
|
14273
|
-
function
|
|
14289
|
+
function translateBlendComponent(ch) {
|
|
14274
14290
|
return {
|
|
14275
|
-
operation: translateBlendMode(
|
|
14276
|
-
srcFactor: translateBlendFactor(
|
|
14277
|
-
dstFactor: translateBlendFactor(
|
|
14291
|
+
operation: translateBlendMode(ch.blendMode),
|
|
14292
|
+
srcFactor: translateBlendFactor(ch.blendSrcFactor),
|
|
14293
|
+
dstFactor: translateBlendFactor(ch.blendDstFactor)
|
|
14278
14294
|
};
|
|
14279
14295
|
}
|
|
14296
|
+
function blendComponentIsNil(ch) {
|
|
14297
|
+
return ch.blendMode === BlendMode.Add && ch.blendSrcFactor === BlendFactor.One && ch.blendDstFactor === BlendFactor.Zero;
|
|
14298
|
+
}
|
|
14299
|
+
function translateBlendState(attachmentState) {
|
|
14300
|
+
if (blendComponentIsNil(attachmentState.rgbBlendState) && blendComponentIsNil(attachmentState.alphaBlendState)) {
|
|
14301
|
+
return undefined;
|
|
14302
|
+
} else {
|
|
14303
|
+
return {
|
|
14304
|
+
color: translateBlendComponent(attachmentState.rgbBlendState),
|
|
14305
|
+
alpha: translateBlendComponent(attachmentState.alphaBlendState)
|
|
14306
|
+
};
|
|
14307
|
+
}
|
|
14308
|
+
}
|
|
14280
14309
|
function translateColorState(attachmentState, format) {
|
|
14281
14310
|
return {
|
|
14282
14311
|
format: translateTextureFormat(format),
|
|
14283
|
-
blend:
|
|
14284
|
-
color: translateBlendState(attachmentState.rgbBlendState),
|
|
14285
|
-
alpha: translateBlendState(attachmentState.alphaBlendState)
|
|
14286
|
-
},
|
|
14312
|
+
blend: translateBlendState(attachmentState),
|
|
14287
14313
|
writeMask: attachmentState.channelWriteMask
|
|
14288
14314
|
};
|
|
14289
14315
|
}
|
|
@@ -14312,7 +14338,7 @@
|
|
|
14312
14338
|
if (frequency === VertexBufferFrequency.PerVertex) return 'vertex';else if (frequency === VertexBufferFrequency.PerInstance) return 'instance';else throw new Error('whoops');
|
|
14313
14339
|
}
|
|
14314
14340
|
function translateVertexFormat(format) {
|
|
14315
|
-
if (format === Format.U8_R) return 'uint8x2';else if (format === Format.U8_RG) return 'uint8x2';else if (format === Format.U8_RGB) return 'uint8x4';else if (format === Format.U8_RGBA) return 'uint8x4';else if (format === Format.U8_RGBA_NORM) return 'unorm8x4';else if (format === Format.S8_RGB_NORM) return 'snorm8x4';else if (format === Format.S8_RGBA_NORM) return 'snorm8x4';else if (format === Format.S16_RG) return 'uint16x2';else if (format === Format.F32_R) return 'float32';else if (format === Format.F32_RG) return 'float32x2';else if (format === Format.F32_RGB) return 'float32x3';else if (format === Format.F32_RGBA) return 'float32x4';else throw
|
|
14341
|
+
if (format === Format.U8_R) return 'uint8x2';else if (format === Format.U8_RG) return 'uint8x2';else if (format === Format.U8_RGB) return 'uint8x4';else if (format === Format.U8_RGBA) return 'uint8x4';else if (format === Format.U8_RG_NORM) return 'unorm8x2';else if (format === Format.U8_RGBA_NORM) return 'unorm8x4';else if (format === Format.S8_RGB_NORM) return 'snorm8x4';else if (format === Format.S8_RGBA_NORM) return 'snorm8x4';else if (format === Format.U16_RG_NORM) return 'unorm16x2';else if (format === Format.U16_RGBA_NORM) return 'unorm16x4';else if (format === Format.S16_RG_NORM) return 'snorm16x2';else if (format === Format.S16_RGBA_NORM) return 'snorm16x4';else if (format === Format.S16_RG) return 'uint16x2';else if (format === Format.F16_RG) return 'float16x2';else if (format === Format.F16_RGBA) return 'float16x4';else if (format === Format.F32_R) return 'float32';else if (format === Format.F32_RG) return 'float32x2';else if (format === Format.F32_RGB) return 'float32x3';else if (format === Format.F32_RGBA) return 'float32x4';else throw 'whoops';
|
|
14316
14342
|
}
|
|
14317
14343
|
function isFormatTextureCompressionBC(format) {
|
|
14318
14344
|
var formatTypeFlags = getFormatTypeFlags(format);
|
|
@@ -14536,7 +14562,7 @@
|
|
|
14536
14562
|
binding: numBindings++,
|
|
14537
14563
|
resource: gpuTextureView
|
|
14538
14564
|
});
|
|
14539
|
-
var sampler = _binding2.sampler !== null ? _binding2.sampler : _this.device.
|
|
14565
|
+
var sampler = _binding2.sampler !== null ? _binding2.sampler : _this.device.getFallbackSampler(samplerEntry);
|
|
14540
14566
|
var gpuSampler = getPlatformSampler(sampler);
|
|
14541
14567
|
gpuBindGroupEntries[1].push({
|
|
14542
14568
|
binding: numBindings++,
|
|
@@ -14545,11 +14571,11 @@
|
|
|
14545
14571
|
}
|
|
14546
14572
|
_this.gpuBindGroup = gpuBindGroupEntries.filter(function (entries) {
|
|
14547
14573
|
return entries.length > 0;
|
|
14548
|
-
}).map(function (
|
|
14574
|
+
}).map(function (gpuBindGroupEntries, i) {
|
|
14549
14575
|
return _this.device.device.createBindGroup({
|
|
14550
|
-
layout: pipeline.getBindGroupLayout(i),
|
|
14551
14576
|
// layout: bindGroupLayout.gpuBindGroupLayout[i],
|
|
14552
|
-
|
|
14577
|
+
layout: pipeline.getBindGroupLayout(i),
|
|
14578
|
+
entries: gpuBindGroupEntries
|
|
14553
14579
|
});
|
|
14554
14580
|
});
|
|
14555
14581
|
_this.bindingLayout = descriptor.bindingLayout;
|
|
@@ -14582,26 +14608,26 @@
|
|
|
14582
14608
|
_this.usage = void 0;
|
|
14583
14609
|
var usage = descriptor.usage,
|
|
14584
14610
|
viewOrSize = descriptor.viewOrSize;
|
|
14585
|
-
var
|
|
14586
|
-
|
|
14611
|
+
var useMapRead = !!(usage & BufferUsage.MAP_READ);
|
|
14612
|
+
// const alignedLength = isView(viewOrSize)
|
|
14613
|
+
// ? viewOrSize.byteLength
|
|
14614
|
+
// : viewOrSize * 4; // 4 bytes alignments (because of the upload which requires this)
|
|
14615
|
+
_this.usage = translateBufferUsage(usage);
|
|
14587
14616
|
// Buffer usages (BufferUsage::(MapRead|CopyDst|Storage)) is invalid. If a buffer usage contains BufferUsage::MapRead the only other allowed usage is BufferUsage::CopyDst.
|
|
14588
14617
|
// @see https://www.w3.org/TR/webgpu/#dom-gpubufferusage-copy_dst
|
|
14589
|
-
if (
|
|
14618
|
+
if (useMapRead) {
|
|
14590
14619
|
_this.usage = BufferUsage.MAP_READ | BufferUsage.COPY_DST;
|
|
14591
14620
|
}
|
|
14592
14621
|
var mapBuffer = isView(viewOrSize);
|
|
14593
|
-
_this.size = isView(viewOrSize) ? viewOrSize.byteLength : viewOrSize;
|
|
14622
|
+
_this.size = isView(viewOrSize) ? viewOrSize.byteLength : viewOrSize * 4;
|
|
14594
14623
|
_this.view = isView(viewOrSize) ? viewOrSize : null;
|
|
14595
14624
|
_this.gpuBuffer = _this.device.device.createBuffer({
|
|
14596
14625
|
usage: _this.usage,
|
|
14597
|
-
size:
|
|
14598
|
-
mappedAtCreation: mapBuffer
|
|
14626
|
+
size: _this.size,
|
|
14627
|
+
mappedAtCreation: useMapRead ? mapBuffer : false
|
|
14599
14628
|
});
|
|
14600
|
-
if (
|
|
14601
|
-
|
|
14602
|
-
// @ts-expect-error
|
|
14603
|
-
new viewOrSize.constructor(arrayBuffer).set(viewOrSize);
|
|
14604
|
-
_this.gpuBuffer.unmap();
|
|
14629
|
+
if (isView(viewOrSize)) {
|
|
14630
|
+
_this.setSubData(0, new Uint8Array(viewOrSize.buffer));
|
|
14605
14631
|
}
|
|
14606
14632
|
return _this;
|
|
14607
14633
|
}
|
|
@@ -14649,7 +14675,6 @@
|
|
|
14649
14675
|
var ComputePass_WebGPU = /*#__PURE__*/function () {
|
|
14650
14676
|
function ComputePass_WebGPU() {
|
|
14651
14677
|
this.commandEncoder = null;
|
|
14652
|
-
this.descriptor = void 0;
|
|
14653
14678
|
this.gpuComputePassDescriptor = void 0;
|
|
14654
14679
|
this.gpuComputePassEncoder = null;
|
|
14655
14680
|
}
|
|
@@ -14670,9 +14695,8 @@
|
|
|
14670
14695
|
/**
|
|
14671
14696
|
* @see https://www.w3.org/TR/webgpu/#dom-gpucommandencoder-begincomputepass
|
|
14672
14697
|
*/;
|
|
14673
|
-
_proto.beginComputePass = function beginComputePass(
|
|
14698
|
+
_proto.beginComputePass = function beginComputePass() {
|
|
14674
14699
|
assert(this.gpuComputePassEncoder === null);
|
|
14675
|
-
this.setComputePassDescriptor(computePassDescriptor);
|
|
14676
14700
|
this.gpuComputePassEncoder = this.commandEncoder.beginComputePass(this.gpuComputePassDescriptor);
|
|
14677
14701
|
};
|
|
14678
14702
|
_proto.setPipeline = function setPipeline(pipeline_) {
|
|
@@ -14680,12 +14704,19 @@
|
|
|
14680
14704
|
var gpuComputePipeline = assertExists(pipeline.gpuComputePipeline);
|
|
14681
14705
|
this.gpuComputePassEncoder.setPipeline(gpuComputePipeline);
|
|
14682
14706
|
};
|
|
14683
|
-
_proto.setBindings = function setBindings(bindingLayoutIndex, bindings_) {
|
|
14707
|
+
_proto.setBindings = function setBindings(bindingLayoutIndex, bindings_, dynamicByteOffsets) {
|
|
14684
14708
|
var bindings = bindings_;
|
|
14685
|
-
this.gpuComputePassEncoder.setBindGroup(bindingLayoutIndex, bindings.gpuBindGroup[0]);
|
|
14709
|
+
this.gpuComputePassEncoder.setBindGroup(bindingLayoutIndex, bindings.gpuBindGroup[0], dynamicByteOffsets);
|
|
14686
14710
|
};
|
|
14687
|
-
_proto.
|
|
14688
|
-
|
|
14711
|
+
_proto.beginDebugGroup = function beginDebugGroup(name) {
|
|
14712
|
+
// FIREFOX MISSING
|
|
14713
|
+
if (this.gpuComputePassEncoder.pushDebugGroup === undefined) return;
|
|
14714
|
+
this.gpuComputePassEncoder.pushDebugGroup(name);
|
|
14715
|
+
};
|
|
14716
|
+
_proto.endDebugGroup = function endDebugGroup() {
|
|
14717
|
+
// FIREFOX MISSING
|
|
14718
|
+
if (this.gpuComputePassEncoder.popDebugGroup === undefined) return;
|
|
14719
|
+
this.gpuComputePassEncoder.popDebugGroup();
|
|
14689
14720
|
};
|
|
14690
14721
|
return ComputePass_WebGPU;
|
|
14691
14722
|
}();
|
|
@@ -14739,27 +14770,26 @@
|
|
|
14739
14770
|
_this.buffers = void 0;
|
|
14740
14771
|
_this.indexFormat = void 0;
|
|
14741
14772
|
var buffers = [];
|
|
14742
|
-
for (var i = 0; i < descriptor.
|
|
14743
|
-
var
|
|
14744
|
-
if (isNil(b)) continue;
|
|
14745
|
-
var arrayStride = b.byteStride;
|
|
14746
|
-
var stepMode = translateVertexBufferFrequency(b.frequency);
|
|
14747
|
-
var attributes = [];
|
|
14748
|
-
buffers[i] = {
|
|
14749
|
-
arrayStride: arrayStride,
|
|
14750
|
-
stepMode: stepMode,
|
|
14751
|
-
attributes: attributes
|
|
14752
|
-
};
|
|
14753
|
-
}
|
|
14754
|
-
for (var _i = 0; _i < descriptor.vertexAttributeDescriptors.length; _i++) {
|
|
14755
|
-
var attr = descriptor.vertexAttributeDescriptors[_i];
|
|
14756
|
-
var _b = assertExists(buffers[attr.bufferIndex]);
|
|
14773
|
+
for (var i = 0; i < descriptor.vertexAttributeDescriptors.length; i++) {
|
|
14774
|
+
var attr = descriptor.vertexAttributeDescriptors[i];
|
|
14757
14775
|
var attribute = {
|
|
14758
14776
|
shaderLocation: attr.location,
|
|
14759
14777
|
format: translateVertexFormat(attr.format),
|
|
14760
14778
|
offset: attr.bufferByteOffset
|
|
14761
14779
|
};
|
|
14762
|
-
|
|
14780
|
+
if (buffers[attr.bufferIndex] !== undefined) {
|
|
14781
|
+
buffers[attr.bufferIndex].attributes.push(attribute);
|
|
14782
|
+
} else {
|
|
14783
|
+
var b = assertExists(descriptor.vertexBufferDescriptors[attr.bufferIndex]);
|
|
14784
|
+
var arrayStride = b.byteStride;
|
|
14785
|
+
var stepMode = translateVertexBufferFrequency(b.frequency);
|
|
14786
|
+
var attributes = [attribute];
|
|
14787
|
+
buffers[attr.bufferIndex] = {
|
|
14788
|
+
arrayStride: arrayStride,
|
|
14789
|
+
stepMode: stepMode,
|
|
14790
|
+
attributes: attributes
|
|
14791
|
+
};
|
|
14792
|
+
}
|
|
14763
14793
|
}
|
|
14764
14794
|
_this.indexFormat = translateIndexFormat(descriptor.indexBufferFormat);
|
|
14765
14795
|
_this.buffers = buffers;
|
|
@@ -14869,17 +14899,35 @@
|
|
|
14869
14899
|
}) || this;
|
|
14870
14900
|
_this.type = ResourceType.QueryPool;
|
|
14871
14901
|
_this.querySet = void 0;
|
|
14902
|
+
_this.resolveBuffer = void 0;
|
|
14903
|
+
_this.cpuBuffer = void 0;
|
|
14904
|
+
_this.results = void 0;
|
|
14872
14905
|
var elemCount = descriptor.elemCount,
|
|
14873
14906
|
type = descriptor.type;
|
|
14874
14907
|
_this.querySet = _this.device.device.createQuerySet({
|
|
14875
14908
|
type: translateQueryPoolType(type),
|
|
14876
14909
|
count: elemCount
|
|
14877
14910
|
});
|
|
14911
|
+
_this.resolveBuffer = _this.device.device.createBuffer({
|
|
14912
|
+
size: elemCount * 8,
|
|
14913
|
+
usage: GPUBufferUsage.QUERY_RESOLVE | GPUBufferUsage.COPY_SRC
|
|
14914
|
+
});
|
|
14915
|
+
_this.cpuBuffer = _this.device.device.createBuffer({
|
|
14916
|
+
size: elemCount * 8,
|
|
14917
|
+
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ
|
|
14918
|
+
});
|
|
14919
|
+
_this.results = null;
|
|
14878
14920
|
return _this;
|
|
14879
14921
|
}
|
|
14880
14922
|
var _proto = QueryPool_WebGPU.prototype;
|
|
14881
14923
|
_proto.queryResultOcclusion = function queryResultOcclusion(dstOffs) {
|
|
14882
|
-
return
|
|
14924
|
+
if (this.results === null) return null;
|
|
14925
|
+
return this.results[dstOffs] !== BigInt(0);
|
|
14926
|
+
};
|
|
14927
|
+
_proto.destroy = function destroy() {
|
|
14928
|
+
this.querySet.destroy();
|
|
14929
|
+
this.resolveBuffer.destroy();
|
|
14930
|
+
this.cpuBuffer.destroy();
|
|
14883
14931
|
};
|
|
14884
14932
|
return QueryPool_WebGPU;
|
|
14885
14933
|
}(ResourceBase_WebGPU);
|
|
@@ -15327,7 +15375,9 @@
|
|
|
15327
15375
|
_proto.setBindings = function setBindings(bindingLayoutIndex, bindings_, dynamicByteOffsets) {
|
|
15328
15376
|
var bindings = bindings_;
|
|
15329
15377
|
this.gpuRenderPassEncoder.setBindGroup(bindingLayoutIndex + 0, bindings.gpuBindGroup[0], dynamicByteOffsets.slice(0, bindings.bindingLayout.numUniformBuffers));
|
|
15330
|
-
|
|
15378
|
+
if (bindings.gpuBindGroup[1]) {
|
|
15379
|
+
this.gpuRenderPassEncoder.setBindGroup(bindingLayoutIndex + 1, bindings.gpuBindGroup[1]);
|
|
15380
|
+
}
|
|
15331
15381
|
};
|
|
15332
15382
|
_proto.setStencilRef = function setStencilRef(ref) {
|
|
15333
15383
|
this.gpuRenderPassEncoder.setStencilReference(ref);
|
|
@@ -15404,7 +15454,6 @@
|
|
|
15404
15454
|
}) || this;
|
|
15405
15455
|
_this.type = ResourceType.RenderPipeline;
|
|
15406
15456
|
_this.descriptor = void 0;
|
|
15407
|
-
_this.isCreating = false;
|
|
15408
15457
|
_this.isCreatingAsync = false;
|
|
15409
15458
|
_this.gpuRenderPipeline = null;
|
|
15410
15459
|
_this.descriptor = descriptor;
|
|
@@ -15445,6 +15494,7 @@
|
|
|
15445
15494
|
minFilter: translateMinMagFilter(descriptor.minFilter),
|
|
15446
15495
|
magFilter: translateMinMagFilter(descriptor.magFilter),
|
|
15447
15496
|
mipmapFilter: translateMipFilter(descriptor.mipFilter),
|
|
15497
|
+
compare: descriptor.compareMode !== undefined ? translateCompareMode(descriptor.compareMode) : undefined,
|
|
15448
15498
|
maxAnisotropy: maxAnisotropy
|
|
15449
15499
|
});
|
|
15450
15500
|
return _this;
|
|
@@ -15503,19 +15553,22 @@
|
|
|
15503
15553
|
function Device_WebGPU(adapter, device, canvas, canvasContext, glsl_compile) {
|
|
15504
15554
|
this.swapChainWidth = 0;
|
|
15505
15555
|
this.swapChainHeight = 0;
|
|
15556
|
+
this.swapChainFormat = void 0;
|
|
15506
15557
|
this.swapChainTextureUsage = GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_DST;
|
|
15507
15558
|
this._resourceUniqueId = 0;
|
|
15508
15559
|
this.renderPassPool = [];
|
|
15509
15560
|
this.computePassPool = [];
|
|
15510
15561
|
this.bindGroupLayoutCache = new HashMap(bindingLayoutDescriptorEqual, nullHashFunc);
|
|
15562
|
+
// private frameCommandEncoder: GPUCommandEncoder | null = null;
|
|
15563
|
+
// private queryPoolsSubmitted: QueryPool_WebGPU[] = [];
|
|
15511
15564
|
this.fallbackTexture2D = void 0;
|
|
15512
15565
|
this.fallbackTexture2DDepth = void 0;
|
|
15513
15566
|
this.fallbackTexture2DArray = void 0;
|
|
15514
15567
|
this.fallbackTexture3D = void 0;
|
|
15515
15568
|
this.fallbackTextureCube = void 0;
|
|
15516
|
-
this.
|
|
15569
|
+
this.fallbackSamplerFiltering = void 0;
|
|
15570
|
+
this.fallbackSamplerComparison = void 0;
|
|
15517
15571
|
this.featureTextureCompressionBC = false;
|
|
15518
|
-
// private fullscreenAlphaClear: FullscreenAlphaClear;
|
|
15519
15572
|
// VendorInfo
|
|
15520
15573
|
this.platformString = 'WebGPU';
|
|
15521
15574
|
this.glslVersion = "#version 440";
|
|
@@ -15525,12 +15578,10 @@
|
|
|
15525
15578
|
this.clipSpaceNearZ = ClipSpaceNearZ.Zero;
|
|
15526
15579
|
this.supportsSyncPipelineCompilation = false;
|
|
15527
15580
|
this.supportMRT = true;
|
|
15528
|
-
this.adapter = void 0;
|
|
15529
15581
|
this.device = void 0;
|
|
15530
15582
|
this.canvas = void 0;
|
|
15531
15583
|
this.canvasContext = void 0;
|
|
15532
15584
|
this.glsl_compile = void 0;
|
|
15533
|
-
this.adapter = adapter;
|
|
15534
15585
|
this.device = device;
|
|
15535
15586
|
this.canvas = canvas;
|
|
15536
15587
|
this.canvasContext = canvasContext;
|
|
@@ -15540,13 +15591,23 @@
|
|
|
15540
15591
|
this.fallbackTexture2DArray = this.createFallbackTexture(TextureDimension.n2DArray, SamplerFormatKind.Float);
|
|
15541
15592
|
this.fallbackTexture3D = this.createFallbackTexture(TextureDimension.n3D, SamplerFormatKind.Float);
|
|
15542
15593
|
this.fallbackTextureCube = this.createFallbackTexture(TextureDimension.Cube, SamplerFormatKind.Float);
|
|
15543
|
-
this.
|
|
15544
|
-
wrapS: WrapMode.
|
|
15545
|
-
wrapT: WrapMode.
|
|
15594
|
+
this.fallbackSamplerFiltering = this.createSampler({
|
|
15595
|
+
wrapS: WrapMode.Repeat,
|
|
15596
|
+
wrapT: WrapMode.Repeat,
|
|
15597
|
+
minFilter: TexFilterMode.Point,
|
|
15598
|
+
magFilter: TexFilterMode.Point,
|
|
15599
|
+
mipFilter: MipFilterMode.Nearest
|
|
15600
|
+
});
|
|
15601
|
+
this.setResourceName(this.fallbackSamplerFiltering, 'Fallback Sampler Filtering');
|
|
15602
|
+
this.fallbackSamplerComparison = this.createSampler({
|
|
15603
|
+
wrapS: WrapMode.Repeat,
|
|
15604
|
+
wrapT: WrapMode.Repeat,
|
|
15546
15605
|
minFilter: TexFilterMode.Point,
|
|
15547
15606
|
magFilter: TexFilterMode.Point,
|
|
15548
|
-
mipFilter: MipFilterMode.
|
|
15607
|
+
mipFilter: MipFilterMode.Nearest,
|
|
15608
|
+
compareMode: CompareMode.Always
|
|
15549
15609
|
});
|
|
15610
|
+
this.setResourceName(this.fallbackSamplerFiltering, 'Fallback Sampler Filtering');
|
|
15550
15611
|
// Firefox doesn't support GPUDevice.features yet...
|
|
15551
15612
|
if (this.device.features) {
|
|
15552
15613
|
this.featureTextureCompressionBC = this.device.features.has('texture-compression-bc');
|
|
@@ -15554,7 +15615,15 @@
|
|
|
15554
15615
|
this.device.onuncapturederror = function (event) {
|
|
15555
15616
|
console.error(event.error);
|
|
15556
15617
|
};
|
|
15557
|
-
|
|
15618
|
+
this.swapChainFormat = navigator.gpu.getPreferredCanvasFormat();
|
|
15619
|
+
// @see https://www.w3.org/TR/webgpu/#canvas-configuration
|
|
15620
|
+
this.canvasContext.configure({
|
|
15621
|
+
device: this.device,
|
|
15622
|
+
format: this.swapChainFormat,
|
|
15623
|
+
usage: this.swapChainTextureUsage,
|
|
15624
|
+
// @see https://www.w3.org/TR/webgpu/#enumdef-gpucanvascompositingalphamode
|
|
15625
|
+
alphaMode: 'opaque'
|
|
15626
|
+
});
|
|
15558
15627
|
}
|
|
15559
15628
|
// SwapChain
|
|
15560
15629
|
var _proto = Device_WebGPU.prototype;
|
|
@@ -15562,16 +15631,6 @@
|
|
|
15562
15631
|
if (this.swapChainWidth === width && this.swapChainHeight === height) return;
|
|
15563
15632
|
this.swapChainWidth = width;
|
|
15564
15633
|
this.swapChainHeight = height;
|
|
15565
|
-
// @see https://www.w3.org/TR/webgpu/#canvas-configuration
|
|
15566
|
-
this.canvasContext.configure({
|
|
15567
|
-
device: this.device,
|
|
15568
|
-
format: 'bgra8unorm',
|
|
15569
|
-
usage: this.swapChainTextureUsage,
|
|
15570
|
-
// @see https://developer.chrome.com/blog/new-in-chrome-94/#canvas-colorspace
|
|
15571
|
-
// colorSpace: 'srgb',
|
|
15572
|
-
// @see https://www.w3.org/TR/webgpu/#enumdef-gpucanvascompositingalphamode
|
|
15573
|
-
alphaMode: 'premultiplied'
|
|
15574
|
-
});
|
|
15575
15634
|
};
|
|
15576
15635
|
_proto.getOnscreenTexture = function getOnscreenTexture() {
|
|
15577
15636
|
// @see https://www.w3.org/TR/webgpu/#dom-gpucanvascontext-getcurrenttexture
|
|
@@ -15603,11 +15662,23 @@
|
|
|
15603
15662
|
_proto.getCanvas = function getCanvas() {
|
|
15604
15663
|
return this.canvas;
|
|
15605
15664
|
};
|
|
15606
|
-
_proto.
|
|
15607
|
-
// this.
|
|
15608
|
-
//
|
|
15609
|
-
|
|
15610
|
-
|
|
15665
|
+
_proto.beginFrame = function beginFrame() {
|
|
15666
|
+
// assert(this.frameCommandEncoder === null);
|
|
15667
|
+
// this.frameCommandEncoder = this.device.createCommandEncoder();
|
|
15668
|
+
};
|
|
15669
|
+
_proto.endFrame = function endFrame() {
|
|
15670
|
+
// assert(this.frameCommandEncoder !== null);
|
|
15671
|
+
// this.device.queue.submit([this.frameCommandEncoder.finish()]);
|
|
15672
|
+
// this.frameCommandEncoder = null;
|
|
15673
|
+
// for (let i = 0; i < this.queryPoolsSubmitted.length; i++) {
|
|
15674
|
+
// const queryPool = this.queryPoolsSubmitted[i];
|
|
15675
|
+
// queryPool.cpuBuffer.mapAsync(GPUMapMode.READ).then(() => {
|
|
15676
|
+
// queryPool.results = new BigUint64Array(
|
|
15677
|
+
// queryPool.cpuBuffer.getMappedRange(),
|
|
15678
|
+
// );
|
|
15679
|
+
// });
|
|
15680
|
+
// }
|
|
15681
|
+
// this.queryPoolsSubmitted.length = 0;
|
|
15611
15682
|
};
|
|
15612
15683
|
_proto.getNextUniqueId = function getNextUniqueId() {
|
|
15613
15684
|
return ++this._resourceUniqueId;
|
|
@@ -15726,6 +15797,14 @@
|
|
|
15726
15797
|
texture.gpuTextureView = gpuTextureView;
|
|
15727
15798
|
}
|
|
15728
15799
|
};
|
|
15800
|
+
_proto.getFallbackSampler = function getFallbackSampler(samplerEntry) {
|
|
15801
|
+
var formatKind = samplerEntry.formatKind;
|
|
15802
|
+
if (formatKind === SamplerFormatKind.Depth && samplerEntry.comparison) {
|
|
15803
|
+
return this.fallbackSamplerComparison;
|
|
15804
|
+
} else {
|
|
15805
|
+
return this.fallbackSamplerFiltering;
|
|
15806
|
+
}
|
|
15807
|
+
};
|
|
15729
15808
|
_proto.getFallbackTexture = function getFallbackTexture(samplerEntry) {
|
|
15730
15809
|
var dimension = samplerEntry.dimension,
|
|
15731
15810
|
formatKind = samplerEntry.formatKind;
|
|
@@ -15832,15 +15911,15 @@
|
|
|
15832
15911
|
entries[1].push({
|
|
15833
15912
|
binding: entries[1].length,
|
|
15834
15913
|
visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT,
|
|
15835
|
-
sampler:
|
|
15836
|
-
type: 'filtering'
|
|
15837
|
-
}
|
|
15914
|
+
sampler: translateBindGroupSamplerBinding(samplerEntry)
|
|
15838
15915
|
});
|
|
15839
15916
|
}
|
|
15840
15917
|
var gpuBindGroupLayout = entries.map(function (entries) {
|
|
15841
|
-
return _this.device.createBindGroupLayout({
|
|
15918
|
+
return entries.length ? _this.device.createBindGroupLayout({
|
|
15842
15919
|
entries: entries
|
|
15843
|
-
});
|
|
15920
|
+
}) : null;
|
|
15921
|
+
}).filter(function (layout) {
|
|
15922
|
+
return !!layout;
|
|
15844
15923
|
});
|
|
15845
15924
|
return {
|
|
15846
15925
|
gpuBindGroupLayout: gpuBindGroupLayout
|
|
@@ -15856,8 +15935,16 @@
|
|
|
15856
15935
|
});
|
|
15857
15936
|
};
|
|
15858
15937
|
_proto._createRenderPipeline = function _createRenderPipeline(renderPipeline, async) {
|
|
15859
|
-
if (
|
|
15860
|
-
|
|
15938
|
+
// if (this.device.createRenderPipelineAsync === undefined) {
|
|
15939
|
+
// async = false;
|
|
15940
|
+
// }
|
|
15941
|
+
// // If we're already in the process of creating a the pipeline async, no need to kick the process off again...
|
|
15942
|
+
// if (async && renderPipeline.isCreatingAsync) {
|
|
15943
|
+
// return;
|
|
15944
|
+
// }
|
|
15945
|
+
if (renderPipeline.gpuRenderPipeline !== null) {
|
|
15946
|
+
return;
|
|
15947
|
+
}
|
|
15861
15948
|
var descriptor = renderPipeline.descriptor;
|
|
15862
15949
|
var program = descriptor.program;
|
|
15863
15950
|
var vertexStage = program.vertexStage,
|
|
@@ -15870,9 +15957,10 @@
|
|
|
15870
15957
|
var buffers = undefined;
|
|
15871
15958
|
if (descriptor.inputLayout !== null) buffers = descriptor.inputLayout.buffers;
|
|
15872
15959
|
var sampleCount = descriptor.sampleCount;
|
|
15873
|
-
renderPipeline.
|
|
15874
|
-
var
|
|
15960
|
+
// renderPipeline.isCreatingAsync = true;
|
|
15961
|
+
var gpuRenderPipelineDescriptor = {
|
|
15875
15962
|
layout: layout,
|
|
15963
|
+
// layout: 'auto',
|
|
15876
15964
|
vertex: _extends$1({}, vertexStage, {
|
|
15877
15965
|
buffers: buffers
|
|
15878
15966
|
}),
|
|
@@ -15887,9 +15975,26 @@
|
|
|
15887
15975
|
};
|
|
15888
15976
|
// TODO: async creation
|
|
15889
15977
|
// @see https://www.w3.org/TR/webgpu/#dom-gpudevice-createrenderpipeline
|
|
15890
|
-
renderPipeline.gpuRenderPipeline =
|
|
15891
|
-
|
|
15978
|
+
// renderPipeline.gpuRenderPipeline =
|
|
15979
|
+
// this.device.createRenderPipeline(gpuRenderPipeline);
|
|
15980
|
+
// if (renderPipeline.name !== undefined)
|
|
15981
|
+
// renderPipeline.gpuRenderPipeline.label = renderPipeline.name;
|
|
15982
|
+
// if (async) {
|
|
15983
|
+
// const gpuRenderPipeline = await this.device.createRenderPipelineAsync(
|
|
15984
|
+
// gpuRenderPipelineDescriptor,
|
|
15985
|
+
// );
|
|
15986
|
+
// // We might have created a sync pipeline while we were async building; no way to cancel the async
|
|
15987
|
+
// // pipeline build at this point, so just chuck it out :/
|
|
15988
|
+
// if (renderPipeline.gpuRenderPipeline === null)
|
|
15989
|
+
// renderPipeline.gpuRenderPipeline = gpuRenderPipeline;
|
|
15990
|
+
// } else {
|
|
15991
|
+
renderPipeline.gpuRenderPipeline = this.device.createRenderPipeline(gpuRenderPipelineDescriptor);
|
|
15992
|
+
// }
|
|
15993
|
+
// // if (renderPipeline.ResourceName !== undefined)
|
|
15994
|
+
// // renderPipeline.gpuRenderPipeline.label = renderPipeline.ResourceName;
|
|
15995
|
+
// renderPipeline.isCreatingAsync = false;
|
|
15892
15996
|
};
|
|
15997
|
+
|
|
15893
15998
|
_proto.createReadback = function createReadback() {
|
|
15894
15999
|
return new Readback_WebGPU({
|
|
15895
16000
|
id: this.getNextUniqueId(),
|
|
@@ -15909,11 +16014,11 @@
|
|
|
15909
16014
|
pass.beginRenderPass(renderPassDescriptor);
|
|
15910
16015
|
return pass;
|
|
15911
16016
|
};
|
|
15912
|
-
_proto.createComputePass = function createComputePass(
|
|
16017
|
+
_proto.createComputePass = function createComputePass() {
|
|
15913
16018
|
var pass = this.computePassPool.pop();
|
|
15914
16019
|
if (pass === undefined) pass = new ComputePass_WebGPU();
|
|
15915
16020
|
pass.commandEncoder = this.device.createCommandEncoder();
|
|
15916
|
-
pass.beginComputePass(
|
|
16021
|
+
pass.beginComputePass();
|
|
15917
16022
|
return pass;
|
|
15918
16023
|
};
|
|
15919
16024
|
_proto.submitPass = function submitPass(_pass) {
|
|
@@ -15922,12 +16027,18 @@
|
|
|
15922
16027
|
var commands = pass.finish();
|
|
15923
16028
|
queue.submit([commands]);
|
|
15924
16029
|
pass.commandEncoder = null;
|
|
15925
|
-
if (pass instanceof RenderPass_WebGPU) {
|
|
15926
|
-
|
|
15927
|
-
|
|
15928
|
-
|
|
15929
|
-
|
|
16030
|
+
// if (pass instanceof RenderPass_WebGPU) {
|
|
16031
|
+
// pass.finish();
|
|
16032
|
+
// this.renderPassPool.push(pass);
|
|
16033
|
+
// if (pass.occlusionQueryPool !== null) {
|
|
16034
|
+
// this.queryPoolsSubmitted.push(pass.occlusionQueryPool);
|
|
16035
|
+
// }
|
|
16036
|
+
// } else if (pass instanceof ComputePass_WebGPU) {
|
|
16037
|
+
// pass.finish();
|
|
16038
|
+
// this.computePassPool.push(pass);
|
|
16039
|
+
// }
|
|
15930
16040
|
};
|
|
16041
|
+
|
|
15931
16042
|
_proto.copySubTexture2D = function copySubTexture2D(dst_, dstX, dstY, src_, srcX, srcY) {
|
|
15932
16043
|
var cmd = this.device.createCommandEncoder();
|
|
15933
16044
|
var dst = dst_;
|
|
@@ -16029,7 +16140,7 @@
|
|
|
16029
16140
|
var _proto = WebGPUDeviceContribution.prototype;
|
|
16030
16141
|
_proto.createSwapChain = /*#__PURE__*/function () {
|
|
16031
16142
|
var _createSwapChain = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee($canvas) {
|
|
16032
|
-
var adapter, optionalFeatures, requiredFeatures, device, context;
|
|
16143
|
+
var adapter, optionalFeatures, requiredFeatures, device, onContextLost, context;
|
|
16033
16144
|
return _regeneratorRuntime$2().wrap(function _callee$(_context) {
|
|
16034
16145
|
while (1) switch (_context.prev = _context.next) {
|
|
16035
16146
|
case 0:
|
|
@@ -16071,35 +16182,44 @@
|
|
|
16071
16182
|
});
|
|
16072
16183
|
case 18:
|
|
16073
16184
|
device = _context.sent;
|
|
16185
|
+
if (device) {
|
|
16186
|
+
// @see https://github.com/gpuweb/gpuweb/blob/main/design/ErrorHandling.md#fatal-errors-requestadapter-requestdevice-and-devicelost
|
|
16187
|
+
onContextLost = this.pluginOptions.onContextLost;
|
|
16188
|
+
device.lost.then(function () {
|
|
16189
|
+
if (onContextLost) {
|
|
16190
|
+
onContextLost();
|
|
16191
|
+
}
|
|
16192
|
+
});
|
|
16193
|
+
}
|
|
16074
16194
|
if (!(device === null)) {
|
|
16075
|
-
_context.next =
|
|
16195
|
+
_context.next = 22;
|
|
16076
16196
|
break;
|
|
16077
16197
|
}
|
|
16078
16198
|
return _context.abrupt("return", null);
|
|
16079
|
-
case
|
|
16199
|
+
case 22:
|
|
16080
16200
|
context = $canvas.getContext('webgpu');
|
|
16081
16201
|
if (context) {
|
|
16082
|
-
_context.next =
|
|
16202
|
+
_context.next = 25;
|
|
16083
16203
|
break;
|
|
16084
16204
|
}
|
|
16085
16205
|
return _context.abrupt("return", null);
|
|
16086
|
-
case
|
|
16087
|
-
_context.prev =
|
|
16088
|
-
_context.next =
|
|
16089
|
-
return init(
|
|
16090
|
-
case
|
|
16091
|
-
_context.next =
|
|
16206
|
+
case 25:
|
|
16207
|
+
_context.prev = 25;
|
|
16208
|
+
_context.next = 28;
|
|
16209
|
+
return init(this.pluginOptions.shaderCompilerPath);
|
|
16210
|
+
case 28:
|
|
16211
|
+
_context.next = 32;
|
|
16092
16212
|
break;
|
|
16093
|
-
case
|
|
16094
|
-
_context.prev =
|
|
16095
|
-
_context.t1 = _context["catch"](
|
|
16096
|
-
case 31:
|
|
16097
|
-
return _context.abrupt("return", new Device_WebGPU(adapter, device, $canvas, context, glsl_compile));
|
|
16213
|
+
case 30:
|
|
16214
|
+
_context.prev = 30;
|
|
16215
|
+
_context.t1 = _context["catch"](25);
|
|
16098
16216
|
case 32:
|
|
16217
|
+
return _context.abrupt("return", new Device_WebGPU(adapter, device, $canvas, context, glsl_compile));
|
|
16218
|
+
case 33:
|
|
16099
16219
|
case "end":
|
|
16100
16220
|
return _context.stop();
|
|
16101
16221
|
}
|
|
16102
|
-
}, _callee,
|
|
16222
|
+
}, _callee, this, [[3, 9], [25, 30]]);
|
|
16103
16223
|
}));
|
|
16104
16224
|
function createSwapChain(_x) {
|
|
16105
16225
|
return _createSwapChain.apply(this, arguments);
|
|
@@ -16123,11 +16243,11 @@
|
|
|
16123
16243
|
}
|
|
16124
16244
|
var _proto = Plugin.prototype;
|
|
16125
16245
|
_proto.init = function init() {
|
|
16126
|
-
|
|
16127
|
-
|
|
16246
|
+
this.context.deviceContribution = new WebGPUDeviceContribution(_extends$1({
|
|
16247
|
+
shaderCompilerPath: '/glsl_wgsl_compiler_bg.wasm'
|
|
16248
|
+
}, this.options));
|
|
16128
16249
|
};
|
|
16129
16250
|
_proto.destroy = function destroy() {
|
|
16130
|
-
// @ts-ignore
|
|
16131
16251
|
delete this.context.deviceContribution;
|
|
16132
16252
|
};
|
|
16133
16253
|
return Plugin;
|
|
@@ -16270,7 +16390,10 @@
|
|
|
16270
16390
|
var deviceRendererPlugin = new Plugin();
|
|
16271
16391
|
_this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin));
|
|
16272
16392
|
_this.registerPlugin(new Plugin$3());
|
|
16273
|
-
_this.registerPlugin(new Plugin$4(
|
|
16393
|
+
_this.registerPlugin(new Plugin$4({
|
|
16394
|
+
shaderCompilerPath: config === null || config === void 0 ? void 0 : config.shaderCompilerPath,
|
|
16395
|
+
onContextLost: config === null || config === void 0 ? void 0 : config.onContextLost
|
|
16396
|
+
}));
|
|
16274
16397
|
_this.registerPlugin(deviceRendererPlugin);
|
|
16275
16398
|
_this.registerPlugin(new Plugin$1());
|
|
16276
16399
|
_this.registerPlugin(new Plugin$2());
|