@luma.gl/webgl 9.2.0-alpha.1 → 9.2.0-alpha.3
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/sampler-parameters.js +13 -2
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/converters/webgl-shadertypes.d.ts.map +1 -1
- package/dist/adapter/converters/webgl-shadertypes.js +1 -2
- package/dist/adapter/converters/webgl-shadertypes.js.map +1 -1
- package/dist/adapter/converters/webgl-texture-table.d.ts.map +1 -1
- package/dist/adapter/converters/webgl-texture-table.js +15 -11
- package/dist/adapter/converters/webgl-texture-table.js.map +1 -1
- package/dist/adapter/converters/webgl-vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/webgl-vertex-formats.js +1 -2
- package/dist/adapter/converters/webgl-vertex-formats.js.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.d.ts +0 -217
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.js +3 -3
- package/dist/adapter/helpers/webgl-texture-utils.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts +7 -7
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +24 -15
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +2 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +1 -0
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +2 -2
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-query-set.d.ts +2 -2
- package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-query-set.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts +1 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +1 -0
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +2 -2
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +2 -1
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +8 -5
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.d.ts +1 -1
- package/dist/adapter/webgl-adapter.d.ts +2 -1
- package/dist/adapter/webgl-adapter.d.ts.map +1 -1
- package/dist/adapter/webgl-adapter.js +35 -25
- package/dist/adapter/webgl-adapter.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +12 -4
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +60 -17
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +1 -0
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/dist.dev.js +124 -57
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +117 -57
- package/dist/index.cjs.map +2 -2
- package/package.json +4 -4
- package/src/adapter/converters/sampler-parameters.ts +13 -2
- package/src/adapter/converters/webgl-shadertypes.ts +1 -2
- package/src/adapter/converters/webgl-texture-table.ts +20 -14
- package/src/adapter/converters/webgl-vertex-formats.ts +1 -2
- package/src/adapter/helpers/webgl-texture-utils.ts +3 -224
- package/src/adapter/resources/webgl-buffer.ts +38 -20
- package/src/adapter/resources/webgl-command-buffer.ts +4 -3
- package/src/adapter/resources/webgl-command-encoder.ts +1 -1
- package/src/adapter/resources/webgl-framebuffer.ts +2 -2
- package/src/adapter/resources/webgl-query-set.ts +2 -2
- package/src/adapter/resources/webgl-render-pass.ts +1 -0
- package/src/adapter/resources/webgl-render-pipeline.ts +7 -3
- package/src/adapter/resources/webgl-texture.ts +8 -5
- package/src/adapter/webgl-adapter.ts +36 -28
- package/src/adapter/webgl-device.ts +85 -31
- package/src/context/debug/webgl-developer-tools.ts +1 -0
package/dist/dist.dev.js
CHANGED
|
@@ -2026,7 +2026,10 @@ var __exports__ = (() => {
|
|
|
2026
2026
|
function getTextureFormatWebGL(format) {
|
|
2027
2027
|
const formatData = WEBGL_TEXTURE_FORMATS[format];
|
|
2028
2028
|
const webglFormat = convertTextureFormatToGL(format);
|
|
2029
|
-
const decoded =
|
|
2029
|
+
const decoded = import_core3.textureFormatDecoder.getInfo(format);
|
|
2030
|
+
if (decoded.compressed) {
|
|
2031
|
+
formatData.dataFormat = webglFormat;
|
|
2032
|
+
}
|
|
2030
2033
|
return {
|
|
2031
2034
|
internalFormat: webglFormat,
|
|
2032
2035
|
format: formatData?.dataFormat || getWebGLPixelDataFormat(decoded.channels, decoded.integer, decoded.normalized, webglFormat),
|
|
@@ -2036,7 +2039,7 @@ var __exports__ = (() => {
|
|
|
2036
2039
|
};
|
|
2037
2040
|
}
|
|
2038
2041
|
function getDepthStencilAttachmentWebGL(format) {
|
|
2039
|
-
const formatInfo =
|
|
2042
|
+
const formatInfo = import_core3.textureFormatDecoder.getInfo(format);
|
|
2040
2043
|
switch (formatInfo.attachment) {
|
|
2041
2044
|
case "depth":
|
|
2042
2045
|
return 36096 /* DEPTH_ATTACHMENT */;
|
|
@@ -2130,8 +2133,8 @@ var __exports__ = (() => {
|
|
|
2130
2133
|
"r16uint": { gl: 33332 /* R16UI */, rb: true },
|
|
2131
2134
|
"r16sint": { gl: 33331 /* R16I */, rb: true },
|
|
2132
2135
|
"r16float": { gl: 33325 /* R16F */, rb: true },
|
|
2133
|
-
"r16unorm
|
|
2134
|
-
"r16snorm
|
|
2136
|
+
"r16unorm": { gl: 33322 /* R16_EXT */, rb: true },
|
|
2137
|
+
"r16snorm": { gl: 36760 /* R16_SNORM_EXT */ },
|
|
2135
2138
|
// Packed 16-bit formats
|
|
2136
2139
|
"rgba4unorm-webgl": { gl: 32854 /* RGBA4 */, rb: true },
|
|
2137
2140
|
"rgb565unorm-webgl": { gl: 36194 /* RGB565 */, rb: true },
|
|
@@ -2139,7 +2142,7 @@ var __exports__ = (() => {
|
|
|
2139
2142
|
// 24-bit formats
|
|
2140
2143
|
"rgb8unorm-webgl": { gl: 32849 /* RGB8 */ },
|
|
2141
2144
|
"rgb8snorm-webgl": { gl: 36758 /* RGB8_SNORM */ },
|
|
2142
|
-
// 32-bit formats
|
|
2145
|
+
// 32-bit formats
|
|
2143
2146
|
"rgba8unorm": { gl: 32856 /* RGBA8 */ },
|
|
2144
2147
|
"rgba8unorm-srgb": { gl: 35907 /* SRGB8_ALPHA8 */ },
|
|
2145
2148
|
"rgba8snorm": { gl: 36759 /* RGBA8_SNORM */ },
|
|
@@ -2151,8 +2154,8 @@ var __exports__ = (() => {
|
|
|
2151
2154
|
"rg16uint": { gl: 33338 /* RG16UI */ },
|
|
2152
2155
|
"rg16sint": { gl: 33337 /* RG16I */ },
|
|
2153
2156
|
"rg16float": { gl: 33327 /* RG16F */, rb: true },
|
|
2154
|
-
"rg16unorm
|
|
2155
|
-
"rg16snorm
|
|
2157
|
+
"rg16unorm": { gl: 33324 /* RG16_EXT */ },
|
|
2158
|
+
"rg16snorm": { gl: 36761 /* RG16_SNORM_EXT */ },
|
|
2156
2159
|
"r32uint": { gl: 33334 /* R32UI */, rb: true },
|
|
2157
2160
|
"r32sint": { gl: 33333 /* R32I */, rb: true },
|
|
2158
2161
|
"r32float": { gl: 33326 /* R32F */ },
|
|
@@ -2174,8 +2177,8 @@ var __exports__ = (() => {
|
|
|
2174
2177
|
"rgba16uint": { gl: 36214 /* RGBA16UI */, rb: true },
|
|
2175
2178
|
"rgba16sint": { gl: 36232 /* RGBA16I */, rb: true },
|
|
2176
2179
|
"rgba16float": { gl: 34842 /* RGBA16F */ },
|
|
2177
|
-
"rgba16unorm
|
|
2178
|
-
"rgba16snorm
|
|
2180
|
+
"rgba16unorm": { gl: 32859 /* RGBA16_EXT */, rb: true },
|
|
2181
|
+
"rgba16snorm": { gl: 36763 /* RGBA16_SNORM_EXT */ },
|
|
2179
2182
|
// 96-bit formats (deprecated!)
|
|
2180
2183
|
"rgb32float-webgl": { gl: 34837 /* RGB32F */, x: EXT_color_buffer_float, dataFormat: 6407 /* RGB */, types: [5126 /* FLOAT */] },
|
|
2181
2184
|
// 128-bit formats
|
|
@@ -2694,7 +2697,15 @@ var __exports__ = (() => {
|
|
|
2694
2697
|
this._initWithByteLength(props.byteLength || 0);
|
|
2695
2698
|
}
|
|
2696
2699
|
}
|
|
2697
|
-
|
|
2700
|
+
destroy() {
|
|
2701
|
+
if (!this.destroyed && this.handle) {
|
|
2702
|
+
this.removeStats();
|
|
2703
|
+
this.trackDeallocatedMemory();
|
|
2704
|
+
this.gl.deleteBuffer(this.handle);
|
|
2705
|
+
this.destroyed = true;
|
|
2706
|
+
this.handle = null;
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2698
2709
|
/** Allocate a new buffer and initialize to contents of typed array */
|
|
2699
2710
|
_initWithData(data, byteOffset = 0, byteLength = data.byteLength + byteOffset) {
|
|
2700
2711
|
const glTarget = this.glTarget;
|
|
@@ -2723,33 +2734,32 @@ var __exports__ = (() => {
|
|
|
2723
2734
|
this.trackAllocatedMemory(byteLength);
|
|
2724
2735
|
return this;
|
|
2725
2736
|
}
|
|
2726
|
-
destroy() {
|
|
2727
|
-
if (!this.destroyed && this.handle) {
|
|
2728
|
-
this.removeStats();
|
|
2729
|
-
this.trackDeallocatedMemory();
|
|
2730
|
-
this.gl.deleteBuffer(this.handle);
|
|
2731
|
-
this.destroyed = true;
|
|
2732
|
-
this.handle = null;
|
|
2733
|
-
}
|
|
2734
|
-
}
|
|
2735
2737
|
write(data, byteOffset = 0) {
|
|
2738
|
+
const dataView = ArrayBuffer.isView(data) ? data : new Uint8Array(data);
|
|
2736
2739
|
const srcOffset = 0;
|
|
2737
2740
|
const byteLength = void 0;
|
|
2738
2741
|
const glTarget = 36663 /* COPY_WRITE_BUFFER */;
|
|
2739
2742
|
this.gl.bindBuffer(glTarget, this.handle);
|
|
2740
2743
|
if (srcOffset !== 0 || byteLength !== void 0) {
|
|
2741
|
-
this.gl.bufferSubData(glTarget, byteOffset,
|
|
2744
|
+
this.gl.bufferSubData(glTarget, byteOffset, dataView, srcOffset, byteLength);
|
|
2742
2745
|
} else {
|
|
2743
|
-
this.gl.bufferSubData(glTarget, byteOffset,
|
|
2746
|
+
this.gl.bufferSubData(glTarget, byteOffset, dataView);
|
|
2744
2747
|
}
|
|
2745
2748
|
this.gl.bindBuffer(glTarget, null);
|
|
2746
2749
|
this._setDebugData(data, byteOffset, data.byteLength);
|
|
2747
2750
|
}
|
|
2748
|
-
|
|
2751
|
+
async mapAndWriteAsync(callback, byteOffset = 0, byteLength = this.byteLength - byteOffset) {
|
|
2752
|
+
const arrayBuffer = new ArrayBuffer(byteLength);
|
|
2753
|
+
await callback(arrayBuffer, "copied");
|
|
2754
|
+
this.write(arrayBuffer, byteOffset);
|
|
2755
|
+
}
|
|
2749
2756
|
async readAsync(byteOffset = 0, byteLength) {
|
|
2750
2757
|
return this.readSyncWebGL(byteOffset, byteLength);
|
|
2751
2758
|
}
|
|
2752
|
-
|
|
2759
|
+
async mapAndReadAsync(callback, byteOffset = 0, byteLength) {
|
|
2760
|
+
const data = await this.readAsync(byteOffset, byteLength);
|
|
2761
|
+
return await callback(data.buffer, "copied");
|
|
2762
|
+
}
|
|
2753
2763
|
readSyncWebGL(byteOffset = 0, byteLength) {
|
|
2754
2764
|
byteLength = byteLength ?? this.byteLength - byteOffset;
|
|
2755
2765
|
const data = new Uint8Array(byteLength);
|
|
@@ -3262,9 +3272,20 @@ ${source}`;
|
|
|
3262
3272
|
case "none":
|
|
3263
3273
|
return convertMaxFilterMode(minFilter);
|
|
3264
3274
|
case "nearest":
|
|
3265
|
-
|
|
3275
|
+
switch (minFilter) {
|
|
3276
|
+
case "nearest":
|
|
3277
|
+
return 9984 /* NEAREST_MIPMAP_NEAREST */;
|
|
3278
|
+
case "linear":
|
|
3279
|
+
return 9985 /* LINEAR_MIPMAP_NEAREST */;
|
|
3280
|
+
}
|
|
3281
|
+
break;
|
|
3266
3282
|
case "linear":
|
|
3267
|
-
|
|
3283
|
+
switch (minFilter) {
|
|
3284
|
+
case "nearest":
|
|
3285
|
+
return 9986 /* NEAREST_MIPMAP_LINEAR */;
|
|
3286
|
+
case "linear":
|
|
3287
|
+
return 9987 /* LINEAR_MIPMAP_LINEAR */;
|
|
3288
|
+
}
|
|
3268
3289
|
}
|
|
3269
3290
|
}
|
|
3270
3291
|
var init_sampler_parameters = __esm({
|
|
@@ -3493,10 +3514,10 @@ ${source}`;
|
|
|
3493
3514
|
const { mipLevel = 0, byteOffset = 0, x = 0, y = 0, z = 0 } = options;
|
|
3494
3515
|
const { glFormat, glType, compressed } = this;
|
|
3495
3516
|
const glTarget = getWebGLCubeFaceTarget(this.glTarget, this.dimension, depth);
|
|
3496
|
-
const glParameters = {
|
|
3517
|
+
const glParameters = !this.compressed ? {
|
|
3497
3518
|
[3314 /* UNPACK_ROW_LENGTH */]: options.bytesPerRow,
|
|
3498
3519
|
[32878 /* UNPACK_IMAGE_HEIGHT */]: options.rowsPerImage
|
|
3499
|
-
};
|
|
3520
|
+
} : {};
|
|
3500
3521
|
this.gl.bindTexture(glTarget, this.handle);
|
|
3501
3522
|
withGLParameters(this.gl, glParameters, () => {
|
|
3502
3523
|
switch (this.dimension) {
|
|
@@ -3570,7 +3591,7 @@ ${source}`;
|
|
|
3570
3591
|
* Sets sampler parameters on texture
|
|
3571
3592
|
*/
|
|
3572
3593
|
_setSamplerParameters(parameters) {
|
|
3573
|
-
import_core13.log.log(
|
|
3594
|
+
import_core13.log.log(2, `${this.id} sampler parameters`, this.device.getGLKeys(parameters))();
|
|
3574
3595
|
this.gl.bindTexture(this.glTarget, this.handle);
|
|
3575
3596
|
for (const [pname, pvalue] of Object.entries(parameters)) {
|
|
3576
3597
|
const param = Number(pname);
|
|
@@ -4291,7 +4312,11 @@ ${source}`;
|
|
|
4291
4312
|
break;
|
|
4292
4313
|
}
|
|
4293
4314
|
const linkErrorLog = this.device.gl.getProgramInfoLog(this.handle);
|
|
4294
|
-
this.device.reportError(
|
|
4315
|
+
this.device.reportError(
|
|
4316
|
+
new Error(`${errorType} during ${status}: ${linkErrorLog}`),
|
|
4317
|
+
this
|
|
4318
|
+
)();
|
|
4319
|
+
this.device.debug();
|
|
4295
4320
|
}
|
|
4296
4321
|
}
|
|
4297
4322
|
/**
|
|
@@ -4623,6 +4648,7 @@ ${source}`;
|
|
|
4623
4648
|
init_webgl_texture_table();
|
|
4624
4649
|
WEBGLCommandBuffer = class extends import_core16.CommandBuffer {
|
|
4625
4650
|
device;
|
|
4651
|
+
handle = null;
|
|
4626
4652
|
commands = [];
|
|
4627
4653
|
constructor(device) {
|
|
4628
4654
|
super(device, {});
|
|
@@ -4663,6 +4689,7 @@ ${source}`;
|
|
|
4663
4689
|
COLOR_CHANNELS = [1, 2, 4, 8];
|
|
4664
4690
|
WEBGLRenderPass = class extends import_core17.RenderPass {
|
|
4665
4691
|
device;
|
|
4692
|
+
handle = null;
|
|
4666
4693
|
/** Parameters that should be applied before each draw call */
|
|
4667
4694
|
glParameters = {};
|
|
4668
4695
|
constructor(device, props) {
|
|
@@ -5526,7 +5553,7 @@ ${source}`;
|
|
|
5526
5553
|
sourceFormat ||= texture?.glFormat || 6408 /* RGBA */;
|
|
5527
5554
|
sourceType ||= texture?.glType || 5121 /* UNSIGNED_BYTE */;
|
|
5528
5555
|
target2 = getPixelArray(target2, sourceType, sourceFormat, sourceWidth, sourceHeight, sourceDepth);
|
|
5529
|
-
const signedType = (0, import_core22.
|
|
5556
|
+
const signedType = (0, import_core22.getDataType)(target2);
|
|
5530
5557
|
sourceType = sourceType || convertDataTypeToGLDataType(signedType);
|
|
5531
5558
|
const prevHandle = gl.bindFramebuffer(
|
|
5532
5559
|
36160 /* FRAMEBUFFER */,
|
|
@@ -5600,7 +5627,7 @@ ${source}`;
|
|
|
5600
5627
|
}
|
|
5601
5628
|
glType ||= 5121 /* UNSIGNED_BYTE */;
|
|
5602
5629
|
const shaderType = convertGLDataTypeToDataType(glType);
|
|
5603
|
-
const ArrayType = (0, import_core22.
|
|
5630
|
+
const ArrayType = (0, import_core22.getTypedArrayConstructor)(shaderType);
|
|
5604
5631
|
const components = glFormatToComponents(glFormat);
|
|
5605
5632
|
return new ArrayType(width * height * components);
|
|
5606
5633
|
}
|
|
@@ -5687,6 +5714,7 @@ ${source}`;
|
|
|
5687
5714
|
// Public `Device` API
|
|
5688
5715
|
/** type of this device */
|
|
5689
5716
|
type = "webgl";
|
|
5717
|
+
// Use the ! assertion to handle the case where _reuseDevices causes the constructor to return early
|
|
5690
5718
|
/** The underlying WebGL context */
|
|
5691
5719
|
handle;
|
|
5692
5720
|
features;
|
|
@@ -5700,7 +5728,6 @@ ${source}`;
|
|
|
5700
5728
|
_resolveContextLost;
|
|
5701
5729
|
/** WebGL2 context. */
|
|
5702
5730
|
gl;
|
|
5703
|
-
debug = false;
|
|
5704
5731
|
/** Store constants */
|
|
5705
5732
|
// @ts-ignore TODO fix
|
|
5706
5733
|
_constants;
|
|
@@ -5712,15 +5739,26 @@ ${source}`;
|
|
|
5712
5739
|
//
|
|
5713
5740
|
// Public API
|
|
5714
5741
|
//
|
|
5742
|
+
get [Symbol.toStringTag]() {
|
|
5743
|
+
return "WebGLDevice";
|
|
5744
|
+
}
|
|
5715
5745
|
toString() {
|
|
5716
5746
|
return `${this[Symbol.toStringTag]}(${this.id})`;
|
|
5717
5747
|
}
|
|
5748
|
+
isVertexFormatSupported(format) {
|
|
5749
|
+
switch (format) {
|
|
5750
|
+
case "unorm8x4-bgra":
|
|
5751
|
+
return false;
|
|
5752
|
+
default:
|
|
5753
|
+
return true;
|
|
5754
|
+
}
|
|
5755
|
+
}
|
|
5718
5756
|
constructor(props) {
|
|
5719
5757
|
super({ ...props, id: props.id || uid("webgl-device") });
|
|
5720
|
-
|
|
5758
|
+
const canvasContextProps = import_core23.Device._getCanvasContextProps(props);
|
|
5759
|
+
if (!canvasContextProps) {
|
|
5721
5760
|
throw new Error("WebGLDevice requires props.createCanvasContext to be set");
|
|
5722
5761
|
}
|
|
5723
|
-
const canvasContextProps = props.createCanvasContext === true ? {} : props.createCanvasContext;
|
|
5724
5762
|
let device = canvasContextProps.canvas?.gl?.device;
|
|
5725
5763
|
if (device) {
|
|
5726
5764
|
throw new Error(`WebGL context already attached to device ${device.id}`);
|
|
@@ -5736,7 +5774,8 @@ ${source}`;
|
|
|
5736
5774
|
if (props.powerPreference !== void 0) {
|
|
5737
5775
|
webglContextAttributes.powerPreference = props.powerPreference;
|
|
5738
5776
|
}
|
|
5739
|
-
const
|
|
5777
|
+
const externalGLContext = this.props._handle;
|
|
5778
|
+
const gl = externalGLContext || createBrowserContext(
|
|
5740
5779
|
this.canvasContext.canvas,
|
|
5741
5780
|
{
|
|
5742
5781
|
onContextLost: (event) => this._resolveContextLost?.({
|
|
@@ -5753,6 +5792,15 @@ ${source}`;
|
|
|
5753
5792
|
}
|
|
5754
5793
|
device = gl.device;
|
|
5755
5794
|
if (device) {
|
|
5795
|
+
if (props._reuseDevices) {
|
|
5796
|
+
import_core23.log.log(
|
|
5797
|
+
1,
|
|
5798
|
+
`Not creating a new Device, instead returning a reference to Device ${device.id} already attached to WebGL context`,
|
|
5799
|
+
device
|
|
5800
|
+
)();
|
|
5801
|
+
device._reused = true;
|
|
5802
|
+
return device;
|
|
5803
|
+
}
|
|
5756
5804
|
throw new Error(`WebGL context already attached to device ${device.id}`);
|
|
5757
5805
|
}
|
|
5758
5806
|
this.handle = gl;
|
|
@@ -5786,15 +5834,27 @@ ${source}`;
|
|
|
5786
5834
|
this.commandEncoder = new WEBGLCommandEncoder(this, { id: `${this}-command-encoder` });
|
|
5787
5835
|
}
|
|
5788
5836
|
/**
|
|
5789
|
-
* Destroys the
|
|
5790
|
-
*
|
|
5837
|
+
* Destroys the device
|
|
5838
|
+
*
|
|
5839
|
+
* @note "Detaches" from the WebGL context unless _reuseDevices is true.
|
|
5840
|
+
*
|
|
5841
|
+
* @note The underlying WebGL context is not immediately destroyed,
|
|
5842
|
+
* but may be destroyed later through normal JavaScript garbage collection.
|
|
5843
|
+
* This is a fundamental limitation since WebGL does not offer any
|
|
5844
|
+
* browser API for destroying WebGL contexts.
|
|
5791
5845
|
*/
|
|
5792
5846
|
destroy() {
|
|
5847
|
+
if (!this.props._reuseDevices && !this._reused) {
|
|
5848
|
+
delete this.gl.device;
|
|
5849
|
+
}
|
|
5793
5850
|
}
|
|
5794
5851
|
get isLost() {
|
|
5795
5852
|
return this.gl.isContextLost();
|
|
5796
5853
|
}
|
|
5797
5854
|
// IMPLEMENTATION OF ABSTRACT DEVICE
|
|
5855
|
+
getTextureByteAlignment() {
|
|
5856
|
+
return 4;
|
|
5857
|
+
}
|
|
5798
5858
|
createCanvasContext(props) {
|
|
5799
5859
|
throw new Error("WebGL only supports a single canvas");
|
|
5800
5860
|
}
|
|
@@ -5973,7 +6033,7 @@ ${source}`;
|
|
|
5973
6033
|
*/
|
|
5974
6034
|
_setWebGLDebugMetadata(handle, resource, options) {
|
|
5975
6035
|
handle.luma = resource;
|
|
5976
|
-
const spectorMetadata = { props: options.spector, id: options.spector
|
|
6036
|
+
const spectorMetadata = { props: options.spector, id: options.spector["id"] };
|
|
5977
6037
|
handle.__SPECTOR_Metadata = spectorMetadata;
|
|
5978
6038
|
}
|
|
5979
6039
|
};
|
|
@@ -6022,7 +6082,8 @@ ${source}`;
|
|
|
6022
6082
|
}
|
|
6023
6083
|
/**
|
|
6024
6084
|
* Get a device instance from a GL context
|
|
6025
|
-
* Creates
|
|
6085
|
+
* Creates a WebGLCanvasContext against the contexts canvas
|
|
6086
|
+
* @note autoResize will be disabled, assuming that whoever created the external context will be handling resizes.
|
|
6026
6087
|
* @param gl
|
|
6027
6088
|
* @returns
|
|
6028
6089
|
*/
|
|
@@ -6037,30 +6098,36 @@ ${source}`;
|
|
|
6037
6098
|
if (!isWebGL(gl)) {
|
|
6038
6099
|
throw new Error("Invalid WebGL2RenderingContext");
|
|
6039
6100
|
}
|
|
6040
|
-
return new WebGLDevice2({
|
|
6101
|
+
return new WebGLDevice2({
|
|
6102
|
+
_handle: gl,
|
|
6103
|
+
createCanvasContext: { canvas: gl.canvas, autoResize: false }
|
|
6104
|
+
});
|
|
6041
6105
|
}
|
|
6042
6106
|
async create(props = {}) {
|
|
6043
6107
|
const { WebGLDevice: WebGLDevice2 } = await Promise.resolve().then(() => (init_webgl_device(), webgl_device_exports));
|
|
6044
6108
|
import_core24.log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created")();
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
const results = await Promise.allSettled(promises);
|
|
6053
|
-
for (const result of results) {
|
|
6054
|
-
if (result.status === "rejected") {
|
|
6055
|
-
import_core24.log.error(`Failed to initialize debug libraries ${result.reason}`)();
|
|
6109
|
+
try {
|
|
6110
|
+
const promises = [];
|
|
6111
|
+
if (props.debugWebGL || props.debug) {
|
|
6112
|
+
promises.push(loadWebGLDeveloperTools());
|
|
6113
|
+
}
|
|
6114
|
+
if (props.debugSpectorJS) {
|
|
6115
|
+
promises.push(loadSpectorJS(props));
|
|
6056
6116
|
}
|
|
6117
|
+
const results = await Promise.allSettled(promises);
|
|
6118
|
+
for (const result of results) {
|
|
6119
|
+
if (result.status === "rejected") {
|
|
6120
|
+
import_core24.log.error(`Failed to initialize debug libraries ${result.reason}`)();
|
|
6121
|
+
}
|
|
6122
|
+
}
|
|
6123
|
+
const device = new WebGLDevice2(props);
|
|
6124
|
+
const message2 = `${device._reused ? "Reusing" : "Created"} device with WebGL2 ${device.props.debug ? "debug " : ""}context: ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
|
|
6125
|
+
import_core24.log.probe(LOG_LEVEL2, message2)();
|
|
6126
|
+
import_core24.log.table(LOG_LEVEL2, device.info)();
|
|
6127
|
+
return device;
|
|
6128
|
+
} finally {
|
|
6129
|
+
import_core24.log.groupEnd(LOG_LEVEL2)();
|
|
6057
6130
|
}
|
|
6058
|
-
const device = new WebGLDevice2(props);
|
|
6059
|
-
const message2 = `Created ${device.type}${device.debug ? " debug" : ""} context: ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
|
|
6060
|
-
import_core24.log.probe(LOG_LEVEL2, message2)();
|
|
6061
|
-
import_core24.log.table(LOG_LEVEL2, device.info)();
|
|
6062
|
-
import_core24.log.groupEnd(LOG_LEVEL2)();
|
|
6063
|
-
return device;
|
|
6064
6131
|
}
|
|
6065
6132
|
};
|
|
6066
6133
|
webgl2Adapter = new WebGLAdapter();
|