@luma.gl/webgl 9.2.6 → 9.3.0-alpha.2
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/resources/webgl-fence.d.ts +14 -0
- package/dist/adapter/resources/webgl-fence.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-fence.js +49 -0
- package/dist/adapter/resources/webgl-fence.js.map +1 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +4 -6
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +21 -4
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +148 -22
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-adapter.d.ts.map +1 -1
- package/dist/adapter/webgl-adapter.js +19 -19
- package/dist/adapter/webgl-adapter.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.d.ts +2 -2
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +16 -6
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +2 -1
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +14 -13
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +4 -6
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/helpers/create-browser-context.d.ts.map +1 -1
- package/dist/context/helpers/create-browser-context.js +47 -35
- package/dist/context/helpers/create-browser-context.js.map +1 -1
- package/dist/dist.dev.js +468 -274
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +447 -275
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/adapter/resources/webgl-fence.ts +55 -0
- package/src/adapter/resources/webgl-render-pass.ts +4 -6
- package/src/adapter/resources/webgl-texture.ts +209 -37
- package/src/adapter/webgl-adapter.ts +23 -20
- package/src/adapter/webgl-canvas-context.ts +19 -8
- package/src/adapter/webgl-device.ts +15 -14
- package/src/context/debug/webgl-developer-tools.ts +13 -6
- package/src/context/helpers/create-browser-context.ts +54 -43
- package/src/index.ts +1 -0
package/dist/index.cjs
CHANGED
|
@@ -281,16 +281,15 @@ function onGLError(props, err, functionName, args) {
|
|
|
281
281
|
const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);
|
|
282
282
|
const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);
|
|
283
283
|
const message2 = `${errorMessage} in gl.${functionName}(${functionArgs})`;
|
|
284
|
-
import_core2.log.error(message2)();
|
|
284
|
+
import_core2.log.error("%cWebGL", "color: white; background: red; padding: 2px 6px; border-radius: 3px;", message2)();
|
|
285
285
|
debugger;
|
|
286
|
+
throw new Error(message2);
|
|
286
287
|
}
|
|
287
288
|
function onValidateGLFunc(props, functionName, functionArgs) {
|
|
288
289
|
let functionString = "";
|
|
289
|
-
if (import_core2.log.level >= 1) {
|
|
290
|
+
if (props.traceWebGL && import_core2.log.level >= 1) {
|
|
290
291
|
functionString = getFunctionString(functionName, functionArgs);
|
|
291
|
-
|
|
292
|
-
import_core2.log.log(1, functionString)();
|
|
293
|
-
}
|
|
292
|
+
import_core2.log.info(1, "%cWebGL", "color: white; background: blue; padding: 2px 6px; border-radius: 3px;", functionString)();
|
|
294
293
|
}
|
|
295
294
|
for (const arg of functionArgs) {
|
|
296
295
|
if (arg === void 0) {
|
|
@@ -1008,38 +1007,53 @@ var init_webgl_state_tracker = __esm({
|
|
|
1008
1007
|
// dist/context/helpers/create-browser-context.js
|
|
1009
1008
|
function createBrowserContext(canvas, props, webglContextAttributes) {
|
|
1010
1009
|
let errorMessage = "";
|
|
1010
|
+
const onCreateError = (event) => {
|
|
1011
|
+
const statusMessage = event.statusMessage;
|
|
1012
|
+
if (statusMessage) {
|
|
1013
|
+
errorMessage ||= statusMessage;
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
canvas.addEventListener("webglcontextcreationerror", onCreateError, false);
|
|
1017
|
+
const allowSoftwareRenderer = webglContextAttributes.failIfMajorPerformanceCaveat !== true;
|
|
1011
1018
|
const webglProps = {
|
|
1012
1019
|
preserveDrawingBuffer: true,
|
|
1013
|
-
|
|
1014
|
-
|
|
1020
|
+
...webglContextAttributes,
|
|
1021
|
+
// Always start by requesting a high-performance context.
|
|
1022
|
+
failIfMajorPerformanceCaveat: true
|
|
1015
1023
|
};
|
|
1016
1024
|
let gl = null;
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
if (!gl && !webglContextAttributes.failIfMajorPerformanceCaveat) {
|
|
1022
|
-
webglProps.failIfMajorPerformanceCaveat = false;
|
|
1023
|
-
gl = canvas.getContext("webgl2", webglProps);
|
|
1024
|
-
gl.luma ||= {};
|
|
1025
|
-
gl.luma.softwareRenderer = true;
|
|
1026
|
-
}
|
|
1027
|
-
if (!gl) {
|
|
1028
|
-
gl = canvas.getContext("webgl", {});
|
|
1029
|
-
if (gl) {
|
|
1030
|
-
gl = null;
|
|
1031
|
-
errorMessage ||= "Your browser only supports WebGL1";
|
|
1025
|
+
try {
|
|
1026
|
+
gl ||= canvas.getContext("webgl2", webglProps);
|
|
1027
|
+
if (!gl && webglProps.failIfMajorPerformanceCaveat) {
|
|
1028
|
+
errorMessage ||= "Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.";
|
|
1032
1029
|
}
|
|
1030
|
+
if (!gl && allowSoftwareRenderer) {
|
|
1031
|
+
webglProps.failIfMajorPerformanceCaveat = false;
|
|
1032
|
+
gl = canvas.getContext("webgl2", webglProps);
|
|
1033
|
+
if (gl) {
|
|
1034
|
+
gl.luma ||= {};
|
|
1035
|
+
gl.luma.softwareRenderer = true;
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
if (!gl) {
|
|
1039
|
+
gl = canvas.getContext("webgl", {});
|
|
1040
|
+
if (gl) {
|
|
1041
|
+
gl = null;
|
|
1042
|
+
errorMessage ||= "Your browser only supports WebGL1";
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
if (!gl) {
|
|
1046
|
+
errorMessage ||= "Your browser does not support WebGL";
|
|
1047
|
+
throw new Error(`Failed to create WebGL context: ${errorMessage}`);
|
|
1048
|
+
}
|
|
1049
|
+
const { onContextLost, onContextRestored } = props;
|
|
1050
|
+
canvas.addEventListener("webglcontextlost", (event) => onContextLost(event), false);
|
|
1051
|
+
canvas.addEventListener("webglcontextrestored", (event) => onContextRestored(event), false);
|
|
1052
|
+
gl.luma ||= {};
|
|
1053
|
+
return gl;
|
|
1054
|
+
} finally {
|
|
1055
|
+
canvas.removeEventListener("webglcontextcreationerror", onCreateError, false);
|
|
1033
1056
|
}
|
|
1034
|
-
if (!gl) {
|
|
1035
|
-
errorMessage ||= "Your browser does not support WebGL";
|
|
1036
|
-
throw new Error(`Failed to create WebGL context: ${errorMessage}`);
|
|
1037
|
-
}
|
|
1038
|
-
const { onContextLost, onContextRestored } = props;
|
|
1039
|
-
canvas.addEventListener("webglcontextlost", (event) => onContextLost(event), false);
|
|
1040
|
-
canvas.addEventListener("webglcontextrestored", (event) => onContextRestored(event), false);
|
|
1041
|
-
gl.luma ||= {};
|
|
1042
|
-
return gl;
|
|
1043
1057
|
}
|
|
1044
1058
|
var init_create_browser_context = __esm({
|
|
1045
1059
|
"dist/context/helpers/create-browser-context.js"() {
|
|
@@ -1794,14 +1808,25 @@ var init_webgl_canvas_context = __esm({
|
|
|
1794
1808
|
super(props);
|
|
1795
1809
|
this.device = device;
|
|
1796
1810
|
this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
|
|
1797
|
-
this.
|
|
1798
|
-
}
|
|
1799
|
-
getCurrentFramebuffer() {
|
|
1800
|
-
this._framebuffer = this._framebuffer || new WEBGLFramebuffer(this.device, { handle: null });
|
|
1801
|
-
return this._framebuffer;
|
|
1811
|
+
this._configureDevice();
|
|
1802
1812
|
}
|
|
1803
1813
|
// IMPLEMENTATION OF ABSTRACT METHODS
|
|
1804
|
-
|
|
1814
|
+
_configureDevice() {
|
|
1815
|
+
var _a, _b, _c;
|
|
1816
|
+
const shouldResize = this.drawingBufferWidth !== ((_a = this._framebuffer) == null ? void 0 : _a.width) || this.drawingBufferHeight !== ((_b = this._framebuffer) == null ? void 0 : _b.height);
|
|
1817
|
+
if (shouldResize) {
|
|
1818
|
+
(_c = this._framebuffer) == null ? void 0 : _c.resize([this.drawingBufferWidth, this.drawingBufferHeight]);
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
_getCurrentFramebuffer() {
|
|
1822
|
+
this._framebuffer ||= new WEBGLFramebuffer(this.device, {
|
|
1823
|
+
id: "canvas-context-framebuffer",
|
|
1824
|
+
handle: null,
|
|
1825
|
+
// Setting handle to null returns a reference to the default WebGL framebuffer
|
|
1826
|
+
width: this.drawingBufferWidth,
|
|
1827
|
+
height: this.drawingBufferHeight
|
|
1828
|
+
});
|
|
1829
|
+
return this._framebuffer;
|
|
1805
1830
|
}
|
|
1806
1831
|
};
|
|
1807
1832
|
}
|
|
@@ -2562,6 +2587,119 @@ var init_webgl_texture_view = __esm({
|
|
|
2562
2587
|
}
|
|
2563
2588
|
});
|
|
2564
2589
|
|
|
2590
|
+
// dist/adapter/converters/webgl-shadertypes.js
|
|
2591
|
+
function convertDataTypeToGLDataType(normalizedType) {
|
|
2592
|
+
return NORMALIZED_SHADER_TYPE_TO_WEBGL[normalizedType];
|
|
2593
|
+
}
|
|
2594
|
+
function convertGLUniformTypeToShaderVariableType(glUniformType) {
|
|
2595
|
+
return WEBGL_SHADER_TYPES[glUniformType];
|
|
2596
|
+
}
|
|
2597
|
+
function isGLSamplerType(type) {
|
|
2598
|
+
return Boolean(WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[type]);
|
|
2599
|
+
}
|
|
2600
|
+
function getTextureBindingFromGLSamplerType(glSamplerType) {
|
|
2601
|
+
return WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[glSamplerType];
|
|
2602
|
+
}
|
|
2603
|
+
var import_constants14, WEBGL_SHADER_TYPES, WEBGL_SAMPLER_TO_TEXTURE_BINDINGS, NORMALIZED_SHADER_TYPE_TO_WEBGL;
|
|
2604
|
+
var init_webgl_shadertypes = __esm({
|
|
2605
|
+
"dist/adapter/converters/webgl-shadertypes.js"() {
|
|
2606
|
+
"use strict";
|
|
2607
|
+
import_constants14 = require("@luma.gl/constants");
|
|
2608
|
+
WEBGL_SHADER_TYPES = {
|
|
2609
|
+
[5126]: "f32",
|
|
2610
|
+
[35664]: "vec2<f32>",
|
|
2611
|
+
[35665]: "vec3<f32>",
|
|
2612
|
+
[35666]: "vec4<f32>",
|
|
2613
|
+
[5124]: "i32",
|
|
2614
|
+
[35667]: "vec2<i32>",
|
|
2615
|
+
[35668]: "vec3<i32>",
|
|
2616
|
+
[35669]: "vec4<i32>",
|
|
2617
|
+
[5125]: "u32",
|
|
2618
|
+
[36294]: "vec2<u32>",
|
|
2619
|
+
[36295]: "vec3<u32>",
|
|
2620
|
+
[36296]: "vec4<u32>",
|
|
2621
|
+
[35670]: "f32",
|
|
2622
|
+
[35671]: "vec2<f32>",
|
|
2623
|
+
[35672]: "vec3<f32>",
|
|
2624
|
+
[35673]: "vec4<f32>",
|
|
2625
|
+
// TODO - are sizes/components below correct?
|
|
2626
|
+
[35674]: "mat2x2<f32>",
|
|
2627
|
+
[35685]: "mat2x3<f32>",
|
|
2628
|
+
[35686]: "mat2x4<f32>",
|
|
2629
|
+
[35687]: "mat3x2<f32>",
|
|
2630
|
+
[35675]: "mat3x3<f32>",
|
|
2631
|
+
[35688]: "mat3x4<f32>",
|
|
2632
|
+
[35689]: "mat4x2<f32>",
|
|
2633
|
+
[35690]: "mat4x3<f32>",
|
|
2634
|
+
[35676]: "mat4x4<f32>"
|
|
2635
|
+
};
|
|
2636
|
+
WEBGL_SAMPLER_TO_TEXTURE_BINDINGS = {
|
|
2637
|
+
[35678]: { viewDimension: "2d", sampleType: "float" },
|
|
2638
|
+
[35680]: { viewDimension: "cube", sampleType: "float" },
|
|
2639
|
+
[35679]: { viewDimension: "3d", sampleType: "float" },
|
|
2640
|
+
[35682]: { viewDimension: "3d", sampleType: "depth" },
|
|
2641
|
+
[36289]: { viewDimension: "2d-array", sampleType: "float" },
|
|
2642
|
+
[36292]: { viewDimension: "2d-array", sampleType: "depth" },
|
|
2643
|
+
[36293]: { viewDimension: "cube", sampleType: "float" },
|
|
2644
|
+
[36298]: { viewDimension: "2d", sampleType: "sint" },
|
|
2645
|
+
[36299]: { viewDimension: "3d", sampleType: "sint" },
|
|
2646
|
+
[36300]: { viewDimension: "cube", sampleType: "sint" },
|
|
2647
|
+
[36303]: { viewDimension: "2d-array", sampleType: "uint" },
|
|
2648
|
+
[36306]: { viewDimension: "2d", sampleType: "uint" },
|
|
2649
|
+
[36307]: { viewDimension: "3d", sampleType: "uint" },
|
|
2650
|
+
[36308]: { viewDimension: "cube", sampleType: "uint" },
|
|
2651
|
+
[36311]: { viewDimension: "2d-array", sampleType: "uint" }
|
|
2652
|
+
};
|
|
2653
|
+
NORMALIZED_SHADER_TYPE_TO_WEBGL = {
|
|
2654
|
+
uint8: 5121,
|
|
2655
|
+
sint8: 5120,
|
|
2656
|
+
unorm8: 5121,
|
|
2657
|
+
snorm8: 5120,
|
|
2658
|
+
uint16: 5123,
|
|
2659
|
+
sint16: 5122,
|
|
2660
|
+
unorm16: 5123,
|
|
2661
|
+
snorm16: 5122,
|
|
2662
|
+
uint32: 5125,
|
|
2663
|
+
sint32: 5124,
|
|
2664
|
+
// WebGPU does not support normalized 32 bit integer attributes
|
|
2665
|
+
// 'unorm32': GL.UNSIGNED_INT,
|
|
2666
|
+
// 'snorm32': GL.INT,
|
|
2667
|
+
float16: 5131,
|
|
2668
|
+
float32: 5126
|
|
2669
|
+
};
|
|
2670
|
+
}
|
|
2671
|
+
});
|
|
2672
|
+
|
|
2673
|
+
// dist/adapter/converters/shader-formats.js
|
|
2674
|
+
function convertGLDataTypeToDataType(type) {
|
|
2675
|
+
return GL_DATA_TYPE_MAP[type];
|
|
2676
|
+
}
|
|
2677
|
+
var import_constants15, GL_DATA_TYPE_MAP;
|
|
2678
|
+
var init_shader_formats = __esm({
|
|
2679
|
+
"dist/adapter/converters/shader-formats.js"() {
|
|
2680
|
+
"use strict";
|
|
2681
|
+
import_constants15 = require("@luma.gl/constants");
|
|
2682
|
+
GL_DATA_TYPE_MAP = {
|
|
2683
|
+
[5124]: "sint32",
|
|
2684
|
+
[5125]: "uint32",
|
|
2685
|
+
[5122]: "sint16",
|
|
2686
|
+
[5123]: "uint16",
|
|
2687
|
+
[5120]: "sint8",
|
|
2688
|
+
[5121]: "uint8",
|
|
2689
|
+
[5126]: "float32",
|
|
2690
|
+
[5131]: "float16",
|
|
2691
|
+
[33635]: "uint16",
|
|
2692
|
+
[32819]: "uint16",
|
|
2693
|
+
[32820]: "uint16",
|
|
2694
|
+
[33640]: "uint32",
|
|
2695
|
+
[35899]: "uint32",
|
|
2696
|
+
[35902]: "uint32",
|
|
2697
|
+
[34042]: "uint32",
|
|
2698
|
+
[36269]: "uint32"
|
|
2699
|
+
};
|
|
2700
|
+
}
|
|
2701
|
+
});
|
|
2702
|
+
|
|
2565
2703
|
// dist/adapter/resources/webgl-texture.js
|
|
2566
2704
|
function getWebGLTextureTarget(dimension) {
|
|
2567
2705
|
switch (dimension) {
|
|
@@ -2583,16 +2721,19 @@ function getWebGLTextureTarget(dimension) {
|
|
|
2583
2721
|
function getWebGLCubeFaceTarget(glTarget, dimension, level) {
|
|
2584
2722
|
return dimension === "cube" ? 34069 + level : glTarget;
|
|
2585
2723
|
}
|
|
2586
|
-
var import_core13,
|
|
2724
|
+
var import_core13, import_constants16, import_core14, WEBGLTexture;
|
|
2587
2725
|
var init_webgl_texture = __esm({
|
|
2588
2726
|
"dist/adapter/resources/webgl-texture.js"() {
|
|
2589
2727
|
"use strict";
|
|
2590
2728
|
import_core13 = require("@luma.gl/core");
|
|
2591
|
-
|
|
2729
|
+
import_constants16 = require("@luma.gl/constants");
|
|
2592
2730
|
init_webgl_texture_table();
|
|
2593
2731
|
init_sampler_parameters();
|
|
2594
2732
|
init_with_parameters();
|
|
2595
2733
|
init_webgl_texture_view();
|
|
2734
|
+
init_webgl_shadertypes();
|
|
2735
|
+
init_shader_formats();
|
|
2736
|
+
import_core14 = require("@luma.gl/core");
|
|
2596
2737
|
WEBGLTexture = class extends import_core13.Texture {
|
|
2597
2738
|
// readonly MAX_ATTRIBUTES: number;
|
|
2598
2739
|
device;
|
|
@@ -2622,8 +2763,10 @@ var init_webgl_texture = __esm({
|
|
|
2622
2763
|
// state
|
|
2623
2764
|
/** Texture binding slot - TODO - move to texture view? */
|
|
2624
2765
|
_textureUnit = 0;
|
|
2766
|
+
/** Chached framebuffer */
|
|
2767
|
+
_framebuffer = null;
|
|
2625
2768
|
constructor(device, props) {
|
|
2626
|
-
super(device, props);
|
|
2769
|
+
super(device, props, { byteAlignment: 1 });
|
|
2627
2770
|
this.device = device;
|
|
2628
2771
|
this.gl = this.device.gl;
|
|
2629
2772
|
const formatInfo = getTextureFormatWebGL(this.props.format);
|
|
@@ -2655,7 +2798,10 @@ var init_webgl_texture = __esm({
|
|
|
2655
2798
|
Object.seal(this);
|
|
2656
2799
|
}
|
|
2657
2800
|
destroy() {
|
|
2801
|
+
var _a;
|
|
2658
2802
|
if (this.handle) {
|
|
2803
|
+
(_a = this._framebuffer) == null ? void 0 : _a.destroy();
|
|
2804
|
+
this._framebuffer = null;
|
|
2659
2805
|
this.gl.deleteTexture(this.handle);
|
|
2660
2806
|
this.removeStats();
|
|
2661
2807
|
this.trackDeallocatedMemory("Texture");
|
|
@@ -2670,11 +2816,37 @@ var init_webgl_texture = __esm({
|
|
|
2670
2816
|
const parameters = convertSamplerParametersToWebGL(this.sampler.props);
|
|
2671
2817
|
this._setSamplerParameters(parameters);
|
|
2672
2818
|
}
|
|
2819
|
+
copyExternalImage(options_) {
|
|
2820
|
+
const options = this._normalizeCopyExternalImageOptions(options_);
|
|
2821
|
+
if (options.sourceX || options.sourceY) {
|
|
2822
|
+
throw new Error("WebGL does not support sourceX/sourceY)");
|
|
2823
|
+
}
|
|
2824
|
+
const { glFormat, glType } = this;
|
|
2825
|
+
const { image, depth, mipLevel, x, y, z, width, height } = options;
|
|
2826
|
+
const glTarget = getWebGLCubeFaceTarget(this.glTarget, this.dimension, z);
|
|
2827
|
+
const glParameters = options.flipY ? { [37440]: true } : {};
|
|
2828
|
+
this.gl.bindTexture(this.glTarget, this.handle);
|
|
2829
|
+
withGLParameters(this.gl, glParameters, () => {
|
|
2830
|
+
switch (this.dimension) {
|
|
2831
|
+
case "2d":
|
|
2832
|
+
case "cube":
|
|
2833
|
+
this.gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, image);
|
|
2834
|
+
break;
|
|
2835
|
+
case "2d-array":
|
|
2836
|
+
case "3d":
|
|
2837
|
+
this.gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, image);
|
|
2838
|
+
break;
|
|
2839
|
+
default:
|
|
2840
|
+
}
|
|
2841
|
+
});
|
|
2842
|
+
this.gl.bindTexture(this.glTarget, null);
|
|
2843
|
+
return { width: options.width, height: options.height };
|
|
2844
|
+
}
|
|
2673
2845
|
copyImageData(options_) {
|
|
2674
2846
|
const options = this._normalizeCopyImageDataOptions(options_);
|
|
2675
2847
|
const typedArray = options.data;
|
|
2676
|
-
const { width, height, depth } =
|
|
2677
|
-
const { mipLevel = 0, byteOffset = 0, x = 0, y = 0
|
|
2848
|
+
const { width, height, depth, z = 0 } = options;
|
|
2849
|
+
const { mipLevel = 0, byteOffset = 0, x = 0, y = 0 } = options;
|
|
2678
2850
|
const { glFormat, glType, compressed } = this;
|
|
2679
2851
|
const glTarget = getWebGLCubeFaceTarget(this.glTarget, this.dimension, z);
|
|
2680
2852
|
let unpackRowLength;
|
|
@@ -2688,10 +2860,11 @@ var init_webgl_texture = __esm({
|
|
|
2688
2860
|
}
|
|
2689
2861
|
}
|
|
2690
2862
|
const glParameters = !this.compressed ? {
|
|
2863
|
+
[3317]: this.byteAlignment,
|
|
2691
2864
|
...unpackRowLength !== void 0 ? { [3314]: unpackRowLength } : {},
|
|
2692
2865
|
[32878]: options.rowsPerImage
|
|
2693
2866
|
} : {};
|
|
2694
|
-
this.gl.bindTexture(glTarget, this.handle);
|
|
2867
|
+
this.gl.bindTexture(this.glTarget, this.handle);
|
|
2695
2868
|
withGLParameters(this.gl, glParameters, () => {
|
|
2696
2869
|
switch (this.dimension) {
|
|
2697
2870
|
case "2d":
|
|
@@ -2713,35 +2886,92 @@ var init_webgl_texture = __esm({
|
|
|
2713
2886
|
default:
|
|
2714
2887
|
}
|
|
2715
2888
|
});
|
|
2716
|
-
this.gl.bindTexture(glTarget, null);
|
|
2889
|
+
this.gl.bindTexture(this.glTarget, null);
|
|
2717
2890
|
}
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2891
|
+
readBuffer(options = {}, buffer) {
|
|
2892
|
+
throw new Error("readBuffer not implemented");
|
|
2893
|
+
}
|
|
2894
|
+
async readDataAsync(options = {}) {
|
|
2895
|
+
return this.readDataSyncWebGL(options);
|
|
2896
|
+
}
|
|
2897
|
+
writeBuffer(buffer, options_ = {}) {
|
|
2898
|
+
}
|
|
2899
|
+
writeData(data, options_ = {}) {
|
|
2900
|
+
const options = this._normalizeTextureWriteOptions(options_);
|
|
2901
|
+
const typedArray = ArrayBuffer.isView(data) ? data : new Uint8Array(data);
|
|
2902
|
+
const {} = this;
|
|
2903
|
+
const { width, height, mipLevel, x, y, z } = options;
|
|
2904
|
+
const { glFormat, glType, compressed } = this;
|
|
2905
|
+
const depth = 0;
|
|
2725
2906
|
const glTarget = getWebGLCubeFaceTarget(this.glTarget, this.dimension, depth);
|
|
2726
|
-
const glParameters =
|
|
2727
|
-
|
|
2907
|
+
const glParameters = !this.compressed ? {
|
|
2908
|
+
// WebGL does not require byte alignment, but allows it to be specified
|
|
2909
|
+
[3317]: this.byteAlignment
|
|
2910
|
+
// [GL.UNPACK_ROW_LENGTH]: bytesPerRow,
|
|
2911
|
+
// [GL.UNPACK_IMAGE_HEIGHT]: rowsPerImage
|
|
2912
|
+
} : {};
|
|
2913
|
+
this.gl.bindTexture(glTarget, this.handle);
|
|
2914
|
+
this.gl.bindBuffer(35052, null);
|
|
2728
2915
|
withGLParameters(this.gl, glParameters, () => {
|
|
2729
2916
|
switch (this.dimension) {
|
|
2730
2917
|
case "2d":
|
|
2731
2918
|
case "cube":
|
|
2732
|
-
|
|
2919
|
+
if (compressed) {
|
|
2920
|
+
this.gl.compressedTexSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, typedArray);
|
|
2921
|
+
} else {
|
|
2922
|
+
this.gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, typedArray);
|
|
2923
|
+
}
|
|
2733
2924
|
break;
|
|
2734
2925
|
case "2d-array":
|
|
2735
2926
|
case "3d":
|
|
2736
|
-
|
|
2927
|
+
if (compressed) {
|
|
2928
|
+
this.gl.compressedTexSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, typedArray);
|
|
2929
|
+
} else {
|
|
2930
|
+
this.gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, typedArray);
|
|
2931
|
+
}
|
|
2737
2932
|
break;
|
|
2738
2933
|
default:
|
|
2739
2934
|
}
|
|
2740
2935
|
});
|
|
2741
|
-
this.gl.bindTexture(
|
|
2742
|
-
|
|
2936
|
+
this.gl.bindTexture(glTarget, null);
|
|
2937
|
+
}
|
|
2938
|
+
// IMPLEMENTATION SPECIFIC
|
|
2939
|
+
/** @todo - for now we always use 1 for maximum compatibility, we can fine tune later */
|
|
2940
|
+
_getRowByteAlignment(format, width) {
|
|
2941
|
+
return 1;
|
|
2942
|
+
}
|
|
2943
|
+
/**
|
|
2944
|
+
* Wraps a given texture into a framebuffer object, that can be further used
|
|
2945
|
+
* to read data from the texture object.
|
|
2946
|
+
*/
|
|
2947
|
+
_getFramebuffer() {
|
|
2948
|
+
this._framebuffer ||= this.device.createFramebuffer({
|
|
2949
|
+
id: `framebuffer-for-${this.id}`,
|
|
2950
|
+
width: this.width,
|
|
2951
|
+
height: this.height,
|
|
2952
|
+
colorAttachments: [this]
|
|
2953
|
+
});
|
|
2954
|
+
return this._framebuffer;
|
|
2743
2955
|
}
|
|
2744
2956
|
// WEBGL SPECIFIC
|
|
2957
|
+
readDataSyncWebGL(options_ = {}) {
|
|
2958
|
+
const options = this._normalizeTextureReadOptions(options_);
|
|
2959
|
+
const memoryLayout = this.computeMemoryLayout(options);
|
|
2960
|
+
const shaderType = convertGLDataTypeToDataType(this.glType);
|
|
2961
|
+
const ArrayType = (0, import_core14.getTypedArrayConstructor)(shaderType);
|
|
2962
|
+
const targetArray = new ArrayType(memoryLayout.byteLength);
|
|
2963
|
+
const signedType = (0, import_core14.getDataType)(targetArray);
|
|
2964
|
+
const sourceType = convertDataTypeToGLDataType(signedType);
|
|
2965
|
+
const framebuffer = this._getFramebuffer();
|
|
2966
|
+
const prevHandle = this.gl.bindFramebuffer(36160, framebuffer.handle);
|
|
2967
|
+
this.gl.readBuffer(36064);
|
|
2968
|
+
this.gl.readPixels(options.x, options.y, options.width, options.height, this.glFormat, sourceType, targetArray);
|
|
2969
|
+
this.gl.bindFramebuffer(36160, prevHandle || null);
|
|
2970
|
+
return targetArray.buffer;
|
|
2971
|
+
}
|
|
2972
|
+
/**
|
|
2973
|
+
* @note - this is used by the DynamicTexture class to generate mipmaps on WebGL
|
|
2974
|
+
*/
|
|
2745
2975
|
generateMipmapsWebGL(options) {
|
|
2746
2976
|
const isFilterableAndRenderable = this.device.isTextureFormatRenderable(this.props.format) && this.device.isTextureFormatFilterable(this.props.format);
|
|
2747
2977
|
if (!isFilterableAndRenderable) {
|
|
@@ -2821,89 +3051,6 @@ var init_webgl_texture = __esm({
|
|
|
2821
3051
|
}
|
|
2822
3052
|
});
|
|
2823
3053
|
|
|
2824
|
-
// dist/adapter/converters/webgl-shadertypes.js
|
|
2825
|
-
function convertDataTypeToGLDataType(normalizedType) {
|
|
2826
|
-
return NORMALIZED_SHADER_TYPE_TO_WEBGL[normalizedType];
|
|
2827
|
-
}
|
|
2828
|
-
function convertGLUniformTypeToShaderVariableType(glUniformType) {
|
|
2829
|
-
return WEBGL_SHADER_TYPES[glUniformType];
|
|
2830
|
-
}
|
|
2831
|
-
function isGLSamplerType(type) {
|
|
2832
|
-
return Boolean(WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[type]);
|
|
2833
|
-
}
|
|
2834
|
-
function getTextureBindingFromGLSamplerType(glSamplerType) {
|
|
2835
|
-
return WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[glSamplerType];
|
|
2836
|
-
}
|
|
2837
|
-
var import_constants15, WEBGL_SHADER_TYPES, WEBGL_SAMPLER_TO_TEXTURE_BINDINGS, NORMALIZED_SHADER_TYPE_TO_WEBGL;
|
|
2838
|
-
var init_webgl_shadertypes = __esm({
|
|
2839
|
-
"dist/adapter/converters/webgl-shadertypes.js"() {
|
|
2840
|
-
"use strict";
|
|
2841
|
-
import_constants15 = require("@luma.gl/constants");
|
|
2842
|
-
WEBGL_SHADER_TYPES = {
|
|
2843
|
-
[5126]: "f32",
|
|
2844
|
-
[35664]: "vec2<f32>",
|
|
2845
|
-
[35665]: "vec3<f32>",
|
|
2846
|
-
[35666]: "vec4<f32>",
|
|
2847
|
-
[5124]: "i32",
|
|
2848
|
-
[35667]: "vec2<i32>",
|
|
2849
|
-
[35668]: "vec3<i32>",
|
|
2850
|
-
[35669]: "vec4<i32>",
|
|
2851
|
-
[5125]: "u32",
|
|
2852
|
-
[36294]: "vec2<u32>",
|
|
2853
|
-
[36295]: "vec3<u32>",
|
|
2854
|
-
[36296]: "vec4<u32>",
|
|
2855
|
-
[35670]: "f32",
|
|
2856
|
-
[35671]: "vec2<f32>",
|
|
2857
|
-
[35672]: "vec3<f32>",
|
|
2858
|
-
[35673]: "vec4<f32>",
|
|
2859
|
-
// TODO - are sizes/components below correct?
|
|
2860
|
-
[35674]: "mat2x2<f32>",
|
|
2861
|
-
[35685]: "mat2x3<f32>",
|
|
2862
|
-
[35686]: "mat2x4<f32>",
|
|
2863
|
-
[35687]: "mat3x2<f32>",
|
|
2864
|
-
[35675]: "mat3x3<f32>",
|
|
2865
|
-
[35688]: "mat3x4<f32>",
|
|
2866
|
-
[35689]: "mat4x2<f32>",
|
|
2867
|
-
[35690]: "mat4x3<f32>",
|
|
2868
|
-
[35676]: "mat4x4<f32>"
|
|
2869
|
-
};
|
|
2870
|
-
WEBGL_SAMPLER_TO_TEXTURE_BINDINGS = {
|
|
2871
|
-
[35678]: { viewDimension: "2d", sampleType: "float" },
|
|
2872
|
-
[35680]: { viewDimension: "cube", sampleType: "float" },
|
|
2873
|
-
[35679]: { viewDimension: "3d", sampleType: "float" },
|
|
2874
|
-
[35682]: { viewDimension: "3d", sampleType: "depth" },
|
|
2875
|
-
[36289]: { viewDimension: "2d-array", sampleType: "float" },
|
|
2876
|
-
[36292]: { viewDimension: "2d-array", sampleType: "depth" },
|
|
2877
|
-
[36293]: { viewDimension: "cube", sampleType: "float" },
|
|
2878
|
-
[36298]: { viewDimension: "2d", sampleType: "sint" },
|
|
2879
|
-
[36299]: { viewDimension: "3d", sampleType: "sint" },
|
|
2880
|
-
[36300]: { viewDimension: "cube", sampleType: "sint" },
|
|
2881
|
-
[36303]: { viewDimension: "2d-array", sampleType: "uint" },
|
|
2882
|
-
[36306]: { viewDimension: "2d", sampleType: "uint" },
|
|
2883
|
-
[36307]: { viewDimension: "3d", sampleType: "uint" },
|
|
2884
|
-
[36308]: { viewDimension: "cube", sampleType: "uint" },
|
|
2885
|
-
[36311]: { viewDimension: "2d-array", sampleType: "uint" }
|
|
2886
|
-
};
|
|
2887
|
-
NORMALIZED_SHADER_TYPE_TO_WEBGL = {
|
|
2888
|
-
uint8: 5121,
|
|
2889
|
-
sint8: 5120,
|
|
2890
|
-
unorm8: 5121,
|
|
2891
|
-
snorm8: 5120,
|
|
2892
|
-
uint16: 5123,
|
|
2893
|
-
sint16: 5122,
|
|
2894
|
-
unorm16: 5123,
|
|
2895
|
-
snorm16: 5122,
|
|
2896
|
-
uint32: 5125,
|
|
2897
|
-
sint32: 5124,
|
|
2898
|
-
// WebGPU does not support normalized 32 bit integer attributes
|
|
2899
|
-
// 'unorm32': GL.UNSIGNED_INT,
|
|
2900
|
-
// 'snorm32': GL.INT,
|
|
2901
|
-
float16: 5131,
|
|
2902
|
-
float32: 5126
|
|
2903
|
-
};
|
|
2904
|
-
}
|
|
2905
|
-
});
|
|
2906
|
-
|
|
2907
3054
|
// dist/adapter/helpers/get-shader-layout-from-glsl.js
|
|
2908
3055
|
function getShaderLayoutFromGLSL(gl, program) {
|
|
2909
3056
|
const shaderLayout = {
|
|
@@ -2995,7 +3142,7 @@ function readVaryings(gl, program) {
|
|
|
2995
3142
|
}
|
|
2996
3143
|
const { name, type: glUniformType, size } = activeInfo;
|
|
2997
3144
|
const uniformType = convertGLUniformTypeToShaderVariableType(glUniformType);
|
|
2998
|
-
const { type, components } = (0,
|
|
3145
|
+
const { type, components } = (0, import_core15.getVariableShaderTypeInfo)(uniformType);
|
|
2999
3146
|
varyings.push({ location, name, type, size: size * components });
|
|
3000
3147
|
}
|
|
3001
3148
|
varyings.sort((a, b) => a.location - b.location);
|
|
@@ -3096,12 +3243,12 @@ function parseUniformName(name) {
|
|
|
3096
3243
|
isArray: Boolean(matches[2])
|
|
3097
3244
|
};
|
|
3098
3245
|
}
|
|
3099
|
-
var
|
|
3246
|
+
var import_core15, import_constants17;
|
|
3100
3247
|
var init_get_shader_layout_from_glsl = __esm({
|
|
3101
3248
|
"dist/adapter/helpers/get-shader-layout-from-glsl.js"() {
|
|
3102
3249
|
"use strict";
|
|
3103
|
-
|
|
3104
|
-
|
|
3250
|
+
import_core15 = require("@luma.gl/core");
|
|
3251
|
+
import_constants17 = require("@luma.gl/constants");
|
|
3105
3252
|
init_webgl_shadertypes();
|
|
3106
3253
|
}
|
|
3107
3254
|
});
|
|
@@ -3190,11 +3337,11 @@ function setUniform(gl, location, type, value) {
|
|
|
3190
3337
|
}
|
|
3191
3338
|
throw new Error("Illegal uniform");
|
|
3192
3339
|
}
|
|
3193
|
-
var
|
|
3340
|
+
var import_constants18;
|
|
3194
3341
|
var init_set_uniform = __esm({
|
|
3195
3342
|
"dist/adapter/helpers/set-uniform.js"() {
|
|
3196
3343
|
"use strict";
|
|
3197
|
-
|
|
3344
|
+
import_constants18 = require("@luma.gl/constants");
|
|
3198
3345
|
}
|
|
3199
3346
|
});
|
|
3200
3347
|
|
|
@@ -3231,11 +3378,11 @@ function getGLPrimitive(topology) {
|
|
|
3231
3378
|
throw new Error(topology);
|
|
3232
3379
|
}
|
|
3233
3380
|
}
|
|
3234
|
-
var
|
|
3381
|
+
var import_constants19;
|
|
3235
3382
|
var init_webgl_topology_utils = __esm({
|
|
3236
3383
|
"dist/adapter/helpers/webgl-topology-utils.js"() {
|
|
3237
3384
|
"use strict";
|
|
3238
|
-
|
|
3385
|
+
import_constants19 = require("@luma.gl/constants");
|
|
3239
3386
|
}
|
|
3240
3387
|
});
|
|
3241
3388
|
|
|
@@ -3248,7 +3395,7 @@ function mergeShaderLayout(baseLayout, overrideLayout) {
|
|
|
3248
3395
|
for (const attribute of (overrideLayout == null ? void 0 : overrideLayout.attributes) || []) {
|
|
3249
3396
|
const baseAttribute = mergedLayout.attributes.find((attr) => attr.name === attribute.name);
|
|
3250
3397
|
if (!baseAttribute) {
|
|
3251
|
-
|
|
3398
|
+
import_core16.log.warn(`shader layout attribute ${attribute.name} not present in shader`);
|
|
3252
3399
|
} else {
|
|
3253
3400
|
baseAttribute.type = attribute.type || baseAttribute.type;
|
|
3254
3401
|
baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;
|
|
@@ -3256,12 +3403,12 @@ function mergeShaderLayout(baseLayout, overrideLayout) {
|
|
|
3256
3403
|
}
|
|
3257
3404
|
return mergedLayout;
|
|
3258
3405
|
}
|
|
3259
|
-
var
|
|
3406
|
+
var import_core16, import_constants20, LOG_PROGRAM_PERF_PRIORITY, WEBGLRenderPipeline;
|
|
3260
3407
|
var init_webgl_render_pipeline = __esm({
|
|
3261
3408
|
"dist/adapter/resources/webgl-render-pipeline.js"() {
|
|
3262
3409
|
"use strict";
|
|
3263
|
-
|
|
3264
|
-
|
|
3410
|
+
import_core16 = require("@luma.gl/core");
|
|
3411
|
+
import_constants20 = require("@luma.gl/constants");
|
|
3265
3412
|
init_get_shader_layout_from_glsl();
|
|
3266
3413
|
init_device_parameters();
|
|
3267
3414
|
init_set_uniform();
|
|
@@ -3271,7 +3418,7 @@ var init_webgl_render_pipeline = __esm({
|
|
|
3271
3418
|
init_webgl_texture_view();
|
|
3272
3419
|
init_webgl_topology_utils();
|
|
3273
3420
|
LOG_PROGRAM_PERF_PRIORITY = 4;
|
|
3274
|
-
WEBGLRenderPipeline = class extends
|
|
3421
|
+
WEBGLRenderPipeline = class extends import_core16.RenderPipeline {
|
|
3275
3422
|
/** The WebGL device that created this render pipeline */
|
|
3276
3423
|
device;
|
|
3277
3424
|
/** Handle to underlying WebGL program */
|
|
@@ -3307,9 +3454,9 @@ var init_webgl_render_pipeline = __esm({
|
|
|
3307
3454
|
this.device.gl.transformFeedbackVaryings(this.handle, varyings, bufferMode);
|
|
3308
3455
|
}
|
|
3309
3456
|
this._linkShaders();
|
|
3310
|
-
|
|
3457
|
+
import_core16.log.time(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
3311
3458
|
this.introspectedLayout = getShaderLayoutFromGLSL(this.device.gl, this.handle);
|
|
3312
|
-
|
|
3459
|
+
import_core16.log.timeEnd(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
3313
3460
|
this.shaderLayout = props.shaderLayout ? mergeShaderLayout(this.introspectedLayout, props.shaderLayout) : this.introspectedLayout;
|
|
3314
3461
|
}
|
|
3315
3462
|
destroy() {
|
|
@@ -3331,12 +3478,12 @@ var init_webgl_render_pipeline = __esm({
|
|
|
3331
3478
|
if (!binding) {
|
|
3332
3479
|
const validBindings = this.shaderLayout.bindings.map((binding_) => `"${binding_.name}"`).join(", ");
|
|
3333
3480
|
if (!(options == null ? void 0 : options.disableWarnings)) {
|
|
3334
|
-
|
|
3481
|
+
import_core16.log.warn(`No binding "${name}" in render pipeline "${this.id}", expected one of ${validBindings}`, value)();
|
|
3335
3482
|
}
|
|
3336
3483
|
continue;
|
|
3337
3484
|
}
|
|
3338
3485
|
if (!value) {
|
|
3339
|
-
|
|
3486
|
+
import_core16.log.warn(`Unsetting binding "${name}" in render pipeline "${this.id}"`)();
|
|
3340
3487
|
}
|
|
3341
3488
|
switch (binding.type) {
|
|
3342
3489
|
case "uniform":
|
|
@@ -3350,7 +3497,7 @@ var init_webgl_render_pipeline = __esm({
|
|
|
3350
3497
|
}
|
|
3351
3498
|
break;
|
|
3352
3499
|
case "sampler":
|
|
3353
|
-
|
|
3500
|
+
import_core16.log.warn(`Ignoring sampler ${name}`)();
|
|
3354
3501
|
break;
|
|
3355
3502
|
default:
|
|
3356
3503
|
throw new Error(binding.type);
|
|
@@ -3383,11 +3530,11 @@ var init_webgl_render_pipeline = __esm({
|
|
|
3383
3530
|
const isIndexed = Boolean(vertexArray.indexBuffer);
|
|
3384
3531
|
const glIndexType = (_a = vertexArray.indexBuffer) == null ? void 0 : _a.glIndexType;
|
|
3385
3532
|
if (this.linkStatus !== "success") {
|
|
3386
|
-
|
|
3533
|
+
import_core16.log.info(2, `RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)();
|
|
3387
3534
|
return false;
|
|
3388
3535
|
}
|
|
3389
3536
|
if (!this._areTexturesRenderable()) {
|
|
3390
|
-
|
|
3537
|
+
import_core16.log.info(2, `RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)();
|
|
3391
3538
|
return false;
|
|
3392
3539
|
}
|
|
3393
3540
|
this.device.gl.useProgram(this.handle);
|
|
@@ -3429,19 +3576,19 @@ var init_webgl_render_pipeline = __esm({
|
|
|
3429
3576
|
const { gl } = this.device;
|
|
3430
3577
|
gl.attachShader(this.handle, this.vs.handle);
|
|
3431
3578
|
gl.attachShader(this.handle, this.fs.handle);
|
|
3432
|
-
|
|
3579
|
+
import_core16.log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
3433
3580
|
gl.linkProgram(this.handle);
|
|
3434
|
-
|
|
3435
|
-
if (
|
|
3581
|
+
import_core16.log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
3582
|
+
if (import_core16.log.level === 0) {
|
|
3436
3583
|
}
|
|
3437
3584
|
if (!this.device.features.has("compilation-status-async-webgl")) {
|
|
3438
3585
|
const status2 = this._getLinkStatus();
|
|
3439
3586
|
this._reportLinkStatus(status2);
|
|
3440
3587
|
return;
|
|
3441
3588
|
}
|
|
3442
|
-
|
|
3589
|
+
import_core16.log.once(1, "RenderPipeline linking is asynchronous")();
|
|
3443
3590
|
await this._waitForLinkComplete();
|
|
3444
|
-
|
|
3591
|
+
import_core16.log.info(2, `RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();
|
|
3445
3592
|
const status = this._getLinkStatus();
|
|
3446
3593
|
this._reportLinkStatus(status);
|
|
3447
3594
|
}
|
|
@@ -3527,7 +3674,7 @@ var init_webgl_render_pipeline = __esm({
|
|
|
3527
3674
|
let texturesRenderable = true;
|
|
3528
3675
|
for (const bindingInfo of this.shaderLayout.bindings) {
|
|
3529
3676
|
if (!this.bindings[bindingInfo.name] && !this.bindings[bindingInfo.name.replace(/Uniforms$/, "")]) {
|
|
3530
|
-
|
|
3677
|
+
import_core16.log.warn(`Binding ${bindingInfo.name} not found in ${this.id}`)();
|
|
3531
3678
|
texturesRenderable = false;
|
|
3532
3679
|
}
|
|
3533
3680
|
}
|
|
@@ -3581,7 +3728,7 @@ var init_webgl_render_pipeline = __esm({
|
|
|
3581
3728
|
} else if (value instanceof WEBGLTexture) {
|
|
3582
3729
|
texture = value;
|
|
3583
3730
|
} else if (value instanceof WEBGLFramebuffer && value.colorAttachments[0] instanceof WEBGLTextureView) {
|
|
3584
|
-
|
|
3731
|
+
import_core16.log.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")();
|
|
3585
3732
|
texture = value.colorAttachments[0].texture;
|
|
3586
3733
|
} else {
|
|
3587
3734
|
throw new Error("No texture");
|
|
@@ -3748,7 +3895,7 @@ function _copyTextureToTexture(device, options) {
|
|
|
3748
3895
|
}
|
|
3749
3896
|
}
|
|
3750
3897
|
function getFramebuffer(source) {
|
|
3751
|
-
if (source instanceof
|
|
3898
|
+
if (source instanceof import_core17.Texture) {
|
|
3752
3899
|
const { width, height, id } = source;
|
|
3753
3900
|
const framebuffer = source.device.createFramebuffer({
|
|
3754
3901
|
id: `framebuffer-for-${id}`,
|
|
@@ -3760,15 +3907,15 @@ function getFramebuffer(source) {
|
|
|
3760
3907
|
}
|
|
3761
3908
|
return { framebuffer: source, destroyFramebuffer: false };
|
|
3762
3909
|
}
|
|
3763
|
-
var
|
|
3910
|
+
var import_core17, import_constants21, WEBGLCommandBuffer;
|
|
3764
3911
|
var init_webgl_command_buffer = __esm({
|
|
3765
3912
|
"dist/adapter/resources/webgl-command-buffer.js"() {
|
|
3766
3913
|
"use strict";
|
|
3767
|
-
|
|
3768
|
-
|
|
3914
|
+
import_core17 = require("@luma.gl/core");
|
|
3915
|
+
import_constants21 = require("@luma.gl/constants");
|
|
3769
3916
|
init_webgl_texture();
|
|
3770
3917
|
init_webgl_texture_table();
|
|
3771
|
-
WEBGLCommandBuffer = class extends
|
|
3918
|
+
WEBGLCommandBuffer = class extends import_core17.CommandBuffer {
|
|
3772
3919
|
device;
|
|
3773
3920
|
handle = null;
|
|
3774
3921
|
commands = [];
|
|
@@ -3801,16 +3948,16 @@ var init_webgl_command_buffer = __esm({
|
|
|
3801
3948
|
});
|
|
3802
3949
|
|
|
3803
3950
|
// dist/adapter/resources/webgl-render-pass.js
|
|
3804
|
-
var
|
|
3951
|
+
var import_core18, import_constants22, COLOR_CHANNELS, WEBGLRenderPass;
|
|
3805
3952
|
var init_webgl_render_pass = __esm({
|
|
3806
3953
|
"dist/adapter/resources/webgl-render-pass.js"() {
|
|
3807
3954
|
"use strict";
|
|
3808
|
-
|
|
3809
|
-
|
|
3955
|
+
import_core18 = require("@luma.gl/core");
|
|
3956
|
+
import_constants22 = require("@luma.gl/constants");
|
|
3810
3957
|
init_with_parameters();
|
|
3811
3958
|
init_unified_parameter_api();
|
|
3812
3959
|
COLOR_CHANNELS = [1, 2, 4, 8];
|
|
3813
|
-
WEBGLRenderPass = class extends
|
|
3960
|
+
WEBGLRenderPass = class extends import_core18.RenderPass {
|
|
3814
3961
|
device;
|
|
3815
3962
|
handle = null;
|
|
3816
3963
|
/** Parameters that should be applied before each draw call */
|
|
@@ -3835,7 +3982,7 @@ var init_webgl_render_pass = __esm({
|
|
|
3835
3982
|
if (this.props.framebuffer && (webglFramebuffer == null ? void 0 : webglFramebuffer.handle)) {
|
|
3836
3983
|
const drawBuffers = this.props.framebuffer.colorAttachments.map((_, i) => 36064 + i);
|
|
3837
3984
|
this.device.gl.drawBuffers(drawBuffers);
|
|
3838
|
-
} else {
|
|
3985
|
+
} else if (!this.props.framebuffer) {
|
|
3839
3986
|
this.device.gl.drawBuffers([1029]);
|
|
3840
3987
|
}
|
|
3841
3988
|
this.clear();
|
|
@@ -3881,9 +4028,9 @@ var init_webgl_render_pass = __esm({
|
|
|
3881
4028
|
if (parameters.blendConstant) {
|
|
3882
4029
|
glParameters.blendColor = parameters.blendConstant;
|
|
3883
4030
|
}
|
|
3884
|
-
if (parameters.stencilReference) {
|
|
3885
|
-
console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL");
|
|
4031
|
+
if (parameters.stencilReference !== void 0) {
|
|
3886
4032
|
glParameters[2967] = parameters.stencilReference;
|
|
4033
|
+
glParameters[36003] = parameters.stencilReference;
|
|
3887
4034
|
}
|
|
3888
4035
|
if ("colorMask" in parameters) {
|
|
3889
4036
|
glParameters.colorMask = COLOR_CHANNELS.map((channel) => Boolean(channel & parameters.colorMask));
|
|
@@ -3961,14 +4108,14 @@ var init_webgl_render_pass = __esm({
|
|
|
3961
4108
|
});
|
|
3962
4109
|
|
|
3963
4110
|
// dist/adapter/resources/webgl-command-encoder.js
|
|
3964
|
-
var
|
|
4111
|
+
var import_core19, WEBGLCommandEncoder;
|
|
3965
4112
|
var init_webgl_command_encoder = __esm({
|
|
3966
4113
|
"dist/adapter/resources/webgl-command-encoder.js"() {
|
|
3967
4114
|
"use strict";
|
|
3968
|
-
|
|
4115
|
+
import_core19 = require("@luma.gl/core");
|
|
3969
4116
|
init_webgl_command_buffer();
|
|
3970
4117
|
init_webgl_render_pass();
|
|
3971
|
-
WEBGLCommandEncoder = class extends
|
|
4118
|
+
WEBGLCommandEncoder = class extends import_core19.CommandEncoder {
|
|
3972
4119
|
device;
|
|
3973
4120
|
handle = null;
|
|
3974
4121
|
commandBuffer;
|
|
@@ -4059,16 +4206,16 @@ function compareConstantArrayValues(v1, v2) {
|
|
|
4059
4206
|
}
|
|
4060
4207
|
return true;
|
|
4061
4208
|
}
|
|
4062
|
-
var
|
|
4209
|
+
var import_core20, import_constants23, import_env2, WEBGLVertexArray;
|
|
4063
4210
|
var init_webgl_vertex_array = __esm({
|
|
4064
4211
|
"dist/adapter/resources/webgl-vertex-array.js"() {
|
|
4065
4212
|
"use strict";
|
|
4066
|
-
|
|
4067
|
-
|
|
4213
|
+
import_core20 = require("@luma.gl/core");
|
|
4214
|
+
import_constants23 = require("@luma.gl/constants");
|
|
4068
4215
|
import_env2 = require("@probe.gl/env");
|
|
4069
4216
|
init_webgl_vertex_formats();
|
|
4070
4217
|
init_fill_array();
|
|
4071
|
-
WEBGLVertexArray = class extends
|
|
4218
|
+
WEBGLVertexArray = class extends import_core20.VertexArray {
|
|
4072
4219
|
get [Symbol.toStringTag]() {
|
|
4073
4220
|
return "VertexArray";
|
|
4074
4221
|
}
|
|
@@ -4235,7 +4382,7 @@ var init_webgl_vertex_array = __esm({
|
|
|
4235
4382
|
this.buffer = this.buffer || this.device.createBuffer({ byteLength });
|
|
4236
4383
|
updateNeeded ||= !compareConstantArrayValues(constantValue, this.bufferValue);
|
|
4237
4384
|
if (updateNeeded) {
|
|
4238
|
-
const typedArray = (0,
|
|
4385
|
+
const typedArray = (0, import_core20.getScratchArray)(value.constructor, length);
|
|
4239
4386
|
fillArray({ target: typedArray, source: constantValue, start: 0, count: length });
|
|
4240
4387
|
this.buffer.write(typedArray);
|
|
4241
4388
|
this.bufferValue = value;
|
|
@@ -4253,15 +4400,15 @@ function isIndex(value) {
|
|
|
4253
4400
|
}
|
|
4254
4401
|
return /^\d+$/.test(value);
|
|
4255
4402
|
}
|
|
4256
|
-
var
|
|
4403
|
+
var import_core21, import_constants24, WEBGLTransformFeedback;
|
|
4257
4404
|
var init_webgl_transform_feedback = __esm({
|
|
4258
4405
|
"dist/adapter/resources/webgl-transform-feedback.js"() {
|
|
4259
4406
|
"use strict";
|
|
4260
|
-
|
|
4261
|
-
|
|
4407
|
+
import_core21 = require("@luma.gl/core");
|
|
4408
|
+
import_constants24 = require("@luma.gl/constants");
|
|
4262
4409
|
init_dist();
|
|
4263
4410
|
init_webgl_topology_utils();
|
|
4264
|
-
WEBGLTransformFeedback = class extends
|
|
4411
|
+
WEBGLTransformFeedback = class extends import_core21.TransformFeedback {
|
|
4265
4412
|
device;
|
|
4266
4413
|
gl;
|
|
4267
4414
|
handle;
|
|
@@ -4324,7 +4471,7 @@ var init_webgl_transform_feedback = __esm({
|
|
|
4324
4471
|
const { buffer, byteLength, byteOffset } = this._getBufferRange(bufferOrRange);
|
|
4325
4472
|
if (location < 0) {
|
|
4326
4473
|
this.unusedBuffers[locationOrName] = buffer;
|
|
4327
|
-
|
|
4474
|
+
import_core21.log.warn(`${this.id} unusedBuffers varying buffer ${locationOrName}`)();
|
|
4328
4475
|
return;
|
|
4329
4476
|
}
|
|
4330
4477
|
this.buffers[location] = { buffer, byteLength, byteOffset };
|
|
@@ -4407,13 +4554,13 @@ var init_webgl_transform_feedback = __esm({
|
|
|
4407
4554
|
});
|
|
4408
4555
|
|
|
4409
4556
|
// dist/adapter/resources/webgl-query-set.js
|
|
4410
|
-
var
|
|
4557
|
+
var import_core22, import_constants25, WEBGLQuerySet;
|
|
4411
4558
|
var init_webgl_query_set = __esm({
|
|
4412
4559
|
"dist/adapter/resources/webgl-query-set.js"() {
|
|
4413
4560
|
"use strict";
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
WEBGLQuerySet = class extends
|
|
4561
|
+
import_core22 = require("@luma.gl/core");
|
|
4562
|
+
import_constants25 = require("@luma.gl/constants");
|
|
4563
|
+
WEBGLQuerySet = class extends import_core22.QuerySet {
|
|
4417
4564
|
device;
|
|
4418
4565
|
handle;
|
|
4419
4566
|
target = null;
|
|
@@ -4546,6 +4693,57 @@ var init_webgl_query_set = __esm({
|
|
|
4546
4693
|
}
|
|
4547
4694
|
});
|
|
4548
4695
|
|
|
4696
|
+
// dist/adapter/resources/webgl-fence.js
|
|
4697
|
+
var import_core23, WEBGLFence;
|
|
4698
|
+
var init_webgl_fence = __esm({
|
|
4699
|
+
"dist/adapter/resources/webgl-fence.js"() {
|
|
4700
|
+
"use strict";
|
|
4701
|
+
import_core23 = require("@luma.gl/core");
|
|
4702
|
+
WEBGLFence = class extends import_core23.Fence {
|
|
4703
|
+
device;
|
|
4704
|
+
gl;
|
|
4705
|
+
handle;
|
|
4706
|
+
signaled;
|
|
4707
|
+
_signaled = false;
|
|
4708
|
+
constructor(device, props = {}) {
|
|
4709
|
+
super(device, {});
|
|
4710
|
+
this.device = device;
|
|
4711
|
+
this.gl = device.gl;
|
|
4712
|
+
const sync = this.props.handle || this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
|
|
4713
|
+
if (!sync) {
|
|
4714
|
+
throw new Error("Failed to create WebGL fence");
|
|
4715
|
+
}
|
|
4716
|
+
this.handle = sync;
|
|
4717
|
+
this.signaled = new Promise((resolve) => {
|
|
4718
|
+
const poll = () => {
|
|
4719
|
+
const status = this.gl.clientWaitSync(this.handle, 0, 0);
|
|
4720
|
+
if (status === this.gl.ALREADY_SIGNALED || status === this.gl.CONDITION_SATISFIED) {
|
|
4721
|
+
this._signaled = true;
|
|
4722
|
+
resolve();
|
|
4723
|
+
} else {
|
|
4724
|
+
setTimeout(poll, 1);
|
|
4725
|
+
}
|
|
4726
|
+
};
|
|
4727
|
+
poll();
|
|
4728
|
+
});
|
|
4729
|
+
}
|
|
4730
|
+
isSignaled() {
|
|
4731
|
+
if (this._signaled) {
|
|
4732
|
+
return true;
|
|
4733
|
+
}
|
|
4734
|
+
const status = this.gl.getSyncParameter(this.handle, this.gl.SYNC_STATUS);
|
|
4735
|
+
this._signaled = status === this.gl.SIGNALED;
|
|
4736
|
+
return this._signaled;
|
|
4737
|
+
}
|
|
4738
|
+
destroy() {
|
|
4739
|
+
if (!this.destroyed) {
|
|
4740
|
+
this.gl.deleteSync(this.handle);
|
|
4741
|
+
}
|
|
4742
|
+
}
|
|
4743
|
+
};
|
|
4744
|
+
}
|
|
4745
|
+
});
|
|
4746
|
+
|
|
4549
4747
|
// dist/adapter/helpers/format-utils.js
|
|
4550
4748
|
function glFormatToComponents(format) {
|
|
4551
4749
|
switch (format) {
|
|
@@ -4586,41 +4784,11 @@ function glTypeToBytes(type) {
|
|
|
4586
4784
|
return 0;
|
|
4587
4785
|
}
|
|
4588
4786
|
}
|
|
4589
|
-
var
|
|
4787
|
+
var import_constants26;
|
|
4590
4788
|
var init_format_utils = __esm({
|
|
4591
4789
|
"dist/adapter/helpers/format-utils.js"() {
|
|
4592
|
-
"use strict";
|
|
4593
|
-
import_constants25 = require("@luma.gl/constants");
|
|
4594
|
-
}
|
|
4595
|
-
});
|
|
4596
|
-
|
|
4597
|
-
// dist/adapter/converters/shader-formats.js
|
|
4598
|
-
function convertGLDataTypeToDataType(type) {
|
|
4599
|
-
return GL_DATA_TYPE_MAP[type];
|
|
4600
|
-
}
|
|
4601
|
-
var import_constants26, GL_DATA_TYPE_MAP;
|
|
4602
|
-
var init_shader_formats = __esm({
|
|
4603
|
-
"dist/adapter/converters/shader-formats.js"() {
|
|
4604
4790
|
"use strict";
|
|
4605
4791
|
import_constants26 = require("@luma.gl/constants");
|
|
4606
|
-
GL_DATA_TYPE_MAP = {
|
|
4607
|
-
[5124]: "sint32",
|
|
4608
|
-
[5125]: "uint32",
|
|
4609
|
-
[5122]: "sint16",
|
|
4610
|
-
[5123]: "uint16",
|
|
4611
|
-
[5120]: "sint8",
|
|
4612
|
-
[5121]: "uint8",
|
|
4613
|
-
[5126]: "float32",
|
|
4614
|
-
[5131]: "float16",
|
|
4615
|
-
[33635]: "uint16",
|
|
4616
|
-
[32819]: "uint16",
|
|
4617
|
-
[32820]: "uint16",
|
|
4618
|
-
[33640]: "uint32",
|
|
4619
|
-
[35899]: "uint32",
|
|
4620
|
-
[35902]: "uint32",
|
|
4621
|
-
[34042]: "uint32",
|
|
4622
|
-
[36269]: "uint32"
|
|
4623
|
-
};
|
|
4624
4792
|
}
|
|
4625
4793
|
});
|
|
4626
4794
|
|
|
@@ -4654,7 +4822,7 @@ function readPixelsToArray(source, options) {
|
|
|
4654
4822
|
sourceFormat ||= (texture == null ? void 0 : texture.glFormat) || 6408;
|
|
4655
4823
|
sourceType ||= (texture == null ? void 0 : texture.glType) || 5121;
|
|
4656
4824
|
target2 = getPixelArray(target2, sourceType, sourceFormat, sourceWidth, sourceHeight, sourceDepth);
|
|
4657
|
-
const signedType = (0,
|
|
4825
|
+
const signedType = (0, import_core24.getDataType)(target2);
|
|
4658
4826
|
sourceType = sourceType || convertDataTypeToGLDataType(signedType);
|
|
4659
4827
|
const prevHandle = gl.bindFramebuffer(36160, handle);
|
|
4660
4828
|
gl.readBuffer(36064 + sourceAttachment);
|
|
@@ -4697,7 +4865,7 @@ function readPixelsToBuffer(source, options) {
|
|
|
4697
4865
|
return webglBufferTarget;
|
|
4698
4866
|
}
|
|
4699
4867
|
function getFramebuffer2(source) {
|
|
4700
|
-
if (!(source instanceof
|
|
4868
|
+
if (!(source instanceof import_core24.Framebuffer)) {
|
|
4701
4869
|
return { framebuffer: toFramebuffer(source), deleteFramebuffer: true };
|
|
4702
4870
|
}
|
|
4703
4871
|
return { framebuffer: source, deleteFramebuffer: false };
|
|
@@ -4719,15 +4887,15 @@ function getPixelArray(pixelArray, glType, glFormat, width, height, depth) {
|
|
|
4719
4887
|
}
|
|
4720
4888
|
glType ||= 5121;
|
|
4721
4889
|
const shaderType = convertGLDataTypeToDataType(glType);
|
|
4722
|
-
const ArrayType = (0,
|
|
4890
|
+
const ArrayType = (0, import_core24.getTypedArrayConstructor)(shaderType);
|
|
4723
4891
|
const components = glFormatToComponents(glFormat);
|
|
4724
4892
|
return new ArrayType(width * height * components);
|
|
4725
4893
|
}
|
|
4726
|
-
var
|
|
4894
|
+
var import_core24, import_constants27;
|
|
4727
4895
|
var init_webgl_texture_utils = __esm({
|
|
4728
4896
|
"dist/adapter/helpers/webgl-texture-utils.js"() {
|
|
4729
4897
|
"use strict";
|
|
4730
|
-
|
|
4898
|
+
import_core24 = require("@luma.gl/core");
|
|
4731
4899
|
import_constants27 = require("@luma.gl/constants");
|
|
4732
4900
|
init_webgl_shadertypes();
|
|
4733
4901
|
init_format_utils();
|
|
@@ -4774,11 +4942,11 @@ function compareConstantArrayValues2(v1, v2) {
|
|
|
4774
4942
|
}
|
|
4775
4943
|
return true;
|
|
4776
4944
|
}
|
|
4777
|
-
var
|
|
4945
|
+
var import_core25, WebGLDevice;
|
|
4778
4946
|
var init_webgl_device = __esm({
|
|
4779
4947
|
"dist/adapter/webgl-device.js"() {
|
|
4780
4948
|
"use strict";
|
|
4781
|
-
|
|
4949
|
+
import_core25 = require("@luma.gl/core");
|
|
4782
4950
|
init_webgl_state_tracker();
|
|
4783
4951
|
init_create_browser_context();
|
|
4784
4952
|
init_webgl_device_info();
|
|
@@ -4799,11 +4967,12 @@ var init_webgl_device = __esm({
|
|
|
4799
4967
|
init_webgl_vertex_array();
|
|
4800
4968
|
init_webgl_transform_feedback();
|
|
4801
4969
|
init_webgl_query_set();
|
|
4970
|
+
init_webgl_fence();
|
|
4802
4971
|
init_webgl_texture_utils();
|
|
4803
4972
|
init_unified_parameter_api();
|
|
4804
4973
|
init_with_parameters();
|
|
4805
4974
|
init_webgl_extensions();
|
|
4806
|
-
WebGLDevice = class extends
|
|
4975
|
+
WebGLDevice = class extends import_core25.Device {
|
|
4807
4976
|
// Public `Device` API
|
|
4808
4977
|
/** type of this device */
|
|
4809
4978
|
type = "webgl";
|
|
@@ -4849,7 +5018,7 @@ var init_webgl_device = __esm({
|
|
|
4849
5018
|
constructor(props) {
|
|
4850
5019
|
var _a, _b;
|
|
4851
5020
|
super({ ...props, id: props.id || uid("webgl-device") });
|
|
4852
|
-
const canvasContextProps =
|
|
5021
|
+
const canvasContextProps = import_core25.Device._getCanvasContextProps(props);
|
|
4853
5022
|
if (!canvasContextProps) {
|
|
4854
5023
|
throw new Error("WebGLDevice requires props.createCanvasContext to be set");
|
|
4855
5024
|
}
|
|
@@ -4868,6 +5037,9 @@ var init_webgl_device = __esm({
|
|
|
4868
5037
|
if (props.powerPreference !== void 0) {
|
|
4869
5038
|
webglContextAttributes.powerPreference = props.powerPreference;
|
|
4870
5039
|
}
|
|
5040
|
+
if (props.failIfMajorPerformanceCaveat !== void 0) {
|
|
5041
|
+
webglContextAttributes.failIfMajorPerformanceCaveat = props.failIfMajorPerformanceCaveat;
|
|
5042
|
+
}
|
|
4871
5043
|
const externalGLContext = this.props._handle;
|
|
4872
5044
|
const gl = externalGLContext || createBrowserContext(this.canvasContext.canvas, {
|
|
4873
5045
|
onContextLost: (event) => {
|
|
@@ -4886,7 +5058,7 @@ var init_webgl_device = __esm({
|
|
|
4886
5058
|
device = gl.device;
|
|
4887
5059
|
if (device) {
|
|
4888
5060
|
if (props._reuseDevices) {
|
|
4889
|
-
|
|
5061
|
+
import_core25.log.log(1, `Not creating a new Device, instead returning a reference to Device ${device.id} already attached to WebGL context`, device)();
|
|
4890
5062
|
device._reused = true;
|
|
4891
5063
|
return device;
|
|
4892
5064
|
}
|
|
@@ -4896,7 +5068,6 @@ var init_webgl_device = __esm({
|
|
|
4896
5068
|
this.gl = gl;
|
|
4897
5069
|
this.spectorJS = initializeSpectorJS({ ...this.props, gl: this.handle });
|
|
4898
5070
|
this.gl.device = this;
|
|
4899
|
-
this.gl._version = 2;
|
|
4900
5071
|
this.info = getDeviceInfo(this.gl, this._extensions);
|
|
4901
5072
|
this.limits = new WebGLDeviceLimits(this.gl);
|
|
4902
5073
|
this.features = new WebGLDeviceFeatures(this.gl, this._extensions, this.props._disabledFeatures);
|
|
@@ -4904,17 +5075,15 @@ var init_webgl_device = __esm({
|
|
|
4904
5075
|
this.features.initializeFeatures();
|
|
4905
5076
|
}
|
|
4906
5077
|
const glState = new WebGLStateTracker(this.gl, {
|
|
4907
|
-
log: (...args) =>
|
|
5078
|
+
log: (...args) => import_core25.log.log(1, ...args)()
|
|
4908
5079
|
});
|
|
4909
5080
|
glState.trackState(this.gl, { copyState: false });
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
import_core23.log.level = Math.max(import_core23.log.level, 1);
|
|
4917
|
-
}
|
|
5081
|
+
if (props.debug || props.debugWebGL) {
|
|
5082
|
+
this.gl = makeDebugContext(this.gl, { debugWebGL: true, traceWebGL: props.debugWebGL });
|
|
5083
|
+
import_core25.log.warn("WebGL debug mode activated. Performance reduced.")();
|
|
5084
|
+
}
|
|
5085
|
+
if (props.debugWebGL) {
|
|
5086
|
+
import_core25.log.level = Math.max(import_core25.log.level, 1);
|
|
4918
5087
|
}
|
|
4919
5088
|
this.commandEncoder = new WEBGLCommandEncoder(this, { id: `${this}-command-encoder` });
|
|
4920
5089
|
}
|
|
@@ -4937,9 +5106,6 @@ var init_webgl_device = __esm({
|
|
|
4937
5106
|
return this.gl.isContextLost();
|
|
4938
5107
|
}
|
|
4939
5108
|
// IMPLEMENTATION OF ABSTRACT DEVICE
|
|
4940
|
-
getTextureByteAlignment() {
|
|
4941
|
-
return 4;
|
|
4942
|
-
}
|
|
4943
5109
|
createCanvasContext(props) {
|
|
4944
5110
|
throw new Error("WebGL only supports a single canvas");
|
|
4945
5111
|
}
|
|
@@ -4971,6 +5137,9 @@ var init_webgl_device = __esm({
|
|
|
4971
5137
|
createQuerySet(props) {
|
|
4972
5138
|
return new WEBGLQuerySet(this, props);
|
|
4973
5139
|
}
|
|
5140
|
+
createFence() {
|
|
5141
|
+
return new WEBGLFence(this);
|
|
5142
|
+
}
|
|
4974
5143
|
createRenderPipeline(props) {
|
|
4975
5144
|
return new WEBGLRenderPipeline(this, props);
|
|
4976
5145
|
}
|
|
@@ -5014,7 +5183,7 @@ var init_webgl_device = __esm({
|
|
|
5014
5183
|
return withGLParameters(this.gl, parameters, func);
|
|
5015
5184
|
}
|
|
5016
5185
|
resetWebGL() {
|
|
5017
|
-
|
|
5186
|
+
import_core25.log.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")();
|
|
5018
5187
|
resetGLParameters(this.gl);
|
|
5019
5188
|
}
|
|
5020
5189
|
_getDeviceSpecificTextureFormatCapabilities(capabilities) {
|
|
@@ -5087,7 +5256,7 @@ var init_webgl_device = __esm({
|
|
|
5087
5256
|
this._constants = this._constants || new Array(maxVertexAttributes).fill(null);
|
|
5088
5257
|
const currentConstant = this._constants[location];
|
|
5089
5258
|
if (currentConstant && compareConstantArrayValues2(currentConstant, constant)) {
|
|
5090
|
-
|
|
5259
|
+
import_core25.log.info(1, `setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`)();
|
|
5091
5260
|
}
|
|
5092
5261
|
this._constants[location] = constant;
|
|
5093
5262
|
switch (constant.constructor) {
|
|
@@ -5128,23 +5297,23 @@ function isWebGL(gl) {
|
|
|
5128
5297
|
if (typeof WebGL2RenderingContext !== "undefined" && gl instanceof WebGL2RenderingContext) {
|
|
5129
5298
|
return true;
|
|
5130
5299
|
}
|
|
5131
|
-
return Boolean(gl &&
|
|
5300
|
+
return Boolean(gl && typeof gl.createVertexArray === "function");
|
|
5132
5301
|
}
|
|
5133
|
-
var
|
|
5302
|
+
var import_core26, LOG_LEVEL2, WebGLAdapter, webgl2Adapter;
|
|
5134
5303
|
var init_webgl_adapter = __esm({
|
|
5135
5304
|
"dist/adapter/webgl-adapter.js"() {
|
|
5136
5305
|
"use strict";
|
|
5137
|
-
|
|
5306
|
+
import_core26 = require("@luma.gl/core");
|
|
5138
5307
|
init_polyfill_webgl1_extensions();
|
|
5139
5308
|
init_spector();
|
|
5140
5309
|
init_webgl_developer_tools();
|
|
5141
5310
|
LOG_LEVEL2 = 1;
|
|
5142
|
-
WebGLAdapter = class extends
|
|
5311
|
+
WebGLAdapter = class extends import_core26.Adapter {
|
|
5143
5312
|
/** type of device's created by this adapter */
|
|
5144
5313
|
type = "webgl";
|
|
5145
5314
|
constructor() {
|
|
5146
5315
|
super();
|
|
5147
|
-
|
|
5316
|
+
import_core26.Device.defaultProps = { ...import_core26.Device.defaultProps, ...DEFAULT_SPECTOR_PROPS };
|
|
5148
5317
|
}
|
|
5149
5318
|
/** Force any created WebGL contexts to be WebGL2 contexts, polyfilled with WebGL1 extensions */
|
|
5150
5319
|
enforceWebGL2(enable2) {
|
|
@@ -5159,7 +5328,7 @@ var init_webgl_adapter = __esm({
|
|
|
5159
5328
|
return true;
|
|
5160
5329
|
}
|
|
5161
5330
|
if (typeof WebGLRenderingContext !== "undefined" && handle instanceof WebGLRenderingContext) {
|
|
5162
|
-
|
|
5331
|
+
import_core26.log.warn("WebGL1 is not supported", handle)();
|
|
5163
5332
|
}
|
|
5164
5333
|
return false;
|
|
5165
5334
|
}
|
|
@@ -5190,28 +5359,29 @@ var init_webgl_adapter = __esm({
|
|
|
5190
5359
|
}
|
|
5191
5360
|
async create(props = {}) {
|
|
5192
5361
|
const { WebGLDevice: WebGLDevice2 } = await Promise.resolve().then(() => (init_webgl_device(), webgl_device_exports));
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
if (result.status === "rejected") {
|
|
5205
|
-
import_core24.log.error(`Failed to initialize debug libraries ${result.reason}`)();
|
|
5206
|
-
}
|
|
5362
|
+
const promises = [];
|
|
5363
|
+
if (props.debugWebGL || props.debug) {
|
|
5364
|
+
promises.push(loadWebGLDeveloperTools());
|
|
5365
|
+
}
|
|
5366
|
+
if (props.debugSpectorJS) {
|
|
5367
|
+
promises.push(loadSpectorJS(props));
|
|
5368
|
+
}
|
|
5369
|
+
const results = await Promise.allSettled(promises);
|
|
5370
|
+
for (const result of results) {
|
|
5371
|
+
if (result.status === "rejected") {
|
|
5372
|
+
import_core26.log.error(`Failed to initialize debug libraries ${result.reason}`)();
|
|
5207
5373
|
}
|
|
5374
|
+
}
|
|
5375
|
+
try {
|
|
5208
5376
|
const device = new WebGLDevice2(props);
|
|
5377
|
+
import_core26.log.groupCollapsed(LOG_LEVEL2, `WebGLDevice ${device.id} created`)();
|
|
5209
5378
|
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}`;
|
|
5210
|
-
|
|
5211
|
-
|
|
5379
|
+
import_core26.log.probe(LOG_LEVEL2, message2)();
|
|
5380
|
+
import_core26.log.table(LOG_LEVEL2, device.info)();
|
|
5212
5381
|
return device;
|
|
5213
5382
|
} finally {
|
|
5214
|
-
|
|
5383
|
+
import_core26.log.groupEnd(LOG_LEVEL2)();
|
|
5384
|
+
import_core26.log.info(LOG_LEVEL2, `%cWebGL call tracing: luma.log.set('debug-webgl') `, "color: white; background: blue; padding: 2px 6px; border-radius: 3px;")();
|
|
5215
5385
|
}
|
|
5216
5386
|
}
|
|
5217
5387
|
};
|
|
@@ -5224,6 +5394,7 @@ var dist_exports = {};
|
|
|
5224
5394
|
__export(dist_exports, {
|
|
5225
5395
|
WEBGLBuffer: () => WEBGLBuffer,
|
|
5226
5396
|
WEBGLCommandEncoder: () => WEBGLCommandEncoder,
|
|
5397
|
+
WEBGLFence: () => WEBGLFence,
|
|
5227
5398
|
WEBGLFramebuffer: () => WEBGLFramebuffer,
|
|
5228
5399
|
WEBGLRenderPass: () => WEBGLRenderPass,
|
|
5229
5400
|
WEBGLRenderPipeline: () => WEBGLRenderPipeline,
|
|
@@ -5255,6 +5426,7 @@ var init_dist = __esm({
|
|
|
5255
5426
|
init_webgl_shader();
|
|
5256
5427
|
init_webgl_sampler();
|
|
5257
5428
|
init_webgl_framebuffer();
|
|
5429
|
+
init_webgl_fence();
|
|
5258
5430
|
init_webgl_render_pipeline();
|
|
5259
5431
|
init_webgl_command_encoder();
|
|
5260
5432
|
init_webgl_render_pass();
|