@luma.gl/webgl 9.0.0-alpha.21 → 9.0.0-alpha.23
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/dist/adapter/converters/device-parameters.d.ts +1 -1
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +9 -9
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/sampler-parameters.d.ts +1 -1
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +1 -1
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/converters/texture-formats.d.ts +27 -38
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +152 -114
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/helpers/attribute-utils.d.ts +1 -1
- package/dist/adapter/helpers/attribute-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/attribute-utils.js +1 -1
- package/dist/adapter/helpers/attribute-utils.js.map +1 -1
- package/dist/adapter/helpers/get-shader-info.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-info.js.map +1 -1
- package/dist/adapter/helpers/uniforms.d.ts +7 -8
- package/dist/adapter/helpers/uniforms.d.ts.map +1 -1
- package/dist/adapter/helpers/uniforms.js +4 -4
- package/dist/adapter/helpers/uniforms.js.map +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts +0 -2
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +0 -20
- package/dist/adapter/objects/constants-to-keys.js.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +11 -8
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +29 -19
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts +0 -1
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +4 -7
- package/dist/adapter/objects/webgl-resource.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +3 -2
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +8 -2
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +168 -25
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.d.ts +3 -2
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +6 -2
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +9 -12
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +29 -79
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts +16 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +80 -0
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +3 -4
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +1 -1
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +39 -19
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +32 -30
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.d.ts +1 -2
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +13 -6
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +20 -2
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/buffer.d.ts +0 -1
- package/dist/classic/buffer.d.ts.map +1 -1
- package/dist/classic/buffer.js +0 -6
- package/dist/classic/buffer.js.map +1 -1
- package/dist/classic/typed-array-utils.d.ts +15 -17
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +1 -1
- package/dist/classic/typed-array-utils.js.map +1 -1
- package/dist/context/context/create-browser-context.js.map +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts +1 -2
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/dist.dev.js +1102 -670
- package/dist/index.cjs +1085 -898
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist.min.js +22 -21
- package/package.json +7 -4
- package/src/adapter/converters/device-parameters.ts +46 -22
- package/src/adapter/converters/sampler-parameters.ts +1 -2
- package/src/adapter/converters/texture-formats.ts +242 -161
- package/src/adapter/helpers/attribute-utils.ts +1 -2
- package/src/adapter/helpers/get-shader-info.ts +3 -0
- package/src/adapter/helpers/uniforms.ts +9 -10
- package/src/adapter/objects/constants-to-keys.ts +0 -25
- package/src/adapter/objects/webgl-renderbuffer.ts +32 -29
- package/src/adapter/objects/webgl-resource.ts +4 -8
- package/src/adapter/resources/webgl-buffer.ts +4 -5
- package/src/adapter/resources/webgl-command-buffer.ts +328 -21
- package/src/adapter/resources/webgl-command-encoder.ts +7 -2
- package/src/adapter/resources/webgl-framebuffer.ts +63 -111
- package/src/adapter/resources/webgl-render-pass.ts +146 -2
- package/src/adapter/resources/webgl-render-pipeline.ts +6 -3
- package/src/adapter/resources/webgl-sampler.ts +1 -2
- package/src/adapter/resources/webgl-texture.ts +61 -43
- package/src/adapter/webgl-canvas-context.ts +2 -2
- package/src/adapter/webgl-device.ts +37 -8
- package/src/classic/buffer.ts +3 -3
- package/src/classic/typed-array-utils.ts +15 -26
- package/src/context/context/create-browser-context.ts +2 -2
- package/src/context/parameters/unified-parameter-api.ts +1 -1
- package/src/context/parameters/webgl-parameter-tables.ts +2 -2
- package/src/index.ts +5 -3
- package/dist/adapter/converters/renderbuffer-formats.d.ts +0 -16
- package/dist/adapter/converters/renderbuffer-formats.d.ts.map +0 -1
- package/dist/adapter/converters/renderbuffer-formats.js +0 -180
- package/dist/adapter/converters/renderbuffer-formats.js.map +0 -1
- package/dist/types/webgl.d.ts +0 -145
- package/dist/types/webgl.d.ts.map +0 -1
- package/dist/types/webgl.js +0 -2
- package/dist/types/webgl.js.map +0 -1
- package/src/.DS_Store +0 -0
- package/src/adapter/.DS_Store +0 -0
- package/src/adapter/converters/renderbuffer-formats.ts +0 -90
- package/src/context/.DS_Store +0 -0
- package/src/types/webgl.ts +0 -286
package/dist/dist.dev.js
CHANGED
|
@@ -48,9 +48,11 @@ var __exports__ = (() => {
|
|
|
48
48
|
WebGLCanvasContext: () => WebGLCanvasContext,
|
|
49
49
|
WebGLDevice: () => WebGLDevice,
|
|
50
50
|
WebGLResource: () => WebGLResource,
|
|
51
|
+
_TEXTURE_FORMATS: () => TEXTURE_FORMATS,
|
|
51
52
|
_checkFloat32ColorAttachment: () => _checkFloat32ColorAttachment,
|
|
52
53
|
assertWebGL2Context: () => assertWebGL2Context,
|
|
53
54
|
assertWebGLContext: () => assertWebGLContext,
|
|
55
|
+
convertGLToTextureFormat: () => convertGLToTextureFormat,
|
|
54
56
|
getParameters: () => getParameters,
|
|
55
57
|
getProgramBindings: () => getProgramBindings,
|
|
56
58
|
getShaderLayout: () => getShaderLayout,
|
|
@@ -973,14 +975,17 @@ var __exports__ = (() => {
|
|
|
973
975
|
var DEFAULT_RESOURCE_PROPS = {
|
|
974
976
|
id: "undefined",
|
|
975
977
|
handle: void 0,
|
|
976
|
-
userData:
|
|
978
|
+
userData: void 0
|
|
977
979
|
};
|
|
978
980
|
var Resource = class {
|
|
979
981
|
/** props.id, for debugging. */
|
|
980
982
|
userData = {};
|
|
983
|
+
/** Whether this resource has been destroyed */
|
|
981
984
|
destroyed = false;
|
|
982
985
|
/** For resources that allocate GPU memory */
|
|
983
986
|
allocatedBytes = 0;
|
|
987
|
+
/** Attached resources will be destroyed when this resource is destroyed. Tracks auto-created "sub" resources. */
|
|
988
|
+
_attachedResources = /* @__PURE__ */ new Set();
|
|
984
989
|
/**
|
|
985
990
|
* Create a new Resource. Called from Subclass
|
|
986
991
|
*/
|
|
@@ -1000,7 +1005,7 @@ var __exports__ = (() => {
|
|
|
1000
1005
|
* destroy can be called on any resource to release it before it is garbage collected.
|
|
1001
1006
|
*/
|
|
1002
1007
|
destroy() {
|
|
1003
|
-
this.
|
|
1008
|
+
this.destroyResource();
|
|
1004
1009
|
}
|
|
1005
1010
|
/** @deprecated Use destroy() */
|
|
1006
1011
|
delete() {
|
|
@@ -1017,14 +1022,41 @@ var __exports__ = (() => {
|
|
|
1017
1022
|
getProps() {
|
|
1018
1023
|
return this.props;
|
|
1019
1024
|
}
|
|
1025
|
+
// ATTACHED RESOURCES
|
|
1026
|
+
/**
|
|
1027
|
+
* Attaches a resource. Attached resources are auto destroyed when this resource is destroyed
|
|
1028
|
+
* Called automatically when sub resources are auto created but can be called by application
|
|
1029
|
+
*/
|
|
1030
|
+
attachResource(resource) {
|
|
1031
|
+
this._attachedResources.add(resource);
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* Detach an attached resource. The resource will no longer be auto-destroyed when this resource is destroyed.
|
|
1035
|
+
*/
|
|
1036
|
+
detachResource(resource) {
|
|
1037
|
+
this._attachedResources.delete(resource);
|
|
1038
|
+
}
|
|
1039
|
+
/**
|
|
1040
|
+
* Destroys a resource (only if owned), and removes from the owned (auto-destroy) list for this resource.
|
|
1041
|
+
*/
|
|
1042
|
+
destroyAttachedResource(resource) {
|
|
1043
|
+
if (this._attachedResources.delete(resource)) {
|
|
1044
|
+
resource.destroy();
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
/** Destroy all owned resources. Make sure the resources are no longer needed before calling. */
|
|
1048
|
+
destroyAttachedResources() {
|
|
1049
|
+
for (const resource of Object.values(this._attachedResources)) {
|
|
1050
|
+
resource.destroy();
|
|
1051
|
+
}
|
|
1052
|
+
this._attachedResources = /* @__PURE__ */ new Set();
|
|
1053
|
+
}
|
|
1020
1054
|
// PROTECTED METHODS
|
|
1021
|
-
/**
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
stats.get(`${name}s Created`).incrementCount();
|
|
1027
|
-
stats.get(`${name}s Active`).incrementCount();
|
|
1055
|
+
/** Perform all destroy steps. Can be called by derived resources when overriding destroy() */
|
|
1056
|
+
destroyResource() {
|
|
1057
|
+
this.destroyAttachedResources();
|
|
1058
|
+
this.removeStats();
|
|
1059
|
+
this.destroyed = true;
|
|
1028
1060
|
}
|
|
1029
1061
|
/** Called by .destroy() to track object destruction. Subclass must call if overriding destroy() */
|
|
1030
1062
|
removeStats() {
|
|
@@ -1046,7 +1078,17 @@ var __exports__ = (() => {
|
|
|
1046
1078
|
stats.get(`${name} Memory`).subtractCount(this.allocatedBytes);
|
|
1047
1079
|
this.allocatedBytes = 0;
|
|
1048
1080
|
}
|
|
1081
|
+
/** Called by resource constructor to track object creation */
|
|
1082
|
+
addStats() {
|
|
1083
|
+
const stats = this._device.statsManager.getStats("Resource Counts");
|
|
1084
|
+
const name = this[Symbol.toStringTag];
|
|
1085
|
+
stats.get("Resources Created").incrementCount();
|
|
1086
|
+
stats.get(`${name}s Created`).incrementCount();
|
|
1087
|
+
stats.get(`${name}s Active`).incrementCount();
|
|
1088
|
+
}
|
|
1049
1089
|
};
|
|
1090
|
+
/** Default properties for resource */
|
|
1091
|
+
__publicField(Resource, "defaultProps", DEFAULT_RESOURCE_PROPS);
|
|
1050
1092
|
function selectivelyMerge(props, defaultProps) {
|
|
1051
1093
|
const mergedProps = {
|
|
1052
1094
|
...defaultProps
|
|
@@ -1074,6 +1116,7 @@ var __exports__ = (() => {
|
|
|
1074
1116
|
get [Symbol.toStringTag]() {
|
|
1075
1117
|
return "Buffer";
|
|
1076
1118
|
}
|
|
1119
|
+
/** Length of buffer in bytes */
|
|
1077
1120
|
constructor(device, props) {
|
|
1078
1121
|
const deducedProps = {
|
|
1079
1122
|
...props
|
|
@@ -1194,34 +1237,30 @@ var __exports__ = (() => {
|
|
|
1194
1237
|
}
|
|
1195
1238
|
statsManager = lumaStats;
|
|
1196
1239
|
userData = {};
|
|
1240
|
+
// Capabilities
|
|
1197
1241
|
/** Information about the device (vendor, versions etc) */
|
|
1198
1242
|
/** Optional capability discovery */
|
|
1199
1243
|
/** WebGPU style device limits */
|
|
1200
1244
|
/** Check if device supports a specific texture format (creation and `nearest` sampling) */
|
|
1201
1245
|
/** Check if linear filtering (sampler interpolation) is supported for a specific texture format */
|
|
1202
1246
|
/** Check if device supports rendering to a specific texture format */
|
|
1203
|
-
|
|
1204
|
-
/**
|
|
1205
|
-
/**
|
|
1247
|
+
// Device loss
|
|
1248
|
+
/** `true` if device is already lost */
|
|
1249
|
+
/** Promise that resolves when device is lost */
|
|
1250
|
+
/**
|
|
1251
|
+
* Trigger device loss.
|
|
1252
|
+
* @returns `true` if context loss could actually be triggered.
|
|
1253
|
+
* @note primarily intended for testing how application reacts to device loss
|
|
1254
|
+
*/
|
|
1255
|
+
loseDevice() {
|
|
1256
|
+
return false;
|
|
1257
|
+
}
|
|
1258
|
+
// Canvas context
|
|
1259
|
+
/** Default / primary canvas context. Can be null as WebGPU devices can be created without a CanvasContext */
|
|
1206
1260
|
/** Creates a new CanvasContext (WebGPU only) */
|
|
1207
1261
|
/** Call after rendering a frame (necessary e.g. on WebGL OffscreenCanvas) */
|
|
1208
1262
|
// Resource creation
|
|
1209
1263
|
/** Create a buffer */
|
|
1210
|
-
createBuffer(props) {
|
|
1211
|
-
if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) {
|
|
1212
|
-
return this._createBuffer({
|
|
1213
|
-
data: props
|
|
1214
|
-
});
|
|
1215
|
-
}
|
|
1216
|
-
if ((props.usage || 0) & Buffer2.INDEX && !props.indexType) {
|
|
1217
|
-
if (props.data instanceof Uint32Array) {
|
|
1218
|
-
props.indexType = "uint32";
|
|
1219
|
-
} else if (props.data instanceof Uint16Array) {
|
|
1220
|
-
props.indexType = "uint16";
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
return this._createBuffer(props);
|
|
1224
|
-
}
|
|
1225
1264
|
/** Create a texture */
|
|
1226
1265
|
createTexture(props) {
|
|
1227
1266
|
if (props instanceof Promise || typeof props === "string") {
|
|
@@ -1236,9 +1275,31 @@ var __exports__ = (() => {
|
|
|
1236
1275
|
/** Create a shader */
|
|
1237
1276
|
/** Create a render pipeline (aka program) */
|
|
1238
1277
|
/** Create a compute pipeline (aka program) */
|
|
1278
|
+
createCommandEncoder(props = {}) {
|
|
1279
|
+
throw new Error("not implemented");
|
|
1280
|
+
}
|
|
1239
1281
|
/** Create a RenderPass */
|
|
1240
1282
|
/** Create a ComputePass */
|
|
1241
|
-
|
|
1283
|
+
/** Get a renderpass that is set up to render to the primary CanvasContext */
|
|
1284
|
+
// Resource creation helpers
|
|
1285
|
+
_getBufferProps(props) {
|
|
1286
|
+
if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) {
|
|
1287
|
+
return {
|
|
1288
|
+
data: props
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
const newProps = {
|
|
1292
|
+
...props
|
|
1293
|
+
};
|
|
1294
|
+
if ((props.usage || 0) & Buffer2.INDEX && !props.indexType) {
|
|
1295
|
+
if (props.data instanceof Uint32Array) {
|
|
1296
|
+
props.indexType = "uint32";
|
|
1297
|
+
} else if (props.data instanceof Uint16Array) {
|
|
1298
|
+
props.indexType = "uint16";
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
return newProps;
|
|
1302
|
+
}
|
|
1242
1303
|
};
|
|
1243
1304
|
__publicField(Device, "VERSION", VERSION2);
|
|
1244
1305
|
|
|
@@ -1326,13 +1387,15 @@ var __exports__ = (() => {
|
|
|
1326
1387
|
if (typeof OffscreenCanvas !== "undefined" && this.canvas instanceof OffscreenCanvas) {
|
|
1327
1388
|
return 1;
|
|
1328
1389
|
}
|
|
1329
|
-
|
|
1330
|
-
|
|
1390
|
+
useDevicePixels = useDevicePixels === void 0 ? this.props.useDevicePixels : useDevicePixels;
|
|
1391
|
+
if (!useDevicePixels || useDevicePixels <= 0) {
|
|
1392
|
+
return 1;
|
|
1331
1393
|
}
|
|
1332
|
-
if (
|
|
1333
|
-
|
|
1394
|
+
if (useDevicePixels === true) {
|
|
1395
|
+
const dpr = typeof window !== "undefined" && window.devicePixelRatio;
|
|
1396
|
+
return dpr || 1;
|
|
1334
1397
|
}
|
|
1335
|
-
return useDevicePixels
|
|
1398
|
+
return useDevicePixels;
|
|
1336
1399
|
}
|
|
1337
1400
|
/**
|
|
1338
1401
|
* Returns the size of drawing buffer in device pixels.
|
|
@@ -1525,8 +1588,8 @@ var __exports__ = (() => {
|
|
|
1525
1588
|
data: null,
|
|
1526
1589
|
dimension: "2d",
|
|
1527
1590
|
format: "rgba8unorm",
|
|
1528
|
-
|
|
1529
|
-
|
|
1591
|
+
width: void 0,
|
|
1592
|
+
height: void 0,
|
|
1530
1593
|
depth: 1,
|
|
1531
1594
|
mipmaps: true,
|
|
1532
1595
|
sampler: {},
|
|
@@ -1534,20 +1597,28 @@ var __exports__ = (() => {
|
|
|
1534
1597
|
compressed: false,
|
|
1535
1598
|
// mipLevels: 1,
|
|
1536
1599
|
usage: 0,
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
border: 0,
|
|
1541
|
-
recreate: false
|
|
1600
|
+
mipLevels: void 0,
|
|
1601
|
+
samples: void 0,
|
|
1602
|
+
type: void 0
|
|
1542
1603
|
};
|
|
1543
1604
|
var Texture = class extends Resource {
|
|
1544
1605
|
get [Symbol.toStringTag]() {
|
|
1545
1606
|
return "Texture";
|
|
1546
1607
|
}
|
|
1547
|
-
|
|
1548
|
-
|
|
1608
|
+
/** dimension of this texture */
|
|
1609
|
+
/** format of this texture */
|
|
1610
|
+
/** width in pixels of this texture */
|
|
1611
|
+
/** height in pixels of this texture */
|
|
1612
|
+
/** depth of this texture */
|
|
1613
|
+
/** Default sampler for this texture */
|
|
1614
|
+
constructor(device, props, defaultProps = DEFAULT_TEXTURE_PROPS) {
|
|
1615
|
+
super(device, props, defaultProps);
|
|
1616
|
+
this.dimension = this.props.dimension;
|
|
1617
|
+
this.format = this.props.format;
|
|
1618
|
+
this.width = this.props.width;
|
|
1619
|
+
this.height = this.props.height;
|
|
1620
|
+
this.depth = this.props.depth;
|
|
1549
1621
|
}
|
|
1550
|
-
/** Default sampler for this device */
|
|
1551
1622
|
};
|
|
1552
1623
|
__publicField(Texture, "COPY_SRC", 1);
|
|
1553
1624
|
__publicField(Texture, "COPY_DST", 2);
|
|
@@ -1616,6 +1687,10 @@ var __exports__ = (() => {
|
|
|
1616
1687
|
}
|
|
1617
1688
|
/** Width of all attachments in this framebuffer */
|
|
1618
1689
|
/** Height of all attachments in this framebuffer */
|
|
1690
|
+
/** Color attachments */
|
|
1691
|
+
colorAttachments = [];
|
|
1692
|
+
/** Depth-stencil attachment, if provided */
|
|
1693
|
+
depthStencilAttachment = null;
|
|
1619
1694
|
constructor(device, props = {}) {
|
|
1620
1695
|
super(device, props, DEFAULT_FRAMEBUFFER_PROPS);
|
|
1621
1696
|
this.width = this.props.width;
|
|
@@ -1626,16 +1701,162 @@ var __exports__ = (() => {
|
|
|
1626
1701
|
* @note resize() destroys existing textures (if size has changed).
|
|
1627
1702
|
*/
|
|
1628
1703
|
resize(size) {
|
|
1629
|
-
|
|
1704
|
+
let updateSize = !size;
|
|
1630
1705
|
if (size) {
|
|
1631
|
-
|
|
1632
|
-
this.height
|
|
1706
|
+
const [width, height] = Array.isArray(size) ? size : [size.width, size.height];
|
|
1707
|
+
updateSize = updateSize || height !== this.height || width !== this.width;
|
|
1708
|
+
this.width = width;
|
|
1709
|
+
this.height = height;
|
|
1633
1710
|
}
|
|
1634
1711
|
if (updateSize) {
|
|
1635
|
-
|
|
1712
|
+
log.log(2, `Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)();
|
|
1713
|
+
this.resizeAttachments(this.width, this.height);
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
// /** Returns fully populated attachment object. */
|
|
1717
|
+
// protected normalizeColorAttachment(
|
|
1718
|
+
// attachment: Texture | ColorTextureFormat
|
|
1719
|
+
// ): Required<ColorAttachment> {
|
|
1720
|
+
// const COLOR_ATTACHMENT_DEFAULTS: Required<ColorAttachment> = {
|
|
1721
|
+
// texture: undefined!,
|
|
1722
|
+
// format: undefined!,
|
|
1723
|
+
// clearValue: [0.0, 0.0, 0.0, 0.0],
|
|
1724
|
+
// loadOp: 'clear',
|
|
1725
|
+
// storeOp: 'store'
|
|
1726
|
+
// };
|
|
1727
|
+
// if (attachment instanceof Texture) {
|
|
1728
|
+
// return {...COLOR_ATTACHMENT_DEFAULTS, texture: attachment};
|
|
1729
|
+
// }
|
|
1730
|
+
// if (typeof attachment === 'string') {
|
|
1731
|
+
// return {...COLOR_ATTACHMENT_DEFAULTS, format: attachment};
|
|
1732
|
+
// }
|
|
1733
|
+
// return {...COLOR_ATTACHMENT_DEFAULTS, ...attachment};
|
|
1734
|
+
// }
|
|
1735
|
+
// /** Wraps texture inside fully populated attachment object. */
|
|
1736
|
+
// protected normalizeDepthStencilAttachment(
|
|
1737
|
+
// attachment: DepthStencilAttachment | Texture | DepthStencilTextureFormat
|
|
1738
|
+
// ): Required<DepthStencilAttachment> {
|
|
1739
|
+
// const DEPTH_STENCIL_ATTACHMENT_DEFAULTS: Required<DepthStencilAttachment> = {
|
|
1740
|
+
// texture: undefined!,
|
|
1741
|
+
// format: undefined!,
|
|
1742
|
+
// depthClearValue: 1.0,
|
|
1743
|
+
// depthLoadOp: 'clear',
|
|
1744
|
+
// depthStoreOp: 'store',
|
|
1745
|
+
// depthReadOnly: false,
|
|
1746
|
+
// stencilClearValue: 0,
|
|
1747
|
+
// stencilLoadOp: 'clear',
|
|
1748
|
+
// stencilStoreOp: 'store',
|
|
1749
|
+
// stencilReadOnly: false
|
|
1750
|
+
// };
|
|
1751
|
+
// if (typeof attachment === 'string') {
|
|
1752
|
+
// return {...DEPTH_STENCIL_ATTACHMENT_DEFAULTS, format: attachment};
|
|
1753
|
+
// }
|
|
1754
|
+
// // @ts-expect-error attachment instanceof Texture doesn't cover Renderbuffer
|
|
1755
|
+
// if (attachment.handle || attachment instanceof Texture) {
|
|
1756
|
+
// return {...DEPTH_STENCIL_ATTACHMENT_DEFAULTS, texture: attachment as Texture};
|
|
1757
|
+
// }
|
|
1758
|
+
// return {...DEPTH_STENCIL_ATTACHMENT_DEFAULTS, ...attachment};
|
|
1759
|
+
// }
|
|
1760
|
+
/** Auto creates any textures */
|
|
1761
|
+
autoCreateAttachmentTextures() {
|
|
1762
|
+
this.colorAttachments = this.props.colorAttachments.map((attachment) => {
|
|
1763
|
+
if (typeof attachment === "string") {
|
|
1764
|
+
const texture = this.createColorTexture(attachment);
|
|
1765
|
+
this.attachResource(texture);
|
|
1766
|
+
return texture;
|
|
1767
|
+
}
|
|
1768
|
+
return attachment;
|
|
1769
|
+
});
|
|
1770
|
+
if (this.props.depthStencilAttachment) {
|
|
1771
|
+
if (typeof this.props.depthStencilAttachment === "string") {
|
|
1772
|
+
const texture = this.createDepthStencilTexture(this.props.depthStencilAttachment);
|
|
1773
|
+
this.attachResource(texture);
|
|
1774
|
+
this.depthStencilAttachment = texture;
|
|
1775
|
+
} else {
|
|
1776
|
+
this.depthStencilAttachment = this.props.depthStencilAttachment;
|
|
1777
|
+
}
|
|
1636
1778
|
}
|
|
1637
1779
|
}
|
|
1638
|
-
/**
|
|
1780
|
+
/** Create a color texture */
|
|
1781
|
+
createColorTexture(format) {
|
|
1782
|
+
return this.device.createTexture({
|
|
1783
|
+
id: "color-attachment",
|
|
1784
|
+
usage: Texture.RENDER_ATTACHMENT,
|
|
1785
|
+
format,
|
|
1786
|
+
width: this.width,
|
|
1787
|
+
height: this.height
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
/** Create depth stencil texture */
|
|
1791
|
+
createDepthStencilTexture(format) {
|
|
1792
|
+
return this.device.createTexture({
|
|
1793
|
+
id: "depth-stencil-attachment",
|
|
1794
|
+
usage: Texture.RENDER_ATTACHMENT,
|
|
1795
|
+
format,
|
|
1796
|
+
width: this.width,
|
|
1797
|
+
height: this.height
|
|
1798
|
+
});
|
|
1799
|
+
}
|
|
1800
|
+
/**
|
|
1801
|
+
* Default implementation of resize
|
|
1802
|
+
* Creates new textures with correct size for all attachments.
|
|
1803
|
+
* and destroys existing textures if owned
|
|
1804
|
+
*/
|
|
1805
|
+
resizeAttachments(width, height) {
|
|
1806
|
+
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
1807
|
+
if (this.colorAttachments[i]) {
|
|
1808
|
+
const resizedTexture = this.device._createTexture({
|
|
1809
|
+
...this.colorAttachments[i].props,
|
|
1810
|
+
width,
|
|
1811
|
+
height
|
|
1812
|
+
});
|
|
1813
|
+
this.destroyAttachedResource(this.colorAttachments[i]);
|
|
1814
|
+
this.colorAttachments[i] = resizedTexture;
|
|
1815
|
+
this.attachResource(resizedTexture);
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
if (this.depthStencilAttachment) {
|
|
1819
|
+
const resizedTexture = this.device._createTexture({
|
|
1820
|
+
...this.depthStencilAttachment.props,
|
|
1821
|
+
width,
|
|
1822
|
+
height
|
|
1823
|
+
});
|
|
1824
|
+
this.destroyAttachedResource(this.depthStencilAttachment);
|
|
1825
|
+
this.depthStencilAttachment = resizedTexture;
|
|
1826
|
+
this.attachResource(resizedTexture);
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
/** Create a color attachment for WebGL *
|
|
1830
|
+
protected override createColorTexture(colorAttachment: Required<ColorAttachment>): Required<ColorAttachment> {
|
|
1831
|
+
return this.device._createTexture({
|
|
1832
|
+
id: `${this.id}-color`,
|
|
1833
|
+
data: null, // reserves texture memory, but texels are undefined
|
|
1834
|
+
format,
|
|
1835
|
+
// type: GL.UNSIGNED_BYTE,
|
|
1836
|
+
width: this.width,
|
|
1837
|
+
height: this.height,
|
|
1838
|
+
// Note: Mipmapping can be disabled by texture resource when we resize the texture
|
|
1839
|
+
// to a non-power-of-two dimenstion (NPOT texture) under WebGL1. To have consistant
|
|
1840
|
+
// behavior we always disable mipmaps.
|
|
1841
|
+
mipmaps: false,
|
|
1842
|
+
// Set MIN and MAG filtering parameters so mipmaps are not used in sampling.
|
|
1843
|
+
// Use LINEAR so subpixel algos like fxaa work.
|
|
1844
|
+
// Set WRAP modes that support NPOT textures too.
|
|
1845
|
+
sampler: {
|
|
1846
|
+
minFilter: 'linear',
|
|
1847
|
+
magFilter: 'linear',
|
|
1848
|
+
addressModeU: 'clamp-to-edge',
|
|
1849
|
+
addressModeV: 'clamp-to-edge'
|
|
1850
|
+
}
|
|
1851
|
+
// parameters: {
|
|
1852
|
+
// [GL.TEXTURE_MIN_FILTER]: GL.LINEAR,
|
|
1853
|
+
// [GL.TEXTURE_MAG_FILTER]: GL.LINEAR,
|
|
1854
|
+
// [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
|
|
1855
|
+
// [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE
|
|
1856
|
+
// }
|
|
1857
|
+
});
|
|
1858
|
+
}
|
|
1859
|
+
*/
|
|
1639
1860
|
};
|
|
1640
1861
|
|
|
1641
1862
|
// ../api/src/adapter/resources/render-pipeline.ts
|
|
@@ -1679,49 +1900,15 @@ var __exports__ = (() => {
|
|
|
1679
1900
|
/** Private "export" for Model class */
|
|
1680
1901
|
__publicField(RenderPipeline, "_DEFAULT_PROPS", DEFAULT_RENDER_PIPELINE_PROPS);
|
|
1681
1902
|
|
|
1682
|
-
// ../api/src/adapter/resources/command-encoder.ts
|
|
1683
|
-
var DEFAULT_COMMAND_ENCODER_PROPS = {
|
|
1684
|
-
...DEFAULT_RESOURCE_PROPS
|
|
1685
|
-
};
|
|
1686
|
-
var CommandEncoder = class extends Resource {
|
|
1687
|
-
get [Symbol.toStringTag]() {
|
|
1688
|
-
return "CommandEncoder";
|
|
1689
|
-
}
|
|
1690
|
-
constructor(props) {
|
|
1691
|
-
super(props, DEFAULT_COMMAND_ENCODER_PROPS);
|
|
1692
|
-
}
|
|
1693
|
-
// beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
|
|
1694
|
-
// beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
|
|
1695
|
-
// finish(options?: {id?: string}): GPUCommandBuffer;
|
|
1696
|
-
pushDebugGroup(groupLabel) {
|
|
1697
|
-
}
|
|
1698
|
-
popDebugGroup() {
|
|
1699
|
-
}
|
|
1700
|
-
insertDebugMarker(markerLabel) {
|
|
1701
|
-
}
|
|
1702
|
-
// writeTimestamp(querySet: Query, queryIndex: number): void;
|
|
1703
|
-
// resolveQuerySet(options: {
|
|
1704
|
-
// querySet: GPUQuerySet,
|
|
1705
|
-
// firstQuery: number,
|
|
1706
|
-
// queryCount: number,
|
|
1707
|
-
// destination: Buffer,
|
|
1708
|
-
// destinationOffset?: number;
|
|
1709
|
-
// }): void;
|
|
1710
|
-
};
|
|
1711
|
-
|
|
1712
1903
|
// ../api/src/adapter/resources/render-pass.ts
|
|
1713
|
-
var
|
|
1714
|
-
...DEFAULT_RESOURCE_PROPS,
|
|
1715
|
-
framebuffer: null,
|
|
1716
|
-
parameters: null
|
|
1717
|
-
};
|
|
1718
|
-
var RenderPass = class extends Resource {
|
|
1904
|
+
var _RenderPass = class extends Resource {
|
|
1719
1905
|
get [Symbol.toStringTag]() {
|
|
1720
1906
|
return "RenderPass";
|
|
1721
1907
|
}
|
|
1722
1908
|
constructor(device, props) {
|
|
1723
|
-
super(device, props,
|
|
1909
|
+
super(device, props, _RenderPass.defaultProps);
|
|
1724
1910
|
}
|
|
1911
|
+
/** A small set of parameters can be changed between every draw call (viewport, scissorRect, blendColor, stencilReference) */
|
|
1725
1912
|
// writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
|
|
1726
1913
|
// beginOcclusionQuery(queryIndex: number): void;
|
|
1727
1914
|
// endOcclusionQuery(): void;
|
|
@@ -1752,6 +1939,63 @@ var __exports__ = (() => {
|
|
|
1752
1939
|
drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
|
|
1753
1940
|
*/
|
|
1754
1941
|
};
|
|
1942
|
+
var RenderPass = _RenderPass;
|
|
1943
|
+
/** Default properties for RenderPass */
|
|
1944
|
+
__publicField(RenderPass, "defaultProps", {
|
|
1945
|
+
...Resource.defaultProps,
|
|
1946
|
+
framebuffer: null,
|
|
1947
|
+
parameters: void 0,
|
|
1948
|
+
clearColor: [0, 0, 0, 0],
|
|
1949
|
+
clearDepth: 1,
|
|
1950
|
+
clearStencil: 0,
|
|
1951
|
+
depthReadOnly: false,
|
|
1952
|
+
stencilReadOnly: false,
|
|
1953
|
+
discard: false
|
|
1954
|
+
});
|
|
1955
|
+
|
|
1956
|
+
// ../api/src/adapter/resources/command-encoder.ts
|
|
1957
|
+
var DEFAULT_COMMAND_ENCODER_PROPS = {
|
|
1958
|
+
...DEFAULT_RESOURCE_PROPS
|
|
1959
|
+
};
|
|
1960
|
+
var CommandEncoder = class extends Resource {
|
|
1961
|
+
get [Symbol.toStringTag]() {
|
|
1962
|
+
return "CommandEncoder";
|
|
1963
|
+
}
|
|
1964
|
+
constructor(props) {
|
|
1965
|
+
super(props, DEFAULT_COMMAND_ENCODER_PROPS);
|
|
1966
|
+
}
|
|
1967
|
+
// TODO - return the CommandBuffer?
|
|
1968
|
+
// beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
|
|
1969
|
+
// beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
|
|
1970
|
+
// finish(options?: {id?: string}): GPUCommandBuffer;
|
|
1971
|
+
pushDebugGroup(groupLabel) {
|
|
1972
|
+
}
|
|
1973
|
+
popDebugGroup() {
|
|
1974
|
+
}
|
|
1975
|
+
insertDebugMarker(markerLabel) {
|
|
1976
|
+
}
|
|
1977
|
+
// writeTimestamp(querySet: Query, queryIndex: number): void;
|
|
1978
|
+
// resolveQuerySet(options: {
|
|
1979
|
+
// querySet: GPUQuerySet,
|
|
1980
|
+
// firstQuery: number,
|
|
1981
|
+
// queryCount: number,
|
|
1982
|
+
// destination: Buffer,
|
|
1983
|
+
// destinationOffset?: number;
|
|
1984
|
+
// }): void;
|
|
1985
|
+
};
|
|
1986
|
+
|
|
1987
|
+
// ../api/src/adapter/resources/command-buffer.ts
|
|
1988
|
+
var DEFAULT_COMMAND_ENCODER_PROPS2 = {
|
|
1989
|
+
...DEFAULT_RESOURCE_PROPS
|
|
1990
|
+
};
|
|
1991
|
+
var CommandBuffer = class extends Resource {
|
|
1992
|
+
get [Symbol.toStringTag]() {
|
|
1993
|
+
return "CommandBuffer";
|
|
1994
|
+
}
|
|
1995
|
+
constructor(props) {
|
|
1996
|
+
super(props, DEFAULT_COMMAND_ENCODER_PROPS2);
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1755
1999
|
|
|
1756
2000
|
// ../api/src/lib/utils/assert.ts
|
|
1757
2001
|
function assert2(condition, message2) {
|
|
@@ -1840,7 +2084,130 @@ var __exports__ = (() => {
|
|
|
1840
2084
|
};
|
|
1841
2085
|
}
|
|
1842
2086
|
}
|
|
1843
|
-
|
|
2087
|
+
return decodeNonStandardFormat(format);
|
|
2088
|
+
}
|
|
2089
|
+
var EXCEPTIONS = {
|
|
2090
|
+
// Packed 16 bit formats
|
|
2091
|
+
"rgba4unorm-webgl": {
|
|
2092
|
+
format: "rgba",
|
|
2093
|
+
bpp: 2
|
|
2094
|
+
},
|
|
2095
|
+
"rgb565unorm-webgl": {
|
|
2096
|
+
format: "rgb",
|
|
2097
|
+
bpp: 2
|
|
2098
|
+
},
|
|
2099
|
+
"rgb5a1unorm-webgl": {
|
|
2100
|
+
format: "rgba",
|
|
2101
|
+
bbp: 2
|
|
2102
|
+
},
|
|
2103
|
+
// Packed 32 bit formats
|
|
2104
|
+
"rgb9e5ufloat": {
|
|
2105
|
+
format: "rgb",
|
|
2106
|
+
bbp: 4
|
|
2107
|
+
},
|
|
2108
|
+
"rg11b10ufloat": {
|
|
2109
|
+
format: "rgb",
|
|
2110
|
+
bbp: 4
|
|
2111
|
+
},
|
|
2112
|
+
"rgb10a2unorm": {
|
|
2113
|
+
format: "rgba",
|
|
2114
|
+
bbp: 4
|
|
2115
|
+
},
|
|
2116
|
+
"rgb10a2unorm-webgl": {
|
|
2117
|
+
format: "rgba",
|
|
2118
|
+
bbp: 4
|
|
2119
|
+
},
|
|
2120
|
+
// Depth/stencil
|
|
2121
|
+
"stencil8": {
|
|
2122
|
+
components: 1,
|
|
2123
|
+
bpp: 1,
|
|
2124
|
+
a: "stencil"
|
|
2125
|
+
},
|
|
2126
|
+
"depth16unorm": {
|
|
2127
|
+
components: 1,
|
|
2128
|
+
bpp: 2,
|
|
2129
|
+
a: "depth"
|
|
2130
|
+
},
|
|
2131
|
+
"depth24plus": {
|
|
2132
|
+
components: 1,
|
|
2133
|
+
bpp: 3,
|
|
2134
|
+
a: "depth"
|
|
2135
|
+
},
|
|
2136
|
+
"depth32float": {
|
|
2137
|
+
components: 1,
|
|
2138
|
+
bpp: 4,
|
|
2139
|
+
a: "depth"
|
|
2140
|
+
},
|
|
2141
|
+
"depth24plus-stencil8": {
|
|
2142
|
+
components: 2,
|
|
2143
|
+
bpp: 4,
|
|
2144
|
+
a: "depth-stencil"
|
|
2145
|
+
},
|
|
2146
|
+
// "depth24unorm-stencil8" feature
|
|
2147
|
+
"depth24unorm-stencil8": {
|
|
2148
|
+
components: 2,
|
|
2149
|
+
bpp: 4,
|
|
2150
|
+
a: "depth-stencil"
|
|
2151
|
+
},
|
|
2152
|
+
// "depth32float-stencil8" feature
|
|
2153
|
+
"depth32float-stencil8": {
|
|
2154
|
+
components: 2,
|
|
2155
|
+
bpp: 4,
|
|
2156
|
+
a: "depth-stencil"
|
|
2157
|
+
}
|
|
2158
|
+
};
|
|
2159
|
+
function decodeNonStandardFormat(format) {
|
|
2160
|
+
const data = EXCEPTIONS[format];
|
|
2161
|
+
if (!data) {
|
|
2162
|
+
throw new Error(`Unknown format ${format}`);
|
|
2163
|
+
}
|
|
2164
|
+
return {
|
|
2165
|
+
format: data.format || "",
|
|
2166
|
+
components: data.components || 1,
|
|
2167
|
+
byteLength: data.bpp || 1,
|
|
2168
|
+
srgb: false,
|
|
2169
|
+
unsized: false
|
|
2170
|
+
};
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
// ../api/src/lib/compiler-log/format-compiler-log.ts
|
|
2174
|
+
function formatCompilerLog(shaderLog, source, options) {
|
|
2175
|
+
const lines = source.split(/\r?\n/);
|
|
2176
|
+
let formattedLog = "";
|
|
2177
|
+
for (const message2 of shaderLog) {
|
|
2178
|
+
formattedLog += formatCompilerMessage(message2, lines, message2.lineNum, options);
|
|
2179
|
+
}
|
|
2180
|
+
return formattedLog;
|
|
2181
|
+
}
|
|
2182
|
+
function formatCompilerMessage(message2, lines, lineNum, options) {
|
|
2183
|
+
if (options?.showSourceCode) {
|
|
2184
|
+
const positionIndicator = message2.linePos > 0 ? `${" ".repeat(message2.linePos + 5)}^^^
|
|
2185
|
+
` : "";
|
|
2186
|
+
const numberedLines = getNumberedLines(lines, lineNum);
|
|
2187
|
+
return `${numberedLines}${positionIndicator}${message2.type.toUpperCase()}: ${message2.message}
|
|
2188
|
+
|
|
2189
|
+
`;
|
|
2190
|
+
}
|
|
2191
|
+
return `${message2.type.toUpperCase()}: ${message2.message}
|
|
2192
|
+
`;
|
|
2193
|
+
}
|
|
2194
|
+
function getNumberedLines(lines, lineNum) {
|
|
2195
|
+
let numberedLines = "";
|
|
2196
|
+
for (let line = lineNum - 2; line <= lineNum; line++) {
|
|
2197
|
+
const sourceLine = lines[line];
|
|
2198
|
+
if (sourceLine !== void 0) {
|
|
2199
|
+
numberedLines += `${padLeft(String(line), 4)}: ${sourceLine}
|
|
2200
|
+
`;
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
return numberedLines;
|
|
2204
|
+
}
|
|
2205
|
+
function padLeft(string, paddedLength) {
|
|
2206
|
+
let result = "";
|
|
2207
|
+
for (let i = string.length; i < paddedLength; ++i) {
|
|
2208
|
+
result += " ";
|
|
2209
|
+
}
|
|
2210
|
+
return result + string;
|
|
1844
2211
|
}
|
|
1845
2212
|
|
|
1846
2213
|
// ../api/src/lib/utils/cast.ts
|
|
@@ -1921,51 +2288,11 @@ var __exports__ = (() => {
|
|
|
1921
2288
|
if (scriptId) {
|
|
1922
2289
|
script.id = scriptId;
|
|
1923
2290
|
}
|
|
1924
|
-
return new Promise((resolve, reject) => {
|
|
1925
|
-
script.onload = resolve;
|
|
1926
|
-
script.onerror = (error2) => reject(new Error(`Unable to load script '${scriptUrl}': ${error2}`));
|
|
1927
|
-
head.appendChild(script);
|
|
1928
|
-
});
|
|
1929
|
-
}
|
|
1930
|
-
|
|
1931
|
-
// ../api/src/lib/compiler-log/format-compiler-log.ts
|
|
1932
|
-
function formatCompilerLog(shaderLog, source, options) {
|
|
1933
|
-
const lines = source.split(/\r?\n/);
|
|
1934
|
-
let formattedLog = "";
|
|
1935
|
-
for (const message2 of shaderLog) {
|
|
1936
|
-
formattedLog += formatCompilerMessage(message2, lines, message2.lineNum, options);
|
|
1937
|
-
}
|
|
1938
|
-
return formattedLog;
|
|
1939
|
-
}
|
|
1940
|
-
function formatCompilerMessage(message2, lines, lineNum, options) {
|
|
1941
|
-
if (options?.showSourceCode) {
|
|
1942
|
-
const positionIndicator = message2.linePos > 0 ? `${" ".repeat(message2.linePos + 5)}^^^
|
|
1943
|
-
` : "";
|
|
1944
|
-
const numberedLines = getNumberedLines(lines, lineNum);
|
|
1945
|
-
return `${numberedLines}${positionIndicator}${message2.type.toUpperCase()}: ${message2.message}
|
|
1946
|
-
|
|
1947
|
-
`;
|
|
1948
|
-
}
|
|
1949
|
-
return `${message2.type.toUpperCase()}: ${message2.message}
|
|
1950
|
-
`;
|
|
1951
|
-
}
|
|
1952
|
-
function getNumberedLines(lines, lineNum) {
|
|
1953
|
-
let numberedLines = "";
|
|
1954
|
-
for (let line = lineNum - 2; line <= lineNum; line++) {
|
|
1955
|
-
const sourceLine = lines[line];
|
|
1956
|
-
if (sourceLine !== void 0) {
|
|
1957
|
-
numberedLines += `${padLeft(String(line), 4)}: ${sourceLine}
|
|
1958
|
-
`;
|
|
1959
|
-
}
|
|
1960
|
-
}
|
|
1961
|
-
return numberedLines;
|
|
1962
|
-
}
|
|
1963
|
-
function padLeft(string, paddedLength) {
|
|
1964
|
-
let result = "";
|
|
1965
|
-
for (let i = string.length; i < paddedLength; ++i) {
|
|
1966
|
-
result += " ";
|
|
1967
|
-
}
|
|
1968
|
-
return result + string;
|
|
2291
|
+
return new Promise((resolve, reject) => {
|
|
2292
|
+
script.onload = resolve;
|
|
2293
|
+
script.onerror = (error2) => reject(new Error(`Unable to load script '${scriptUrl}': ${error2}`));
|
|
2294
|
+
head.appendChild(script);
|
|
2295
|
+
});
|
|
1969
2296
|
}
|
|
1970
2297
|
|
|
1971
2298
|
// src/context/polyfill/polyfill-vertex-array-object.ts
|
|
@@ -2403,13 +2730,13 @@ var __exports__ = (() => {
|
|
|
2403
2730
|
GL2[GL2["SHADING_LANGUAGE_VERSION"] = 35724] = "SHADING_LANGUAGE_VERSION";
|
|
2404
2731
|
GL2[GL2["CURRENT_PROGRAM"] = 35725] = "CURRENT_PROGRAM";
|
|
2405
2732
|
GL2[GL2["NEVER"] = 512] = "NEVER";
|
|
2406
|
-
GL2[GL2["ALWAYS"] = 519] = "ALWAYS";
|
|
2407
2733
|
GL2[GL2["LESS"] = 513] = "LESS";
|
|
2408
2734
|
GL2[GL2["EQUAL"] = 514] = "EQUAL";
|
|
2409
2735
|
GL2[GL2["LEQUAL"] = 515] = "LEQUAL";
|
|
2410
2736
|
GL2[GL2["GREATER"] = 516] = "GREATER";
|
|
2411
|
-
GL2[GL2["GEQUAL"] = 518] = "GEQUAL";
|
|
2412
2737
|
GL2[GL2["NOTEQUAL"] = 517] = "NOTEQUAL";
|
|
2738
|
+
GL2[GL2["GEQUAL"] = 518] = "GEQUAL";
|
|
2739
|
+
GL2[GL2["ALWAYS"] = 519] = "ALWAYS";
|
|
2413
2740
|
GL2[GL2["KEEP"] = 7680] = "KEEP";
|
|
2414
2741
|
GL2[GL2["REPLACE"] = 7681] = "REPLACE";
|
|
2415
2742
|
GL2[GL2["INCR"] = 7682] = "INCR";
|
|
@@ -4162,7 +4489,8 @@ var __exports__ = (() => {
|
|
|
4162
4489
|
"r8unorm": {
|
|
4163
4490
|
gl: GL.R8,
|
|
4164
4491
|
b: 1,
|
|
4165
|
-
c: 1
|
|
4492
|
+
c: 1,
|
|
4493
|
+
renderbuffer: true
|
|
4166
4494
|
},
|
|
4167
4495
|
"r8snorm": {
|
|
4168
4496
|
gl: GL.R8_SNORM,
|
|
@@ -4172,18 +4500,21 @@ var __exports__ = (() => {
|
|
|
4172
4500
|
"r8uint": {
|
|
4173
4501
|
gl: GL.R8UI,
|
|
4174
4502
|
b: 1,
|
|
4175
|
-
c: 1
|
|
4503
|
+
c: 1,
|
|
4504
|
+
renderbuffer: true
|
|
4176
4505
|
},
|
|
4177
4506
|
"r8sint": {
|
|
4178
4507
|
gl: GL.R8I,
|
|
4179
4508
|
b: 1,
|
|
4180
|
-
c: 1
|
|
4509
|
+
c: 1,
|
|
4510
|
+
renderbuffer: true
|
|
4181
4511
|
},
|
|
4182
4512
|
// 16-bit formats
|
|
4183
4513
|
"rg8unorm": {
|
|
4184
4514
|
gl: GL.RG8,
|
|
4185
4515
|
b: 2,
|
|
4186
|
-
c: 2
|
|
4516
|
+
c: 2,
|
|
4517
|
+
renderbuffer: true
|
|
4187
4518
|
},
|
|
4188
4519
|
"rg8snorm": {
|
|
4189
4520
|
gl: GL.RG8_SNORM,
|
|
@@ -4193,69 +4524,80 @@ var __exports__ = (() => {
|
|
|
4193
4524
|
"rg8uint": {
|
|
4194
4525
|
gl: GL.RG8UI,
|
|
4195
4526
|
b: 2,
|
|
4196
|
-
c: 2
|
|
4527
|
+
c: 2,
|
|
4528
|
+
renderbuffer: true
|
|
4197
4529
|
},
|
|
4198
4530
|
"rg8sint": {
|
|
4199
4531
|
gl: GL.RG8I,
|
|
4200
4532
|
b: 2,
|
|
4201
|
-
c: 2
|
|
4533
|
+
c: 2,
|
|
4534
|
+
renderbuffer: true
|
|
4202
4535
|
},
|
|
4203
4536
|
"r16uint": {
|
|
4204
4537
|
gl: GL.R16UI,
|
|
4205
4538
|
b: 2,
|
|
4206
|
-
c: 1
|
|
4539
|
+
c: 1,
|
|
4540
|
+
renderbuffer: true
|
|
4207
4541
|
},
|
|
4208
4542
|
"r16sint": {
|
|
4209
4543
|
gl: GL.R16I,
|
|
4210
4544
|
b: 2,
|
|
4211
|
-
c: 1
|
|
4545
|
+
c: 1,
|
|
4546
|
+
renderbuffer: true
|
|
4212
4547
|
},
|
|
4213
4548
|
"r16float": {
|
|
4214
4549
|
gl: GL.R16F,
|
|
4215
4550
|
b: 2,
|
|
4216
4551
|
c: 1,
|
|
4217
4552
|
render: "texture-renderable-float16-webgl",
|
|
4218
|
-
filter: "texture-filter-linear-float16-webgl"
|
|
4553
|
+
filter: "texture-filter-linear-float16-webgl",
|
|
4554
|
+
renderbuffer: true
|
|
4219
4555
|
},
|
|
4220
4556
|
"r16unorm-webgl": {
|
|
4221
4557
|
gl: GL.R16_EXT,
|
|
4222
4558
|
b: 2,
|
|
4223
4559
|
c: 1,
|
|
4224
|
-
f: "texture-formats-norm16-webgl"
|
|
4560
|
+
f: "texture-formats-norm16-webgl",
|
|
4561
|
+
renderbuffer: true,
|
|
4562
|
+
x: EXT_TEXTURE_NORM16
|
|
4225
4563
|
},
|
|
4226
4564
|
"r16snorm-webgl": {
|
|
4227
4565
|
gl: GL.R16_SNORM_EXT,
|
|
4228
4566
|
b: 2,
|
|
4229
4567
|
c: 1,
|
|
4230
|
-
f: "texture-formats-norm16-webgl"
|
|
4568
|
+
f: "texture-formats-norm16-webgl",
|
|
4569
|
+
x: EXT_TEXTURE_NORM16
|
|
4231
4570
|
},
|
|
4232
4571
|
// Packed 16-bit formats
|
|
4233
4572
|
"rgba4unorm-webgl": {
|
|
4234
4573
|
gl: GL.RGBA4,
|
|
4235
4574
|
b: 2,
|
|
4236
4575
|
c: 4,
|
|
4237
|
-
wgpu: false
|
|
4576
|
+
wgpu: false,
|
|
4577
|
+
renderbuffer: true
|
|
4238
4578
|
},
|
|
4239
4579
|
"rgb565unorm-webgl": {
|
|
4240
4580
|
gl: GL.RGB565,
|
|
4241
4581
|
b: 2,
|
|
4242
4582
|
c: 4,
|
|
4243
|
-
wgpu: false
|
|
4583
|
+
wgpu: false,
|
|
4584
|
+
renderbuffer: true
|
|
4244
4585
|
},
|
|
4245
4586
|
"rgb5a1unorm-webgl": {
|
|
4246
4587
|
gl: GL.RGB5_A1,
|
|
4247
4588
|
b: 2,
|
|
4248
4589
|
c: 4,
|
|
4249
|
-
wgpu: false
|
|
4590
|
+
wgpu: false,
|
|
4591
|
+
renderbuffer: true
|
|
4250
4592
|
},
|
|
4251
4593
|
// 24-bit formats
|
|
4252
|
-
"
|
|
4594
|
+
"rgb8unorm-webgl": {
|
|
4253
4595
|
gl: GL.RGB8,
|
|
4254
4596
|
b: 3,
|
|
4255
4597
|
c: 3,
|
|
4256
4598
|
wgpu: false
|
|
4257
4599
|
},
|
|
4258
|
-
"
|
|
4600
|
+
"rgb8snorm-webgl": {
|
|
4259
4601
|
gl: GL.RGB8_SNORM,
|
|
4260
4602
|
b: 3,
|
|
4261
4603
|
c: 3,
|
|
@@ -4322,31 +4664,36 @@ var __exports__ = (() => {
|
|
|
4322
4664
|
b: 4,
|
|
4323
4665
|
c: 2,
|
|
4324
4666
|
render: "texture-renderable-float16-webgl",
|
|
4325
|
-
filter: "texture-filter-linear-float16-webgl"
|
|
4667
|
+
filter: "texture-filter-linear-float16-webgl",
|
|
4668
|
+
renderbuffer: true
|
|
4326
4669
|
},
|
|
4327
4670
|
"rg16unorm-webgl": {
|
|
4328
4671
|
gl: GL.RG16_EXT,
|
|
4329
4672
|
b: 2,
|
|
4330
4673
|
c: 2,
|
|
4331
|
-
f: "texture-formats-norm16-webgl"
|
|
4674
|
+
f: "texture-formats-norm16-webgl",
|
|
4675
|
+
x: EXT_TEXTURE_NORM16
|
|
4332
4676
|
},
|
|
4333
4677
|
"rg16snorm-webgl": {
|
|
4334
4678
|
gl: GL.RG16_SNORM_EXT,
|
|
4335
4679
|
b: 2,
|
|
4336
4680
|
c: 2,
|
|
4337
|
-
f: "texture-formats-norm16-webgl"
|
|
4681
|
+
f: "texture-formats-norm16-webgl",
|
|
4682
|
+
x: EXT_TEXTURE_NORM16
|
|
4338
4683
|
},
|
|
4339
4684
|
"r32uint": {
|
|
4340
4685
|
gl: GL.R32UI,
|
|
4341
4686
|
b: 4,
|
|
4342
4687
|
c: 1,
|
|
4343
|
-
bpp: 4
|
|
4688
|
+
bpp: 4,
|
|
4689
|
+
renderbuffer: true
|
|
4344
4690
|
},
|
|
4345
4691
|
"r32sint": {
|
|
4346
4692
|
gl: GL.R32I,
|
|
4347
4693
|
b: 4,
|
|
4348
4694
|
c: 1,
|
|
4349
|
-
bpp: 4
|
|
4695
|
+
bpp: 4,
|
|
4696
|
+
renderbuffer: true
|
|
4350
4697
|
},
|
|
4351
4698
|
"r32float": {
|
|
4352
4699
|
gl: GL.R32F,
|
|
@@ -4370,13 +4717,15 @@ var __exports__ = (() => {
|
|
|
4370
4717
|
b: 4,
|
|
4371
4718
|
c: 3,
|
|
4372
4719
|
p: 1,
|
|
4373
|
-
render: "texture-renderable-float32-webgl"
|
|
4720
|
+
render: "texture-renderable-float32-webgl",
|
|
4721
|
+
renderbuffer: true
|
|
4374
4722
|
},
|
|
4375
4723
|
"rgb10a2unorm": {
|
|
4376
4724
|
gl: GL.RGB10_A2,
|
|
4377
4725
|
b: 4,
|
|
4378
4726
|
c: 4,
|
|
4379
|
-
p: 1
|
|
4727
|
+
p: 1,
|
|
4728
|
+
renderbuffer: true
|
|
4380
4729
|
},
|
|
4381
4730
|
// webgl2 only
|
|
4382
4731
|
"rgb10a2unorm-webgl": {
|
|
@@ -4385,48 +4734,56 @@ var __exports__ = (() => {
|
|
|
4385
4734
|
gl: GL.RGB10_A2UI,
|
|
4386
4735
|
p: 1,
|
|
4387
4736
|
wgpu: false,
|
|
4388
|
-
bpp: 4
|
|
4737
|
+
bpp: 4,
|
|
4738
|
+
renderbuffer: true
|
|
4389
4739
|
},
|
|
4390
4740
|
// 48-bit formats
|
|
4391
4741
|
"rgb16unorm-webgl": {
|
|
4392
4742
|
gl: GL.RGB16_EXT,
|
|
4393
4743
|
b: 2,
|
|
4394
4744
|
c: 3,
|
|
4395
|
-
f: "texture-formats-norm16-webgl"
|
|
4745
|
+
f: "texture-formats-norm16-webgl",
|
|
4746
|
+
x: EXT_TEXTURE_NORM16
|
|
4396
4747
|
},
|
|
4397
4748
|
"rgb16snorm-webgl": {
|
|
4398
4749
|
gl: GL.RGB16_SNORM_EXT,
|
|
4399
4750
|
b: 2,
|
|
4400
4751
|
c: 3,
|
|
4401
|
-
f: "texture-formats-norm16-webgl"
|
|
4752
|
+
f: "texture-formats-norm16-webgl",
|
|
4753
|
+
x: EXT_TEXTURE_NORM16
|
|
4402
4754
|
},
|
|
4403
4755
|
// 64-bit formats
|
|
4404
4756
|
"rg32uint": {
|
|
4405
4757
|
gl: GL.RG32UI,
|
|
4406
4758
|
b: 8,
|
|
4407
|
-
c: 2
|
|
4759
|
+
c: 2,
|
|
4760
|
+
renderbuffer: true
|
|
4408
4761
|
},
|
|
4409
4762
|
"rg32sint": {
|
|
4410
4763
|
gl: GL.RG32I,
|
|
4411
4764
|
b: 8,
|
|
4412
|
-
c: 2
|
|
4765
|
+
c: 2,
|
|
4766
|
+
renderbuffer: true
|
|
4413
4767
|
},
|
|
4414
4768
|
"rg32float": {
|
|
4415
4769
|
gl: GL.RG32F,
|
|
4416
4770
|
b: 8,
|
|
4417
4771
|
c: 2,
|
|
4418
4772
|
render: "texture-renderable-float32-webgl",
|
|
4419
|
-
filter: "texture-filter-linear-float32-webgl"
|
|
4773
|
+
filter: "texture-filter-linear-float32-webgl",
|
|
4774
|
+
renderbuffer: true
|
|
4420
4775
|
},
|
|
4421
4776
|
"rgba16uint": {
|
|
4422
4777
|
gl: GL.RGBA16UI,
|
|
4423
4778
|
b: 8,
|
|
4424
|
-
c: 4
|
|
4779
|
+
c: 4,
|
|
4780
|
+
renderbuffer: true
|
|
4425
4781
|
},
|
|
4426
4782
|
"rgba16sint": {
|
|
4427
4783
|
gl: GL.RGBA16I,
|
|
4428
4784
|
b: 8,
|
|
4429
|
-
c: 4
|
|
4785
|
+
c: 4,
|
|
4786
|
+
renderbuffer: true
|
|
4430
4787
|
},
|
|
4431
4788
|
"rgba16float": {
|
|
4432
4789
|
gl: GL.RGBA16F,
|
|
@@ -4440,13 +4797,16 @@ var __exports__ = (() => {
|
|
|
4440
4797
|
gl: GL.RGBA16_EXT,
|
|
4441
4798
|
b: 2,
|
|
4442
4799
|
c: 4,
|
|
4443
|
-
f: "texture-formats-norm16-webgl"
|
|
4800
|
+
f: "texture-formats-norm16-webgl",
|
|
4801
|
+
renderbuffer: true,
|
|
4802
|
+
x: EXT_TEXTURE_NORM16
|
|
4444
4803
|
},
|
|
4445
4804
|
"rgba16snorm-webgl": {
|
|
4446
4805
|
gl: GL.RGBA16_SNORM_EXT,
|
|
4447
4806
|
b: 2,
|
|
4448
4807
|
c: 4,
|
|
4449
|
-
f: "texture-formats-norm16-webgl"
|
|
4808
|
+
f: "texture-formats-norm16-webgl",
|
|
4809
|
+
x: EXT_TEXTURE_NORM16
|
|
4450
4810
|
},
|
|
4451
4811
|
// 96-bit formats (deprecated!)
|
|
4452
4812
|
"rgb32float-webgl": {
|
|
@@ -4464,27 +4824,31 @@ var __exports__ = (() => {
|
|
|
4464
4824
|
"rgba32uint": {
|
|
4465
4825
|
gl: GL.RGBA32UI,
|
|
4466
4826
|
b: 16,
|
|
4467
|
-
c: 4
|
|
4827
|
+
c: 4,
|
|
4828
|
+
renderbuffer: true
|
|
4468
4829
|
},
|
|
4469
4830
|
"rgba32sint": {
|
|
4470
4831
|
gl: GL.RGBA32I,
|
|
4471
4832
|
b: 16,
|
|
4472
|
-
c: 4
|
|
4833
|
+
c: 4,
|
|
4834
|
+
renderbuffer: true
|
|
4473
4835
|
},
|
|
4474
4836
|
"rgba32float": {
|
|
4475
4837
|
gl: GL.RGBA32F,
|
|
4476
|
-
gl1: GL.RGBA,
|
|
4477
4838
|
b: 16,
|
|
4478
4839
|
c: 4,
|
|
4479
4840
|
render: "texture-renderable-float32-webgl",
|
|
4480
|
-
filter: "texture-filter-linear-float32-webgl"
|
|
4841
|
+
filter: "texture-filter-linear-float32-webgl",
|
|
4842
|
+
renderbuffer: true
|
|
4481
4843
|
},
|
|
4482
4844
|
// Depth and stencil formats
|
|
4483
4845
|
"stencil8": {
|
|
4484
4846
|
gl: GL.STENCIL_INDEX8,
|
|
4847
|
+
gl1: GL.STENCIL_INDEX8,
|
|
4485
4848
|
b: 1,
|
|
4486
4849
|
c: 1,
|
|
4487
|
-
attachment: GL.STENCIL_ATTACHMENT
|
|
4850
|
+
attachment: GL.STENCIL_ATTACHMENT,
|
|
4851
|
+
renderbuffer: true
|
|
4488
4852
|
},
|
|
4489
4853
|
// 8 stencil bits
|
|
4490
4854
|
"depth16unorm": {
|
|
@@ -4492,7 +4856,8 @@ var __exports__ = (() => {
|
|
|
4492
4856
|
gl1: GL.DEPTH_COMPONENT16,
|
|
4493
4857
|
b: 2,
|
|
4494
4858
|
c: 1,
|
|
4495
|
-
attachment: GL.DEPTH_ATTACHMENT
|
|
4859
|
+
attachment: GL.DEPTH_ATTACHMENT,
|
|
4860
|
+
renderbuffer: true
|
|
4496
4861
|
},
|
|
4497
4862
|
// 16 depth bits
|
|
4498
4863
|
"depth24plus": {
|
|
@@ -4505,15 +4870,19 @@ var __exports__ = (() => {
|
|
|
4505
4870
|
gl: GL.DEPTH_COMPONENT32F,
|
|
4506
4871
|
b: 4,
|
|
4507
4872
|
c: 1,
|
|
4508
|
-
attachment: GL.DEPTH_ATTACHMENT
|
|
4873
|
+
attachment: GL.DEPTH_ATTACHMENT,
|
|
4874
|
+
renderbuffer: true
|
|
4509
4875
|
},
|
|
4876
|
+
// The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
|
|
4510
4877
|
"depth24plus-stencil8": {
|
|
4511
|
-
|
|
4512
|
-
gl: GL.UNSIGNED_INT_24_8,
|
|
4878
|
+
gl: GL.DEPTH_STENCIL,
|
|
4513
4879
|
gl1: GL.DEPTH_STENCIL,
|
|
4880
|
+
b: 4,
|
|
4514
4881
|
c: 2,
|
|
4515
4882
|
p: 1,
|
|
4516
|
-
attachment: GL.DEPTH_STENCIL_ATTACHMENT
|
|
4883
|
+
attachment: GL.DEPTH_STENCIL_ATTACHMENT,
|
|
4884
|
+
renderbuffer: true,
|
|
4885
|
+
depthTexture: true
|
|
4517
4886
|
},
|
|
4518
4887
|
// "depth24unorm-stencil8" feature
|
|
4519
4888
|
"depth24unorm-stencil8": {
|
|
@@ -4521,7 +4890,8 @@ var __exports__ = (() => {
|
|
|
4521
4890
|
b: 4,
|
|
4522
4891
|
c: 2,
|
|
4523
4892
|
p: 1,
|
|
4524
|
-
attachment: GL.DEPTH_STENCIL_ATTACHMENT
|
|
4893
|
+
attachment: GL.DEPTH_STENCIL_ATTACHMENT,
|
|
4894
|
+
renderbuffer: true
|
|
4525
4895
|
},
|
|
4526
4896
|
// "depth32float-stencil8" feature
|
|
4527
4897
|
"depth32float-stencil8": {
|
|
@@ -4529,7 +4899,8 @@ var __exports__ = (() => {
|
|
|
4529
4899
|
b: 5,
|
|
4530
4900
|
c: 2,
|
|
4531
4901
|
p: 1,
|
|
4532
|
-
attachment: GL.DEPTH_STENCIL_ATTACHMENT
|
|
4902
|
+
attachment: GL.DEPTH_STENCIL_ATTACHMENT,
|
|
4903
|
+
renderbuffer: true
|
|
4533
4904
|
},
|
|
4534
4905
|
// BC compressed formats: check device.features.has("texture-compression-bc");
|
|
4535
4906
|
"bc1-rgb-unorm-webgl": {
|
|
@@ -4803,18 +5174,33 @@ var __exports__ = (() => {
|
|
|
4803
5174
|
f: texture_compression_atc_webgl
|
|
4804
5175
|
}
|
|
4805
5176
|
};
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
5177
|
+
var DATA_FORMAT_CHANNELS = {
|
|
5178
|
+
[GL.RED]: 1,
|
|
5179
|
+
[GL.RED_INTEGER]: 1,
|
|
5180
|
+
[GL.RG]: 2,
|
|
5181
|
+
[GL.RG_INTEGER]: 2,
|
|
5182
|
+
[GL.RGB]: 3,
|
|
5183
|
+
[GL.RGB_INTEGER]: 3,
|
|
5184
|
+
[GL.RGBA]: 4,
|
|
5185
|
+
[GL.RGBA_INTEGER]: 4,
|
|
5186
|
+
[GL.DEPTH_COMPONENT]: 1,
|
|
5187
|
+
[GL.DEPTH_STENCIL]: 1,
|
|
5188
|
+
[GL.ALPHA]: 1,
|
|
5189
|
+
[GL.LUMINANCE]: 1,
|
|
5190
|
+
[GL.LUMINANCE_ALPHA]: 2
|
|
5191
|
+
};
|
|
5192
|
+
var TYPE_SIZES2 = {
|
|
5193
|
+
[GL.FLOAT]: 4,
|
|
5194
|
+
[GL.UNSIGNED_INT]: 4,
|
|
5195
|
+
[GL.INT]: 4,
|
|
5196
|
+
[GL.UNSIGNED_SHORT]: 2,
|
|
5197
|
+
[GL.SHORT]: 2,
|
|
5198
|
+
[GL.HALF_FLOAT]: 2,
|
|
5199
|
+
[GL.BYTE]: 1,
|
|
5200
|
+
[GL.UNSIGNED_BYTE]: 1
|
|
5201
|
+
};
|
|
4816
5202
|
function isTextureFormatSupported(gl, formatOrGL) {
|
|
4817
|
-
const format =
|
|
5203
|
+
const format = convertGLToTextureFormat(formatOrGL);
|
|
4818
5204
|
const info = TEXTURE_FORMATS[format];
|
|
4819
5205
|
if (!info) {
|
|
4820
5206
|
return false;
|
|
@@ -4828,8 +5214,29 @@ var __exports__ = (() => {
|
|
|
4828
5214
|
}
|
|
4829
5215
|
return true;
|
|
4830
5216
|
}
|
|
5217
|
+
function isRenderbufferFormatSupported(gl, format) {
|
|
5218
|
+
return isTextureFormatSupported(gl, format) && TEXTURE_FORMATS[format]?.renderbuffer;
|
|
5219
|
+
}
|
|
5220
|
+
function convertGLToTextureFormat(format) {
|
|
5221
|
+
if (typeof format === "string") {
|
|
5222
|
+
return format;
|
|
5223
|
+
}
|
|
5224
|
+
const entry = Object.entries(TEXTURE_FORMATS).find(([, entry2]) => entry2.gl === format || entry2.gl1 === format);
|
|
5225
|
+
if (!entry) {
|
|
5226
|
+
throw new Error(`Unknown texture format ${format}`);
|
|
5227
|
+
}
|
|
5228
|
+
return entry[0];
|
|
5229
|
+
}
|
|
5230
|
+
function convertTextureFormatToGL(format, isWebGL23) {
|
|
5231
|
+
const formatInfo = TEXTURE_FORMATS[format];
|
|
5232
|
+
const webglFormat = isWebGL23 ? formatInfo?.gl : formatInfo?.gl1;
|
|
5233
|
+
if (webglFormat === void 0) {
|
|
5234
|
+
throw new Error(`Unsupported texture format ${format}`);
|
|
5235
|
+
}
|
|
5236
|
+
return webglFormat;
|
|
5237
|
+
}
|
|
4831
5238
|
function isTextureFormatFilterable(gl, formatOrGL) {
|
|
4832
|
-
const format =
|
|
5239
|
+
const format = convertGLToTextureFormat(formatOrGL);
|
|
4833
5240
|
if (!isTextureFormatSupported(gl, format)) {
|
|
4834
5241
|
return false;
|
|
4835
5242
|
}
|
|
@@ -4850,7 +5257,7 @@ var __exports__ = (() => {
|
|
|
4850
5257
|
return true;
|
|
4851
5258
|
}
|
|
4852
5259
|
function isTextureFormatRenderable(gl, formatOrGL) {
|
|
4853
|
-
const format =
|
|
5260
|
+
const format = convertGLToTextureFormat(formatOrGL);
|
|
4854
5261
|
if (!isTextureFormatSupported(gl, format)) {
|
|
4855
5262
|
return false;
|
|
4856
5263
|
}
|
|
@@ -4859,21 +5266,9 @@ var __exports__ = (() => {
|
|
|
4859
5266
|
}
|
|
4860
5267
|
return true;
|
|
4861
5268
|
}
|
|
4862
|
-
function
|
|
4863
|
-
const format =
|
|
4864
|
-
const
|
|
4865
|
-
const webglFormat = isWebGL2(gl) ? formatInfo?.gl : formatInfo?.gl1;
|
|
4866
|
-
if (typeof format === "number") {
|
|
4867
|
-
return webglFormat || format;
|
|
4868
|
-
}
|
|
4869
|
-
if (webglFormat === void 0) {
|
|
4870
|
-
throw new Error(`Unsupported texture format ${format}`);
|
|
4871
|
-
}
|
|
4872
|
-
return webglFormat;
|
|
4873
|
-
}
|
|
4874
|
-
function getWebGLTextureParameters(gl, formatOrGL) {
|
|
4875
|
-
const format = getTextureFormat(formatOrGL);
|
|
4876
|
-
const webglFormat = getWebGLTextureFormat(gl, format);
|
|
5269
|
+
function getWebGLTextureParameters(formatOrGL, isWebGL23) {
|
|
5270
|
+
const format = convertGLToTextureFormat(formatOrGL);
|
|
5271
|
+
const webglFormat = convertTextureFormatToGL(format, isWebGL23);
|
|
4877
5272
|
const decoded = decodeTextureFormat(format);
|
|
4878
5273
|
return {
|
|
4879
5274
|
format: webglFormat,
|
|
@@ -4883,17 +5278,12 @@ var __exports__ = (() => {
|
|
|
4883
5278
|
compressed: decoded.compressed
|
|
4884
5279
|
};
|
|
4885
5280
|
}
|
|
4886
|
-
function
|
|
4887
|
-
const format = getTextureFormat(formatOrGL);
|
|
4888
|
-
if (typeof format === "number") {
|
|
4889
|
-
throw new Error("unsupported depth stencil format");
|
|
4890
|
-
}
|
|
5281
|
+
function getDepthStencilAttachmentWebGL(format) {
|
|
4891
5282
|
const info = TEXTURE_FORMATS[format];
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
throw new Error("not a depth stencil format");
|
|
5283
|
+
if (!info?.attachment) {
|
|
5284
|
+
throw new Error(`${format} is not a depth stencil format`);
|
|
4895
5285
|
}
|
|
4896
|
-
return attachment;
|
|
5286
|
+
return info.attachment;
|
|
4897
5287
|
}
|
|
4898
5288
|
function _checkFloat32ColorAttachment(gl, internalFormat = gl.RGBA, srcFormat = GL.RGBA, srcType = GL.UNSIGNED_BYTE) {
|
|
4899
5289
|
let texture = null;
|
|
@@ -4918,34 +5308,9 @@ var __exports__ = (() => {
|
|
|
4918
5308
|
gl.deleteFramebuffer(framebuffer);
|
|
4919
5309
|
}
|
|
4920
5310
|
}
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
[GL.RG]: 2,
|
|
4925
|
-
[GL.RG_INTEGER]: 2,
|
|
4926
|
-
[GL.RGB]: 3,
|
|
4927
|
-
[GL.RGB_INTEGER]: 3,
|
|
4928
|
-
[GL.RGBA]: 4,
|
|
4929
|
-
[GL.RGBA_INTEGER]: 4,
|
|
4930
|
-
[GL.DEPTH_COMPONENT]: 1,
|
|
4931
|
-
[GL.DEPTH_STENCIL]: 1,
|
|
4932
|
-
[GL.ALPHA]: 1,
|
|
4933
|
-
[GL.LUMINANCE]: 1,
|
|
4934
|
-
[GL.LUMINANCE_ALPHA]: 2
|
|
4935
|
-
};
|
|
4936
|
-
var TYPE_SIZES2 = {
|
|
4937
|
-
[GL.FLOAT]: 4,
|
|
4938
|
-
[GL.UNSIGNED_INT]: 4,
|
|
4939
|
-
[GL.INT]: 4,
|
|
4940
|
-
[GL.UNSIGNED_SHORT]: 2,
|
|
4941
|
-
[GL.SHORT]: 2,
|
|
4942
|
-
[GL.HALF_FLOAT]: 2,
|
|
4943
|
-
[GL.BYTE]: 1,
|
|
4944
|
-
[GL.UNSIGNED_BYTE]: 1
|
|
4945
|
-
};
|
|
4946
|
-
function getTextureFormatBytesPerPixel(gl, formatOrGL) {
|
|
4947
|
-
const format = getTextureFormat(formatOrGL);
|
|
4948
|
-
const params = getWebGLTextureParameters(gl, format);
|
|
5311
|
+
function getTextureFormatBytesPerPixel(formatOrGL, isWebGL23) {
|
|
5312
|
+
const format = convertGLToTextureFormat(formatOrGL);
|
|
5313
|
+
const params = getWebGLTextureParameters(format, isWebGL23);
|
|
4949
5314
|
const channels = DATA_FORMAT_CHANNELS[params.dataFormat] || 4;
|
|
4950
5315
|
const channelSize = TYPE_SIZES2[params.type] || 1;
|
|
4951
5316
|
return channels * channelSize;
|
|
@@ -5350,22 +5715,22 @@ void main(void) {}`;
|
|
|
5350
5715
|
}
|
|
5351
5716
|
function convertCompareFunction(parameter, value) {
|
|
5352
5717
|
return map(parameter, value, {
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5718
|
+
never: GL.NEVER,
|
|
5719
|
+
less: GL.LESS,
|
|
5720
|
+
equal: GL.EQUAL,
|
|
5356
5721
|
"less-equal": GL.LEQUAL,
|
|
5357
|
-
|
|
5722
|
+
greater: GL.GREATER,
|
|
5358
5723
|
"not-equal": GL.NOTEQUAL,
|
|
5359
5724
|
"greater-equal": GL.GEQUAL,
|
|
5360
|
-
|
|
5725
|
+
always: GL.ALWAYS
|
|
5361
5726
|
});
|
|
5362
5727
|
}
|
|
5363
5728
|
function convertStencilOperation(parameter, value) {
|
|
5364
5729
|
return map(parameter, value, {
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5730
|
+
keep: GL.KEEP,
|
|
5731
|
+
zero: GL.ZERO,
|
|
5732
|
+
replace: GL.REPLACE,
|
|
5733
|
+
invert: GL.INVERT,
|
|
5369
5734
|
"increment-clamp": GL.INCR,
|
|
5370
5735
|
"decrement-clamp": GL.DECR,
|
|
5371
5736
|
"increment-wrap": GL.INCR_WRAP,
|
|
@@ -5523,16 +5888,17 @@ void main(void) {}`;
|
|
|
5523
5888
|
this.trackDeallocatedMemory();
|
|
5524
5889
|
this.gl.deleteBuffer(this.handle);
|
|
5525
5890
|
this.destroyed = true;
|
|
5891
|
+
this.handle = null;
|
|
5526
5892
|
}
|
|
5527
5893
|
}
|
|
5528
5894
|
write(data, byteOffset = 0) {
|
|
5529
5895
|
const srcOffset = 0;
|
|
5530
|
-
const byteLength =
|
|
5896
|
+
const byteLength = void 0;
|
|
5531
5897
|
const target = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;
|
|
5532
5898
|
this.gl.bindBuffer(target, this.handle);
|
|
5533
5899
|
if (srcOffset !== 0 || byteLength !== void 0) {
|
|
5534
5900
|
this.device.assertWebGL2();
|
|
5535
|
-
this.
|
|
5901
|
+
this.gl2.bufferSubData(target, byteOffset, data, srcOffset, byteLength);
|
|
5536
5902
|
} else {
|
|
5537
5903
|
this.gl.bufferSubData(target, byteOffset, data);
|
|
5538
5904
|
}
|
|
@@ -5622,11 +5988,21 @@ void main(void) {}`;
|
|
|
5622
5988
|
};
|
|
5623
5989
|
|
|
5624
5990
|
// src/adapter/resources/webgl-texture.ts
|
|
5991
|
+
var DEFAULT_WEBGL_TEXTURE_PROPS = {
|
|
5992
|
+
// deprecated
|
|
5993
|
+
parameters: {},
|
|
5994
|
+
pixelStore: {},
|
|
5995
|
+
pixels: null,
|
|
5996
|
+
border: 0,
|
|
5997
|
+
dataFormat: void 0,
|
|
5998
|
+
textureUnit: void 0,
|
|
5999
|
+
target: void 0
|
|
6000
|
+
};
|
|
5625
6001
|
var _WEBGLTexture = class extends Texture {
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
6002
|
+
/** Sampler object (currently unused) */
|
|
6003
|
+
sampler = void 0;
|
|
6004
|
+
// data;
|
|
6005
|
+
glFormat = void 0;
|
|
5630
6006
|
type = void 0;
|
|
5631
6007
|
dataFormat = void 0;
|
|
5632
6008
|
mipmaps = void 0;
|
|
@@ -5640,8 +6016,6 @@ void main(void) {}`;
|
|
|
5640
6016
|
* attempting to bind it as GL_TEXTURE_3D will give rise to a run-time error
|
|
5641
6017
|
* */
|
|
5642
6018
|
textureUnit = void 0;
|
|
5643
|
-
/** Sampler object (currently unused) */
|
|
5644
|
-
sampler = void 0;
|
|
5645
6019
|
/**
|
|
5646
6020
|
* Program.draw() checks the loaded flag of all textures to avoid
|
|
5647
6021
|
* Textures that are still loading from promises
|
|
@@ -5650,7 +6024,8 @@ void main(void) {}`;
|
|
|
5650
6024
|
loaded = false;
|
|
5651
6025
|
constructor(device, props) {
|
|
5652
6026
|
super(device, {
|
|
5653
|
-
|
|
6027
|
+
...DEFAULT_WEBGL_TEXTURE_PROPS,
|
|
6028
|
+
format: "rgba8unorm",
|
|
5654
6029
|
...props
|
|
5655
6030
|
});
|
|
5656
6031
|
this.device = cast(device);
|
|
@@ -5661,6 +6036,7 @@ void main(void) {}`;
|
|
|
5661
6036
|
...this.props,
|
|
5662
6037
|
data: typeof this.props.data
|
|
5663
6038
|
});
|
|
6039
|
+
this.glFormat = GL.RGBA;
|
|
5664
6040
|
this.target = getWebGLTextureTarget(this.props);
|
|
5665
6041
|
this.loaded = false;
|
|
5666
6042
|
if (typeof this.props?.data === "string") {
|
|
@@ -5706,7 +6082,6 @@ void main(void) {}`;
|
|
|
5706
6082
|
} = props;
|
|
5707
6083
|
const {
|
|
5708
6084
|
pixels = null,
|
|
5709
|
-
recreate = false,
|
|
5710
6085
|
pixelStore = {},
|
|
5711
6086
|
textureUnit = void 0
|
|
5712
6087
|
} = props;
|
|
@@ -5724,6 +6099,7 @@ void main(void) {}`;
|
|
|
5724
6099
|
const {
|
|
5725
6100
|
depth = 0
|
|
5726
6101
|
} = props;
|
|
6102
|
+
const glFormat = convertTextureFormatToGL(props.format, this.device.isWebGL2);
|
|
5727
6103
|
({
|
|
5728
6104
|
width,
|
|
5729
6105
|
height,
|
|
@@ -5739,11 +6115,9 @@ void main(void) {}`;
|
|
|
5739
6115
|
width,
|
|
5740
6116
|
height
|
|
5741
6117
|
}));
|
|
5742
|
-
const format = getWebGLTextureFormat(this.gl, props.format);
|
|
5743
6118
|
this.width = width;
|
|
5744
6119
|
this.height = height;
|
|
5745
|
-
this.
|
|
5746
|
-
this.format = format;
|
|
6120
|
+
this.glFormat = glFormat;
|
|
5747
6121
|
this.type = type;
|
|
5748
6122
|
this.dataFormat = dataFormat;
|
|
5749
6123
|
this.textureUnit = textureUnit;
|
|
@@ -5761,7 +6135,7 @@ void main(void) {}`;
|
|
|
5761
6135
|
width,
|
|
5762
6136
|
height,
|
|
5763
6137
|
depth,
|
|
5764
|
-
format,
|
|
6138
|
+
format: glFormat,
|
|
5765
6139
|
type,
|
|
5766
6140
|
dataFormat,
|
|
5767
6141
|
// @ts-expect-error
|
|
@@ -5773,9 +6147,6 @@ void main(void) {}`;
|
|
|
5773
6147
|
if (mipmaps) {
|
|
5774
6148
|
this.generateMipmap();
|
|
5775
6149
|
}
|
|
5776
|
-
if (recreate) {
|
|
5777
|
-
this.data = data;
|
|
5778
|
-
}
|
|
5779
6150
|
if (isVideo) {
|
|
5780
6151
|
this._video = {
|
|
5781
6152
|
video: data,
|
|
@@ -5893,7 +6264,7 @@ void main(void) {}`;
|
|
|
5893
6264
|
*/
|
|
5894
6265
|
// eslint-disable-next-line max-statements, complexity
|
|
5895
6266
|
setImageData(options) {
|
|
5896
|
-
if (this.props.dimension === "3d") {
|
|
6267
|
+
if (this.props.dimension === "3d" || this.props.dimension === "2d-array") {
|
|
5897
6268
|
return this.setImageData3D(options);
|
|
5898
6269
|
}
|
|
5899
6270
|
this.trackDeallocatedMemory("Texture");
|
|
@@ -5901,7 +6272,7 @@ void main(void) {}`;
|
|
|
5901
6272
|
target = this.target,
|
|
5902
6273
|
pixels = null,
|
|
5903
6274
|
level = 0,
|
|
5904
|
-
|
|
6275
|
+
glFormat = this.glFormat,
|
|
5905
6276
|
offset = 0,
|
|
5906
6277
|
parameters = {}
|
|
5907
6278
|
} = options;
|
|
@@ -5947,13 +6318,13 @@ void main(void) {}`;
|
|
|
5947
6318
|
withParameters(this.gl, parameters, () => {
|
|
5948
6319
|
switch (dataType) {
|
|
5949
6320
|
case "null":
|
|
5950
|
-
gl.texImage2D(target, level,
|
|
6321
|
+
gl.texImage2D(target, level, glFormat, width, height, 0, dataFormat, type, data);
|
|
5951
6322
|
break;
|
|
5952
6323
|
case "typed-array":
|
|
5953
6324
|
gl.texImage2D(
|
|
5954
6325
|
target,
|
|
5955
6326
|
level,
|
|
5956
|
-
|
|
6327
|
+
glFormat,
|
|
5957
6328
|
width,
|
|
5958
6329
|
height,
|
|
5959
6330
|
0,
|
|
@@ -5968,14 +6339,14 @@ void main(void) {}`;
|
|
|
5968
6339
|
case "buffer":
|
|
5969
6340
|
gl2 = this.device.assertWebGL2();
|
|
5970
6341
|
gl2.bindBuffer(GL.PIXEL_UNPACK_BUFFER, data.handle || data);
|
|
5971
|
-
gl2.texImage2D(target, level,
|
|
6342
|
+
gl2.texImage2D(target, level, glFormat, width, height, 0, dataFormat, type, offset);
|
|
5972
6343
|
gl2.bindBuffer(GL.PIXEL_UNPACK_BUFFER, null);
|
|
5973
6344
|
break;
|
|
5974
6345
|
case "browser-object":
|
|
5975
6346
|
if (this.device.isWebGL2) {
|
|
5976
|
-
gl.texImage2D(target, level,
|
|
6347
|
+
gl.texImage2D(target, level, glFormat, width, height, 0, dataFormat, type, data);
|
|
5977
6348
|
} else {
|
|
5978
|
-
gl.texImage2D(target, level,
|
|
6349
|
+
gl.texImage2D(target, level, glFormat, dataFormat, type, data);
|
|
5979
6350
|
}
|
|
5980
6351
|
break;
|
|
5981
6352
|
case "compressed":
|
|
@@ -5990,7 +6361,7 @@ void main(void) {}`;
|
|
|
5990
6361
|
if (data && data.byteLength) {
|
|
5991
6362
|
this.trackAllocatedMemory(data.byteLength, "Texture");
|
|
5992
6363
|
} else {
|
|
5993
|
-
const bytesPerPixel = getTextureFormatBytesPerPixel(this.
|
|
6364
|
+
const bytesPerPixel = getTextureFormatBytesPerPixel(this.props.format, this.device.isWebGL2);
|
|
5994
6365
|
this.trackAllocatedMemory(this.width * this.height * bytesPerPixel, "Texture");
|
|
5995
6366
|
}
|
|
5996
6367
|
this.loaded = true;
|
|
@@ -6010,7 +6381,7 @@ void main(void) {}`;
|
|
|
6010
6381
|
width = this.width,
|
|
6011
6382
|
height = this.height,
|
|
6012
6383
|
level = 0,
|
|
6013
|
-
|
|
6384
|
+
glFormat = this.glFormat,
|
|
6014
6385
|
type = this.type,
|
|
6015
6386
|
dataFormat = this.dataFormat,
|
|
6016
6387
|
compressed = false,
|
|
@@ -6048,7 +6419,7 @@ void main(void) {}`;
|
|
|
6048
6419
|
this.gl.bindTexture(this.target, this.handle);
|
|
6049
6420
|
withParameters(this.gl, parameters, () => {
|
|
6050
6421
|
if (compressed) {
|
|
6051
|
-
this.gl.compressedTexSubImage2D(target, level, x, y, width, height,
|
|
6422
|
+
this.gl.compressedTexSubImage2D(target, level, x, y, width, height, glFormat, data);
|
|
6052
6423
|
} else if (data === null) {
|
|
6053
6424
|
this.gl.texSubImage2D(target, level, x, y, width, height, dataFormat, type, null);
|
|
6054
6425
|
} else if (ArrayBuffer.isView(data)) {
|
|
@@ -6157,7 +6528,7 @@ void main(void) {}`;
|
|
|
6157
6528
|
type,
|
|
6158
6529
|
compressed
|
|
6159
6530
|
} = opts;
|
|
6160
|
-
const parameters = getWebGLTextureParameters(this.
|
|
6531
|
+
const parameters = getWebGLTextureParameters(format, this.device.isWebGL2);
|
|
6161
6532
|
dataFormat = dataFormat || parameters.dataFormat;
|
|
6162
6533
|
type = type || parameters.type;
|
|
6163
6534
|
compressed = compressed || parameters.compressed;
|
|
@@ -6300,7 +6671,7 @@ void main(void) {}`;
|
|
|
6300
6671
|
} = options;
|
|
6301
6672
|
this.trackDeallocatedMemory("Texture");
|
|
6302
6673
|
this.gl.bindTexture(this.target, this.handle);
|
|
6303
|
-
const webglTextureFormat = getWebGLTextureParameters(this.
|
|
6674
|
+
const webglTextureFormat = getWebGLTextureParameters(format, this.device.isWebGL2);
|
|
6304
6675
|
withParameters(this.gl, parameters, () => {
|
|
6305
6676
|
if (ArrayBuffer.isView(data)) {
|
|
6306
6677
|
this.gl.texImage3D(
|
|
@@ -6325,7 +6696,7 @@ void main(void) {}`;
|
|
|
6325
6696
|
if (data && data.byteLength) {
|
|
6326
6697
|
this.trackAllocatedMemory(data.byteLength, "Texture");
|
|
6327
6698
|
} else {
|
|
6328
|
-
const bytesPerPixel = getTextureFormatBytesPerPixel(this.
|
|
6699
|
+
const bytesPerPixel = getTextureFormatBytesPerPixel(this.props.format, this.device.isWebGL2);
|
|
6329
6700
|
this.trackAllocatedMemory(this.width * this.height * this.depth * bytesPerPixel, "Texture");
|
|
6330
6701
|
}
|
|
6331
6702
|
this.loaded = true;
|
|
@@ -6424,16 +6795,6 @@ void main(void) {}`;
|
|
|
6424
6795
|
assert2(value !== void 0, `Accessing undefined constant GL.${name}`);
|
|
6425
6796
|
return value;
|
|
6426
6797
|
}
|
|
6427
|
-
function getKey(gl, value) {
|
|
6428
|
-
gl = gl.gl || gl;
|
|
6429
|
-
value = Number(value);
|
|
6430
|
-
for (const key in gl) {
|
|
6431
|
-
if (gl[key] === value) {
|
|
6432
|
-
return `GL.${key}`;
|
|
6433
|
-
}
|
|
6434
|
-
}
|
|
6435
|
-
return String(value);
|
|
6436
|
-
}
|
|
6437
6798
|
|
|
6438
6799
|
// src/adapter/objects/webgl-resource.ts
|
|
6439
6800
|
var ERR_RESOURCE_METHOD_UNDEFINED = "Resource subclass must define virtual methods";
|
|
@@ -6464,9 +6825,6 @@ void main(void) {}`;
|
|
|
6464
6825
|
get handle() {
|
|
6465
6826
|
return this._handle;
|
|
6466
6827
|
}
|
|
6467
|
-
destroy() {
|
|
6468
|
-
this.delete();
|
|
6469
|
-
}
|
|
6470
6828
|
delete({
|
|
6471
6829
|
deleteChildren = false
|
|
6472
6830
|
} = {}) {
|
|
@@ -6476,7 +6834,7 @@ void main(void) {}`;
|
|
|
6476
6834
|
}
|
|
6477
6835
|
this._handle = null;
|
|
6478
6836
|
if (children && deleteChildren) {
|
|
6479
|
-
children.filter(Boolean).forEach((child) => child.
|
|
6837
|
+
children.filter(Boolean).forEach((child) => child.destroy());
|
|
6480
6838
|
}
|
|
6481
6839
|
return this;
|
|
6482
6840
|
}
|
|
@@ -6539,10 +6897,10 @@ void main(void) {}`;
|
|
|
6539
6897
|
const parameter = PARAMETERS[pname];
|
|
6540
6898
|
const parameterAvailable = parameter && (!("webgl2" in parameter) || isWebgl2) && (!("extension" in parameter) || this.gl.getExtension(parameter.extension));
|
|
6541
6899
|
if (parameterAvailable) {
|
|
6542
|
-
const key = keys ?
|
|
6900
|
+
const key = keys ? this.device.getGLKey(pname) : pname;
|
|
6543
6901
|
values[key] = this.getParameter(pname, options);
|
|
6544
6902
|
if (keys && parameter.type === "GLenum") {
|
|
6545
|
-
values[key] =
|
|
6903
|
+
values[key] = this.device.getGLKey(values[key]);
|
|
6546
6904
|
}
|
|
6547
6905
|
}
|
|
6548
6906
|
}
|
|
@@ -6640,204 +6998,8 @@ void main(void) {}`;
|
|
|
6640
6998
|
*/
|
|
6641
6999
|
};
|
|
6642
7000
|
|
|
6643
|
-
// src/adapter/converters/renderbuffer-formats.ts
|
|
6644
|
-
function isRenderbufferFormatSupported(gl, format) {
|
|
6645
|
-
const info = RENDERBUFFER_FORMATS[format];
|
|
6646
|
-
if (!info) {
|
|
6647
|
-
return false;
|
|
6648
|
-
}
|
|
6649
|
-
if (info.ext) {
|
|
6650
|
-
return Boolean(gl.getExtension(info.ext));
|
|
6651
|
-
}
|
|
6652
|
-
if (info.gl2) {
|
|
6653
|
-
return isWebGL2(gl);
|
|
6654
|
-
}
|
|
6655
|
-
return true;
|
|
6656
|
-
}
|
|
6657
|
-
function getRenderbufferFormatBytesPerPixel(format) {
|
|
6658
|
-
return RENDERBUFFER_FORMATS[format].bpp;
|
|
6659
|
-
}
|
|
6660
|
-
var EXT_FLOAT_WEBGL2 = "EXT_color_buffer_float";
|
|
6661
|
-
var RENDERBUFFER_FORMATS = {
|
|
6662
|
-
[GL.DEPTH_COMPONENT16]: {
|
|
6663
|
-
bpp: 2
|
|
6664
|
-
},
|
|
6665
|
-
// 16 depth bits.
|
|
6666
|
-
[GL.DEPTH_COMPONENT24]: {
|
|
6667
|
-
gl2: true,
|
|
6668
|
-
bpp: 3
|
|
6669
|
-
},
|
|
6670
|
-
[GL.DEPTH_COMPONENT32F]: {
|
|
6671
|
-
gl2: true,
|
|
6672
|
-
bpp: 4
|
|
6673
|
-
},
|
|
6674
|
-
[GL.STENCIL_INDEX8]: {
|
|
6675
|
-
bpp: 1
|
|
6676
|
-
},
|
|
6677
|
-
// 8 stencil bits.
|
|
6678
|
-
[GL.DEPTH_STENCIL]: {
|
|
6679
|
-
bpp: 4
|
|
6680
|
-
},
|
|
6681
|
-
[GL.DEPTH24_STENCIL8]: {
|
|
6682
|
-
gl2: true,
|
|
6683
|
-
bpp: 4
|
|
6684
|
-
},
|
|
6685
|
-
[GL.DEPTH32F_STENCIL8]: {
|
|
6686
|
-
gl2: true,
|
|
6687
|
-
bpp: 5
|
|
6688
|
-
},
|
|
6689
|
-
// When using a WebGL 1 context, color renderbuffer formats are limited
|
|
6690
|
-
[GL.RGBA4]: {
|
|
6691
|
-
bpp: 2
|
|
6692
|
-
},
|
|
6693
|
-
[GL.RGB565]: {
|
|
6694
|
-
bpp: 2
|
|
6695
|
-
},
|
|
6696
|
-
[GL.RGB5_A1]: {
|
|
6697
|
-
bpp: 2
|
|
6698
|
-
},
|
|
6699
|
-
// When using a WebGL 2 context, the following values are available additionally:
|
|
6700
|
-
[GL.R8]: {
|
|
6701
|
-
gl2: true,
|
|
6702
|
-
bpp: 1
|
|
6703
|
-
},
|
|
6704
|
-
[GL.R8UI]: {
|
|
6705
|
-
gl2: true,
|
|
6706
|
-
bpp: 1
|
|
6707
|
-
},
|
|
6708
|
-
[GL.R8I]: {
|
|
6709
|
-
gl2: true,
|
|
6710
|
-
bpp: 1
|
|
6711
|
-
},
|
|
6712
|
-
[GL.R16UI]: {
|
|
6713
|
-
gl2: true,
|
|
6714
|
-
bpp: 2
|
|
6715
|
-
},
|
|
6716
|
-
[GL.R16I]: {
|
|
6717
|
-
gl2: true,
|
|
6718
|
-
bpp: 2
|
|
6719
|
-
},
|
|
6720
|
-
[GL.R32UI]: {
|
|
6721
|
-
gl2: true,
|
|
6722
|
-
bpp: 4
|
|
6723
|
-
},
|
|
6724
|
-
[GL.R32I]: {
|
|
6725
|
-
gl2: true,
|
|
6726
|
-
bpp: 4
|
|
6727
|
-
},
|
|
6728
|
-
[GL.RG8]: {
|
|
6729
|
-
gl2: true,
|
|
6730
|
-
bpp: 2
|
|
6731
|
-
},
|
|
6732
|
-
[GL.RG8UI]: {
|
|
6733
|
-
gl2: true,
|
|
6734
|
-
bpp: 2
|
|
6735
|
-
},
|
|
6736
|
-
[GL.RG8I]: {
|
|
6737
|
-
gl2: true,
|
|
6738
|
-
bpp: 2
|
|
6739
|
-
},
|
|
6740
|
-
[GL.RG16UI]: {
|
|
6741
|
-
gl2: true,
|
|
6742
|
-
bpp: 4
|
|
6743
|
-
},
|
|
6744
|
-
[GL.RG16I]: {
|
|
6745
|
-
gl2: true,
|
|
6746
|
-
bpp: 4
|
|
6747
|
-
},
|
|
6748
|
-
[GL.RG32UI]: {
|
|
6749
|
-
gl2: true,
|
|
6750
|
-
bpp: 8
|
|
6751
|
-
},
|
|
6752
|
-
[GL.RG32I]: {
|
|
6753
|
-
gl2: true,
|
|
6754
|
-
bpp: 8
|
|
6755
|
-
},
|
|
6756
|
-
[GL.RGB8]: {
|
|
6757
|
-
gl2: true,
|
|
6758
|
-
bpp: 3
|
|
6759
|
-
},
|
|
6760
|
-
[GL.RGBA8]: {
|
|
6761
|
-
gl2: true,
|
|
6762
|
-
bpp: 4
|
|
6763
|
-
},
|
|
6764
|
-
// [GL.SRGB8_ALPHA8]: {gl2: true, gl1: SRGB}, // When using the EXT_sRGB WebGL1 extension
|
|
6765
|
-
[GL.RGB10_A2]: {
|
|
6766
|
-
gl2: true,
|
|
6767
|
-
bpp: 4
|
|
6768
|
-
},
|
|
6769
|
-
[GL.RGBA8UI]: {
|
|
6770
|
-
gl2: true,
|
|
6771
|
-
bpp: 4
|
|
6772
|
-
},
|
|
6773
|
-
[GL.RGBA8I]: {
|
|
6774
|
-
gl2: true,
|
|
6775
|
-
bpp: 4
|
|
6776
|
-
},
|
|
6777
|
-
[GL.RGB10_A2UI]: {
|
|
6778
|
-
gl2: true,
|
|
6779
|
-
bpp: 4
|
|
6780
|
-
},
|
|
6781
|
-
[GL.RGBA16UI]: {
|
|
6782
|
-
gl2: true,
|
|
6783
|
-
bpp: 8
|
|
6784
|
-
},
|
|
6785
|
-
[GL.RGBA16I]: {
|
|
6786
|
-
gl2: true,
|
|
6787
|
-
bpp: 8
|
|
6788
|
-
},
|
|
6789
|
-
[GL.RGBA32I]: {
|
|
6790
|
-
gl2: true,
|
|
6791
|
-
bpp: 16
|
|
6792
|
-
},
|
|
6793
|
-
[GL.RGBA32UI]: {
|
|
6794
|
-
gl2: true,
|
|
6795
|
-
bpp: 16
|
|
6796
|
-
},
|
|
6797
|
-
// When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
|
|
6798
|
-
[GL.R16F]: {
|
|
6799
|
-
ext: EXT_FLOAT_WEBGL2,
|
|
6800
|
-
bpp: 2
|
|
6801
|
-
},
|
|
6802
|
-
[GL.RG16F]: {
|
|
6803
|
-
ext: EXT_FLOAT_WEBGL2,
|
|
6804
|
-
bpp: 4
|
|
6805
|
-
},
|
|
6806
|
-
[GL.RGBA16F]: {
|
|
6807
|
-
ext: EXT_FLOAT_WEBGL2,
|
|
6808
|
-
bpp: 8
|
|
6809
|
-
},
|
|
6810
|
-
[GL.R32F]: {
|
|
6811
|
-
ext: EXT_FLOAT_WEBGL2,
|
|
6812
|
-
bpp: 4
|
|
6813
|
-
},
|
|
6814
|
-
[GL.RG32F]: {
|
|
6815
|
-
ext: EXT_FLOAT_WEBGL2,
|
|
6816
|
-
bpp: 8
|
|
6817
|
-
},
|
|
6818
|
-
// TODO - can't get WEBGL_color_buffer_float to work on renderbuffers
|
|
6819
|
-
[GL.RGBA32F]: {
|
|
6820
|
-
ext: EXT_FLOAT_WEBGL2,
|
|
6821
|
-
bpp: 16
|
|
6822
|
-
},
|
|
6823
|
-
// [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2, gl1: EXT_FLOAT_WEBGL1},
|
|
6824
|
-
[GL.R11F_G11F_B10F]: {
|
|
6825
|
-
ext: EXT_FLOAT_WEBGL2,
|
|
6826
|
-
bpp: 4
|
|
6827
|
-
}
|
|
6828
|
-
};
|
|
6829
|
-
|
|
6830
7001
|
// src/adapter/objects/webgl-renderbuffer.ts
|
|
6831
|
-
var
|
|
6832
|
-
id: void 0,
|
|
6833
|
-
handle: void 0,
|
|
6834
|
-
userData: void 0,
|
|
6835
|
-
format: 0,
|
|
6836
|
-
width: 1,
|
|
6837
|
-
height: 1,
|
|
6838
|
-
samples: 0
|
|
6839
|
-
};
|
|
6840
|
-
var WEBGLRenderbuffer = class extends WebGLResource {
|
|
7002
|
+
var _WEBGLRenderbuffer = class extends WebGLResource {
|
|
6841
7003
|
get [Symbol.toStringTag]() {
|
|
6842
7004
|
return "Renderbuffer";
|
|
6843
7005
|
}
|
|
@@ -6853,11 +7015,19 @@ void main(void) {}`;
|
|
|
6853
7015
|
get samples() {
|
|
6854
7016
|
return this.props.samples;
|
|
6855
7017
|
}
|
|
6856
|
-
|
|
6857
|
-
return
|
|
7018
|
+
get attachment() {
|
|
7019
|
+
return;
|
|
7020
|
+
}
|
|
7021
|
+
/** WebGL format constant */
|
|
7022
|
+
static isTextureFormatSupported(device, format) {
|
|
7023
|
+
return isRenderbufferFormatSupported(device.gl, format);
|
|
6858
7024
|
}
|
|
6859
7025
|
constructor(device, props) {
|
|
6860
|
-
|
|
7026
|
+
if (typeof props.format === "number") {
|
|
7027
|
+
throw new Error("Renderbuffer");
|
|
7028
|
+
}
|
|
7029
|
+
super(device, props, _WEBGLRenderbuffer.defaultProps);
|
|
7030
|
+
this.glFormat = convertTextureFormatToGL(this.props.format, device.isWebGL2);
|
|
6861
7031
|
this._initialize(this.props);
|
|
6862
7032
|
}
|
|
6863
7033
|
resize(size) {
|
|
@@ -6869,7 +7039,6 @@ void main(void) {}`;
|
|
|
6869
7039
|
});
|
|
6870
7040
|
this._initialize(this.props);
|
|
6871
7041
|
}
|
|
6872
|
-
return this;
|
|
6873
7042
|
}
|
|
6874
7043
|
// PRIVATE METHODS
|
|
6875
7044
|
/** Creates and initializes a renderbuffer object's data store */
|
|
@@ -6884,13 +7053,12 @@ void main(void) {}`;
|
|
|
6884
7053
|
this.trackDeallocatedMemory();
|
|
6885
7054
|
this.gl.bindRenderbuffer(GL.RENDERBUFFER, this.handle);
|
|
6886
7055
|
if (samples !== 0 && this.device.isWebGL2) {
|
|
6887
|
-
this.
|
|
7056
|
+
this.gl2.renderbufferStorageMultisample(GL.RENDERBUFFER, samples, this.glFormat, width, height);
|
|
6888
7057
|
} else {
|
|
6889
|
-
this.gl.renderbufferStorage(GL.RENDERBUFFER,
|
|
7058
|
+
this.gl.renderbufferStorage(GL.RENDERBUFFER, this.glFormat, width, height);
|
|
6890
7059
|
}
|
|
6891
7060
|
this.gl.bindRenderbuffer(GL.RENDERBUFFER, null);
|
|
6892
|
-
this.trackAllocatedMemory(width * height * (samples || 1) *
|
|
6893
|
-
return this;
|
|
7061
|
+
this.trackAllocatedMemory(width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat, this.device.isWebGL2));
|
|
6894
7062
|
}
|
|
6895
7063
|
// RESOURCE IMPLEMENTATION
|
|
6896
7064
|
_createHandle() {
|
|
@@ -6904,51 +7072,57 @@ void main(void) {}`;
|
|
|
6904
7072
|
this.gl.bindRenderbuffer(GL.RENDERBUFFER, handle);
|
|
6905
7073
|
}
|
|
6906
7074
|
};
|
|
7075
|
+
var WEBGLRenderbuffer = _WEBGLRenderbuffer;
|
|
7076
|
+
__publicField(WEBGLRenderbuffer, "defaultProps", {
|
|
7077
|
+
id: void 0,
|
|
7078
|
+
handle: void 0,
|
|
7079
|
+
userData: void 0,
|
|
7080
|
+
format: void 0,
|
|
7081
|
+
// 'depth16unorm'
|
|
7082
|
+
width: 1,
|
|
7083
|
+
height: 1,
|
|
7084
|
+
samples: 0
|
|
7085
|
+
});
|
|
6907
7086
|
|
|
6908
7087
|
// src/adapter/resources/webgl-framebuffer.ts
|
|
6909
7088
|
var WEBGLFramebuffer = class extends Framebuffer {
|
|
6910
7089
|
get texture() {
|
|
6911
7090
|
return this.colorAttachments[0];
|
|
6912
7091
|
}
|
|
6913
|
-
colorAttachments = [];
|
|
6914
|
-
depthStencilAttachment = null;
|
|
6915
|
-
_ownResources = [];
|
|
6916
7092
|
constructor(device, props) {
|
|
6917
7093
|
super(device, props);
|
|
7094
|
+
const isDefaultFramebuffer = props.handle === null;
|
|
6918
7095
|
this.device = device;
|
|
6919
7096
|
this.gl = device.gl;
|
|
6920
|
-
this.handle = this.props.handle
|
|
6921
|
-
if (
|
|
7097
|
+
this.handle = this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();
|
|
7098
|
+
if (!isDefaultFramebuffer) {
|
|
6922
7099
|
device.setSpectorMetadata(this.handle, {
|
|
6923
7100
|
id: this.props.id,
|
|
6924
7101
|
props: this.props
|
|
6925
7102
|
});
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
this._attachOne(attachmentPoint, attachment);
|
|
7103
|
+
this.autoCreateAttachmentTextures();
|
|
7104
|
+
this.gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle);
|
|
7105
|
+
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
7106
|
+
const attachment = this.colorAttachments[i];
|
|
7107
|
+
const attachmentPoint = GL.COLOR_ATTACHMENT0 + i;
|
|
7108
|
+
if (attachment) {
|
|
7109
|
+
this._attachOne(attachmentPoint, attachment);
|
|
7110
|
+
}
|
|
6935
7111
|
}
|
|
7112
|
+
if (this.depthStencilAttachment) {
|
|
7113
|
+
this._attachOne(getDepthStencilAttachmentWebGL(this.depthStencilAttachment.format), this.depthStencilAttachment);
|
|
7114
|
+
}
|
|
7115
|
+
this.gl.bindFramebuffer(GL.FRAMEBUFFER, null);
|
|
6936
7116
|
}
|
|
6937
|
-
if (this.props.depthStencilAttachment) {
|
|
6938
|
-
this._attachOne(getWebGLDepthStencilAttachment(this.depthStencilAttachment.format), this.depthStencilAttachment);
|
|
6939
|
-
}
|
|
6940
|
-
this.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
|
|
6941
7117
|
if (props.check !== false) {
|
|
6942
7118
|
this._checkStatus();
|
|
6943
7119
|
}
|
|
6944
7120
|
}
|
|
7121
|
+
/** destroys any auto created resources etc. */
|
|
6945
7122
|
destroy() {
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
resource.destroy();
|
|
6949
|
-
}
|
|
7123
|
+
super.destroy();
|
|
7124
|
+
if (!this.destroyed && this.handle !== null) {
|
|
6950
7125
|
this.gl.deleteFramebuffer(this.handle);
|
|
6951
|
-
this.destroyed = true;
|
|
6952
7126
|
}
|
|
6953
7127
|
}
|
|
6954
7128
|
// PRIVATE
|
|
@@ -6957,84 +7131,29 @@ void main(void) {}`;
|
|
|
6957
7131
|
const {
|
|
6958
7132
|
gl
|
|
6959
7133
|
} = this;
|
|
6960
|
-
const
|
|
7134
|
+
const prevHandle2 = gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle);
|
|
6961
7135
|
const status = gl.checkFramebufferStatus(GL.FRAMEBUFFER);
|
|
6962
|
-
gl.bindFramebuffer(GL.FRAMEBUFFER,
|
|
7136
|
+
gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle2 || null);
|
|
6963
7137
|
if (status !== gl.FRAMEBUFFER_COMPLETE) {
|
|
6964
7138
|
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
6965
7139
|
}
|
|
6966
7140
|
}
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
return void 0;
|
|
6971
|
-
}
|
|
6972
|
-
if (colorAttachment instanceof WEBGLTexture) {
|
|
6973
|
-
return colorAttachment;
|
|
6974
|
-
}
|
|
6975
|
-
return this._createColorAttachment(colorAttachment, this.width, this.height);
|
|
6976
|
-
});
|
|
6977
|
-
}
|
|
6978
|
-
/** Create a color attachment */
|
|
6979
|
-
_createColorAttachment(format, width, height) {
|
|
6980
|
-
const texture = this.device._createTexture({
|
|
6981
|
-
id: `${this.id}-color`,
|
|
6982
|
-
data: null,
|
|
6983
|
-
// reserves texture memory, but texels are undefined
|
|
6984
|
-
format,
|
|
6985
|
-
// type: GL.UNSIGNED_BYTE,
|
|
6986
|
-
width,
|
|
6987
|
-
height,
|
|
6988
|
-
// Note: Mipmapping can be disabled by texture resource when we resize the texture
|
|
6989
|
-
// to a non-power-of-two dimenstion (NPOT texture) under WebGL1. To have consistant
|
|
6990
|
-
// behavior we always disable mipmaps.
|
|
6991
|
-
mipmaps: false,
|
|
6992
|
-
// Set MIN and MAG filtering parameters so mipmaps are not used in sampling.
|
|
6993
|
-
// Use LINEAR so subpixel algos like fxaa work.
|
|
6994
|
-
// Set WRAP modes that support NPOT textures too.
|
|
6995
|
-
sampler: {
|
|
6996
|
-
minFilter: "linear",
|
|
6997
|
-
magFilter: "linear",
|
|
6998
|
-
addressModeU: "clamp-to-edge",
|
|
6999
|
-
addressModeV: "clamp-to-edge"
|
|
7000
|
-
}
|
|
7001
|
-
// parameters: {
|
|
7002
|
-
// [GL.TEXTURE_MIN_FILTER]: GL.LINEAR,
|
|
7003
|
-
// [GL.TEXTURE_MAG_FILTER]: GL.LINEAR,
|
|
7004
|
-
// [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
|
|
7005
|
-
// [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE
|
|
7006
|
-
// }
|
|
7007
|
-
});
|
|
7008
|
-
this._ownResources.push(texture);
|
|
7009
|
-
return texture;
|
|
7010
|
-
}
|
|
7011
|
-
/** Create a depth stencil attachment GL.DEPTH24_STENCIL8 */
|
|
7012
|
-
_createDepthStencilAttachment() {
|
|
7013
|
-
if (!this.props.depthStencilAttachment) {
|
|
7014
|
-
return void 0;
|
|
7015
|
-
}
|
|
7016
|
-
if (this.props.depthStencilAttachment instanceof WEBGLRenderbuffer) {
|
|
7017
|
-
return this.props.depthStencilAttachment;
|
|
7018
|
-
}
|
|
7019
|
-
if (this.props.depthStencilAttachment instanceof Texture) {
|
|
7020
|
-
return this.props.depthStencilAttachment;
|
|
7021
|
-
}
|
|
7022
|
-
const format = this.props.depthStencilAttachment;
|
|
7023
|
-
const webglFormat = getWebGLTextureFormat(this.gl, format);
|
|
7024
|
-
const texture = new WEBGLRenderbuffer(this.device, {
|
|
7141
|
+
/** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */
|
|
7142
|
+
createDepthStencilTexture(format) {
|
|
7143
|
+
return new WEBGLRenderbuffer(this.device, {
|
|
7025
7144
|
id: `${this.id}-depth-stencil`,
|
|
7026
7145
|
// TODO misleading if not depth and stencil?
|
|
7027
|
-
format
|
|
7146
|
+
format,
|
|
7028
7147
|
// dataFormat: GL.DEPTH_STENCIL,
|
|
7029
7148
|
// type: GL.UNSIGNED_INT_24_8,
|
|
7030
7149
|
width: this.width,
|
|
7031
7150
|
height: this.height
|
|
7032
7151
|
});
|
|
7033
|
-
this._ownResources.push(texture);
|
|
7034
|
-
return texture;
|
|
7035
7152
|
}
|
|
7036
|
-
/**
|
|
7037
|
-
|
|
7153
|
+
/**
|
|
7154
|
+
* Attachment resize is expected to be a noop if size is same
|
|
7155
|
+
*/
|
|
7156
|
+
resizeAttachments(width, height) {
|
|
7038
7157
|
if (this.handle === null) {
|
|
7039
7158
|
this.width = this.gl.drawingBufferWidth;
|
|
7040
7159
|
this.height = this.gl.drawingBufferHeight;
|
|
@@ -7046,19 +7165,18 @@ void main(void) {}`;
|
|
|
7046
7165
|
if (height === void 0) {
|
|
7047
7166
|
height = this.gl.drawingBufferHeight;
|
|
7048
7167
|
}
|
|
7049
|
-
if (width !== this.width && height !== this.height) {
|
|
7050
|
-
log.log(2, `Resizing framebuffer ${this.id} to ${width}x${height}`)();
|
|
7051
|
-
}
|
|
7052
7168
|
for (const colorAttachment of this.colorAttachments) {
|
|
7053
7169
|
colorAttachment.resize({
|
|
7054
7170
|
width,
|
|
7055
7171
|
height
|
|
7056
7172
|
});
|
|
7057
7173
|
}
|
|
7058
|
-
this.depthStencilAttachment
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7174
|
+
if (this.depthStencilAttachment) {
|
|
7175
|
+
this.depthStencilAttachment.resize({
|
|
7176
|
+
width,
|
|
7177
|
+
height
|
|
7178
|
+
});
|
|
7179
|
+
}
|
|
7062
7180
|
return this;
|
|
7063
7181
|
}
|
|
7064
7182
|
/** Attach one attachment */
|
|
@@ -7564,12 +7682,9 @@ void main(void) {}`;
|
|
|
7564
7682
|
}
|
|
7565
7683
|
Object.seal(this);
|
|
7566
7684
|
}
|
|
7567
|
-
write(data, byteOffset) {
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
offset: byteOffset
|
|
7571
|
-
});
|
|
7572
|
-
}
|
|
7685
|
+
// override write(data: TypedArray, byteOffset: number = 0): void {
|
|
7686
|
+
// this.subData({data, offset: byteOffset});
|
|
7687
|
+
// }
|
|
7573
7688
|
// returns number of elements in the buffer (assuming that the full buffer is used)
|
|
7574
7689
|
getElementCount(accessor = this.accessor) {
|
|
7575
7690
|
return Math.round(this.byteLength / Accessor.getBytesPerElement(accessor));
|
|
@@ -7981,10 +8096,17 @@ ${formattedLog}`)();
|
|
|
7981
8096
|
}
|
|
7982
8097
|
|
|
7983
8098
|
// src/adapter/resources/webgl-render-pass.ts
|
|
8099
|
+
var GL_DEPTH_BUFFER_BIT = 256;
|
|
8100
|
+
var GL_STENCIL_BUFFER_BIT = 1024;
|
|
8101
|
+
var GL_COLOR_BUFFER_BIT = 16384;
|
|
8102
|
+
var GL_COLOR = 6144;
|
|
7984
8103
|
var WEBGLRenderPass = class extends RenderPass {
|
|
8104
|
+
/** Parameters that should be applied before each draw call */
|
|
7985
8105
|
constructor(device, props) {
|
|
7986
8106
|
super(device, props);
|
|
7987
8107
|
this.device = device;
|
|
8108
|
+
this.setParameters(this.props.parameters);
|
|
8109
|
+
this.clear();
|
|
7988
8110
|
}
|
|
7989
8111
|
end() {
|
|
7990
8112
|
}
|
|
@@ -7998,6 +8120,102 @@ ${formattedLog}`)();
|
|
|
7998
8120
|
// beginOcclusionQuery(queryIndex: number): void;
|
|
7999
8121
|
// endOcclusionQuery(): void;
|
|
8000
8122
|
// executeBundles(bundles: Iterable<GPURenderBundle>): void;
|
|
8123
|
+
/**
|
|
8124
|
+
* Maps RenderPass parameters to GL parameters
|
|
8125
|
+
*/
|
|
8126
|
+
setParameters(parameters = {}) {
|
|
8127
|
+
const glParameters = {};
|
|
8128
|
+
if (this.props.framebuffer) {
|
|
8129
|
+
glParameters.framebuffer = this.props.framebuffer;
|
|
8130
|
+
}
|
|
8131
|
+
if (this.props.depthReadOnly) {
|
|
8132
|
+
glParameters.depthMask = !this.props.depthReadOnly;
|
|
8133
|
+
}
|
|
8134
|
+
glParameters.stencilMask = this.props.stencilReadOnly ? 0 : 1;
|
|
8135
|
+
glParameters[GL.RASTERIZER_DISCARD] = this.props.discard;
|
|
8136
|
+
if (parameters.viewport) {
|
|
8137
|
+
glParameters.viewport = parameters.viewport;
|
|
8138
|
+
glParameters.depthRange = [parameters.viewport[4], parameters.viewport[5]];
|
|
8139
|
+
}
|
|
8140
|
+
glParameters.scissorTest = Boolean(parameters.scissorRect);
|
|
8141
|
+
if (parameters.scissorRect) {
|
|
8142
|
+
glParameters.scissor = parameters.scissorRect;
|
|
8143
|
+
}
|
|
8144
|
+
if (parameters.blendConstant) {
|
|
8145
|
+
glParameters.blendColor = parameters.blendConstant;
|
|
8146
|
+
}
|
|
8147
|
+
if (parameters.stencilReference) {
|
|
8148
|
+
console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL");
|
|
8149
|
+
parameters[GL.STENCIL_REF] = parameters.stencilReference;
|
|
8150
|
+
}
|
|
8151
|
+
this.glParameters = glParameters;
|
|
8152
|
+
}
|
|
8153
|
+
// Internal
|
|
8154
|
+
/**
|
|
8155
|
+
* Optionally clears depth, color and stencil buffers based on parameters
|
|
8156
|
+
*/
|
|
8157
|
+
clear() {
|
|
8158
|
+
const glParameters = {
|
|
8159
|
+
...this.glParameters
|
|
8160
|
+
};
|
|
8161
|
+
let clearMask = 0;
|
|
8162
|
+
if (this.props.clearColor !== false) {
|
|
8163
|
+
clearMask |= GL_COLOR_BUFFER_BIT;
|
|
8164
|
+
glParameters.clearColor = this.props.clearColor;
|
|
8165
|
+
}
|
|
8166
|
+
if (this.props.clearDepth !== false) {
|
|
8167
|
+
clearMask |= GL_DEPTH_BUFFER_BIT;
|
|
8168
|
+
glParameters.clearDepth = this.props.clearDepth;
|
|
8169
|
+
}
|
|
8170
|
+
if (this.props.clearStencil !== false) {
|
|
8171
|
+
clearMask |= GL_STENCIL_BUFFER_BIT;
|
|
8172
|
+
glParameters.clearStencil = this.props.clearStencil;
|
|
8173
|
+
}
|
|
8174
|
+
if (clearMask !== 0) {
|
|
8175
|
+
withParameters(this.device, glParameters, () => {
|
|
8176
|
+
this.device.gl.clear(clearMask);
|
|
8177
|
+
});
|
|
8178
|
+
}
|
|
8179
|
+
}
|
|
8180
|
+
/**
|
|
8181
|
+
* WebGL2 - clear a specific color buffer
|
|
8182
|
+
*/
|
|
8183
|
+
clearColorBuffer(drawBuffer = 0, value = [0, 0, 0, 0]) {
|
|
8184
|
+
withParameters(this.device.gl2, {
|
|
8185
|
+
framebuffer: this.props.framebuffer
|
|
8186
|
+
}, () => {
|
|
8187
|
+
switch (value.constructor) {
|
|
8188
|
+
case Int32Array:
|
|
8189
|
+
this.device.gl2.clearBufferiv(GL_COLOR, drawBuffer, value);
|
|
8190
|
+
break;
|
|
8191
|
+
case Uint32Array:
|
|
8192
|
+
this.device.gl2.clearBufferuiv(GL_COLOR, drawBuffer, value);
|
|
8193
|
+
break;
|
|
8194
|
+
case Float32Array:
|
|
8195
|
+
default:
|
|
8196
|
+
this.device.gl2.clearBufferfv(GL_COLOR, drawBuffer, value);
|
|
8197
|
+
break;
|
|
8198
|
+
}
|
|
8199
|
+
});
|
|
8200
|
+
}
|
|
8201
|
+
// clearDepthStencil() {
|
|
8202
|
+
// const GL_DEPTH = 0x1801;
|
|
8203
|
+
// const GL_STENCIL = 0x1802;
|
|
8204
|
+
// const GL_DEPTH_STENCIL = 0x84f9;
|
|
8205
|
+
// case GL_DEPTH:
|
|
8206
|
+
// this.device.gl2.clearBufferfv(GL_DEPTH, 0, [value]);
|
|
8207
|
+
// break;
|
|
8208
|
+
// case GL_STENCIL:
|
|
8209
|
+
// this.device.gl2.clearBufferiv(GL_STENCIL, 0, [value]);
|
|
8210
|
+
// break;
|
|
8211
|
+
// case GL_DEPTH_STENCIL:
|
|
8212
|
+
// const [depth, stencil] = value;
|
|
8213
|
+
// this.device.gl2.clearBufferfi(GL_DEPTH_STENCIL, 0, depth, stencil);
|
|
8214
|
+
// break;
|
|
8215
|
+
// default:
|
|
8216
|
+
// assert(false, ERR_ARGUMENTS);
|
|
8217
|
+
// }
|
|
8218
|
+
// });
|
|
8001
8219
|
};
|
|
8002
8220
|
|
|
8003
8221
|
// src/adapter/helpers/uniforms.ts
|
|
@@ -8653,7 +8871,7 @@ ${formattedLog}`)();
|
|
|
8653
8871
|
*/
|
|
8654
8872
|
draw(options) {
|
|
8655
8873
|
const {
|
|
8656
|
-
renderPass
|
|
8874
|
+
renderPass,
|
|
8657
8875
|
vertexCount,
|
|
8658
8876
|
// indexCount,
|
|
8659
8877
|
instanceCount,
|
|
@@ -8678,10 +8896,9 @@ ${formattedLog}`)();
|
|
|
8678
8896
|
}
|
|
8679
8897
|
this._applyBindings();
|
|
8680
8898
|
this._applyUniforms();
|
|
8899
|
+
const webglRenderPass = renderPass;
|
|
8681
8900
|
withDeviceParameters(this.device, this.props.parameters, () => {
|
|
8682
|
-
withGLParameters(this.device, {
|
|
8683
|
-
framebuffer: renderPass.props.framebuffer
|
|
8684
|
-
}, () => {
|
|
8901
|
+
withGLParameters(this.device, webglRenderPass.glParameters, () => {
|
|
8685
8902
|
if (isIndexed && isInstanced) {
|
|
8686
8903
|
this.device.gl2?.drawElementsInstanced(
|
|
8687
8904
|
drawMode,
|
|
@@ -8857,6 +9074,257 @@ ${formattedLog}`)();
|
|
|
8857
9074
|
return layout.attributes.find((binding) => binding.name === name) || null;
|
|
8858
9075
|
}
|
|
8859
9076
|
|
|
9077
|
+
// src/adapter/resources/webgl-command-buffer.ts
|
|
9078
|
+
function cast2(value) {
|
|
9079
|
+
return value;
|
|
9080
|
+
}
|
|
9081
|
+
var WEBGLCommandBuffer = class extends CommandBuffer {
|
|
9082
|
+
commands = [];
|
|
9083
|
+
constructor(device) {
|
|
9084
|
+
super({});
|
|
9085
|
+
this.device = device;
|
|
9086
|
+
}
|
|
9087
|
+
submitCommands(commands = this.commands) {
|
|
9088
|
+
for (const command of commands) {
|
|
9089
|
+
switch (command.name) {
|
|
9090
|
+
case "copy-buffer-to-buffer":
|
|
9091
|
+
_copyBufferToBuffer(this.device, command.options);
|
|
9092
|
+
break;
|
|
9093
|
+
case "copy-buffer-to-texture":
|
|
9094
|
+
_copyBufferToTexture(this.device, command.options);
|
|
9095
|
+
break;
|
|
9096
|
+
case "copy-texture-to-buffer":
|
|
9097
|
+
_copyTextureToBuffer(this.device, command.options);
|
|
9098
|
+
break;
|
|
9099
|
+
case "copy-texture-to-texture":
|
|
9100
|
+
_copyTextureToTexture(this.device, command.options);
|
|
9101
|
+
break;
|
|
9102
|
+
}
|
|
9103
|
+
}
|
|
9104
|
+
}
|
|
9105
|
+
};
|
|
9106
|
+
function _copyBufferToBuffer(device, options) {
|
|
9107
|
+
const source = cast2(options.source);
|
|
9108
|
+
const destination = cast2(options.destination);
|
|
9109
|
+
const gl2 = device.assertWebGL2();
|
|
9110
|
+
if (gl2) {
|
|
9111
|
+
gl2.bindBuffer(GL.COPY_READ_BUFFER, source.handle);
|
|
9112
|
+
gl2.bindBuffer(GL.COPY_WRITE_BUFFER, destination.handle);
|
|
9113
|
+
gl2.copyBufferSubData(GL.COPY_READ_BUFFER, GL.COPY_WRITE_BUFFER, options.sourceOffset ?? 0, options.destinationOffset ?? 0, options.size);
|
|
9114
|
+
gl2.bindBuffer(GL.COPY_READ_BUFFER, null);
|
|
9115
|
+
gl2.bindBuffer(GL.COPY_WRITE_BUFFER, null);
|
|
9116
|
+
} else {
|
|
9117
|
+
throw new Error("copyBufferToBuffer not implemented in WebGL1");
|
|
9118
|
+
}
|
|
9119
|
+
}
|
|
9120
|
+
function _copyBufferToTexture(device, options) {
|
|
9121
|
+
throw new Error("Not implemented");
|
|
9122
|
+
}
|
|
9123
|
+
function _copyTextureToBuffer(device, options) {
|
|
9124
|
+
const {
|
|
9125
|
+
/** Texture to copy to/from. */
|
|
9126
|
+
source,
|
|
9127
|
+
/** Mip-map level of the texture to copy to/from. (Default 0) */
|
|
9128
|
+
mipLevel = 0,
|
|
9129
|
+
/** Defines which aspects of the texture to copy to/from. */
|
|
9130
|
+
aspect = "all",
|
|
9131
|
+
/** Width to copy */
|
|
9132
|
+
width = options.source.width,
|
|
9133
|
+
/** Height to copy */
|
|
9134
|
+
height = options.source.height,
|
|
9135
|
+
depthOrArrayLayers = 0,
|
|
9136
|
+
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
|
|
9137
|
+
origin = [0, 0],
|
|
9138
|
+
/** Destination buffer */
|
|
9139
|
+
destination,
|
|
9140
|
+
/** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */
|
|
9141
|
+
byteOffset = 0,
|
|
9142
|
+
/**
|
|
9143
|
+
* The stride, in bytes, between the beginning of each block row and the subsequent block row.
|
|
9144
|
+
* Required if there are multiple block rows (i.e. the copy height or depth is more than one block).
|
|
9145
|
+
*/
|
|
9146
|
+
bytesPerRow,
|
|
9147
|
+
/**
|
|
9148
|
+
* Number of block rows per single image of the texture.
|
|
9149
|
+
* rowsPerImage × bytesPerRow is the stride, in bytes, between the beginning of each image of data and the subsequent image.
|
|
9150
|
+
* Required if there are multiple images (i.e. the copy depth is more than one).
|
|
9151
|
+
*/
|
|
9152
|
+
rowsPerImage
|
|
9153
|
+
} = options;
|
|
9154
|
+
if (aspect !== "all") {
|
|
9155
|
+
throw new Error("not supported");
|
|
9156
|
+
}
|
|
9157
|
+
if (mipLevel !== 0 || depthOrArrayLayers !== void 0 || bytesPerRow || rowsPerImage) {
|
|
9158
|
+
throw new Error("not implemented");
|
|
9159
|
+
}
|
|
9160
|
+
const gl2 = device.assertWebGL2();
|
|
9161
|
+
const {
|
|
9162
|
+
framebuffer,
|
|
9163
|
+
destroyFramebuffer
|
|
9164
|
+
} = getFramebuffer(source);
|
|
9165
|
+
try {
|
|
9166
|
+
const webglBuffer = destination;
|
|
9167
|
+
const sourceWidth = width || framebuffer.width;
|
|
9168
|
+
const sourceHeight = height || framebuffer.height;
|
|
9169
|
+
const sourceFormat = GL.RGBA;
|
|
9170
|
+
const sourceType = GL.UNSIGNED_BYTE;
|
|
9171
|
+
gl2.bindBuffer(GL.PIXEL_PACK_BUFFER, webglBuffer.handle);
|
|
9172
|
+
gl2.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);
|
|
9173
|
+
gl2.readPixels(origin[0], origin[1], sourceWidth, sourceHeight, sourceFormat, sourceType, byteOffset);
|
|
9174
|
+
} finally {
|
|
9175
|
+
gl2.bindBuffer(GL.PIXEL_PACK_BUFFER, null);
|
|
9176
|
+
gl2.bindFramebuffer(GL.FRAMEBUFFER, null);
|
|
9177
|
+
if (destroyFramebuffer) {
|
|
9178
|
+
framebuffer.destroy();
|
|
9179
|
+
}
|
|
9180
|
+
}
|
|
9181
|
+
}
|
|
9182
|
+
function _copyTextureToTexture(device, options) {
|
|
9183
|
+
const {
|
|
9184
|
+
/** Texture to copy to/from. */
|
|
9185
|
+
source,
|
|
9186
|
+
/** Mip-map level of the texture to copy to/from. (Default 0) */
|
|
9187
|
+
// mipLevel = 0,
|
|
9188
|
+
/** Defines which aspects of the texture to copy to/from. */
|
|
9189
|
+
// aspect = 'all',
|
|
9190
|
+
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
|
|
9191
|
+
origin = [0, 0],
|
|
9192
|
+
/** Texture to copy to/from. */
|
|
9193
|
+
destination
|
|
9194
|
+
/** Mip-map level of the texture to copy to/from. (Default 0) */
|
|
9195
|
+
// destinationMipLevel = options.mipLevel,
|
|
9196
|
+
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
|
|
9197
|
+
// destinationOrigin = [0, 0],
|
|
9198
|
+
/** Defines which aspects of the texture to copy to/from. */
|
|
9199
|
+
// destinationAspect = options.aspect,
|
|
9200
|
+
} = options;
|
|
9201
|
+
let {
|
|
9202
|
+
width = options.destination.width,
|
|
9203
|
+
height = options.destination.width
|
|
9204
|
+
// depthOrArrayLayers = 0
|
|
9205
|
+
} = options;
|
|
9206
|
+
const destinationMipmaplevel = 0;
|
|
9207
|
+
const destinationInternalFormat = GL.RGBA;
|
|
9208
|
+
const {
|
|
9209
|
+
framebuffer,
|
|
9210
|
+
destroyFramebuffer
|
|
9211
|
+
} = getFramebuffer(source);
|
|
9212
|
+
const [sourceX, sourceY] = origin;
|
|
9213
|
+
const isSubCopy = false;
|
|
9214
|
+
device.gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);
|
|
9215
|
+
let texture = null;
|
|
9216
|
+
let textureTarget;
|
|
9217
|
+
if (destination instanceof WEBGLTexture) {
|
|
9218
|
+
texture = destination;
|
|
9219
|
+
width = Number.isFinite(width) ? width : texture.width;
|
|
9220
|
+
height = Number.isFinite(height) ? height : texture.height;
|
|
9221
|
+
texture.bind(0);
|
|
9222
|
+
textureTarget = texture.destination;
|
|
9223
|
+
} else {
|
|
9224
|
+
throw new Error("whoops");
|
|
9225
|
+
}
|
|
9226
|
+
if (!isSubCopy) {
|
|
9227
|
+
device.gl.copyTexImage2D(
|
|
9228
|
+
textureTarget,
|
|
9229
|
+
destinationMipmaplevel,
|
|
9230
|
+
destinationInternalFormat,
|
|
9231
|
+
sourceX,
|
|
9232
|
+
sourceY,
|
|
9233
|
+
width,
|
|
9234
|
+
height,
|
|
9235
|
+
0
|
|
9236
|
+
/* border must be 0 */
|
|
9237
|
+
);
|
|
9238
|
+
} else {
|
|
9239
|
+
}
|
|
9240
|
+
if (texture) {
|
|
9241
|
+
texture.unbind();
|
|
9242
|
+
}
|
|
9243
|
+
device.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
|
|
9244
|
+
if (destroyFramebuffer) {
|
|
9245
|
+
framebuffer.destroy();
|
|
9246
|
+
}
|
|
9247
|
+
return texture;
|
|
9248
|
+
}
|
|
9249
|
+
function getFramebuffer(source) {
|
|
9250
|
+
if (source instanceof Texture) {
|
|
9251
|
+
const {
|
|
9252
|
+
width,
|
|
9253
|
+
height,
|
|
9254
|
+
id
|
|
9255
|
+
} = source;
|
|
9256
|
+
const framebuffer = source.device.createFramebuffer({
|
|
9257
|
+
id: `framebuffer-for-${id}`,
|
|
9258
|
+
width,
|
|
9259
|
+
height,
|
|
9260
|
+
colorAttachments: [source]
|
|
9261
|
+
});
|
|
9262
|
+
return {
|
|
9263
|
+
framebuffer,
|
|
9264
|
+
destroyFramebuffer: true
|
|
9265
|
+
};
|
|
9266
|
+
}
|
|
9267
|
+
return {
|
|
9268
|
+
framebuffer: source,
|
|
9269
|
+
destroyFramebuffer: false
|
|
9270
|
+
};
|
|
9271
|
+
}
|
|
9272
|
+
|
|
9273
|
+
// src/adapter/resources/webgl-command-encoder.ts
|
|
9274
|
+
var WEBGLCommandEncoder = class extends CommandEncoder {
|
|
9275
|
+
constructor(device, props) {
|
|
9276
|
+
super(props);
|
|
9277
|
+
this.device = device;
|
|
9278
|
+
this.commandBuffer = new WEBGLCommandBuffer(device);
|
|
9279
|
+
}
|
|
9280
|
+
destroy() {
|
|
9281
|
+
}
|
|
9282
|
+
finish() {
|
|
9283
|
+
this.commandBuffer.submitCommands();
|
|
9284
|
+
}
|
|
9285
|
+
// beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
|
|
9286
|
+
// beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
|
|
9287
|
+
// finish(options?: {id?: string}): GPUCommandBuffer;
|
|
9288
|
+
copyBufferToBuffer(options) {
|
|
9289
|
+
this.commandBuffer.commands.push({
|
|
9290
|
+
name: "copy-buffer-to-buffer",
|
|
9291
|
+
options
|
|
9292
|
+
});
|
|
9293
|
+
}
|
|
9294
|
+
copyBufferToTexture(options) {
|
|
9295
|
+
this.commandBuffer.commands.push({
|
|
9296
|
+
name: "copy-buffer-to-texture",
|
|
9297
|
+
options
|
|
9298
|
+
});
|
|
9299
|
+
}
|
|
9300
|
+
copyTextureToBuffer(options) {
|
|
9301
|
+
this.commandBuffer.commands.push({
|
|
9302
|
+
name: "copy-texture-to-buffer",
|
|
9303
|
+
options
|
|
9304
|
+
});
|
|
9305
|
+
}
|
|
9306
|
+
copyTextureToTexture(options) {
|
|
9307
|
+
this.commandBuffer.commands.push({
|
|
9308
|
+
name: "copy-texture-to-texture",
|
|
9309
|
+
options
|
|
9310
|
+
});
|
|
9311
|
+
}
|
|
9312
|
+
pushDebugGroup(groupLabel) {
|
|
9313
|
+
}
|
|
9314
|
+
popDebugGroup() {
|
|
9315
|
+
}
|
|
9316
|
+
insertDebugMarker(markerLabel) {
|
|
9317
|
+
}
|
|
9318
|
+
// writeTimestamp(querySet: Query, queryIndex: number): void {}
|
|
9319
|
+
// resolveQuerySet(options: {
|
|
9320
|
+
// querySet: GPUQuerySet,
|
|
9321
|
+
// firstQuery: number,
|
|
9322
|
+
// queryCount: number,
|
|
9323
|
+
// destination: Buffer,
|
|
9324
|
+
// destinationOffset?: number;
|
|
9325
|
+
// }): void;
|
|
9326
|
+
};
|
|
9327
|
+
|
|
8860
9328
|
// src/adapter/webgl-device.ts
|
|
8861
9329
|
var LOG_LEVEL2 = 1;
|
|
8862
9330
|
var _WebGLDevice = class extends Device {
|
|
@@ -9020,8 +9488,9 @@ ${formattedLog}`)();
|
|
|
9020
9488
|
createCanvasContext(props) {
|
|
9021
9489
|
throw new Error("WebGL only supports a single canvas");
|
|
9022
9490
|
}
|
|
9023
|
-
|
|
9024
|
-
|
|
9491
|
+
createBuffer(props) {
|
|
9492
|
+
const newProps = this._getBufferProps(props);
|
|
9493
|
+
return new ClassicBuffer(this, newProps);
|
|
9025
9494
|
}
|
|
9026
9495
|
_createTexture(props) {
|
|
9027
9496
|
return new WEBGLTexture(this, props);
|
|
@@ -9057,6 +9526,9 @@ ${formattedLog}`)();
|
|
|
9057
9526
|
});
|
|
9058
9527
|
return this.renderPass;
|
|
9059
9528
|
}
|
|
9529
|
+
createCommandEncoder(props) {
|
|
9530
|
+
return new WEBGLCommandEncoder(this, props);
|
|
9531
|
+
}
|
|
9060
9532
|
/**
|
|
9061
9533
|
* Offscreen Canvas Support: Commit the frame
|
|
9062
9534
|
* https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/commit
|
|
@@ -9091,19 +9563,21 @@ ${formattedLog}`)();
|
|
|
9091
9563
|
return this._webglLimits;
|
|
9092
9564
|
}
|
|
9093
9565
|
/**
|
|
9094
|
-
*
|
|
9095
|
-
* @note
|
|
9096
|
-
* @todo Promote to `Device` API?
|
|
9566
|
+
* Triggers device (or WebGL context) loss.
|
|
9567
|
+
* @note primarily intended for testing how application reacts to device loss
|
|
9097
9568
|
*/
|
|
9098
9569
|
loseDevice() {
|
|
9570
|
+
let deviceLossTriggered = false;
|
|
9099
9571
|
const ext = this.gl.getExtension("WEBGL_lose_context");
|
|
9100
9572
|
if (ext) {
|
|
9573
|
+
deviceLossTriggered = true;
|
|
9101
9574
|
ext.loseContext();
|
|
9102
9575
|
}
|
|
9103
9576
|
this._resolveContextLost?.({
|
|
9104
9577
|
reason: "destroyed",
|
|
9105
9578
|
message: "Application triggered context loss"
|
|
9106
9579
|
});
|
|
9580
|
+
return deviceLossTriggered;
|
|
9107
9581
|
}
|
|
9108
9582
|
/** Save current WebGL context state onto an internal stack */
|
|
9109
9583
|
pushState() {
|
|
@@ -9120,6 +9594,21 @@ ${formattedLog}`)();
|
|
|
9120
9594
|
setSpectorMetadata(handle, props) {
|
|
9121
9595
|
handle.__SPECTOR_Metadata = props;
|
|
9122
9596
|
}
|
|
9597
|
+
/**
|
|
9598
|
+
* Returns the GL.<KEY> constant that corresponds to a numeric value of a GL constant
|
|
9599
|
+
* Be aware that there are some duplicates especially for constants that are 0,
|
|
9600
|
+
* so this isn't guaranteed to return the right key in all cases.
|
|
9601
|
+
*/
|
|
9602
|
+
getGLKey(value, gl) {
|
|
9603
|
+
gl = gl || this.gl2 || this.gl;
|
|
9604
|
+
const number = Number(value);
|
|
9605
|
+
for (const key in gl) {
|
|
9606
|
+
if (gl[key] === number) {
|
|
9607
|
+
return `GL.${key}`;
|
|
9608
|
+
}
|
|
9609
|
+
}
|
|
9610
|
+
return String(value);
|
|
9611
|
+
}
|
|
9123
9612
|
};
|
|
9124
9613
|
var WebGLDevice = _WebGLDevice;
|
|
9125
9614
|
//
|
|
@@ -9141,63 +9630,6 @@ ${formattedLog}`)();
|
|
|
9141
9630
|
}
|
|
9142
9631
|
return Boolean(gl && gl._version === 2);
|
|
9143
9632
|
}
|
|
9144
|
-
|
|
9145
|
-
// src/adapter/resources/webgl-command-buffer.ts
|
|
9146
|
-
var CommandBuffer = class {
|
|
9147
|
-
commands = [];
|
|
9148
|
-
};
|
|
9149
|
-
|
|
9150
|
-
// src/adapter/resources/webgl-command-encoder.ts
|
|
9151
|
-
var WEBGLCommandEncoder = class extends CommandEncoder {
|
|
9152
|
-
commandBuffer = new CommandBuffer();
|
|
9153
|
-
constructor(device, props) {
|
|
9154
|
-
super(props);
|
|
9155
|
-
this.device = device;
|
|
9156
|
-
}
|
|
9157
|
-
destroy() {
|
|
9158
|
-
}
|
|
9159
|
-
// beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
|
|
9160
|
-
// beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
|
|
9161
|
-
// finish(options?: {id?: string}): GPUCommandBuffer;
|
|
9162
|
-
copyBufferToBuffer(options) {
|
|
9163
|
-
this.commandBuffer.commands.push({
|
|
9164
|
-
name: "copy-buffer-to-buffer",
|
|
9165
|
-
options
|
|
9166
|
-
});
|
|
9167
|
-
}
|
|
9168
|
-
copyBufferToTexture(options) {
|
|
9169
|
-
this.commandBuffer.commands.push({
|
|
9170
|
-
name: "copy-buffer-to-texture",
|
|
9171
|
-
options
|
|
9172
|
-
});
|
|
9173
|
-
}
|
|
9174
|
-
copyTextureToBuffer(options) {
|
|
9175
|
-
this.commandBuffer.commands.push({
|
|
9176
|
-
name: "copy-texture-to-buffer",
|
|
9177
|
-
options
|
|
9178
|
-
});
|
|
9179
|
-
}
|
|
9180
|
-
copyTextureToTexture(options) {
|
|
9181
|
-
this.commandBuffer.commands.push({
|
|
9182
|
-
name: "copy-texture-to-texture",
|
|
9183
|
-
options
|
|
9184
|
-
});
|
|
9185
|
-
}
|
|
9186
|
-
pushDebugGroup(groupLabel) {
|
|
9187
|
-
}
|
|
9188
|
-
popDebugGroup() {
|
|
9189
|
-
}
|
|
9190
|
-
insertDebugMarker(markerLabel) {
|
|
9191
|
-
}
|
|
9192
|
-
// writeTimestamp(querySet: Query, queryIndex: number): void {}
|
|
9193
|
-
// resolveQuerySet(options: {
|
|
9194
|
-
// querySet: GPUQuerySet,
|
|
9195
|
-
// firstQuery: number,
|
|
9196
|
-
// queryCount: number,
|
|
9197
|
-
// destination: Buffer,
|
|
9198
|
-
// destinationOffset?: number;
|
|
9199
|
-
// }): void;
|
|
9200
|
-
};
|
|
9201
9633
|
return __toCommonJS(src_exports);
|
|
9202
9634
|
})();
|
|
9203
9635
|
return __exports__;
|