@luma.gl/webgl 9.0.0-alpha.20 → 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 +10 -10
- 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/get-shader-layout.js +1 -1
- package/dist/adapter/helpers/get-shader-layout.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 +14 -11
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +31 -21
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts +2 -3
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +6 -9
- package/dist/adapter/objects/webgl-resource.js.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts +6 -6
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js +2 -2
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts +2 -2
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +4 -3
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +9 -3
- 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 +5 -4
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +7 -3
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-external-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +18 -21
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +36 -86
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts +18 -3
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +81 -1
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +5 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +7 -8
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts +3 -3
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +2 -2
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.d.ts +2 -2
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +1 -1
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +41 -21
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +35 -33
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.d.ts +4 -5
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +2 -2
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +22 -15
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +29 -11
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/accessor.d.ts +1 -1
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +1 -1
- package/dist/classic/accessor.js.map +1 -1
- package/dist/classic/buffer.d.ts +3 -4
- package/dist/classic/buffer.d.ts.map +1 -1
- package/dist/classic/buffer.js +4 -10
- 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 +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/context/state-tracker/with-parameters.js +1 -1
- package/dist/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/dist.dev.js +1107 -676
- package/dist/index.cjs +1088 -901
- package/dist/index.d.ts +18 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -16
- 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 +47 -23
- 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/get-shader-layout.ts +1 -1
- 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 +35 -32
- package/src/adapter/objects/webgl-resource.ts +6 -10
- package/src/adapter/objects/webgl-vertex-array-object.ts +6 -6
- package/src/adapter/resources/webgl-buffer.ts +6 -7
- package/src/adapter/resources/webgl-command-buffer.ts +330 -23
- package/src/adapter/resources/webgl-command-encoder.ts +9 -4
- package/src/adapter/resources/webgl-external-texture.ts +1 -1
- package/src/adapter/resources/webgl-framebuffer.ts +75 -123
- package/src/adapter/resources/webgl-render-pass.ts +148 -4
- package/src/adapter/resources/webgl-render-pipeline.ts +12 -9
- package/src/adapter/resources/webgl-sampler.ts +3 -4
- package/src/adapter/resources/webgl-shader.ts +2 -2
- package/src/adapter/resources/webgl-texture.ts +64 -46
- package/src/adapter/webgl-canvas-context.ts +5 -5
- package/src/adapter/webgl-device.ts +47 -18
- package/src/classic/accessor.ts +1 -1
- package/src/classic/buffer.ts +7 -7
- 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 +2 -2
- package/src/context/parameters/webgl-parameter-tables.ts +2 -2
- package/src/context/state-tracker/with-parameters.ts +1 -1
- package/src/index.ts +24 -22
- 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 -181
- 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/adapter/converters/renderbuffer-formats.ts +0 -92
- 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,
|
|
@@ -927,7 +929,7 @@ var __exports__ = (() => {
|
|
|
927
929
|
var lumaStats = new StatsManager();
|
|
928
930
|
|
|
929
931
|
// ../api/src/init.ts
|
|
930
|
-
function
|
|
932
|
+
function initializeLuma() {
|
|
931
933
|
const VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
|
|
932
934
|
const STARTUP_MESSAGE = "set luma.log.level=1 (or higher) to trace rendering";
|
|
933
935
|
if (globalThis.luma && globalThis.luma.VERSION !== VERSION3) {
|
|
@@ -948,8 +950,7 @@ var __exports__ = (() => {
|
|
|
948
950
|
}
|
|
949
951
|
return VERSION3;
|
|
950
952
|
}
|
|
951
|
-
var VERSION2 =
|
|
952
|
-
var init_default = globalThis.luma;
|
|
953
|
+
var VERSION2 = initializeLuma();
|
|
953
954
|
|
|
954
955
|
// ../api/src/lib/utils/utils.ts
|
|
955
956
|
var uidCounters = {};
|
|
@@ -974,14 +975,17 @@ var __exports__ = (() => {
|
|
|
974
975
|
var DEFAULT_RESOURCE_PROPS = {
|
|
975
976
|
id: "undefined",
|
|
976
977
|
handle: void 0,
|
|
977
|
-
userData:
|
|
978
|
+
userData: void 0
|
|
978
979
|
};
|
|
979
980
|
var Resource = class {
|
|
980
981
|
/** props.id, for debugging. */
|
|
981
982
|
userData = {};
|
|
983
|
+
/** Whether this resource has been destroyed */
|
|
982
984
|
destroyed = false;
|
|
983
985
|
/** For resources that allocate GPU memory */
|
|
984
986
|
allocatedBytes = 0;
|
|
987
|
+
/** Attached resources will be destroyed when this resource is destroyed. Tracks auto-created "sub" resources. */
|
|
988
|
+
_attachedResources = /* @__PURE__ */ new Set();
|
|
985
989
|
/**
|
|
986
990
|
* Create a new Resource. Called from Subclass
|
|
987
991
|
*/
|
|
@@ -1001,7 +1005,7 @@ var __exports__ = (() => {
|
|
|
1001
1005
|
* destroy can be called on any resource to release it before it is garbage collected.
|
|
1002
1006
|
*/
|
|
1003
1007
|
destroy() {
|
|
1004
|
-
this.
|
|
1008
|
+
this.destroyResource();
|
|
1005
1009
|
}
|
|
1006
1010
|
/** @deprecated Use destroy() */
|
|
1007
1011
|
delete() {
|
|
@@ -1018,14 +1022,41 @@ var __exports__ = (() => {
|
|
|
1018
1022
|
getProps() {
|
|
1019
1023
|
return this.props;
|
|
1020
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
|
+
}
|
|
1021
1054
|
// PROTECTED METHODS
|
|
1022
|
-
/**
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
stats.get(`${name}s Created`).incrementCount();
|
|
1028
|
-
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;
|
|
1029
1060
|
}
|
|
1030
1061
|
/** Called by .destroy() to track object destruction. Subclass must call if overriding destroy() */
|
|
1031
1062
|
removeStats() {
|
|
@@ -1047,7 +1078,17 @@ var __exports__ = (() => {
|
|
|
1047
1078
|
stats.get(`${name} Memory`).subtractCount(this.allocatedBytes);
|
|
1048
1079
|
this.allocatedBytes = 0;
|
|
1049
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
|
+
}
|
|
1050
1089
|
};
|
|
1090
|
+
/** Default properties for resource */
|
|
1091
|
+
__publicField(Resource, "defaultProps", DEFAULT_RESOURCE_PROPS);
|
|
1051
1092
|
function selectivelyMerge(props, defaultProps) {
|
|
1052
1093
|
const mergedProps = {
|
|
1053
1094
|
...defaultProps
|
|
@@ -1075,6 +1116,7 @@ var __exports__ = (() => {
|
|
|
1075
1116
|
get [Symbol.toStringTag]() {
|
|
1076
1117
|
return "Buffer";
|
|
1077
1118
|
}
|
|
1119
|
+
/** Length of buffer in bytes */
|
|
1078
1120
|
constructor(device, props) {
|
|
1079
1121
|
const deducedProps = {
|
|
1080
1122
|
...props
|
|
@@ -1195,34 +1237,30 @@ var __exports__ = (() => {
|
|
|
1195
1237
|
}
|
|
1196
1238
|
statsManager = lumaStats;
|
|
1197
1239
|
userData = {};
|
|
1240
|
+
// Capabilities
|
|
1198
1241
|
/** Information about the device (vendor, versions etc) */
|
|
1199
1242
|
/** Optional capability discovery */
|
|
1200
1243
|
/** WebGPU style device limits */
|
|
1201
1244
|
/** Check if device supports a specific texture format (creation and `nearest` sampling) */
|
|
1202
1245
|
/** Check if linear filtering (sampler interpolation) is supported for a specific texture format */
|
|
1203
1246
|
/** Check if device supports rendering to a specific texture format */
|
|
1204
|
-
|
|
1205
|
-
/**
|
|
1206
|
-
/**
|
|
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 */
|
|
1207
1260
|
/** Creates a new CanvasContext (WebGPU only) */
|
|
1208
1261
|
/** Call after rendering a frame (necessary e.g. on WebGL OffscreenCanvas) */
|
|
1209
1262
|
// Resource creation
|
|
1210
1263
|
/** Create a buffer */
|
|
1211
|
-
createBuffer(props) {
|
|
1212
|
-
if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) {
|
|
1213
|
-
return this._createBuffer({
|
|
1214
|
-
data: props
|
|
1215
|
-
});
|
|
1216
|
-
}
|
|
1217
|
-
if ((props.usage || 0) & Buffer2.INDEX && !props.indexType) {
|
|
1218
|
-
if (props.data instanceof Uint32Array) {
|
|
1219
|
-
props.indexType = "uint32";
|
|
1220
|
-
} else if (props.data instanceof Uint16Array) {
|
|
1221
|
-
props.indexType = "uint16";
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
return this._createBuffer(props);
|
|
1225
|
-
}
|
|
1226
1264
|
/** Create a texture */
|
|
1227
1265
|
createTexture(props) {
|
|
1228
1266
|
if (props instanceof Promise || typeof props === "string") {
|
|
@@ -1237,9 +1275,31 @@ var __exports__ = (() => {
|
|
|
1237
1275
|
/** Create a shader */
|
|
1238
1276
|
/** Create a render pipeline (aka program) */
|
|
1239
1277
|
/** Create a compute pipeline (aka program) */
|
|
1278
|
+
createCommandEncoder(props = {}) {
|
|
1279
|
+
throw new Error("not implemented");
|
|
1280
|
+
}
|
|
1240
1281
|
/** Create a RenderPass */
|
|
1241
1282
|
/** Create a ComputePass */
|
|
1242
|
-
|
|
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
|
+
}
|
|
1243
1303
|
};
|
|
1244
1304
|
__publicField(Device, "VERSION", VERSION2);
|
|
1245
1305
|
|
|
@@ -1327,13 +1387,15 @@ var __exports__ = (() => {
|
|
|
1327
1387
|
if (typeof OffscreenCanvas !== "undefined" && this.canvas instanceof OffscreenCanvas) {
|
|
1328
1388
|
return 1;
|
|
1329
1389
|
}
|
|
1330
|
-
|
|
1331
|
-
|
|
1390
|
+
useDevicePixels = useDevicePixels === void 0 ? this.props.useDevicePixels : useDevicePixels;
|
|
1391
|
+
if (!useDevicePixels || useDevicePixels <= 0) {
|
|
1392
|
+
return 1;
|
|
1332
1393
|
}
|
|
1333
|
-
if (
|
|
1334
|
-
|
|
1394
|
+
if (useDevicePixels === true) {
|
|
1395
|
+
const dpr = typeof window !== "undefined" && window.devicePixelRatio;
|
|
1396
|
+
return dpr || 1;
|
|
1335
1397
|
}
|
|
1336
|
-
return useDevicePixels
|
|
1398
|
+
return useDevicePixels;
|
|
1337
1399
|
}
|
|
1338
1400
|
/**
|
|
1339
1401
|
* Returns the size of drawing buffer in device pixels.
|
|
@@ -1526,8 +1588,8 @@ var __exports__ = (() => {
|
|
|
1526
1588
|
data: null,
|
|
1527
1589
|
dimension: "2d",
|
|
1528
1590
|
format: "rgba8unorm",
|
|
1529
|
-
|
|
1530
|
-
|
|
1591
|
+
width: void 0,
|
|
1592
|
+
height: void 0,
|
|
1531
1593
|
depth: 1,
|
|
1532
1594
|
mipmaps: true,
|
|
1533
1595
|
sampler: {},
|
|
@@ -1535,20 +1597,28 @@ var __exports__ = (() => {
|
|
|
1535
1597
|
compressed: false,
|
|
1536
1598
|
// mipLevels: 1,
|
|
1537
1599
|
usage: 0,
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
border: 0,
|
|
1542
|
-
recreate: false
|
|
1600
|
+
mipLevels: void 0,
|
|
1601
|
+
samples: void 0,
|
|
1602
|
+
type: void 0
|
|
1543
1603
|
};
|
|
1544
1604
|
var Texture = class extends Resource {
|
|
1545
1605
|
get [Symbol.toStringTag]() {
|
|
1546
1606
|
return "Texture";
|
|
1547
1607
|
}
|
|
1548
|
-
|
|
1549
|
-
|
|
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;
|
|
1550
1621
|
}
|
|
1551
|
-
/** Default sampler for this device */
|
|
1552
1622
|
};
|
|
1553
1623
|
__publicField(Texture, "COPY_SRC", 1);
|
|
1554
1624
|
__publicField(Texture, "COPY_DST", 2);
|
|
@@ -1617,6 +1687,10 @@ var __exports__ = (() => {
|
|
|
1617
1687
|
}
|
|
1618
1688
|
/** Width of all attachments in this framebuffer */
|
|
1619
1689
|
/** Height of all attachments in this framebuffer */
|
|
1690
|
+
/** Color attachments */
|
|
1691
|
+
colorAttachments = [];
|
|
1692
|
+
/** Depth-stencil attachment, if provided */
|
|
1693
|
+
depthStencilAttachment = null;
|
|
1620
1694
|
constructor(device, props = {}) {
|
|
1621
1695
|
super(device, props, DEFAULT_FRAMEBUFFER_PROPS);
|
|
1622
1696
|
this.width = this.props.width;
|
|
@@ -1627,16 +1701,162 @@ var __exports__ = (() => {
|
|
|
1627
1701
|
* @note resize() destroys existing textures (if size has changed).
|
|
1628
1702
|
*/
|
|
1629
1703
|
resize(size) {
|
|
1630
|
-
|
|
1704
|
+
let updateSize = !size;
|
|
1631
1705
|
if (size) {
|
|
1632
|
-
|
|
1633
|
-
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;
|
|
1634
1710
|
}
|
|
1635
1711
|
if (updateSize) {
|
|
1636
|
-
|
|
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
|
+
}
|
|
1637
1778
|
}
|
|
1638
1779
|
}
|
|
1639
|
-
/**
|
|
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
|
+
*/
|
|
1640
1860
|
};
|
|
1641
1861
|
|
|
1642
1862
|
// ../api/src/adapter/resources/render-pipeline.ts
|
|
@@ -1680,49 +1900,15 @@ var __exports__ = (() => {
|
|
|
1680
1900
|
/** Private "export" for Model class */
|
|
1681
1901
|
__publicField(RenderPipeline, "_DEFAULT_PROPS", DEFAULT_RENDER_PIPELINE_PROPS);
|
|
1682
1902
|
|
|
1683
|
-
// ../api/src/adapter/resources/command-encoder.ts
|
|
1684
|
-
var DEFAULT_COMMAND_ENCODER_PROPS = {
|
|
1685
|
-
...DEFAULT_RESOURCE_PROPS
|
|
1686
|
-
};
|
|
1687
|
-
var CommandEncoder = class extends Resource {
|
|
1688
|
-
get [Symbol.toStringTag]() {
|
|
1689
|
-
return "CommandEncoder";
|
|
1690
|
-
}
|
|
1691
|
-
constructor(props) {
|
|
1692
|
-
super(props, DEFAULT_COMMAND_ENCODER_PROPS);
|
|
1693
|
-
}
|
|
1694
|
-
// beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
|
|
1695
|
-
// beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
|
|
1696
|
-
// finish(options?: {id?: string}): GPUCommandBuffer;
|
|
1697
|
-
pushDebugGroup(groupLabel) {
|
|
1698
|
-
}
|
|
1699
|
-
popDebugGroup() {
|
|
1700
|
-
}
|
|
1701
|
-
insertDebugMarker(markerLabel) {
|
|
1702
|
-
}
|
|
1703
|
-
// writeTimestamp(querySet: Query, queryIndex: number): void;
|
|
1704
|
-
// resolveQuerySet(options: {
|
|
1705
|
-
// querySet: GPUQuerySet,
|
|
1706
|
-
// firstQuery: number,
|
|
1707
|
-
// queryCount: number,
|
|
1708
|
-
// destination: Buffer,
|
|
1709
|
-
// destinationOffset?: number;
|
|
1710
|
-
// }): void;
|
|
1711
|
-
};
|
|
1712
|
-
|
|
1713
1903
|
// ../api/src/adapter/resources/render-pass.ts
|
|
1714
|
-
var
|
|
1715
|
-
...DEFAULT_RESOURCE_PROPS,
|
|
1716
|
-
framebuffer: null,
|
|
1717
|
-
parameters: null
|
|
1718
|
-
};
|
|
1719
|
-
var RenderPass = class extends Resource {
|
|
1904
|
+
var _RenderPass = class extends Resource {
|
|
1720
1905
|
get [Symbol.toStringTag]() {
|
|
1721
1906
|
return "RenderPass";
|
|
1722
1907
|
}
|
|
1723
1908
|
constructor(device, props) {
|
|
1724
|
-
super(device, props,
|
|
1909
|
+
super(device, props, _RenderPass.defaultProps);
|
|
1725
1910
|
}
|
|
1911
|
+
/** A small set of parameters can be changed between every draw call (viewport, scissorRect, blendColor, stencilReference) */
|
|
1726
1912
|
// writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
|
|
1727
1913
|
// beginOcclusionQuery(queryIndex: number): void;
|
|
1728
1914
|
// endOcclusionQuery(): void;
|
|
@@ -1753,6 +1939,63 @@ var __exports__ = (() => {
|
|
|
1753
1939
|
drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
|
|
1754
1940
|
*/
|
|
1755
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
|
+
};
|
|
1756
1999
|
|
|
1757
2000
|
// ../api/src/lib/utils/assert.ts
|
|
1758
2001
|
function assert2(condition, message2) {
|
|
@@ -1841,7 +2084,130 @@ var __exports__ = (() => {
|
|
|
1841
2084
|
};
|
|
1842
2085
|
}
|
|
1843
2086
|
}
|
|
1844
|
-
|
|
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;
|
|
1845
2211
|
}
|
|
1846
2212
|
|
|
1847
2213
|
// ../api/src/lib/utils/cast.ts
|
|
@@ -1922,51 +2288,11 @@ var __exports__ = (() => {
|
|
|
1922
2288
|
if (scriptId) {
|
|
1923
2289
|
script.id = scriptId;
|
|
1924
2290
|
}
|
|
1925
|
-
return new Promise((resolve, reject) => {
|
|
1926
|
-
script.onload = resolve;
|
|
1927
|
-
script.onerror = (error2) => reject(new Error(`Unable to load script '${scriptUrl}': ${error2}`));
|
|
1928
|
-
head.appendChild(script);
|
|
1929
|
-
});
|
|
1930
|
-
}
|
|
1931
|
-
|
|
1932
|
-
// ../api/src/lib/compiler-log/format-compiler-log.ts
|
|
1933
|
-
function formatCompilerLog(shaderLog, source, options) {
|
|
1934
|
-
const lines = source.split(/\r?\n/);
|
|
1935
|
-
let formattedLog = "";
|
|
1936
|
-
for (const message2 of shaderLog) {
|
|
1937
|
-
formattedLog += formatCompilerMessage(message2, lines, message2.lineNum, options);
|
|
1938
|
-
}
|
|
1939
|
-
return formattedLog;
|
|
1940
|
-
}
|
|
1941
|
-
function formatCompilerMessage(message2, lines, lineNum, options) {
|
|
1942
|
-
if (options?.showSourceCode) {
|
|
1943
|
-
const positionIndicator = message2.linePos > 0 ? `${" ".repeat(message2.linePos + 5)}^^^
|
|
1944
|
-
` : "";
|
|
1945
|
-
const numberedLines = getNumberedLines(lines, lineNum);
|
|
1946
|
-
return `${numberedLines}${positionIndicator}${message2.type.toUpperCase()}: ${message2.message}
|
|
1947
|
-
|
|
1948
|
-
`;
|
|
1949
|
-
}
|
|
1950
|
-
return `${message2.type.toUpperCase()}: ${message2.message}
|
|
1951
|
-
`;
|
|
1952
|
-
}
|
|
1953
|
-
function getNumberedLines(lines, lineNum) {
|
|
1954
|
-
let numberedLines = "";
|
|
1955
|
-
for (let line = lineNum - 2; line <= lineNum; line++) {
|
|
1956
|
-
const sourceLine = lines[line];
|
|
1957
|
-
if (sourceLine !== void 0) {
|
|
1958
|
-
numberedLines += `${padLeft(String(line), 4)}: ${sourceLine}
|
|
1959
|
-
`;
|
|
1960
|
-
}
|
|
1961
|
-
}
|
|
1962
|
-
return numberedLines;
|
|
1963
|
-
}
|
|
1964
|
-
function padLeft(string, paddedLength) {
|
|
1965
|
-
let result = "";
|
|
1966
|
-
for (let i = string.length; i < paddedLength; ++i) {
|
|
1967
|
-
result += " ";
|
|
1968
|
-
}
|
|
1969
|
-
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
|
+
});
|
|
1970
2296
|
}
|
|
1971
2297
|
|
|
1972
2298
|
// src/context/polyfill/polyfill-vertex-array-object.ts
|
|
@@ -2404,13 +2730,13 @@ var __exports__ = (() => {
|
|
|
2404
2730
|
GL2[GL2["SHADING_LANGUAGE_VERSION"] = 35724] = "SHADING_LANGUAGE_VERSION";
|
|
2405
2731
|
GL2[GL2["CURRENT_PROGRAM"] = 35725] = "CURRENT_PROGRAM";
|
|
2406
2732
|
GL2[GL2["NEVER"] = 512] = "NEVER";
|
|
2407
|
-
GL2[GL2["ALWAYS"] = 519] = "ALWAYS";
|
|
2408
2733
|
GL2[GL2["LESS"] = 513] = "LESS";
|
|
2409
2734
|
GL2[GL2["EQUAL"] = 514] = "EQUAL";
|
|
2410
2735
|
GL2[GL2["LEQUAL"] = 515] = "LEQUAL";
|
|
2411
2736
|
GL2[GL2["GREATER"] = 516] = "GREATER";
|
|
2412
|
-
GL2[GL2["GEQUAL"] = 518] = "GEQUAL";
|
|
2413
2737
|
GL2[GL2["NOTEQUAL"] = 517] = "NOTEQUAL";
|
|
2738
|
+
GL2[GL2["GEQUAL"] = 518] = "GEQUAL";
|
|
2739
|
+
GL2[GL2["ALWAYS"] = 519] = "ALWAYS";
|
|
2414
2740
|
GL2[GL2["KEEP"] = 7680] = "KEEP";
|
|
2415
2741
|
GL2[GL2["REPLACE"] = 7681] = "REPLACE";
|
|
2416
2742
|
GL2[GL2["INCR"] = 7682] = "INCR";
|
|
@@ -4163,7 +4489,8 @@ var __exports__ = (() => {
|
|
|
4163
4489
|
"r8unorm": {
|
|
4164
4490
|
gl: GL.R8,
|
|
4165
4491
|
b: 1,
|
|
4166
|
-
c: 1
|
|
4492
|
+
c: 1,
|
|
4493
|
+
renderbuffer: true
|
|
4167
4494
|
},
|
|
4168
4495
|
"r8snorm": {
|
|
4169
4496
|
gl: GL.R8_SNORM,
|
|
@@ -4173,18 +4500,21 @@ var __exports__ = (() => {
|
|
|
4173
4500
|
"r8uint": {
|
|
4174
4501
|
gl: GL.R8UI,
|
|
4175
4502
|
b: 1,
|
|
4176
|
-
c: 1
|
|
4503
|
+
c: 1,
|
|
4504
|
+
renderbuffer: true
|
|
4177
4505
|
},
|
|
4178
4506
|
"r8sint": {
|
|
4179
4507
|
gl: GL.R8I,
|
|
4180
4508
|
b: 1,
|
|
4181
|
-
c: 1
|
|
4509
|
+
c: 1,
|
|
4510
|
+
renderbuffer: true
|
|
4182
4511
|
},
|
|
4183
4512
|
// 16-bit formats
|
|
4184
4513
|
"rg8unorm": {
|
|
4185
4514
|
gl: GL.RG8,
|
|
4186
4515
|
b: 2,
|
|
4187
|
-
c: 2
|
|
4516
|
+
c: 2,
|
|
4517
|
+
renderbuffer: true
|
|
4188
4518
|
},
|
|
4189
4519
|
"rg8snorm": {
|
|
4190
4520
|
gl: GL.RG8_SNORM,
|
|
@@ -4194,69 +4524,80 @@ var __exports__ = (() => {
|
|
|
4194
4524
|
"rg8uint": {
|
|
4195
4525
|
gl: GL.RG8UI,
|
|
4196
4526
|
b: 2,
|
|
4197
|
-
c: 2
|
|
4527
|
+
c: 2,
|
|
4528
|
+
renderbuffer: true
|
|
4198
4529
|
},
|
|
4199
4530
|
"rg8sint": {
|
|
4200
4531
|
gl: GL.RG8I,
|
|
4201
4532
|
b: 2,
|
|
4202
|
-
c: 2
|
|
4533
|
+
c: 2,
|
|
4534
|
+
renderbuffer: true
|
|
4203
4535
|
},
|
|
4204
4536
|
"r16uint": {
|
|
4205
4537
|
gl: GL.R16UI,
|
|
4206
4538
|
b: 2,
|
|
4207
|
-
c: 1
|
|
4539
|
+
c: 1,
|
|
4540
|
+
renderbuffer: true
|
|
4208
4541
|
},
|
|
4209
4542
|
"r16sint": {
|
|
4210
4543
|
gl: GL.R16I,
|
|
4211
4544
|
b: 2,
|
|
4212
|
-
c: 1
|
|
4545
|
+
c: 1,
|
|
4546
|
+
renderbuffer: true
|
|
4213
4547
|
},
|
|
4214
4548
|
"r16float": {
|
|
4215
4549
|
gl: GL.R16F,
|
|
4216
4550
|
b: 2,
|
|
4217
4551
|
c: 1,
|
|
4218
4552
|
render: "texture-renderable-float16-webgl",
|
|
4219
|
-
filter: "texture-filter-linear-float16-webgl"
|
|
4553
|
+
filter: "texture-filter-linear-float16-webgl",
|
|
4554
|
+
renderbuffer: true
|
|
4220
4555
|
},
|
|
4221
4556
|
"r16unorm-webgl": {
|
|
4222
4557
|
gl: GL.R16_EXT,
|
|
4223
4558
|
b: 2,
|
|
4224
4559
|
c: 1,
|
|
4225
|
-
f: "texture-formats-norm16-webgl"
|
|
4560
|
+
f: "texture-formats-norm16-webgl",
|
|
4561
|
+
renderbuffer: true,
|
|
4562
|
+
x: EXT_TEXTURE_NORM16
|
|
4226
4563
|
},
|
|
4227
4564
|
"r16snorm-webgl": {
|
|
4228
4565
|
gl: GL.R16_SNORM_EXT,
|
|
4229
4566
|
b: 2,
|
|
4230
4567
|
c: 1,
|
|
4231
|
-
f: "texture-formats-norm16-webgl"
|
|
4568
|
+
f: "texture-formats-norm16-webgl",
|
|
4569
|
+
x: EXT_TEXTURE_NORM16
|
|
4232
4570
|
},
|
|
4233
4571
|
// Packed 16-bit formats
|
|
4234
4572
|
"rgba4unorm-webgl": {
|
|
4235
4573
|
gl: GL.RGBA4,
|
|
4236
4574
|
b: 2,
|
|
4237
4575
|
c: 4,
|
|
4238
|
-
wgpu: false
|
|
4576
|
+
wgpu: false,
|
|
4577
|
+
renderbuffer: true
|
|
4239
4578
|
},
|
|
4240
4579
|
"rgb565unorm-webgl": {
|
|
4241
4580
|
gl: GL.RGB565,
|
|
4242
4581
|
b: 2,
|
|
4243
4582
|
c: 4,
|
|
4244
|
-
wgpu: false
|
|
4583
|
+
wgpu: false,
|
|
4584
|
+
renderbuffer: true
|
|
4245
4585
|
},
|
|
4246
4586
|
"rgb5a1unorm-webgl": {
|
|
4247
4587
|
gl: GL.RGB5_A1,
|
|
4248
4588
|
b: 2,
|
|
4249
4589
|
c: 4,
|
|
4250
|
-
wgpu: false
|
|
4590
|
+
wgpu: false,
|
|
4591
|
+
renderbuffer: true
|
|
4251
4592
|
},
|
|
4252
4593
|
// 24-bit formats
|
|
4253
|
-
"
|
|
4594
|
+
"rgb8unorm-webgl": {
|
|
4254
4595
|
gl: GL.RGB8,
|
|
4255
4596
|
b: 3,
|
|
4256
4597
|
c: 3,
|
|
4257
4598
|
wgpu: false
|
|
4258
4599
|
},
|
|
4259
|
-
"
|
|
4600
|
+
"rgb8snorm-webgl": {
|
|
4260
4601
|
gl: GL.RGB8_SNORM,
|
|
4261
4602
|
b: 3,
|
|
4262
4603
|
c: 3,
|
|
@@ -4323,31 +4664,36 @@ var __exports__ = (() => {
|
|
|
4323
4664
|
b: 4,
|
|
4324
4665
|
c: 2,
|
|
4325
4666
|
render: "texture-renderable-float16-webgl",
|
|
4326
|
-
filter: "texture-filter-linear-float16-webgl"
|
|
4667
|
+
filter: "texture-filter-linear-float16-webgl",
|
|
4668
|
+
renderbuffer: true
|
|
4327
4669
|
},
|
|
4328
4670
|
"rg16unorm-webgl": {
|
|
4329
4671
|
gl: GL.RG16_EXT,
|
|
4330
4672
|
b: 2,
|
|
4331
4673
|
c: 2,
|
|
4332
|
-
f: "texture-formats-norm16-webgl"
|
|
4674
|
+
f: "texture-formats-norm16-webgl",
|
|
4675
|
+
x: EXT_TEXTURE_NORM16
|
|
4333
4676
|
},
|
|
4334
4677
|
"rg16snorm-webgl": {
|
|
4335
4678
|
gl: GL.RG16_SNORM_EXT,
|
|
4336
4679
|
b: 2,
|
|
4337
4680
|
c: 2,
|
|
4338
|
-
f: "texture-formats-norm16-webgl"
|
|
4681
|
+
f: "texture-formats-norm16-webgl",
|
|
4682
|
+
x: EXT_TEXTURE_NORM16
|
|
4339
4683
|
},
|
|
4340
4684
|
"r32uint": {
|
|
4341
4685
|
gl: GL.R32UI,
|
|
4342
4686
|
b: 4,
|
|
4343
4687
|
c: 1,
|
|
4344
|
-
bpp: 4
|
|
4688
|
+
bpp: 4,
|
|
4689
|
+
renderbuffer: true
|
|
4345
4690
|
},
|
|
4346
4691
|
"r32sint": {
|
|
4347
4692
|
gl: GL.R32I,
|
|
4348
4693
|
b: 4,
|
|
4349
4694
|
c: 1,
|
|
4350
|
-
bpp: 4
|
|
4695
|
+
bpp: 4,
|
|
4696
|
+
renderbuffer: true
|
|
4351
4697
|
},
|
|
4352
4698
|
"r32float": {
|
|
4353
4699
|
gl: GL.R32F,
|
|
@@ -4371,13 +4717,15 @@ var __exports__ = (() => {
|
|
|
4371
4717
|
b: 4,
|
|
4372
4718
|
c: 3,
|
|
4373
4719
|
p: 1,
|
|
4374
|
-
render: "texture-renderable-float32-webgl"
|
|
4720
|
+
render: "texture-renderable-float32-webgl",
|
|
4721
|
+
renderbuffer: true
|
|
4375
4722
|
},
|
|
4376
4723
|
"rgb10a2unorm": {
|
|
4377
4724
|
gl: GL.RGB10_A2,
|
|
4378
4725
|
b: 4,
|
|
4379
4726
|
c: 4,
|
|
4380
|
-
p: 1
|
|
4727
|
+
p: 1,
|
|
4728
|
+
renderbuffer: true
|
|
4381
4729
|
},
|
|
4382
4730
|
// webgl2 only
|
|
4383
4731
|
"rgb10a2unorm-webgl": {
|
|
@@ -4386,48 +4734,56 @@ var __exports__ = (() => {
|
|
|
4386
4734
|
gl: GL.RGB10_A2UI,
|
|
4387
4735
|
p: 1,
|
|
4388
4736
|
wgpu: false,
|
|
4389
|
-
bpp: 4
|
|
4737
|
+
bpp: 4,
|
|
4738
|
+
renderbuffer: true
|
|
4390
4739
|
},
|
|
4391
4740
|
// 48-bit formats
|
|
4392
4741
|
"rgb16unorm-webgl": {
|
|
4393
4742
|
gl: GL.RGB16_EXT,
|
|
4394
4743
|
b: 2,
|
|
4395
4744
|
c: 3,
|
|
4396
|
-
f: "texture-formats-norm16-webgl"
|
|
4745
|
+
f: "texture-formats-norm16-webgl",
|
|
4746
|
+
x: EXT_TEXTURE_NORM16
|
|
4397
4747
|
},
|
|
4398
4748
|
"rgb16snorm-webgl": {
|
|
4399
4749
|
gl: GL.RGB16_SNORM_EXT,
|
|
4400
4750
|
b: 2,
|
|
4401
4751
|
c: 3,
|
|
4402
|
-
f: "texture-formats-norm16-webgl"
|
|
4752
|
+
f: "texture-formats-norm16-webgl",
|
|
4753
|
+
x: EXT_TEXTURE_NORM16
|
|
4403
4754
|
},
|
|
4404
4755
|
// 64-bit formats
|
|
4405
4756
|
"rg32uint": {
|
|
4406
4757
|
gl: GL.RG32UI,
|
|
4407
4758
|
b: 8,
|
|
4408
|
-
c: 2
|
|
4759
|
+
c: 2,
|
|
4760
|
+
renderbuffer: true
|
|
4409
4761
|
},
|
|
4410
4762
|
"rg32sint": {
|
|
4411
4763
|
gl: GL.RG32I,
|
|
4412
4764
|
b: 8,
|
|
4413
|
-
c: 2
|
|
4765
|
+
c: 2,
|
|
4766
|
+
renderbuffer: true
|
|
4414
4767
|
},
|
|
4415
4768
|
"rg32float": {
|
|
4416
4769
|
gl: GL.RG32F,
|
|
4417
4770
|
b: 8,
|
|
4418
4771
|
c: 2,
|
|
4419
4772
|
render: "texture-renderable-float32-webgl",
|
|
4420
|
-
filter: "texture-filter-linear-float32-webgl"
|
|
4773
|
+
filter: "texture-filter-linear-float32-webgl",
|
|
4774
|
+
renderbuffer: true
|
|
4421
4775
|
},
|
|
4422
4776
|
"rgba16uint": {
|
|
4423
4777
|
gl: GL.RGBA16UI,
|
|
4424
4778
|
b: 8,
|
|
4425
|
-
c: 4
|
|
4779
|
+
c: 4,
|
|
4780
|
+
renderbuffer: true
|
|
4426
4781
|
},
|
|
4427
4782
|
"rgba16sint": {
|
|
4428
4783
|
gl: GL.RGBA16I,
|
|
4429
4784
|
b: 8,
|
|
4430
|
-
c: 4
|
|
4785
|
+
c: 4,
|
|
4786
|
+
renderbuffer: true
|
|
4431
4787
|
},
|
|
4432
4788
|
"rgba16float": {
|
|
4433
4789
|
gl: GL.RGBA16F,
|
|
@@ -4441,13 +4797,16 @@ var __exports__ = (() => {
|
|
|
4441
4797
|
gl: GL.RGBA16_EXT,
|
|
4442
4798
|
b: 2,
|
|
4443
4799
|
c: 4,
|
|
4444
|
-
f: "texture-formats-norm16-webgl"
|
|
4800
|
+
f: "texture-formats-norm16-webgl",
|
|
4801
|
+
renderbuffer: true,
|
|
4802
|
+
x: EXT_TEXTURE_NORM16
|
|
4445
4803
|
},
|
|
4446
4804
|
"rgba16snorm-webgl": {
|
|
4447
4805
|
gl: GL.RGBA16_SNORM_EXT,
|
|
4448
4806
|
b: 2,
|
|
4449
4807
|
c: 4,
|
|
4450
|
-
f: "texture-formats-norm16-webgl"
|
|
4808
|
+
f: "texture-formats-norm16-webgl",
|
|
4809
|
+
x: EXT_TEXTURE_NORM16
|
|
4451
4810
|
},
|
|
4452
4811
|
// 96-bit formats (deprecated!)
|
|
4453
4812
|
"rgb32float-webgl": {
|
|
@@ -4465,27 +4824,31 @@ var __exports__ = (() => {
|
|
|
4465
4824
|
"rgba32uint": {
|
|
4466
4825
|
gl: GL.RGBA32UI,
|
|
4467
4826
|
b: 16,
|
|
4468
|
-
c: 4
|
|
4827
|
+
c: 4,
|
|
4828
|
+
renderbuffer: true
|
|
4469
4829
|
},
|
|
4470
4830
|
"rgba32sint": {
|
|
4471
4831
|
gl: GL.RGBA32I,
|
|
4472
4832
|
b: 16,
|
|
4473
|
-
c: 4
|
|
4833
|
+
c: 4,
|
|
4834
|
+
renderbuffer: true
|
|
4474
4835
|
},
|
|
4475
4836
|
"rgba32float": {
|
|
4476
4837
|
gl: GL.RGBA32F,
|
|
4477
|
-
gl1: GL.RGBA,
|
|
4478
4838
|
b: 16,
|
|
4479
4839
|
c: 4,
|
|
4480
4840
|
render: "texture-renderable-float32-webgl",
|
|
4481
|
-
filter: "texture-filter-linear-float32-webgl"
|
|
4841
|
+
filter: "texture-filter-linear-float32-webgl",
|
|
4842
|
+
renderbuffer: true
|
|
4482
4843
|
},
|
|
4483
4844
|
// Depth and stencil formats
|
|
4484
4845
|
"stencil8": {
|
|
4485
4846
|
gl: GL.STENCIL_INDEX8,
|
|
4847
|
+
gl1: GL.STENCIL_INDEX8,
|
|
4486
4848
|
b: 1,
|
|
4487
4849
|
c: 1,
|
|
4488
|
-
attachment: GL.STENCIL_ATTACHMENT
|
|
4850
|
+
attachment: GL.STENCIL_ATTACHMENT,
|
|
4851
|
+
renderbuffer: true
|
|
4489
4852
|
},
|
|
4490
4853
|
// 8 stencil bits
|
|
4491
4854
|
"depth16unorm": {
|
|
@@ -4493,7 +4856,8 @@ var __exports__ = (() => {
|
|
|
4493
4856
|
gl1: GL.DEPTH_COMPONENT16,
|
|
4494
4857
|
b: 2,
|
|
4495
4858
|
c: 1,
|
|
4496
|
-
attachment: GL.DEPTH_ATTACHMENT
|
|
4859
|
+
attachment: GL.DEPTH_ATTACHMENT,
|
|
4860
|
+
renderbuffer: true
|
|
4497
4861
|
},
|
|
4498
4862
|
// 16 depth bits
|
|
4499
4863
|
"depth24plus": {
|
|
@@ -4506,15 +4870,19 @@ var __exports__ = (() => {
|
|
|
4506
4870
|
gl: GL.DEPTH_COMPONENT32F,
|
|
4507
4871
|
b: 4,
|
|
4508
4872
|
c: 1,
|
|
4509
|
-
attachment: GL.DEPTH_ATTACHMENT
|
|
4873
|
+
attachment: GL.DEPTH_ATTACHMENT,
|
|
4874
|
+
renderbuffer: true
|
|
4510
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.
|
|
4511
4877
|
"depth24plus-stencil8": {
|
|
4512
|
-
|
|
4513
|
-
gl: GL.UNSIGNED_INT_24_8,
|
|
4878
|
+
gl: GL.DEPTH_STENCIL,
|
|
4514
4879
|
gl1: GL.DEPTH_STENCIL,
|
|
4880
|
+
b: 4,
|
|
4515
4881
|
c: 2,
|
|
4516
4882
|
p: 1,
|
|
4517
|
-
attachment: GL.DEPTH_STENCIL_ATTACHMENT
|
|
4883
|
+
attachment: GL.DEPTH_STENCIL_ATTACHMENT,
|
|
4884
|
+
renderbuffer: true,
|
|
4885
|
+
depthTexture: true
|
|
4518
4886
|
},
|
|
4519
4887
|
// "depth24unorm-stencil8" feature
|
|
4520
4888
|
"depth24unorm-stencil8": {
|
|
@@ -4522,7 +4890,8 @@ var __exports__ = (() => {
|
|
|
4522
4890
|
b: 4,
|
|
4523
4891
|
c: 2,
|
|
4524
4892
|
p: 1,
|
|
4525
|
-
attachment: GL.DEPTH_STENCIL_ATTACHMENT
|
|
4893
|
+
attachment: GL.DEPTH_STENCIL_ATTACHMENT,
|
|
4894
|
+
renderbuffer: true
|
|
4526
4895
|
},
|
|
4527
4896
|
// "depth32float-stencil8" feature
|
|
4528
4897
|
"depth32float-stencil8": {
|
|
@@ -4530,7 +4899,8 @@ var __exports__ = (() => {
|
|
|
4530
4899
|
b: 5,
|
|
4531
4900
|
c: 2,
|
|
4532
4901
|
p: 1,
|
|
4533
|
-
attachment: GL.DEPTH_STENCIL_ATTACHMENT
|
|
4902
|
+
attachment: GL.DEPTH_STENCIL_ATTACHMENT,
|
|
4903
|
+
renderbuffer: true
|
|
4534
4904
|
},
|
|
4535
4905
|
// BC compressed formats: check device.features.has("texture-compression-bc");
|
|
4536
4906
|
"bc1-rgb-unorm-webgl": {
|
|
@@ -4804,18 +5174,33 @@ var __exports__ = (() => {
|
|
|
4804
5174
|
f: texture_compression_atc_webgl
|
|
4805
5175
|
}
|
|
4806
5176
|
};
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
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
|
+
};
|
|
4817
5202
|
function isTextureFormatSupported(gl, formatOrGL) {
|
|
4818
|
-
const format =
|
|
5203
|
+
const format = convertGLToTextureFormat(formatOrGL);
|
|
4819
5204
|
const info = TEXTURE_FORMATS[format];
|
|
4820
5205
|
if (!info) {
|
|
4821
5206
|
return false;
|
|
@@ -4829,8 +5214,29 @@ var __exports__ = (() => {
|
|
|
4829
5214
|
}
|
|
4830
5215
|
return true;
|
|
4831
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
|
+
}
|
|
4832
5238
|
function isTextureFormatFilterable(gl, formatOrGL) {
|
|
4833
|
-
const format =
|
|
5239
|
+
const format = convertGLToTextureFormat(formatOrGL);
|
|
4834
5240
|
if (!isTextureFormatSupported(gl, format)) {
|
|
4835
5241
|
return false;
|
|
4836
5242
|
}
|
|
@@ -4851,7 +5257,7 @@ var __exports__ = (() => {
|
|
|
4851
5257
|
return true;
|
|
4852
5258
|
}
|
|
4853
5259
|
function isTextureFormatRenderable(gl, formatOrGL) {
|
|
4854
|
-
const format =
|
|
5260
|
+
const format = convertGLToTextureFormat(formatOrGL);
|
|
4855
5261
|
if (!isTextureFormatSupported(gl, format)) {
|
|
4856
5262
|
return false;
|
|
4857
5263
|
}
|
|
@@ -4860,21 +5266,9 @@ var __exports__ = (() => {
|
|
|
4860
5266
|
}
|
|
4861
5267
|
return true;
|
|
4862
5268
|
}
|
|
4863
|
-
function
|
|
4864
|
-
const format =
|
|
4865
|
-
const
|
|
4866
|
-
const webglFormat = isWebGL2(gl) ? formatInfo?.gl : formatInfo?.gl1;
|
|
4867
|
-
if (typeof format === "number") {
|
|
4868
|
-
return webglFormat || format;
|
|
4869
|
-
}
|
|
4870
|
-
if (webglFormat === void 0) {
|
|
4871
|
-
throw new Error(`Unsupported texture format ${format}`);
|
|
4872
|
-
}
|
|
4873
|
-
return webglFormat;
|
|
4874
|
-
}
|
|
4875
|
-
function getWebGLTextureParameters(gl, formatOrGL) {
|
|
4876
|
-
const format = getTextureFormat(formatOrGL);
|
|
4877
|
-
const webglFormat = getWebGLTextureFormat(gl, format);
|
|
5269
|
+
function getWebGLTextureParameters(formatOrGL, isWebGL23) {
|
|
5270
|
+
const format = convertGLToTextureFormat(formatOrGL);
|
|
5271
|
+
const webglFormat = convertTextureFormatToGL(format, isWebGL23);
|
|
4878
5272
|
const decoded = decodeTextureFormat(format);
|
|
4879
5273
|
return {
|
|
4880
5274
|
format: webglFormat,
|
|
@@ -4884,17 +5278,12 @@ var __exports__ = (() => {
|
|
|
4884
5278
|
compressed: decoded.compressed
|
|
4885
5279
|
};
|
|
4886
5280
|
}
|
|
4887
|
-
function
|
|
4888
|
-
const format = getTextureFormat(formatOrGL);
|
|
4889
|
-
if (typeof format === "number") {
|
|
4890
|
-
throw new Error("unsupported depth stencil format");
|
|
4891
|
-
}
|
|
5281
|
+
function getDepthStencilAttachmentWebGL(format) {
|
|
4892
5282
|
const info = TEXTURE_FORMATS[format];
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
throw new Error("not a depth stencil format");
|
|
5283
|
+
if (!info?.attachment) {
|
|
5284
|
+
throw new Error(`${format} is not a depth stencil format`);
|
|
4896
5285
|
}
|
|
4897
|
-
return attachment;
|
|
5286
|
+
return info.attachment;
|
|
4898
5287
|
}
|
|
4899
5288
|
function _checkFloat32ColorAttachment(gl, internalFormat = gl.RGBA, srcFormat = GL.RGBA, srcType = GL.UNSIGNED_BYTE) {
|
|
4900
5289
|
let texture = null;
|
|
@@ -4919,34 +5308,9 @@ var __exports__ = (() => {
|
|
|
4919
5308
|
gl.deleteFramebuffer(framebuffer);
|
|
4920
5309
|
}
|
|
4921
5310
|
}
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
[GL.RG]: 2,
|
|
4926
|
-
[GL.RG_INTEGER]: 2,
|
|
4927
|
-
[GL.RGB]: 3,
|
|
4928
|
-
[GL.RGB_INTEGER]: 3,
|
|
4929
|
-
[GL.RGBA]: 4,
|
|
4930
|
-
[GL.RGBA_INTEGER]: 4,
|
|
4931
|
-
[GL.DEPTH_COMPONENT]: 1,
|
|
4932
|
-
[GL.DEPTH_STENCIL]: 1,
|
|
4933
|
-
[GL.ALPHA]: 1,
|
|
4934
|
-
[GL.LUMINANCE]: 1,
|
|
4935
|
-
[GL.LUMINANCE_ALPHA]: 2
|
|
4936
|
-
};
|
|
4937
|
-
var TYPE_SIZES2 = {
|
|
4938
|
-
[GL.FLOAT]: 4,
|
|
4939
|
-
[GL.UNSIGNED_INT]: 4,
|
|
4940
|
-
[GL.INT]: 4,
|
|
4941
|
-
[GL.UNSIGNED_SHORT]: 2,
|
|
4942
|
-
[GL.SHORT]: 2,
|
|
4943
|
-
[GL.HALF_FLOAT]: 2,
|
|
4944
|
-
[GL.BYTE]: 1,
|
|
4945
|
-
[GL.UNSIGNED_BYTE]: 1
|
|
4946
|
-
};
|
|
4947
|
-
function getTextureFormatBytesPerPixel(gl, formatOrGL) {
|
|
4948
|
-
const format = getTextureFormat(formatOrGL);
|
|
4949
|
-
const params = getWebGLTextureParameters(gl, format);
|
|
5311
|
+
function getTextureFormatBytesPerPixel(formatOrGL, isWebGL23) {
|
|
5312
|
+
const format = convertGLToTextureFormat(formatOrGL);
|
|
5313
|
+
const params = getWebGLTextureParameters(format, isWebGL23);
|
|
4950
5314
|
const channels = DATA_FORMAT_CHANNELS[params.dataFormat] || 4;
|
|
4951
5315
|
const channelSize = TYPE_SIZES2[params.type] || 1;
|
|
4952
5316
|
return channels * channelSize;
|
|
@@ -5351,22 +5715,22 @@ void main(void) {}`;
|
|
|
5351
5715
|
}
|
|
5352
5716
|
function convertCompareFunction(parameter, value) {
|
|
5353
5717
|
return map(parameter, value, {
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5718
|
+
never: GL.NEVER,
|
|
5719
|
+
less: GL.LESS,
|
|
5720
|
+
equal: GL.EQUAL,
|
|
5357
5721
|
"less-equal": GL.LEQUAL,
|
|
5358
|
-
|
|
5722
|
+
greater: GL.GREATER,
|
|
5359
5723
|
"not-equal": GL.NOTEQUAL,
|
|
5360
5724
|
"greater-equal": GL.GEQUAL,
|
|
5361
|
-
|
|
5725
|
+
always: GL.ALWAYS
|
|
5362
5726
|
});
|
|
5363
5727
|
}
|
|
5364
5728
|
function convertStencilOperation(parameter, value) {
|
|
5365
5729
|
return map(parameter, value, {
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5730
|
+
keep: GL.KEEP,
|
|
5731
|
+
zero: GL.ZERO,
|
|
5732
|
+
replace: GL.REPLACE,
|
|
5733
|
+
invert: GL.INVERT,
|
|
5370
5734
|
"increment-clamp": GL.INCR,
|
|
5371
5735
|
"decrement-clamp": GL.DECR,
|
|
5372
5736
|
"increment-wrap": GL.INCR_WRAP,
|
|
@@ -5524,16 +5888,17 @@ void main(void) {}`;
|
|
|
5524
5888
|
this.trackDeallocatedMemory();
|
|
5525
5889
|
this.gl.deleteBuffer(this.handle);
|
|
5526
5890
|
this.destroyed = true;
|
|
5891
|
+
this.handle = null;
|
|
5527
5892
|
}
|
|
5528
5893
|
}
|
|
5529
5894
|
write(data, byteOffset = 0) {
|
|
5530
5895
|
const srcOffset = 0;
|
|
5531
|
-
const byteLength =
|
|
5896
|
+
const byteLength = void 0;
|
|
5532
5897
|
const target = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;
|
|
5533
5898
|
this.gl.bindBuffer(target, this.handle);
|
|
5534
5899
|
if (srcOffset !== 0 || byteLength !== void 0) {
|
|
5535
5900
|
this.device.assertWebGL2();
|
|
5536
|
-
this.
|
|
5901
|
+
this.gl2.bufferSubData(target, byteOffset, data, srcOffset, byteLength);
|
|
5537
5902
|
} else {
|
|
5538
5903
|
this.gl.bufferSubData(target, byteOffset, data);
|
|
5539
5904
|
}
|
|
@@ -5623,11 +5988,21 @@ void main(void) {}`;
|
|
|
5623
5988
|
};
|
|
5624
5989
|
|
|
5625
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
|
+
};
|
|
5626
6001
|
var _WEBGLTexture = class extends Texture {
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
6002
|
+
/** Sampler object (currently unused) */
|
|
6003
|
+
sampler = void 0;
|
|
6004
|
+
// data;
|
|
6005
|
+
glFormat = void 0;
|
|
5631
6006
|
type = void 0;
|
|
5632
6007
|
dataFormat = void 0;
|
|
5633
6008
|
mipmaps = void 0;
|
|
@@ -5641,8 +6016,6 @@ void main(void) {}`;
|
|
|
5641
6016
|
* attempting to bind it as GL_TEXTURE_3D will give rise to a run-time error
|
|
5642
6017
|
* */
|
|
5643
6018
|
textureUnit = void 0;
|
|
5644
|
-
/** Sampler object (currently unused) */
|
|
5645
|
-
sampler = void 0;
|
|
5646
6019
|
/**
|
|
5647
6020
|
* Program.draw() checks the loaded flag of all textures to avoid
|
|
5648
6021
|
* Textures that are still loading from promises
|
|
@@ -5651,7 +6024,8 @@ void main(void) {}`;
|
|
|
5651
6024
|
loaded = false;
|
|
5652
6025
|
constructor(device, props) {
|
|
5653
6026
|
super(device, {
|
|
5654
|
-
|
|
6027
|
+
...DEFAULT_WEBGL_TEXTURE_PROPS,
|
|
6028
|
+
format: "rgba8unorm",
|
|
5655
6029
|
...props
|
|
5656
6030
|
});
|
|
5657
6031
|
this.device = cast(device);
|
|
@@ -5662,6 +6036,7 @@ void main(void) {}`;
|
|
|
5662
6036
|
...this.props,
|
|
5663
6037
|
data: typeof this.props.data
|
|
5664
6038
|
});
|
|
6039
|
+
this.glFormat = GL.RGBA;
|
|
5665
6040
|
this.target = getWebGLTextureTarget(this.props);
|
|
5666
6041
|
this.loaded = false;
|
|
5667
6042
|
if (typeof this.props?.data === "string") {
|
|
@@ -5707,7 +6082,6 @@ void main(void) {}`;
|
|
|
5707
6082
|
} = props;
|
|
5708
6083
|
const {
|
|
5709
6084
|
pixels = null,
|
|
5710
|
-
recreate = false,
|
|
5711
6085
|
pixelStore = {},
|
|
5712
6086
|
textureUnit = void 0
|
|
5713
6087
|
} = props;
|
|
@@ -5725,6 +6099,7 @@ void main(void) {}`;
|
|
|
5725
6099
|
const {
|
|
5726
6100
|
depth = 0
|
|
5727
6101
|
} = props;
|
|
6102
|
+
const glFormat = convertTextureFormatToGL(props.format, this.device.isWebGL2);
|
|
5728
6103
|
({
|
|
5729
6104
|
width,
|
|
5730
6105
|
height,
|
|
@@ -5740,11 +6115,9 @@ void main(void) {}`;
|
|
|
5740
6115
|
width,
|
|
5741
6116
|
height
|
|
5742
6117
|
}));
|
|
5743
|
-
const format = getWebGLTextureFormat(this.gl, props.format);
|
|
5744
6118
|
this.width = width;
|
|
5745
6119
|
this.height = height;
|
|
5746
|
-
this.
|
|
5747
|
-
this.format = format;
|
|
6120
|
+
this.glFormat = glFormat;
|
|
5748
6121
|
this.type = type;
|
|
5749
6122
|
this.dataFormat = dataFormat;
|
|
5750
6123
|
this.textureUnit = textureUnit;
|
|
@@ -5762,7 +6135,7 @@ void main(void) {}`;
|
|
|
5762
6135
|
width,
|
|
5763
6136
|
height,
|
|
5764
6137
|
depth,
|
|
5765
|
-
format,
|
|
6138
|
+
format: glFormat,
|
|
5766
6139
|
type,
|
|
5767
6140
|
dataFormat,
|
|
5768
6141
|
// @ts-expect-error
|
|
@@ -5774,9 +6147,6 @@ void main(void) {}`;
|
|
|
5774
6147
|
if (mipmaps) {
|
|
5775
6148
|
this.generateMipmap();
|
|
5776
6149
|
}
|
|
5777
|
-
if (recreate) {
|
|
5778
|
-
this.data = data;
|
|
5779
|
-
}
|
|
5780
6150
|
if (isVideo) {
|
|
5781
6151
|
this._video = {
|
|
5782
6152
|
video: data,
|
|
@@ -5894,7 +6264,7 @@ void main(void) {}`;
|
|
|
5894
6264
|
*/
|
|
5895
6265
|
// eslint-disable-next-line max-statements, complexity
|
|
5896
6266
|
setImageData(options) {
|
|
5897
|
-
if (this.props.dimension === "3d") {
|
|
6267
|
+
if (this.props.dimension === "3d" || this.props.dimension === "2d-array") {
|
|
5898
6268
|
return this.setImageData3D(options);
|
|
5899
6269
|
}
|
|
5900
6270
|
this.trackDeallocatedMemory("Texture");
|
|
@@ -5902,7 +6272,7 @@ void main(void) {}`;
|
|
|
5902
6272
|
target = this.target,
|
|
5903
6273
|
pixels = null,
|
|
5904
6274
|
level = 0,
|
|
5905
|
-
|
|
6275
|
+
glFormat = this.glFormat,
|
|
5906
6276
|
offset = 0,
|
|
5907
6277
|
parameters = {}
|
|
5908
6278
|
} = options;
|
|
@@ -5948,13 +6318,13 @@ void main(void) {}`;
|
|
|
5948
6318
|
withParameters(this.gl, parameters, () => {
|
|
5949
6319
|
switch (dataType) {
|
|
5950
6320
|
case "null":
|
|
5951
|
-
gl.texImage2D(target, level,
|
|
6321
|
+
gl.texImage2D(target, level, glFormat, width, height, 0, dataFormat, type, data);
|
|
5952
6322
|
break;
|
|
5953
6323
|
case "typed-array":
|
|
5954
6324
|
gl.texImage2D(
|
|
5955
6325
|
target,
|
|
5956
6326
|
level,
|
|
5957
|
-
|
|
6327
|
+
glFormat,
|
|
5958
6328
|
width,
|
|
5959
6329
|
height,
|
|
5960
6330
|
0,
|
|
@@ -5969,14 +6339,14 @@ void main(void) {}`;
|
|
|
5969
6339
|
case "buffer":
|
|
5970
6340
|
gl2 = this.device.assertWebGL2();
|
|
5971
6341
|
gl2.bindBuffer(GL.PIXEL_UNPACK_BUFFER, data.handle || data);
|
|
5972
|
-
gl2.texImage2D(target, level,
|
|
6342
|
+
gl2.texImage2D(target, level, glFormat, width, height, 0, dataFormat, type, offset);
|
|
5973
6343
|
gl2.bindBuffer(GL.PIXEL_UNPACK_BUFFER, null);
|
|
5974
6344
|
break;
|
|
5975
6345
|
case "browser-object":
|
|
5976
6346
|
if (this.device.isWebGL2) {
|
|
5977
|
-
gl.texImage2D(target, level,
|
|
6347
|
+
gl.texImage2D(target, level, glFormat, width, height, 0, dataFormat, type, data);
|
|
5978
6348
|
} else {
|
|
5979
|
-
gl.texImage2D(target, level,
|
|
6349
|
+
gl.texImage2D(target, level, glFormat, dataFormat, type, data);
|
|
5980
6350
|
}
|
|
5981
6351
|
break;
|
|
5982
6352
|
case "compressed":
|
|
@@ -5991,7 +6361,7 @@ void main(void) {}`;
|
|
|
5991
6361
|
if (data && data.byteLength) {
|
|
5992
6362
|
this.trackAllocatedMemory(data.byteLength, "Texture");
|
|
5993
6363
|
} else {
|
|
5994
|
-
const bytesPerPixel = getTextureFormatBytesPerPixel(this.
|
|
6364
|
+
const bytesPerPixel = getTextureFormatBytesPerPixel(this.props.format, this.device.isWebGL2);
|
|
5995
6365
|
this.trackAllocatedMemory(this.width * this.height * bytesPerPixel, "Texture");
|
|
5996
6366
|
}
|
|
5997
6367
|
this.loaded = true;
|
|
@@ -6011,7 +6381,7 @@ void main(void) {}`;
|
|
|
6011
6381
|
width = this.width,
|
|
6012
6382
|
height = this.height,
|
|
6013
6383
|
level = 0,
|
|
6014
|
-
|
|
6384
|
+
glFormat = this.glFormat,
|
|
6015
6385
|
type = this.type,
|
|
6016
6386
|
dataFormat = this.dataFormat,
|
|
6017
6387
|
compressed = false,
|
|
@@ -6049,7 +6419,7 @@ void main(void) {}`;
|
|
|
6049
6419
|
this.gl.bindTexture(this.target, this.handle);
|
|
6050
6420
|
withParameters(this.gl, parameters, () => {
|
|
6051
6421
|
if (compressed) {
|
|
6052
|
-
this.gl.compressedTexSubImage2D(target, level, x, y, width, height,
|
|
6422
|
+
this.gl.compressedTexSubImage2D(target, level, x, y, width, height, glFormat, data);
|
|
6053
6423
|
} else if (data === null) {
|
|
6054
6424
|
this.gl.texSubImage2D(target, level, x, y, width, height, dataFormat, type, null);
|
|
6055
6425
|
} else if (ArrayBuffer.isView(data)) {
|
|
@@ -6158,7 +6528,7 @@ void main(void) {}`;
|
|
|
6158
6528
|
type,
|
|
6159
6529
|
compressed
|
|
6160
6530
|
} = opts;
|
|
6161
|
-
const parameters = getWebGLTextureParameters(this.
|
|
6531
|
+
const parameters = getWebGLTextureParameters(format, this.device.isWebGL2);
|
|
6162
6532
|
dataFormat = dataFormat || parameters.dataFormat;
|
|
6163
6533
|
type = type || parameters.type;
|
|
6164
6534
|
compressed = compressed || parameters.compressed;
|
|
@@ -6301,7 +6671,7 @@ void main(void) {}`;
|
|
|
6301
6671
|
} = options;
|
|
6302
6672
|
this.trackDeallocatedMemory("Texture");
|
|
6303
6673
|
this.gl.bindTexture(this.target, this.handle);
|
|
6304
|
-
const webglTextureFormat = getWebGLTextureParameters(this.
|
|
6674
|
+
const webglTextureFormat = getWebGLTextureParameters(format, this.device.isWebGL2);
|
|
6305
6675
|
withParameters(this.gl, parameters, () => {
|
|
6306
6676
|
if (ArrayBuffer.isView(data)) {
|
|
6307
6677
|
this.gl.texImage3D(
|
|
@@ -6326,7 +6696,7 @@ void main(void) {}`;
|
|
|
6326
6696
|
if (data && data.byteLength) {
|
|
6327
6697
|
this.trackAllocatedMemory(data.byteLength, "Texture");
|
|
6328
6698
|
} else {
|
|
6329
|
-
const bytesPerPixel = getTextureFormatBytesPerPixel(this.
|
|
6699
|
+
const bytesPerPixel = getTextureFormatBytesPerPixel(this.props.format, this.device.isWebGL2);
|
|
6330
6700
|
this.trackAllocatedMemory(this.width * this.height * this.depth * bytesPerPixel, "Texture");
|
|
6331
6701
|
}
|
|
6332
6702
|
this.loaded = true;
|
|
@@ -6425,16 +6795,6 @@ void main(void) {}`;
|
|
|
6425
6795
|
assert2(value !== void 0, `Accessing undefined constant GL.${name}`);
|
|
6426
6796
|
return value;
|
|
6427
6797
|
}
|
|
6428
|
-
function getKey(gl, value) {
|
|
6429
|
-
gl = gl.gl || gl;
|
|
6430
|
-
value = Number(value);
|
|
6431
|
-
for (const key in gl) {
|
|
6432
|
-
if (gl[key] === value) {
|
|
6433
|
-
return `GL.${key}`;
|
|
6434
|
-
}
|
|
6435
|
-
}
|
|
6436
|
-
return String(value);
|
|
6437
|
-
}
|
|
6438
6798
|
|
|
6439
6799
|
// src/adapter/objects/webgl-resource.ts
|
|
6440
6800
|
var ERR_RESOURCE_METHOD_UNDEFINED = "Resource subclass must define virtual methods";
|
|
@@ -6465,9 +6825,6 @@ void main(void) {}`;
|
|
|
6465
6825
|
get handle() {
|
|
6466
6826
|
return this._handle;
|
|
6467
6827
|
}
|
|
6468
|
-
destroy() {
|
|
6469
|
-
this.delete();
|
|
6470
|
-
}
|
|
6471
6828
|
delete({
|
|
6472
6829
|
deleteChildren = false
|
|
6473
6830
|
} = {}) {
|
|
@@ -6477,7 +6834,7 @@ void main(void) {}`;
|
|
|
6477
6834
|
}
|
|
6478
6835
|
this._handle = null;
|
|
6479
6836
|
if (children && deleteChildren) {
|
|
6480
|
-
children.filter(Boolean).forEach((child) => child.
|
|
6837
|
+
children.filter(Boolean).forEach((child) => child.destroy());
|
|
6481
6838
|
}
|
|
6482
6839
|
return this;
|
|
6483
6840
|
}
|
|
@@ -6540,10 +6897,10 @@ void main(void) {}`;
|
|
|
6540
6897
|
const parameter = PARAMETERS[pname];
|
|
6541
6898
|
const parameterAvailable = parameter && (!("webgl2" in parameter) || isWebgl2) && (!("extension" in parameter) || this.gl.getExtension(parameter.extension));
|
|
6542
6899
|
if (parameterAvailable) {
|
|
6543
|
-
const key = keys ?
|
|
6900
|
+
const key = keys ? this.device.getGLKey(pname) : pname;
|
|
6544
6901
|
values[key] = this.getParameter(pname, options);
|
|
6545
6902
|
if (keys && parameter.type === "GLenum") {
|
|
6546
|
-
values[key] =
|
|
6903
|
+
values[key] = this.device.getGLKey(values[key]);
|
|
6547
6904
|
}
|
|
6548
6905
|
}
|
|
6549
6906
|
}
|
|
@@ -6641,204 +6998,8 @@ void main(void) {}`;
|
|
|
6641
6998
|
*/
|
|
6642
6999
|
};
|
|
6643
7000
|
|
|
6644
|
-
// src/adapter/converters/renderbuffer-formats.ts
|
|
6645
|
-
function isRenderbufferFormatSupported(gl, format) {
|
|
6646
|
-
const info = RENDERBUFFER_FORMATS[format];
|
|
6647
|
-
if (!info) {
|
|
6648
|
-
return false;
|
|
6649
|
-
}
|
|
6650
|
-
if (info.ext) {
|
|
6651
|
-
return Boolean(gl.getExtension(info.ext));
|
|
6652
|
-
}
|
|
6653
|
-
if (info.gl2) {
|
|
6654
|
-
return isWebGL2(gl);
|
|
6655
|
-
}
|
|
6656
|
-
return true;
|
|
6657
|
-
}
|
|
6658
|
-
function getRenderbufferFormatBytesPerPixel(format) {
|
|
6659
|
-
return RENDERBUFFER_FORMATS[format].bpp;
|
|
6660
|
-
}
|
|
6661
|
-
var EXT_FLOAT_WEBGL2 = "EXT_color_buffer_float";
|
|
6662
|
-
var RENDERBUFFER_FORMATS = {
|
|
6663
|
-
[GL.DEPTH_COMPONENT16]: {
|
|
6664
|
-
bpp: 2
|
|
6665
|
-
},
|
|
6666
|
-
// 16 depth bits.
|
|
6667
|
-
[GL.DEPTH_COMPONENT24]: {
|
|
6668
|
-
gl2: true,
|
|
6669
|
-
bpp: 3
|
|
6670
|
-
},
|
|
6671
|
-
[GL.DEPTH_COMPONENT32F]: {
|
|
6672
|
-
gl2: true,
|
|
6673
|
-
bpp: 4
|
|
6674
|
-
},
|
|
6675
|
-
[GL.STENCIL_INDEX8]: {
|
|
6676
|
-
bpp: 1
|
|
6677
|
-
},
|
|
6678
|
-
// 8 stencil bits.
|
|
6679
|
-
[GL.DEPTH_STENCIL]: {
|
|
6680
|
-
bpp: 4
|
|
6681
|
-
},
|
|
6682
|
-
[GL.DEPTH24_STENCIL8]: {
|
|
6683
|
-
gl2: true,
|
|
6684
|
-
bpp: 4
|
|
6685
|
-
},
|
|
6686
|
-
[GL.DEPTH32F_STENCIL8]: {
|
|
6687
|
-
gl2: true,
|
|
6688
|
-
bpp: 5
|
|
6689
|
-
},
|
|
6690
|
-
// When using a WebGL 1 context, color renderbuffer formats are limited
|
|
6691
|
-
[GL.RGBA4]: {
|
|
6692
|
-
bpp: 2
|
|
6693
|
-
},
|
|
6694
|
-
[GL.RGB565]: {
|
|
6695
|
-
bpp: 2
|
|
6696
|
-
},
|
|
6697
|
-
[GL.RGB5_A1]: {
|
|
6698
|
-
bpp: 2
|
|
6699
|
-
},
|
|
6700
|
-
// When using a WebGL 2 context, the following values are available additionally:
|
|
6701
|
-
[GL.R8]: {
|
|
6702
|
-
gl2: true,
|
|
6703
|
-
bpp: 1
|
|
6704
|
-
},
|
|
6705
|
-
[GL.R8UI]: {
|
|
6706
|
-
gl2: true,
|
|
6707
|
-
bpp: 1
|
|
6708
|
-
},
|
|
6709
|
-
[GL.R8I]: {
|
|
6710
|
-
gl2: true,
|
|
6711
|
-
bpp: 1
|
|
6712
|
-
},
|
|
6713
|
-
[GL.R16UI]: {
|
|
6714
|
-
gl2: true,
|
|
6715
|
-
bpp: 2
|
|
6716
|
-
},
|
|
6717
|
-
[GL.R16I]: {
|
|
6718
|
-
gl2: true,
|
|
6719
|
-
bpp: 2
|
|
6720
|
-
},
|
|
6721
|
-
[GL.R32UI]: {
|
|
6722
|
-
gl2: true,
|
|
6723
|
-
bpp: 4
|
|
6724
|
-
},
|
|
6725
|
-
[GL.R32I]: {
|
|
6726
|
-
gl2: true,
|
|
6727
|
-
bpp: 4
|
|
6728
|
-
},
|
|
6729
|
-
[GL.RG8]: {
|
|
6730
|
-
gl2: true,
|
|
6731
|
-
bpp: 2
|
|
6732
|
-
},
|
|
6733
|
-
[GL.RG8UI]: {
|
|
6734
|
-
gl2: true,
|
|
6735
|
-
bpp: 2
|
|
6736
|
-
},
|
|
6737
|
-
[GL.RG8I]: {
|
|
6738
|
-
gl2: true,
|
|
6739
|
-
bpp: 2
|
|
6740
|
-
},
|
|
6741
|
-
[GL.RG16UI]: {
|
|
6742
|
-
gl2: true,
|
|
6743
|
-
bpp: 4
|
|
6744
|
-
},
|
|
6745
|
-
[GL.RG16I]: {
|
|
6746
|
-
gl2: true,
|
|
6747
|
-
bpp: 4
|
|
6748
|
-
},
|
|
6749
|
-
[GL.RG32UI]: {
|
|
6750
|
-
gl2: true,
|
|
6751
|
-
bpp: 8
|
|
6752
|
-
},
|
|
6753
|
-
[GL.RG32I]: {
|
|
6754
|
-
gl2: true,
|
|
6755
|
-
bpp: 8
|
|
6756
|
-
},
|
|
6757
|
-
[GL.RGB8]: {
|
|
6758
|
-
gl2: true,
|
|
6759
|
-
bpp: 3
|
|
6760
|
-
},
|
|
6761
|
-
[GL.RGBA8]: {
|
|
6762
|
-
gl2: true,
|
|
6763
|
-
bpp: 4
|
|
6764
|
-
},
|
|
6765
|
-
// [GL.SRGB8_ALPHA8]: {gl2: true, gl1: SRGB}, // When using the EXT_sRGB WebGL1 extension
|
|
6766
|
-
[GL.RGB10_A2]: {
|
|
6767
|
-
gl2: true,
|
|
6768
|
-
bpp: 4
|
|
6769
|
-
},
|
|
6770
|
-
[GL.RGBA8UI]: {
|
|
6771
|
-
gl2: true,
|
|
6772
|
-
bpp: 4
|
|
6773
|
-
},
|
|
6774
|
-
[GL.RGBA8I]: {
|
|
6775
|
-
gl2: true,
|
|
6776
|
-
bpp: 4
|
|
6777
|
-
},
|
|
6778
|
-
[GL.RGB10_A2UI]: {
|
|
6779
|
-
gl2: true,
|
|
6780
|
-
bpp: 4
|
|
6781
|
-
},
|
|
6782
|
-
[GL.RGBA16UI]: {
|
|
6783
|
-
gl2: true,
|
|
6784
|
-
bpp: 8
|
|
6785
|
-
},
|
|
6786
|
-
[GL.RGBA16I]: {
|
|
6787
|
-
gl2: true,
|
|
6788
|
-
bpp: 8
|
|
6789
|
-
},
|
|
6790
|
-
[GL.RGBA32I]: {
|
|
6791
|
-
gl2: true,
|
|
6792
|
-
bpp: 16
|
|
6793
|
-
},
|
|
6794
|
-
[GL.RGBA32UI]: {
|
|
6795
|
-
gl2: true,
|
|
6796
|
-
bpp: 16
|
|
6797
|
-
},
|
|
6798
|
-
// When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
|
|
6799
|
-
[GL.R16F]: {
|
|
6800
|
-
ext: EXT_FLOAT_WEBGL2,
|
|
6801
|
-
bpp: 2
|
|
6802
|
-
},
|
|
6803
|
-
[GL.RG16F]: {
|
|
6804
|
-
ext: EXT_FLOAT_WEBGL2,
|
|
6805
|
-
bpp: 4
|
|
6806
|
-
},
|
|
6807
|
-
[GL.RGBA16F]: {
|
|
6808
|
-
ext: EXT_FLOAT_WEBGL2,
|
|
6809
|
-
bpp: 8
|
|
6810
|
-
},
|
|
6811
|
-
[GL.R32F]: {
|
|
6812
|
-
ext: EXT_FLOAT_WEBGL2,
|
|
6813
|
-
bpp: 4
|
|
6814
|
-
},
|
|
6815
|
-
[GL.RG32F]: {
|
|
6816
|
-
ext: EXT_FLOAT_WEBGL2,
|
|
6817
|
-
bpp: 8
|
|
6818
|
-
},
|
|
6819
|
-
// TODO - can't get WEBGL_color_buffer_float to work on renderbuffers
|
|
6820
|
-
[GL.RGBA32F]: {
|
|
6821
|
-
ext: EXT_FLOAT_WEBGL2,
|
|
6822
|
-
bpp: 16
|
|
6823
|
-
},
|
|
6824
|
-
// [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2, gl1: EXT_FLOAT_WEBGL1},
|
|
6825
|
-
[GL.R11F_G11F_B10F]: {
|
|
6826
|
-
ext: EXT_FLOAT_WEBGL2,
|
|
6827
|
-
bpp: 4
|
|
6828
|
-
}
|
|
6829
|
-
};
|
|
6830
|
-
|
|
6831
7001
|
// src/adapter/objects/webgl-renderbuffer.ts
|
|
6832
|
-
var
|
|
6833
|
-
id: void 0,
|
|
6834
|
-
handle: void 0,
|
|
6835
|
-
userData: void 0,
|
|
6836
|
-
format: 0,
|
|
6837
|
-
width: 1,
|
|
6838
|
-
height: 1,
|
|
6839
|
-
samples: 0
|
|
6840
|
-
};
|
|
6841
|
-
var WEBGLRenderbuffer = class extends WebGLResource {
|
|
7002
|
+
var _WEBGLRenderbuffer = class extends WebGLResource {
|
|
6842
7003
|
get [Symbol.toStringTag]() {
|
|
6843
7004
|
return "Renderbuffer";
|
|
6844
7005
|
}
|
|
@@ -6854,11 +7015,19 @@ void main(void) {}`;
|
|
|
6854
7015
|
get samples() {
|
|
6855
7016
|
return this.props.samples;
|
|
6856
7017
|
}
|
|
6857
|
-
|
|
6858
|
-
return
|
|
7018
|
+
get attachment() {
|
|
7019
|
+
return;
|
|
7020
|
+
}
|
|
7021
|
+
/** WebGL format constant */
|
|
7022
|
+
static isTextureFormatSupported(device, format) {
|
|
7023
|
+
return isRenderbufferFormatSupported(device.gl, format);
|
|
6859
7024
|
}
|
|
6860
7025
|
constructor(device, props) {
|
|
6861
|
-
|
|
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);
|
|
6862
7031
|
this._initialize(this.props);
|
|
6863
7032
|
}
|
|
6864
7033
|
resize(size) {
|
|
@@ -6870,7 +7039,6 @@ void main(void) {}`;
|
|
|
6870
7039
|
});
|
|
6871
7040
|
this._initialize(this.props);
|
|
6872
7041
|
}
|
|
6873
|
-
return this;
|
|
6874
7042
|
}
|
|
6875
7043
|
// PRIVATE METHODS
|
|
6876
7044
|
/** Creates and initializes a renderbuffer object's data store */
|
|
@@ -6885,13 +7053,12 @@ void main(void) {}`;
|
|
|
6885
7053
|
this.trackDeallocatedMemory();
|
|
6886
7054
|
this.gl.bindRenderbuffer(GL.RENDERBUFFER, this.handle);
|
|
6887
7055
|
if (samples !== 0 && this.device.isWebGL2) {
|
|
6888
|
-
this.
|
|
7056
|
+
this.gl2.renderbufferStorageMultisample(GL.RENDERBUFFER, samples, this.glFormat, width, height);
|
|
6889
7057
|
} else {
|
|
6890
|
-
this.gl.renderbufferStorage(GL.RENDERBUFFER,
|
|
7058
|
+
this.gl.renderbufferStorage(GL.RENDERBUFFER, this.glFormat, width, height);
|
|
6891
7059
|
}
|
|
6892
7060
|
this.gl.bindRenderbuffer(GL.RENDERBUFFER, null);
|
|
6893
|
-
this.trackAllocatedMemory(width * height * (samples || 1) *
|
|
6894
|
-
return this;
|
|
7061
|
+
this.trackAllocatedMemory(width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat, this.device.isWebGL2));
|
|
6895
7062
|
}
|
|
6896
7063
|
// RESOURCE IMPLEMENTATION
|
|
6897
7064
|
_createHandle() {
|
|
@@ -6905,51 +7072,57 @@ void main(void) {}`;
|
|
|
6905
7072
|
this.gl.bindRenderbuffer(GL.RENDERBUFFER, handle);
|
|
6906
7073
|
}
|
|
6907
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
|
+
});
|
|
6908
7086
|
|
|
6909
7087
|
// src/adapter/resources/webgl-framebuffer.ts
|
|
6910
7088
|
var WEBGLFramebuffer = class extends Framebuffer {
|
|
6911
7089
|
get texture() {
|
|
6912
7090
|
return this.colorAttachments[0];
|
|
6913
7091
|
}
|
|
6914
|
-
colorAttachments = [];
|
|
6915
|
-
depthStencilAttachment = null;
|
|
6916
|
-
_ownResources = [];
|
|
6917
7092
|
constructor(device, props) {
|
|
6918
7093
|
super(device, props);
|
|
7094
|
+
const isDefaultFramebuffer = props.handle === null;
|
|
6919
7095
|
this.device = device;
|
|
6920
7096
|
this.gl = device.gl;
|
|
6921
|
-
this.handle = this.props.handle
|
|
6922
|
-
if (
|
|
7097
|
+
this.handle = this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();
|
|
7098
|
+
if (!isDefaultFramebuffer) {
|
|
6923
7099
|
device.setSpectorMetadata(this.handle, {
|
|
6924
7100
|
id: this.props.id,
|
|
6925
7101
|
props: this.props
|
|
6926
7102
|
});
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
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
|
+
}
|
|
6936
7111
|
}
|
|
7112
|
+
if (this.depthStencilAttachment) {
|
|
7113
|
+
this._attachOne(getDepthStencilAttachmentWebGL(this.depthStencilAttachment.format), this.depthStencilAttachment);
|
|
7114
|
+
}
|
|
7115
|
+
this.gl.bindFramebuffer(GL.FRAMEBUFFER, null);
|
|
6937
7116
|
}
|
|
6938
|
-
if (this.props.depthStencilAttachment) {
|
|
6939
|
-
this._attachOne(getWebGLDepthStencilAttachment(this.depthStencilAttachment.format), this.depthStencilAttachment);
|
|
6940
|
-
}
|
|
6941
|
-
this.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
|
|
6942
7117
|
if (props.check !== false) {
|
|
6943
7118
|
this._checkStatus();
|
|
6944
7119
|
}
|
|
6945
7120
|
}
|
|
7121
|
+
/** destroys any auto created resources etc. */
|
|
6946
7122
|
destroy() {
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
resource.destroy();
|
|
6950
|
-
}
|
|
7123
|
+
super.destroy();
|
|
7124
|
+
if (!this.destroyed && this.handle !== null) {
|
|
6951
7125
|
this.gl.deleteFramebuffer(this.handle);
|
|
6952
|
-
this.destroyed = true;
|
|
6953
7126
|
}
|
|
6954
7127
|
}
|
|
6955
7128
|
// PRIVATE
|
|
@@ -6958,84 +7131,29 @@ void main(void) {}`;
|
|
|
6958
7131
|
const {
|
|
6959
7132
|
gl
|
|
6960
7133
|
} = this;
|
|
6961
|
-
const
|
|
7134
|
+
const prevHandle2 = gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle);
|
|
6962
7135
|
const status = gl.checkFramebufferStatus(GL.FRAMEBUFFER);
|
|
6963
|
-
gl.bindFramebuffer(GL.FRAMEBUFFER,
|
|
7136
|
+
gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle2 || null);
|
|
6964
7137
|
if (status !== gl.FRAMEBUFFER_COMPLETE) {
|
|
6965
7138
|
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
6966
7139
|
}
|
|
6967
7140
|
}
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
return void 0;
|
|
6972
|
-
}
|
|
6973
|
-
if (colorAttachment instanceof WEBGLTexture) {
|
|
6974
|
-
return colorAttachment;
|
|
6975
|
-
}
|
|
6976
|
-
return this._createColorAttachment(colorAttachment, this.width, this.height);
|
|
6977
|
-
});
|
|
6978
|
-
}
|
|
6979
|
-
/** Create a color attachment */
|
|
6980
|
-
_createColorAttachment(format, width, height) {
|
|
6981
|
-
const texture = this.device._createTexture({
|
|
6982
|
-
id: `${this.id}-color`,
|
|
6983
|
-
data: null,
|
|
6984
|
-
// reserves texture memory, but texels are undefined
|
|
6985
|
-
format,
|
|
6986
|
-
// type: GL.UNSIGNED_BYTE,
|
|
6987
|
-
width,
|
|
6988
|
-
height,
|
|
6989
|
-
// Note: Mipmapping can be disabled by texture resource when we resize the texture
|
|
6990
|
-
// to a non-power-of-two dimenstion (NPOT texture) under WebGL1. To have consistant
|
|
6991
|
-
// behavior we always disable mipmaps.
|
|
6992
|
-
mipmaps: false,
|
|
6993
|
-
// Set MIN and MAG filtering parameters so mipmaps are not used in sampling.
|
|
6994
|
-
// Use LINEAR so subpixel algos like fxaa work.
|
|
6995
|
-
// Set WRAP modes that support NPOT textures too.
|
|
6996
|
-
sampler: {
|
|
6997
|
-
minFilter: "linear",
|
|
6998
|
-
magFilter: "linear",
|
|
6999
|
-
addressModeU: "clamp-to-edge",
|
|
7000
|
-
addressModeV: "clamp-to-edge"
|
|
7001
|
-
}
|
|
7002
|
-
// parameters: {
|
|
7003
|
-
// [GL.TEXTURE_MIN_FILTER]: GL.LINEAR,
|
|
7004
|
-
// [GL.TEXTURE_MAG_FILTER]: GL.LINEAR,
|
|
7005
|
-
// [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
|
|
7006
|
-
// [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE
|
|
7007
|
-
// }
|
|
7008
|
-
});
|
|
7009
|
-
this._ownResources.push(texture);
|
|
7010
|
-
return texture;
|
|
7011
|
-
}
|
|
7012
|
-
/** Create a depth stencil attachment GL.DEPTH24_STENCIL8 */
|
|
7013
|
-
_createDepthStencilAttachment() {
|
|
7014
|
-
if (!this.props.depthStencilAttachment) {
|
|
7015
|
-
return void 0;
|
|
7016
|
-
}
|
|
7017
|
-
if (this.props.depthStencilAttachment instanceof WEBGLRenderbuffer) {
|
|
7018
|
-
return this.props.depthStencilAttachment;
|
|
7019
|
-
}
|
|
7020
|
-
if (this.props.depthStencilAttachment instanceof Texture) {
|
|
7021
|
-
return this.props.depthStencilAttachment;
|
|
7022
|
-
}
|
|
7023
|
-
const format = this.props.depthStencilAttachment;
|
|
7024
|
-
const webglFormat = getWebGLTextureFormat(this.gl, format);
|
|
7025
|
-
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, {
|
|
7026
7144
|
id: `${this.id}-depth-stencil`,
|
|
7027
7145
|
// TODO misleading if not depth and stencil?
|
|
7028
|
-
format
|
|
7146
|
+
format,
|
|
7029
7147
|
// dataFormat: GL.DEPTH_STENCIL,
|
|
7030
7148
|
// type: GL.UNSIGNED_INT_24_8,
|
|
7031
7149
|
width: this.width,
|
|
7032
7150
|
height: this.height
|
|
7033
7151
|
});
|
|
7034
|
-
this._ownResources.push(texture);
|
|
7035
|
-
return texture;
|
|
7036
7152
|
}
|
|
7037
|
-
/**
|
|
7038
|
-
|
|
7153
|
+
/**
|
|
7154
|
+
* Attachment resize is expected to be a noop if size is same
|
|
7155
|
+
*/
|
|
7156
|
+
resizeAttachments(width, height) {
|
|
7039
7157
|
if (this.handle === null) {
|
|
7040
7158
|
this.width = this.gl.drawingBufferWidth;
|
|
7041
7159
|
this.height = this.gl.drawingBufferHeight;
|
|
@@ -7047,25 +7165,24 @@ void main(void) {}`;
|
|
|
7047
7165
|
if (height === void 0) {
|
|
7048
7166
|
height = this.gl.drawingBufferHeight;
|
|
7049
7167
|
}
|
|
7050
|
-
if (width !== this.width && height !== this.height) {
|
|
7051
|
-
log.log(2, `Resizing framebuffer ${this.id} to ${width}x${height}`)();
|
|
7052
|
-
}
|
|
7053
7168
|
for (const colorAttachment of this.colorAttachments) {
|
|
7054
7169
|
colorAttachment.resize({
|
|
7055
7170
|
width,
|
|
7056
7171
|
height
|
|
7057
7172
|
});
|
|
7058
7173
|
}
|
|
7059
|
-
this.depthStencilAttachment
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7174
|
+
if (this.depthStencilAttachment) {
|
|
7175
|
+
this.depthStencilAttachment.resize({
|
|
7176
|
+
width,
|
|
7177
|
+
height
|
|
7178
|
+
});
|
|
7179
|
+
}
|
|
7063
7180
|
return this;
|
|
7064
7181
|
}
|
|
7065
7182
|
/** Attach one attachment */
|
|
7066
7183
|
_attachOne(attachmentPoint, attachment) {
|
|
7067
7184
|
if (attachment instanceof WEBGLRenderbuffer) {
|
|
7068
|
-
this.
|
|
7185
|
+
this._attachWEBGLRenderbuffer(attachmentPoint, attachment);
|
|
7069
7186
|
return attachment;
|
|
7070
7187
|
} else if (Array.isArray(attachment)) {
|
|
7071
7188
|
const [texture, layer = 0, level = 0] = attachment;
|
|
@@ -7077,13 +7194,13 @@ void main(void) {}`;
|
|
|
7077
7194
|
}
|
|
7078
7195
|
throw new Error("attach");
|
|
7079
7196
|
}
|
|
7080
|
-
|
|
7197
|
+
_attachWEBGLRenderbuffer(attachment, renderbuffer) {
|
|
7081
7198
|
this.gl.framebufferRenderbuffer(GL.FRAMEBUFFER, attachment, GL.RENDERBUFFER, renderbuffer.handle);
|
|
7082
7199
|
}
|
|
7083
7200
|
/**
|
|
7084
7201
|
* @param attachment
|
|
7085
7202
|
* @param texture
|
|
7086
|
-
* @param layer = 0 - index into
|
|
7203
|
+
* @param layer = 0 - index into WEBGLTextureArray and Texture3D or face for `TextureCubeMap`
|
|
7087
7204
|
* @param level = 0 - mipmapLevel (must be 0 in WebGL1)
|
|
7088
7205
|
*/
|
|
7089
7206
|
_attachTexture(attachment, texture, layer, level) {
|
|
@@ -7565,12 +7682,9 @@ void main(void) {}`;
|
|
|
7565
7682
|
}
|
|
7566
7683
|
Object.seal(this);
|
|
7567
7684
|
}
|
|
7568
|
-
write(data, byteOffset) {
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
offset: byteOffset
|
|
7572
|
-
});
|
|
7573
|
-
}
|
|
7685
|
+
// override write(data: TypedArray, byteOffset: number = 0): void {
|
|
7686
|
+
// this.subData({data, offset: byteOffset});
|
|
7687
|
+
// }
|
|
7574
7688
|
// returns number of elements in the buffer (assuming that the full buffer is used)
|
|
7575
7689
|
getElementCount(accessor = this.accessor) {
|
|
7576
7690
|
return Math.round(this.byteLength / Accessor.getBytesPerElement(accessor));
|
|
@@ -7982,10 +8096,17 @@ ${formattedLog}`)();
|
|
|
7982
8096
|
}
|
|
7983
8097
|
|
|
7984
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;
|
|
7985
8103
|
var WEBGLRenderPass = class extends RenderPass {
|
|
8104
|
+
/** Parameters that should be applied before each draw call */
|
|
7986
8105
|
constructor(device, props) {
|
|
7987
8106
|
super(device, props);
|
|
7988
8107
|
this.device = device;
|
|
8108
|
+
this.setParameters(this.props.parameters);
|
|
8109
|
+
this.clear();
|
|
7989
8110
|
}
|
|
7990
8111
|
end() {
|
|
7991
8112
|
}
|
|
@@ -7999,6 +8120,102 @@ ${formattedLog}`)();
|
|
|
7999
8120
|
// beginOcclusionQuery(queryIndex: number): void;
|
|
8000
8121
|
// endOcclusionQuery(): void;
|
|
8001
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
|
+
// });
|
|
8002
8219
|
};
|
|
8003
8220
|
|
|
8004
8221
|
// src/adapter/helpers/uniforms.ts
|
|
@@ -8654,7 +8871,7 @@ ${formattedLog}`)();
|
|
|
8654
8871
|
*/
|
|
8655
8872
|
draw(options) {
|
|
8656
8873
|
const {
|
|
8657
|
-
renderPass
|
|
8874
|
+
renderPass,
|
|
8658
8875
|
vertexCount,
|
|
8659
8876
|
// indexCount,
|
|
8660
8877
|
instanceCount,
|
|
@@ -8679,10 +8896,9 @@ ${formattedLog}`)();
|
|
|
8679
8896
|
}
|
|
8680
8897
|
this._applyBindings();
|
|
8681
8898
|
this._applyUniforms();
|
|
8899
|
+
const webglRenderPass = renderPass;
|
|
8682
8900
|
withDeviceParameters(this.device, this.props.parameters, () => {
|
|
8683
|
-
withGLParameters(this.device, {
|
|
8684
|
-
framebuffer: renderPass.props.framebuffer
|
|
8685
|
-
}, () => {
|
|
8901
|
+
withGLParameters(this.device, webglRenderPass.glParameters, () => {
|
|
8686
8902
|
if (isIndexed && isInstanced) {
|
|
8687
8903
|
this.device.gl2?.drawElementsInstanced(
|
|
8688
8904
|
drawMode,
|
|
@@ -8858,6 +9074,257 @@ ${formattedLog}`)();
|
|
|
8858
9074
|
return layout.attributes.find((binding) => binding.name === name) || null;
|
|
8859
9075
|
}
|
|
8860
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
|
+
|
|
8861
9328
|
// src/adapter/webgl-device.ts
|
|
8862
9329
|
var LOG_LEVEL2 = 1;
|
|
8863
9330
|
var _WebGLDevice = class extends Device {
|
|
@@ -9021,8 +9488,9 @@ ${formattedLog}`)();
|
|
|
9021
9488
|
createCanvasContext(props) {
|
|
9022
9489
|
throw new Error("WebGL only supports a single canvas");
|
|
9023
9490
|
}
|
|
9024
|
-
|
|
9025
|
-
|
|
9491
|
+
createBuffer(props) {
|
|
9492
|
+
const newProps = this._getBufferProps(props);
|
|
9493
|
+
return new ClassicBuffer(this, newProps);
|
|
9026
9494
|
}
|
|
9027
9495
|
_createTexture(props) {
|
|
9028
9496
|
return new WEBGLTexture(this, props);
|
|
@@ -9058,6 +9526,9 @@ ${formattedLog}`)();
|
|
|
9058
9526
|
});
|
|
9059
9527
|
return this.renderPass;
|
|
9060
9528
|
}
|
|
9529
|
+
createCommandEncoder(props) {
|
|
9530
|
+
return new WEBGLCommandEncoder(this, props);
|
|
9531
|
+
}
|
|
9061
9532
|
/**
|
|
9062
9533
|
* Offscreen Canvas Support: Commit the frame
|
|
9063
9534
|
* https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/commit
|
|
@@ -9092,19 +9563,21 @@ ${formattedLog}`)();
|
|
|
9092
9563
|
return this._webglLimits;
|
|
9093
9564
|
}
|
|
9094
9565
|
/**
|
|
9095
|
-
*
|
|
9096
|
-
* @note
|
|
9097
|
-
* @todo Promote to `Device` API?
|
|
9566
|
+
* Triggers device (or WebGL context) loss.
|
|
9567
|
+
* @note primarily intended for testing how application reacts to device loss
|
|
9098
9568
|
*/
|
|
9099
9569
|
loseDevice() {
|
|
9570
|
+
let deviceLossTriggered = false;
|
|
9100
9571
|
const ext = this.gl.getExtension("WEBGL_lose_context");
|
|
9101
9572
|
if (ext) {
|
|
9573
|
+
deviceLossTriggered = true;
|
|
9102
9574
|
ext.loseContext();
|
|
9103
9575
|
}
|
|
9104
9576
|
this._resolveContextLost?.({
|
|
9105
9577
|
reason: "destroyed",
|
|
9106
9578
|
message: "Application triggered context loss"
|
|
9107
9579
|
});
|
|
9580
|
+
return deviceLossTriggered;
|
|
9108
9581
|
}
|
|
9109
9582
|
/** Save current WebGL context state onto an internal stack */
|
|
9110
9583
|
pushState() {
|
|
@@ -9121,6 +9594,21 @@ ${formattedLog}`)();
|
|
|
9121
9594
|
setSpectorMetadata(handle, props) {
|
|
9122
9595
|
handle.__SPECTOR_Metadata = props;
|
|
9123
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
|
+
}
|
|
9124
9612
|
};
|
|
9125
9613
|
var WebGLDevice = _WebGLDevice;
|
|
9126
9614
|
//
|
|
@@ -9142,63 +9630,6 @@ ${formattedLog}`)();
|
|
|
9142
9630
|
}
|
|
9143
9631
|
return Boolean(gl && gl._version === 2);
|
|
9144
9632
|
}
|
|
9145
|
-
|
|
9146
|
-
// src/adapter/resources/webgl-command-buffer.ts
|
|
9147
|
-
var CommandBuffer = class {
|
|
9148
|
-
commands = [];
|
|
9149
|
-
};
|
|
9150
|
-
|
|
9151
|
-
// src/adapter/resources/webgl-command-encoder.ts
|
|
9152
|
-
var WEBGLCommandEncoder = class extends CommandEncoder {
|
|
9153
|
-
commandBuffer = new CommandBuffer();
|
|
9154
|
-
constructor(device, props) {
|
|
9155
|
-
super(props);
|
|
9156
|
-
this.device = device;
|
|
9157
|
-
}
|
|
9158
|
-
destroy() {
|
|
9159
|
-
}
|
|
9160
|
-
// beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
|
|
9161
|
-
// beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
|
|
9162
|
-
// finish(options?: {id?: string}): GPUCommandBuffer;
|
|
9163
|
-
copyBufferToBuffer(options) {
|
|
9164
|
-
this.commandBuffer.commands.push({
|
|
9165
|
-
name: "copy-buffer-to-buffer",
|
|
9166
|
-
options
|
|
9167
|
-
});
|
|
9168
|
-
}
|
|
9169
|
-
copyBufferToTexture(options) {
|
|
9170
|
-
this.commandBuffer.commands.push({
|
|
9171
|
-
name: "copy-buffer-to-texture",
|
|
9172
|
-
options
|
|
9173
|
-
});
|
|
9174
|
-
}
|
|
9175
|
-
copyTextureToBuffer(options) {
|
|
9176
|
-
this.commandBuffer.commands.push({
|
|
9177
|
-
name: "copy-texture-to-buffer",
|
|
9178
|
-
options
|
|
9179
|
-
});
|
|
9180
|
-
}
|
|
9181
|
-
copyTextureToTexture(options) {
|
|
9182
|
-
this.commandBuffer.commands.push({
|
|
9183
|
-
name: "copy-texture-to-texture",
|
|
9184
|
-
options
|
|
9185
|
-
});
|
|
9186
|
-
}
|
|
9187
|
-
pushDebugGroup(groupLabel) {
|
|
9188
|
-
}
|
|
9189
|
-
popDebugGroup() {
|
|
9190
|
-
}
|
|
9191
|
-
insertDebugMarker(markerLabel) {
|
|
9192
|
-
}
|
|
9193
|
-
// writeTimestamp(querySet: Query, queryIndex: number): void {}
|
|
9194
|
-
// resolveQuerySet(options: {
|
|
9195
|
-
// querySet: GPUQuerySet,
|
|
9196
|
-
// firstQuery: number,
|
|
9197
|
-
// queryCount: number,
|
|
9198
|
-
// destination: Buffer,
|
|
9199
|
-
// destinationOffset?: number;
|
|
9200
|
-
// }): void;
|
|
9201
|
-
};
|
|
9202
9633
|
return __toCommonJS(src_exports);
|
|
9203
9634
|
})();
|
|
9204
9635
|
return __exports__;
|