@luma.gl/webgl 9.2.6 → 9.3.0-alpha.4
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/helpers/get-shader-layout-from-glsl.js +11 -8
- package/dist/adapter/helpers/get-shader-layout-from-glsl.js.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +20 -0
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +2 -3
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +9 -5
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- 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 +9 -6
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +1 -2
- package/dist/adapter/resources/webgl-render-pipeline.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/resources/webgl-transform-feedback.js +5 -5
- package/dist/adapter/resources/webgl-transform-feedback.js.map +1 -1
- package/dist/adapter/webgl-adapter.d.ts.map +1 -1
- package/dist/adapter/webgl-adapter.js +22 -23
- 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 +4 -2
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +39 -24
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +4 -4
- package/dist/context/debug/spector.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +6 -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 +46 -36
- package/dist/context/helpers/create-browser-context.js.map +1 -1
- package/dist/context/helpers/webgl-context-data.d.ts +5 -1
- package/dist/context/helpers/webgl-context-data.d.ts.map +1 -1
- package/dist/context/helpers/webgl-context-data.js +9 -10
- package/dist/context/helpers/webgl-context-data.js.map +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts +1 -1
- package/dist/context/parameters/unified-parameter-api.js +2 -2
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/state-tracker/webgl-state-tracker.js +2 -2
- package/dist/context/state-tracker/webgl-state-tracker.js.map +1 -1
- package/dist/dist.dev.js +567 -318
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +550 -314
- 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/dist/utils/fill-array.js +1 -1
- package/dist/utils/fill-array.js.map +1 -1
- package/package.json +5 -5
- package/src/adapter/helpers/get-shader-layout-from-glsl.ts +11 -9
- package/src/adapter/helpers/parse-shader-compiler-log.ts +23 -1
- package/src/adapter/resources/webgl-command-buffer.ts +18 -22
- package/src/adapter/resources/webgl-fence.ts +55 -0
- package/src/adapter/resources/webgl-render-pass.ts +10 -6
- package/src/adapter/resources/webgl-render-pipeline.ts +1 -2
- package/src/adapter/resources/webgl-texture.ts +209 -37
- package/src/adapter/resources/webgl-transform-feedback.ts +5 -5
- package/src/adapter/webgl-adapter.ts +26 -24
- package/src/adapter/webgl-canvas-context.ts +19 -8
- package/src/adapter/webgl-device.ts +41 -29
- package/src/context/debug/spector.ts +4 -4
- package/src/context/debug/webgl-developer-tools.ts +15 -6
- package/src/context/helpers/create-browser-context.ts +54 -43
- package/src/context/helpers/webgl-context-data.ts +17 -11
- package/src/context/parameters/unified-parameter-api.ts +2 -2
- package/src/context/state-tracker/webgl-state-tracker.ts +2 -2
- package/src/index.ts +1 -0
- package/src/utils/fill-array.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -155,6 +155,24 @@ var init_load_script = __esm({
|
|
|
155
155
|
}
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
+
// dist/context/helpers/webgl-context-data.js
|
|
159
|
+
function getWebGLContextData(gl) {
|
|
160
|
+
const contextData = gl.luma || {
|
|
161
|
+
_polyfilled: false,
|
|
162
|
+
extensions: {},
|
|
163
|
+
softwareRenderer: false
|
|
164
|
+
};
|
|
165
|
+
contextData._polyfilled ??= false;
|
|
166
|
+
contextData.extensions ||= {};
|
|
167
|
+
gl.luma = contextData;
|
|
168
|
+
return contextData;
|
|
169
|
+
}
|
|
170
|
+
var init_webgl_context_data = __esm({
|
|
171
|
+
"dist/context/helpers/webgl-context-data.js"() {
|
|
172
|
+
"use strict";
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
158
176
|
// dist/context/debug/spector.js
|
|
159
177
|
async function loadSpectorJS(props) {
|
|
160
178
|
if (!globalThis.SPECTOR) {
|
|
@@ -195,9 +213,10 @@ function initializeSpectorJS(props) {
|
|
|
195
213
|
}
|
|
196
214
|
if (props.gl) {
|
|
197
215
|
const gl = props.gl;
|
|
198
|
-
const
|
|
216
|
+
const contextData = getWebGLContextData(gl);
|
|
217
|
+
const device = contextData.device;
|
|
199
218
|
spector == null ? void 0 : spector.startCapture(props.gl, 500);
|
|
200
|
-
|
|
219
|
+
contextData.device = device;
|
|
201
220
|
new Promise((resolve) => setTimeout(resolve, 2e3)).then((_) => {
|
|
202
221
|
import_core.log.info("Spector capture stopped after 2 seconds")();
|
|
203
222
|
spector == null ? void 0 : spector.stopCapture();
|
|
@@ -211,6 +230,7 @@ var init_spector = __esm({
|
|
|
211
230
|
"use strict";
|
|
212
231
|
import_core = require("@luma.gl/core");
|
|
213
232
|
init_load_script();
|
|
233
|
+
init_webgl_context_data();
|
|
214
234
|
LOG_LEVEL = 1;
|
|
215
235
|
spector = null;
|
|
216
236
|
initialized = false;
|
|
@@ -226,7 +246,7 @@ var init_spector = __esm({
|
|
|
226
246
|
});
|
|
227
247
|
|
|
228
248
|
// dist/context/debug/webgl-developer-tools.js
|
|
229
|
-
function
|
|
249
|
+
function getWebGLContextData2(gl) {
|
|
230
250
|
gl.luma = gl.luma || {};
|
|
231
251
|
return gl.luma;
|
|
232
252
|
}
|
|
@@ -241,7 +261,7 @@ function makeDebugContext(gl, props = {}) {
|
|
|
241
261
|
return props.debugWebGL || props.traceWebGL ? getDebugContext(gl, props) : getRealContext(gl);
|
|
242
262
|
}
|
|
243
263
|
function getRealContext(gl) {
|
|
244
|
-
const data =
|
|
264
|
+
const data = getWebGLContextData2(gl);
|
|
245
265
|
return data.realContext ? data.realContext : gl;
|
|
246
266
|
}
|
|
247
267
|
function getDebugContext(gl, props) {
|
|
@@ -249,7 +269,7 @@ function getDebugContext(gl, props) {
|
|
|
249
269
|
import_core2.log.warn("webgl-debug not loaded")();
|
|
250
270
|
return gl;
|
|
251
271
|
}
|
|
252
|
-
const data =
|
|
272
|
+
const data = getWebGLContextData2(gl);
|
|
253
273
|
if (data.debugContext) {
|
|
254
274
|
return data.debugContext;
|
|
255
275
|
}
|
|
@@ -267,6 +287,7 @@ function getDebugContext(gl, props) {
|
|
|
267
287
|
const debugContext = Object.create(WebGLDebugContext);
|
|
268
288
|
data.realContext = gl;
|
|
269
289
|
data.debugContext = debugContext;
|
|
290
|
+
debugContext.luma = data;
|
|
270
291
|
debugContext.debug = true;
|
|
271
292
|
return debugContext;
|
|
272
293
|
}
|
|
@@ -281,16 +302,15 @@ function onGLError(props, err, functionName, args) {
|
|
|
281
302
|
const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);
|
|
282
303
|
const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);
|
|
283
304
|
const message2 = `${errorMessage} in gl.${functionName}(${functionArgs})`;
|
|
284
|
-
import_core2.log.error(message2)();
|
|
305
|
+
import_core2.log.error("%cWebGL", "color: white; background: red; padding: 2px 6px; border-radius: 3px;", message2)();
|
|
285
306
|
debugger;
|
|
307
|
+
throw new Error(message2);
|
|
286
308
|
}
|
|
287
309
|
function onValidateGLFunc(props, functionName, functionArgs) {
|
|
288
310
|
let functionString = "";
|
|
289
|
-
if (import_core2.log.level >= 1) {
|
|
311
|
+
if (props.traceWebGL && import_core2.log.level >= 1) {
|
|
290
312
|
functionString = getFunctionString(functionName, functionArgs);
|
|
291
|
-
|
|
292
|
-
import_core2.log.log(1, functionString)();
|
|
293
|
-
}
|
|
313
|
+
import_core2.log.info(1, "%cWebGL", "color: white; background: blue; padding: 2px 6px; border-radius: 3px;", functionString)();
|
|
294
314
|
}
|
|
295
315
|
for (const arg of functionArgs) {
|
|
296
316
|
if (arg === void 0) {
|
|
@@ -792,6 +812,7 @@ var init_webgl_parameter_tables = __esm({
|
|
|
792
812
|
|
|
793
813
|
// dist/context/parameters/unified-parameter-api.js
|
|
794
814
|
function setGLParameters(gl, parameters) {
|
|
815
|
+
var _a;
|
|
795
816
|
if (isObjectEmpty(parameters)) {
|
|
796
817
|
return;
|
|
797
818
|
}
|
|
@@ -807,7 +828,7 @@ function setGLParameters(gl, parameters) {
|
|
|
807
828
|
}
|
|
808
829
|
}
|
|
809
830
|
}
|
|
810
|
-
const cache = gl.
|
|
831
|
+
const cache = (_a = gl.lumaState) == null ? void 0 : _a.cache;
|
|
811
832
|
if (cache) {
|
|
812
833
|
for (const key in compositeSetters) {
|
|
813
834
|
const compositeSetter = GL_COMPOSITE_PARAMETER_SETTERS[key];
|
|
@@ -930,7 +951,7 @@ var init_webgl_state_tracker = __esm({
|
|
|
930
951
|
init_webgl_parameter_tables();
|
|
931
952
|
WebGLStateTracker = class {
|
|
932
953
|
static get(gl) {
|
|
933
|
-
return gl.
|
|
954
|
+
return gl.lumaState;
|
|
934
955
|
}
|
|
935
956
|
gl;
|
|
936
957
|
program = null;
|
|
@@ -968,7 +989,7 @@ var init_webgl_state_tracker = __esm({
|
|
|
968
989
|
throw new Error("WebGLStateTracker");
|
|
969
990
|
}
|
|
970
991
|
this.initialized = true;
|
|
971
|
-
this.gl.
|
|
992
|
+
this.gl.lumaState = this;
|
|
972
993
|
installProgramSpy(gl);
|
|
973
994
|
for (const key in GL_HOOKED_SETTERS) {
|
|
974
995
|
const setter = GL_HOOKED_SETTERS[key];
|
|
@@ -1008,42 +1029,57 @@ var init_webgl_state_tracker = __esm({
|
|
|
1008
1029
|
// dist/context/helpers/create-browser-context.js
|
|
1009
1030
|
function createBrowserContext(canvas, props, webglContextAttributes) {
|
|
1010
1031
|
let errorMessage = "";
|
|
1032
|
+
const onCreateError = (event) => {
|
|
1033
|
+
const statusMessage = event.statusMessage;
|
|
1034
|
+
if (statusMessage) {
|
|
1035
|
+
errorMessage ||= statusMessage;
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1038
|
+
canvas.addEventListener("webglcontextcreationerror", onCreateError, false);
|
|
1039
|
+
const allowSoftwareRenderer = webglContextAttributes.failIfMajorPerformanceCaveat !== true;
|
|
1011
1040
|
const webglProps = {
|
|
1012
1041
|
preserveDrawingBuffer: true,
|
|
1013
|
-
|
|
1014
|
-
|
|
1042
|
+
...webglContextAttributes,
|
|
1043
|
+
// Always start by requesting a high-performance context.
|
|
1044
|
+
failIfMajorPerformanceCaveat: true
|
|
1015
1045
|
};
|
|
1016
1046
|
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";
|
|
1047
|
+
try {
|
|
1048
|
+
gl ||= canvas.getContext("webgl2", webglProps);
|
|
1049
|
+
if (!gl && webglProps.failIfMajorPerformanceCaveat) {
|
|
1050
|
+
errorMessage ||= "Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.";
|
|
1032
1051
|
}
|
|
1052
|
+
let softwareRenderer = false;
|
|
1053
|
+
if (!gl && allowSoftwareRenderer) {
|
|
1054
|
+
webglProps.failIfMajorPerformanceCaveat = false;
|
|
1055
|
+
gl = canvas.getContext("webgl2", webglProps);
|
|
1056
|
+
softwareRenderer = true;
|
|
1057
|
+
}
|
|
1058
|
+
if (!gl) {
|
|
1059
|
+
gl = canvas.getContext("webgl", {});
|
|
1060
|
+
if (gl) {
|
|
1061
|
+
gl = null;
|
|
1062
|
+
errorMessage ||= "Your browser only supports WebGL1";
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
if (!gl) {
|
|
1066
|
+
errorMessage ||= "Your browser does not support WebGL";
|
|
1067
|
+
throw new Error(`Failed to create WebGL context: ${errorMessage}`);
|
|
1068
|
+
}
|
|
1069
|
+
const luma = getWebGLContextData(gl);
|
|
1070
|
+
luma.softwareRenderer = softwareRenderer;
|
|
1071
|
+
const { onContextLost, onContextRestored } = props;
|
|
1072
|
+
canvas.addEventListener("webglcontextlost", (event) => onContextLost(event), false);
|
|
1073
|
+
canvas.addEventListener("webglcontextrestored", (event) => onContextRestored(event), false);
|
|
1074
|
+
return gl;
|
|
1075
|
+
} finally {
|
|
1076
|
+
canvas.removeEventListener("webglcontextcreationerror", onCreateError, false);
|
|
1033
1077
|
}
|
|
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
1078
|
}
|
|
1044
1079
|
var init_create_browser_context = __esm({
|
|
1045
1080
|
"dist/context/helpers/create-browser-context.js"() {
|
|
1046
1081
|
"use strict";
|
|
1082
|
+
init_webgl_context_data();
|
|
1047
1083
|
}
|
|
1048
1084
|
});
|
|
1049
1085
|
|
|
@@ -1794,14 +1830,25 @@ var init_webgl_canvas_context = __esm({
|
|
|
1794
1830
|
super(props);
|
|
1795
1831
|
this.device = device;
|
|
1796
1832
|
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;
|
|
1833
|
+
this._configureDevice();
|
|
1802
1834
|
}
|
|
1803
1835
|
// IMPLEMENTATION OF ABSTRACT METHODS
|
|
1804
|
-
|
|
1836
|
+
_configureDevice() {
|
|
1837
|
+
var _a, _b, _c;
|
|
1838
|
+
const shouldResize = this.drawingBufferWidth !== ((_a = this._framebuffer) == null ? void 0 : _a.width) || this.drawingBufferHeight !== ((_b = this._framebuffer) == null ? void 0 : _b.height);
|
|
1839
|
+
if (shouldResize) {
|
|
1840
|
+
(_c = this._framebuffer) == null ? void 0 : _c.resize([this.drawingBufferWidth, this.drawingBufferHeight]);
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
_getCurrentFramebuffer() {
|
|
1844
|
+
this._framebuffer ||= new WEBGLFramebuffer(this.device, {
|
|
1845
|
+
id: "canvas-context-framebuffer",
|
|
1846
|
+
handle: null,
|
|
1847
|
+
// Setting handle to null returns a reference to the default WebGL framebuffer
|
|
1848
|
+
width: this.drawingBufferWidth,
|
|
1849
|
+
height: this.drawingBufferHeight
|
|
1850
|
+
});
|
|
1851
|
+
return this._framebuffer;
|
|
1805
1852
|
}
|
|
1806
1853
|
};
|
|
1807
1854
|
}
|
|
@@ -1963,15 +2010,27 @@ var init_webgl_buffer = __esm({
|
|
|
1963
2010
|
|
|
1964
2011
|
// dist/adapter/helpers/parse-shader-compiler-log.js
|
|
1965
2012
|
function parseShaderCompilerLog(errLog) {
|
|
2013
|
+
var _a;
|
|
1966
2014
|
const lines = errLog.split(/\r?\n/);
|
|
1967
2015
|
const messages = [];
|
|
1968
2016
|
for (const line of lines) {
|
|
1969
2017
|
if (line.length <= 1) {
|
|
1970
2018
|
continue;
|
|
1971
2019
|
}
|
|
2020
|
+
const lineWithTrimmedWhitespace = line.trim();
|
|
1972
2021
|
const segments = line.split(":");
|
|
2022
|
+
const trimmedMessageType = (_a = segments[0]) == null ? void 0 : _a.trim();
|
|
1973
2023
|
if (segments.length === 2) {
|
|
1974
2024
|
const [messageType2, message2] = segments;
|
|
2025
|
+
if (!messageType2 || !message2) {
|
|
2026
|
+
messages.push({
|
|
2027
|
+
message: lineWithTrimmedWhitespace,
|
|
2028
|
+
type: getMessageType(trimmedMessageType || "info"),
|
|
2029
|
+
lineNum: 0,
|
|
2030
|
+
linePos: 0
|
|
2031
|
+
});
|
|
2032
|
+
continue;
|
|
2033
|
+
}
|
|
1975
2034
|
messages.push({
|
|
1976
2035
|
message: message2.trim(),
|
|
1977
2036
|
type: getMessageType(messageType2),
|
|
@@ -1981,6 +2040,15 @@ function parseShaderCompilerLog(errLog) {
|
|
|
1981
2040
|
continue;
|
|
1982
2041
|
}
|
|
1983
2042
|
const [messageType, linePosition, lineNumber, ...rest] = segments;
|
|
2043
|
+
if (!messageType || !linePosition || !lineNumber) {
|
|
2044
|
+
messages.push({
|
|
2045
|
+
message: segments.slice(1).join(":").trim() || lineWithTrimmedWhitespace,
|
|
2046
|
+
type: getMessageType(trimmedMessageType || "info"),
|
|
2047
|
+
lineNum: 0,
|
|
2048
|
+
linePos: 0
|
|
2049
|
+
});
|
|
2050
|
+
continue;
|
|
2051
|
+
}
|
|
1984
2052
|
let lineNum = parseInt(lineNumber, 10);
|
|
1985
2053
|
if (isNaN(lineNum)) {
|
|
1986
2054
|
lineNum = 0;
|
|
@@ -2562,6 +2630,119 @@ var init_webgl_texture_view = __esm({
|
|
|
2562
2630
|
}
|
|
2563
2631
|
});
|
|
2564
2632
|
|
|
2633
|
+
// dist/adapter/converters/webgl-shadertypes.js
|
|
2634
|
+
function convertDataTypeToGLDataType(normalizedType) {
|
|
2635
|
+
return NORMALIZED_SHADER_TYPE_TO_WEBGL[normalizedType];
|
|
2636
|
+
}
|
|
2637
|
+
function convertGLUniformTypeToShaderVariableType(glUniformType) {
|
|
2638
|
+
return WEBGL_SHADER_TYPES[glUniformType];
|
|
2639
|
+
}
|
|
2640
|
+
function isGLSamplerType(type) {
|
|
2641
|
+
return Boolean(WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[type]);
|
|
2642
|
+
}
|
|
2643
|
+
function getTextureBindingFromGLSamplerType(glSamplerType) {
|
|
2644
|
+
return WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[glSamplerType];
|
|
2645
|
+
}
|
|
2646
|
+
var import_constants14, WEBGL_SHADER_TYPES, WEBGL_SAMPLER_TO_TEXTURE_BINDINGS, NORMALIZED_SHADER_TYPE_TO_WEBGL;
|
|
2647
|
+
var init_webgl_shadertypes = __esm({
|
|
2648
|
+
"dist/adapter/converters/webgl-shadertypes.js"() {
|
|
2649
|
+
"use strict";
|
|
2650
|
+
import_constants14 = require("@luma.gl/constants");
|
|
2651
|
+
WEBGL_SHADER_TYPES = {
|
|
2652
|
+
[5126]: "f32",
|
|
2653
|
+
[35664]: "vec2<f32>",
|
|
2654
|
+
[35665]: "vec3<f32>",
|
|
2655
|
+
[35666]: "vec4<f32>",
|
|
2656
|
+
[5124]: "i32",
|
|
2657
|
+
[35667]: "vec2<i32>",
|
|
2658
|
+
[35668]: "vec3<i32>",
|
|
2659
|
+
[35669]: "vec4<i32>",
|
|
2660
|
+
[5125]: "u32",
|
|
2661
|
+
[36294]: "vec2<u32>",
|
|
2662
|
+
[36295]: "vec3<u32>",
|
|
2663
|
+
[36296]: "vec4<u32>",
|
|
2664
|
+
[35670]: "f32",
|
|
2665
|
+
[35671]: "vec2<f32>",
|
|
2666
|
+
[35672]: "vec3<f32>",
|
|
2667
|
+
[35673]: "vec4<f32>",
|
|
2668
|
+
// TODO - are sizes/components below correct?
|
|
2669
|
+
[35674]: "mat2x2<f32>",
|
|
2670
|
+
[35685]: "mat2x3<f32>",
|
|
2671
|
+
[35686]: "mat2x4<f32>",
|
|
2672
|
+
[35687]: "mat3x2<f32>",
|
|
2673
|
+
[35675]: "mat3x3<f32>",
|
|
2674
|
+
[35688]: "mat3x4<f32>",
|
|
2675
|
+
[35689]: "mat4x2<f32>",
|
|
2676
|
+
[35690]: "mat4x3<f32>",
|
|
2677
|
+
[35676]: "mat4x4<f32>"
|
|
2678
|
+
};
|
|
2679
|
+
WEBGL_SAMPLER_TO_TEXTURE_BINDINGS = {
|
|
2680
|
+
[35678]: { viewDimension: "2d", sampleType: "float" },
|
|
2681
|
+
[35680]: { viewDimension: "cube", sampleType: "float" },
|
|
2682
|
+
[35679]: { viewDimension: "3d", sampleType: "float" },
|
|
2683
|
+
[35682]: { viewDimension: "3d", sampleType: "depth" },
|
|
2684
|
+
[36289]: { viewDimension: "2d-array", sampleType: "float" },
|
|
2685
|
+
[36292]: { viewDimension: "2d-array", sampleType: "depth" },
|
|
2686
|
+
[36293]: { viewDimension: "cube", sampleType: "float" },
|
|
2687
|
+
[36298]: { viewDimension: "2d", sampleType: "sint" },
|
|
2688
|
+
[36299]: { viewDimension: "3d", sampleType: "sint" },
|
|
2689
|
+
[36300]: { viewDimension: "cube", sampleType: "sint" },
|
|
2690
|
+
[36303]: { viewDimension: "2d-array", sampleType: "uint" },
|
|
2691
|
+
[36306]: { viewDimension: "2d", sampleType: "uint" },
|
|
2692
|
+
[36307]: { viewDimension: "3d", sampleType: "uint" },
|
|
2693
|
+
[36308]: { viewDimension: "cube", sampleType: "uint" },
|
|
2694
|
+
[36311]: { viewDimension: "2d-array", sampleType: "uint" }
|
|
2695
|
+
};
|
|
2696
|
+
NORMALIZED_SHADER_TYPE_TO_WEBGL = {
|
|
2697
|
+
uint8: 5121,
|
|
2698
|
+
sint8: 5120,
|
|
2699
|
+
unorm8: 5121,
|
|
2700
|
+
snorm8: 5120,
|
|
2701
|
+
uint16: 5123,
|
|
2702
|
+
sint16: 5122,
|
|
2703
|
+
unorm16: 5123,
|
|
2704
|
+
snorm16: 5122,
|
|
2705
|
+
uint32: 5125,
|
|
2706
|
+
sint32: 5124,
|
|
2707
|
+
// WebGPU does not support normalized 32 bit integer attributes
|
|
2708
|
+
// 'unorm32': GL.UNSIGNED_INT,
|
|
2709
|
+
// 'snorm32': GL.INT,
|
|
2710
|
+
float16: 5131,
|
|
2711
|
+
float32: 5126
|
|
2712
|
+
};
|
|
2713
|
+
}
|
|
2714
|
+
});
|
|
2715
|
+
|
|
2716
|
+
// dist/adapter/converters/shader-formats.js
|
|
2717
|
+
function convertGLDataTypeToDataType(type) {
|
|
2718
|
+
return GL_DATA_TYPE_MAP[type];
|
|
2719
|
+
}
|
|
2720
|
+
var import_constants15, GL_DATA_TYPE_MAP;
|
|
2721
|
+
var init_shader_formats = __esm({
|
|
2722
|
+
"dist/adapter/converters/shader-formats.js"() {
|
|
2723
|
+
"use strict";
|
|
2724
|
+
import_constants15 = require("@luma.gl/constants");
|
|
2725
|
+
GL_DATA_TYPE_MAP = {
|
|
2726
|
+
[5124]: "sint32",
|
|
2727
|
+
[5125]: "uint32",
|
|
2728
|
+
[5122]: "sint16",
|
|
2729
|
+
[5123]: "uint16",
|
|
2730
|
+
[5120]: "sint8",
|
|
2731
|
+
[5121]: "uint8",
|
|
2732
|
+
[5126]: "float32",
|
|
2733
|
+
[5131]: "float16",
|
|
2734
|
+
[33635]: "uint16",
|
|
2735
|
+
[32819]: "uint16",
|
|
2736
|
+
[32820]: "uint16",
|
|
2737
|
+
[33640]: "uint32",
|
|
2738
|
+
[35899]: "uint32",
|
|
2739
|
+
[35902]: "uint32",
|
|
2740
|
+
[34042]: "uint32",
|
|
2741
|
+
[36269]: "uint32"
|
|
2742
|
+
};
|
|
2743
|
+
}
|
|
2744
|
+
});
|
|
2745
|
+
|
|
2565
2746
|
// dist/adapter/resources/webgl-texture.js
|
|
2566
2747
|
function getWebGLTextureTarget(dimension) {
|
|
2567
2748
|
switch (dimension) {
|
|
@@ -2583,16 +2764,19 @@ function getWebGLTextureTarget(dimension) {
|
|
|
2583
2764
|
function getWebGLCubeFaceTarget(glTarget, dimension, level) {
|
|
2584
2765
|
return dimension === "cube" ? 34069 + level : glTarget;
|
|
2585
2766
|
}
|
|
2586
|
-
var import_core13,
|
|
2767
|
+
var import_core13, import_constants16, import_core14, WEBGLTexture;
|
|
2587
2768
|
var init_webgl_texture = __esm({
|
|
2588
2769
|
"dist/adapter/resources/webgl-texture.js"() {
|
|
2589
2770
|
"use strict";
|
|
2590
2771
|
import_core13 = require("@luma.gl/core");
|
|
2591
|
-
|
|
2772
|
+
import_constants16 = require("@luma.gl/constants");
|
|
2592
2773
|
init_webgl_texture_table();
|
|
2593
2774
|
init_sampler_parameters();
|
|
2594
2775
|
init_with_parameters();
|
|
2595
2776
|
init_webgl_texture_view();
|
|
2777
|
+
init_webgl_shadertypes();
|
|
2778
|
+
init_shader_formats();
|
|
2779
|
+
import_core14 = require("@luma.gl/core");
|
|
2596
2780
|
WEBGLTexture = class extends import_core13.Texture {
|
|
2597
2781
|
// readonly MAX_ATTRIBUTES: number;
|
|
2598
2782
|
device;
|
|
@@ -2622,8 +2806,10 @@ var init_webgl_texture = __esm({
|
|
|
2622
2806
|
// state
|
|
2623
2807
|
/** Texture binding slot - TODO - move to texture view? */
|
|
2624
2808
|
_textureUnit = 0;
|
|
2809
|
+
/** Chached framebuffer */
|
|
2810
|
+
_framebuffer = null;
|
|
2625
2811
|
constructor(device, props) {
|
|
2626
|
-
super(device, props);
|
|
2812
|
+
super(device, props, { byteAlignment: 1 });
|
|
2627
2813
|
this.device = device;
|
|
2628
2814
|
this.gl = this.device.gl;
|
|
2629
2815
|
const formatInfo = getTextureFormatWebGL(this.props.format);
|
|
@@ -2655,7 +2841,10 @@ var init_webgl_texture = __esm({
|
|
|
2655
2841
|
Object.seal(this);
|
|
2656
2842
|
}
|
|
2657
2843
|
destroy() {
|
|
2844
|
+
var _a;
|
|
2658
2845
|
if (this.handle) {
|
|
2846
|
+
(_a = this._framebuffer) == null ? void 0 : _a.destroy();
|
|
2847
|
+
this._framebuffer = null;
|
|
2659
2848
|
this.gl.deleteTexture(this.handle);
|
|
2660
2849
|
this.removeStats();
|
|
2661
2850
|
this.trackDeallocatedMemory("Texture");
|
|
@@ -2670,11 +2859,37 @@ var init_webgl_texture = __esm({
|
|
|
2670
2859
|
const parameters = convertSamplerParametersToWebGL(this.sampler.props);
|
|
2671
2860
|
this._setSamplerParameters(parameters);
|
|
2672
2861
|
}
|
|
2862
|
+
copyExternalImage(options_) {
|
|
2863
|
+
const options = this._normalizeCopyExternalImageOptions(options_);
|
|
2864
|
+
if (options.sourceX || options.sourceY) {
|
|
2865
|
+
throw new Error("WebGL does not support sourceX/sourceY)");
|
|
2866
|
+
}
|
|
2867
|
+
const { glFormat, glType } = this;
|
|
2868
|
+
const { image, depth, mipLevel, x, y, z, width, height } = options;
|
|
2869
|
+
const glTarget = getWebGLCubeFaceTarget(this.glTarget, this.dimension, z);
|
|
2870
|
+
const glParameters = options.flipY ? { [37440]: true } : {};
|
|
2871
|
+
this.gl.bindTexture(this.glTarget, this.handle);
|
|
2872
|
+
withGLParameters(this.gl, glParameters, () => {
|
|
2873
|
+
switch (this.dimension) {
|
|
2874
|
+
case "2d":
|
|
2875
|
+
case "cube":
|
|
2876
|
+
this.gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, image);
|
|
2877
|
+
break;
|
|
2878
|
+
case "2d-array":
|
|
2879
|
+
case "3d":
|
|
2880
|
+
this.gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, image);
|
|
2881
|
+
break;
|
|
2882
|
+
default:
|
|
2883
|
+
}
|
|
2884
|
+
});
|
|
2885
|
+
this.gl.bindTexture(this.glTarget, null);
|
|
2886
|
+
return { width: options.width, height: options.height };
|
|
2887
|
+
}
|
|
2673
2888
|
copyImageData(options_) {
|
|
2674
2889
|
const options = this._normalizeCopyImageDataOptions(options_);
|
|
2675
2890
|
const typedArray = options.data;
|
|
2676
|
-
const { width, height, depth } =
|
|
2677
|
-
const { mipLevel = 0, byteOffset = 0, x = 0, y = 0
|
|
2891
|
+
const { width, height, depth, z = 0 } = options;
|
|
2892
|
+
const { mipLevel = 0, byteOffset = 0, x = 0, y = 0 } = options;
|
|
2678
2893
|
const { glFormat, glType, compressed } = this;
|
|
2679
2894
|
const glTarget = getWebGLCubeFaceTarget(this.glTarget, this.dimension, z);
|
|
2680
2895
|
let unpackRowLength;
|
|
@@ -2688,10 +2903,11 @@ var init_webgl_texture = __esm({
|
|
|
2688
2903
|
}
|
|
2689
2904
|
}
|
|
2690
2905
|
const glParameters = !this.compressed ? {
|
|
2906
|
+
[3317]: this.byteAlignment,
|
|
2691
2907
|
...unpackRowLength !== void 0 ? { [3314]: unpackRowLength } : {},
|
|
2692
2908
|
[32878]: options.rowsPerImage
|
|
2693
2909
|
} : {};
|
|
2694
|
-
this.gl.bindTexture(glTarget, this.handle);
|
|
2910
|
+
this.gl.bindTexture(this.glTarget, this.handle);
|
|
2695
2911
|
withGLParameters(this.gl, glParameters, () => {
|
|
2696
2912
|
switch (this.dimension) {
|
|
2697
2913
|
case "2d":
|
|
@@ -2713,35 +2929,92 @@ var init_webgl_texture = __esm({
|
|
|
2713
2929
|
default:
|
|
2714
2930
|
}
|
|
2715
2931
|
});
|
|
2716
|
-
this.gl.bindTexture(glTarget, null);
|
|
2932
|
+
this.gl.bindTexture(this.glTarget, null);
|
|
2717
2933
|
}
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2934
|
+
readBuffer(options = {}, buffer) {
|
|
2935
|
+
throw new Error("readBuffer not implemented");
|
|
2936
|
+
}
|
|
2937
|
+
async readDataAsync(options = {}) {
|
|
2938
|
+
return this.readDataSyncWebGL(options);
|
|
2939
|
+
}
|
|
2940
|
+
writeBuffer(buffer, options_ = {}) {
|
|
2941
|
+
}
|
|
2942
|
+
writeData(data, options_ = {}) {
|
|
2943
|
+
const options = this._normalizeTextureWriteOptions(options_);
|
|
2944
|
+
const typedArray = ArrayBuffer.isView(data) ? data : new Uint8Array(data);
|
|
2945
|
+
const {} = this;
|
|
2946
|
+
const { width, height, mipLevel, x, y, z } = options;
|
|
2947
|
+
const { glFormat, glType, compressed } = this;
|
|
2948
|
+
const depth = 0;
|
|
2725
2949
|
const glTarget = getWebGLCubeFaceTarget(this.glTarget, this.dimension, depth);
|
|
2726
|
-
const glParameters =
|
|
2727
|
-
|
|
2950
|
+
const glParameters = !this.compressed ? {
|
|
2951
|
+
// WebGL does not require byte alignment, but allows it to be specified
|
|
2952
|
+
[3317]: this.byteAlignment
|
|
2953
|
+
// [GL.UNPACK_ROW_LENGTH]: bytesPerRow,
|
|
2954
|
+
// [GL.UNPACK_IMAGE_HEIGHT]: rowsPerImage
|
|
2955
|
+
} : {};
|
|
2956
|
+
this.gl.bindTexture(glTarget, this.handle);
|
|
2957
|
+
this.gl.bindBuffer(35052, null);
|
|
2728
2958
|
withGLParameters(this.gl, glParameters, () => {
|
|
2729
2959
|
switch (this.dimension) {
|
|
2730
2960
|
case "2d":
|
|
2731
2961
|
case "cube":
|
|
2732
|
-
|
|
2962
|
+
if (compressed) {
|
|
2963
|
+
this.gl.compressedTexSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, typedArray);
|
|
2964
|
+
} else {
|
|
2965
|
+
this.gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, typedArray);
|
|
2966
|
+
}
|
|
2733
2967
|
break;
|
|
2734
2968
|
case "2d-array":
|
|
2735
2969
|
case "3d":
|
|
2736
|
-
|
|
2970
|
+
if (compressed) {
|
|
2971
|
+
this.gl.compressedTexSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, typedArray);
|
|
2972
|
+
} else {
|
|
2973
|
+
this.gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, typedArray);
|
|
2974
|
+
}
|
|
2737
2975
|
break;
|
|
2738
2976
|
default:
|
|
2739
2977
|
}
|
|
2740
2978
|
});
|
|
2741
|
-
this.gl.bindTexture(
|
|
2742
|
-
|
|
2979
|
+
this.gl.bindTexture(glTarget, null);
|
|
2980
|
+
}
|
|
2981
|
+
// IMPLEMENTATION SPECIFIC
|
|
2982
|
+
/** @todo - for now we always use 1 for maximum compatibility, we can fine tune later */
|
|
2983
|
+
_getRowByteAlignment(format, width) {
|
|
2984
|
+
return 1;
|
|
2985
|
+
}
|
|
2986
|
+
/**
|
|
2987
|
+
* Wraps a given texture into a framebuffer object, that can be further used
|
|
2988
|
+
* to read data from the texture object.
|
|
2989
|
+
*/
|
|
2990
|
+
_getFramebuffer() {
|
|
2991
|
+
this._framebuffer ||= this.device.createFramebuffer({
|
|
2992
|
+
id: `framebuffer-for-${this.id}`,
|
|
2993
|
+
width: this.width,
|
|
2994
|
+
height: this.height,
|
|
2995
|
+
colorAttachments: [this]
|
|
2996
|
+
});
|
|
2997
|
+
return this._framebuffer;
|
|
2743
2998
|
}
|
|
2744
2999
|
// WEBGL SPECIFIC
|
|
3000
|
+
readDataSyncWebGL(options_ = {}) {
|
|
3001
|
+
const options = this._normalizeTextureReadOptions(options_);
|
|
3002
|
+
const memoryLayout = this.computeMemoryLayout(options);
|
|
3003
|
+
const shaderType = convertGLDataTypeToDataType(this.glType);
|
|
3004
|
+
const ArrayType = (0, import_core14.getTypedArrayConstructor)(shaderType);
|
|
3005
|
+
const targetArray = new ArrayType(memoryLayout.byteLength);
|
|
3006
|
+
const signedType = (0, import_core14.getDataType)(targetArray);
|
|
3007
|
+
const sourceType = convertDataTypeToGLDataType(signedType);
|
|
3008
|
+
const framebuffer = this._getFramebuffer();
|
|
3009
|
+
const prevHandle = this.gl.bindFramebuffer(36160, framebuffer.handle);
|
|
3010
|
+
this.gl.readBuffer(36064);
|
|
3011
|
+
this.gl.readPixels(options.x, options.y, options.width, options.height, this.glFormat, sourceType, targetArray);
|
|
3012
|
+
this.gl.bindFramebuffer(36160, prevHandle || null);
|
|
3013
|
+
return targetArray.buffer;
|
|
3014
|
+
}
|
|
3015
|
+
/**
|
|
3016
|
+
* @note - this is used by the DynamicTexture class to generate mipmaps on WebGL
|
|
3017
|
+
*/
|
|
2745
3018
|
generateMipmapsWebGL(options) {
|
|
2746
3019
|
const isFilterableAndRenderable = this.device.isTextureFormatRenderable(this.props.format) && this.device.isTextureFormatFilterable(this.props.format);
|
|
2747
3020
|
if (!isFilterableAndRenderable) {
|
|
@@ -2821,89 +3094,6 @@ var init_webgl_texture = __esm({
|
|
|
2821
3094
|
}
|
|
2822
3095
|
});
|
|
2823
3096
|
|
|
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
3097
|
// dist/adapter/helpers/get-shader-layout-from-glsl.js
|
|
2908
3098
|
function getShaderLayoutFromGLSL(gl, program) {
|
|
2909
3099
|
const shaderLayout = {
|
|
@@ -2995,7 +3185,7 @@ function readVaryings(gl, program) {
|
|
|
2995
3185
|
}
|
|
2996
3186
|
const { name, type: glUniformType, size } = activeInfo;
|
|
2997
3187
|
const uniformType = convertGLUniformTypeToShaderVariableType(glUniformType);
|
|
2998
|
-
const { type, components } = (0,
|
|
3188
|
+
const { type, components } = (0, import_core15.getVariableShaderTypeInfo)(uniformType);
|
|
2999
3189
|
varyings.push({ location, name, type, size: size * components });
|
|
3000
3190
|
}
|
|
3001
3191
|
varyings.sort((a, b) => a.location - b.location);
|
|
@@ -3056,7 +3246,11 @@ function readUniformBlocks(gl, program) {
|
|
|
3056
3246
|
const uniformOffset = gl.getActiveUniforms(program, uniformIndices, 35387);
|
|
3057
3247
|
const uniformStride = gl.getActiveUniforms(program, uniformIndices, 35388);
|
|
3058
3248
|
for (let i = 0; i < blockInfo.uniformCount; ++i) {
|
|
3059
|
-
const
|
|
3249
|
+
const uniformIndex = uniformIndices[i];
|
|
3250
|
+
if (uniformIndex === void 0) {
|
|
3251
|
+
continue;
|
|
3252
|
+
}
|
|
3253
|
+
const activeInfo = gl.getActiveUniform(program, uniformIndex);
|
|
3060
3254
|
if (!activeInfo) {
|
|
3061
3255
|
throw new Error("activeInfo");
|
|
3062
3256
|
}
|
|
@@ -3087,21 +3281,20 @@ function parseUniformName(name) {
|
|
|
3087
3281
|
}
|
|
3088
3282
|
const UNIFORM_NAME_REGEXP = /([^[]*)(\[[0-9]+\])?/;
|
|
3089
3283
|
const matches = UNIFORM_NAME_REGEXP.exec(name);
|
|
3090
|
-
|
|
3091
|
-
throw new Error(`Failed to parse GLSL uniform name ${name}`);
|
|
3092
|
-
}
|
|
3284
|
+
const uniformName = (0, import_core15.assertDefined)(matches == null ? void 0 : matches[1], `Failed to parse GLSL uniform name ${name}`);
|
|
3093
3285
|
return {
|
|
3094
|
-
name:
|
|
3095
|
-
|
|
3096
|
-
|
|
3286
|
+
name: uniformName,
|
|
3287
|
+
// TODO - is this a bug, shouldn't we return the value?
|
|
3288
|
+
length: (matches == null ? void 0 : matches[2]) ? 1 : 0,
|
|
3289
|
+
isArray: Boolean(matches == null ? void 0 : matches[2])
|
|
3097
3290
|
};
|
|
3098
3291
|
}
|
|
3099
|
-
var
|
|
3292
|
+
var import_core15, import_constants17;
|
|
3100
3293
|
var init_get_shader_layout_from_glsl = __esm({
|
|
3101
3294
|
"dist/adapter/helpers/get-shader-layout-from-glsl.js"() {
|
|
3102
3295
|
"use strict";
|
|
3103
|
-
|
|
3104
|
-
|
|
3296
|
+
import_core15 = require("@luma.gl/core");
|
|
3297
|
+
import_constants17 = require("@luma.gl/constants");
|
|
3105
3298
|
init_webgl_shadertypes();
|
|
3106
3299
|
}
|
|
3107
3300
|
});
|
|
@@ -3190,11 +3383,11 @@ function setUniform(gl, location, type, value) {
|
|
|
3190
3383
|
}
|
|
3191
3384
|
throw new Error("Illegal uniform");
|
|
3192
3385
|
}
|
|
3193
|
-
var
|
|
3386
|
+
var import_constants18;
|
|
3194
3387
|
var init_set_uniform = __esm({
|
|
3195
3388
|
"dist/adapter/helpers/set-uniform.js"() {
|
|
3196
3389
|
"use strict";
|
|
3197
|
-
|
|
3390
|
+
import_constants18 = require("@luma.gl/constants");
|
|
3198
3391
|
}
|
|
3199
3392
|
});
|
|
3200
3393
|
|
|
@@ -3231,11 +3424,11 @@ function getGLPrimitive(topology) {
|
|
|
3231
3424
|
throw new Error(topology);
|
|
3232
3425
|
}
|
|
3233
3426
|
}
|
|
3234
|
-
var
|
|
3427
|
+
var import_constants19;
|
|
3235
3428
|
var init_webgl_topology_utils = __esm({
|
|
3236
3429
|
"dist/adapter/helpers/webgl-topology-utils.js"() {
|
|
3237
3430
|
"use strict";
|
|
3238
|
-
|
|
3431
|
+
import_constants19 = require("@luma.gl/constants");
|
|
3239
3432
|
}
|
|
3240
3433
|
});
|
|
3241
3434
|
|
|
@@ -3248,7 +3441,7 @@ function mergeShaderLayout(baseLayout, overrideLayout) {
|
|
|
3248
3441
|
for (const attribute of (overrideLayout == null ? void 0 : overrideLayout.attributes) || []) {
|
|
3249
3442
|
const baseAttribute = mergedLayout.attributes.find((attr) => attr.name === attribute.name);
|
|
3250
3443
|
if (!baseAttribute) {
|
|
3251
|
-
|
|
3444
|
+
import_core16.log.warn(`shader layout attribute ${attribute.name} not present in shader`);
|
|
3252
3445
|
} else {
|
|
3253
3446
|
baseAttribute.type = attribute.type || baseAttribute.type;
|
|
3254
3447
|
baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;
|
|
@@ -3256,12 +3449,12 @@ function mergeShaderLayout(baseLayout, overrideLayout) {
|
|
|
3256
3449
|
}
|
|
3257
3450
|
return mergedLayout;
|
|
3258
3451
|
}
|
|
3259
|
-
var
|
|
3452
|
+
var import_core16, import_constants20, LOG_PROGRAM_PERF_PRIORITY, WEBGLRenderPipeline;
|
|
3260
3453
|
var init_webgl_render_pipeline = __esm({
|
|
3261
3454
|
"dist/adapter/resources/webgl-render-pipeline.js"() {
|
|
3262
3455
|
"use strict";
|
|
3263
|
-
|
|
3264
|
-
|
|
3456
|
+
import_core16 = require("@luma.gl/core");
|
|
3457
|
+
import_constants20 = require("@luma.gl/constants");
|
|
3265
3458
|
init_get_shader_layout_from_glsl();
|
|
3266
3459
|
init_device_parameters();
|
|
3267
3460
|
init_set_uniform();
|
|
@@ -3271,7 +3464,7 @@ var init_webgl_render_pipeline = __esm({
|
|
|
3271
3464
|
init_webgl_texture_view();
|
|
3272
3465
|
init_webgl_topology_utils();
|
|
3273
3466
|
LOG_PROGRAM_PERF_PRIORITY = 4;
|
|
3274
|
-
WEBGLRenderPipeline = class extends
|
|
3467
|
+
WEBGLRenderPipeline = class extends import_core16.RenderPipeline {
|
|
3275
3468
|
/** The WebGL device that created this render pipeline */
|
|
3276
3469
|
device;
|
|
3277
3470
|
/** Handle to underlying WebGL program */
|
|
@@ -3307,9 +3500,9 @@ var init_webgl_render_pipeline = __esm({
|
|
|
3307
3500
|
this.device.gl.transformFeedbackVaryings(this.handle, varyings, bufferMode);
|
|
3308
3501
|
}
|
|
3309
3502
|
this._linkShaders();
|
|
3310
|
-
|
|
3503
|
+
import_core16.log.time(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
3311
3504
|
this.introspectedLayout = getShaderLayoutFromGLSL(this.device.gl, this.handle);
|
|
3312
|
-
|
|
3505
|
+
import_core16.log.timeEnd(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
3313
3506
|
this.shaderLayout = props.shaderLayout ? mergeShaderLayout(this.introspectedLayout, props.shaderLayout) : this.introspectedLayout;
|
|
3314
3507
|
}
|
|
3315
3508
|
destroy() {
|
|
@@ -3331,12 +3524,12 @@ var init_webgl_render_pipeline = __esm({
|
|
|
3331
3524
|
if (!binding) {
|
|
3332
3525
|
const validBindings = this.shaderLayout.bindings.map((binding_) => `"${binding_.name}"`).join(", ");
|
|
3333
3526
|
if (!(options == null ? void 0 : options.disableWarnings)) {
|
|
3334
|
-
|
|
3527
|
+
import_core16.log.warn(`No binding "${name}" in render pipeline "${this.id}", expected one of ${validBindings}`, value)();
|
|
3335
3528
|
}
|
|
3336
3529
|
continue;
|
|
3337
3530
|
}
|
|
3338
3531
|
if (!value) {
|
|
3339
|
-
|
|
3532
|
+
import_core16.log.warn(`Unsetting binding "${name}" in render pipeline "${this.id}"`)();
|
|
3340
3533
|
}
|
|
3341
3534
|
switch (binding.type) {
|
|
3342
3535
|
case "uniform":
|
|
@@ -3350,7 +3543,7 @@ var init_webgl_render_pipeline = __esm({
|
|
|
3350
3543
|
}
|
|
3351
3544
|
break;
|
|
3352
3545
|
case "sampler":
|
|
3353
|
-
|
|
3546
|
+
import_core16.log.warn(`Ignoring sampler ${name}`)();
|
|
3354
3547
|
break;
|
|
3355
3548
|
default:
|
|
3356
3549
|
throw new Error(binding.type);
|
|
@@ -3383,11 +3576,11 @@ var init_webgl_render_pipeline = __esm({
|
|
|
3383
3576
|
const isIndexed = Boolean(vertexArray.indexBuffer);
|
|
3384
3577
|
const glIndexType = (_a = vertexArray.indexBuffer) == null ? void 0 : _a.glIndexType;
|
|
3385
3578
|
if (this.linkStatus !== "success") {
|
|
3386
|
-
|
|
3579
|
+
import_core16.log.info(2, `RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)();
|
|
3387
3580
|
return false;
|
|
3388
3581
|
}
|
|
3389
3582
|
if (!this._areTexturesRenderable()) {
|
|
3390
|
-
|
|
3583
|
+
import_core16.log.info(2, `RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)();
|
|
3391
3584
|
return false;
|
|
3392
3585
|
}
|
|
3393
3586
|
this.device.gl.useProgram(this.handle);
|
|
@@ -3429,19 +3622,19 @@ var init_webgl_render_pipeline = __esm({
|
|
|
3429
3622
|
const { gl } = this.device;
|
|
3430
3623
|
gl.attachShader(this.handle, this.vs.handle);
|
|
3431
3624
|
gl.attachShader(this.handle, this.fs.handle);
|
|
3432
|
-
|
|
3625
|
+
import_core16.log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
3433
3626
|
gl.linkProgram(this.handle);
|
|
3434
|
-
|
|
3435
|
-
if (
|
|
3627
|
+
import_core16.log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
3628
|
+
if (import_core16.log.level === 0) {
|
|
3436
3629
|
}
|
|
3437
3630
|
if (!this.device.features.has("compilation-status-async-webgl")) {
|
|
3438
3631
|
const status2 = this._getLinkStatus();
|
|
3439
3632
|
this._reportLinkStatus(status2);
|
|
3440
3633
|
return;
|
|
3441
3634
|
}
|
|
3442
|
-
|
|
3635
|
+
import_core16.log.once(1, "RenderPipeline linking is asynchronous")();
|
|
3443
3636
|
await this._waitForLinkComplete();
|
|
3444
|
-
|
|
3637
|
+
import_core16.log.info(2, `RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();
|
|
3445
3638
|
const status = this._getLinkStatus();
|
|
3446
3639
|
this._reportLinkStatus(status);
|
|
3447
3640
|
}
|
|
@@ -3527,7 +3720,7 @@ var init_webgl_render_pipeline = __esm({
|
|
|
3527
3720
|
let texturesRenderable = true;
|
|
3528
3721
|
for (const bindingInfo of this.shaderLayout.bindings) {
|
|
3529
3722
|
if (!this.bindings[bindingInfo.name] && !this.bindings[bindingInfo.name.replace(/Uniforms$/, "")]) {
|
|
3530
|
-
|
|
3723
|
+
import_core16.log.warn(`Binding ${bindingInfo.name} not found in ${this.id}`)();
|
|
3531
3724
|
texturesRenderable = false;
|
|
3532
3725
|
}
|
|
3533
3726
|
}
|
|
@@ -3554,7 +3747,7 @@ var init_webgl_render_pipeline = __esm({
|
|
|
3554
3747
|
if (location === 4294967295) {
|
|
3555
3748
|
throw new Error(`Invalid uniform block name ${name}`);
|
|
3556
3749
|
}
|
|
3557
|
-
gl.uniformBlockBinding(this.handle,
|
|
3750
|
+
gl.uniformBlockBinding(this.handle, location, uniformBufferIndex);
|
|
3558
3751
|
if (value instanceof WEBGLBuffer) {
|
|
3559
3752
|
gl.bindBufferBase(35345, uniformBufferIndex, value.handle);
|
|
3560
3753
|
} else {
|
|
@@ -3581,7 +3774,7 @@ var init_webgl_render_pipeline = __esm({
|
|
|
3581
3774
|
} else if (value instanceof WEBGLTexture) {
|
|
3582
3775
|
texture = value;
|
|
3583
3776
|
} else if (value instanceof WEBGLFramebuffer && value.colorAttachments[0] instanceof WEBGLTextureView) {
|
|
3584
|
-
|
|
3777
|
+
import_core16.log.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")();
|
|
3585
3778
|
texture = value.colorAttachments[0].texture;
|
|
3586
3779
|
} else {
|
|
3587
3780
|
throw new Error("No texture");
|
|
@@ -3642,7 +3835,7 @@ function _copyTextureToBuffer(device, options) {
|
|
|
3642
3835
|
height = options.sourceTexture.height,
|
|
3643
3836
|
depthOrArrayLayers = 0,
|
|
3644
3837
|
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
|
|
3645
|
-
origin = [0, 0],
|
|
3838
|
+
origin = [0, 0, 0],
|
|
3646
3839
|
/** Destination buffer */
|
|
3647
3840
|
destinationBuffer,
|
|
3648
3841
|
/** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */
|
|
@@ -3671,7 +3864,8 @@ function _copyTextureToBuffer(device, options) {
|
|
|
3671
3864
|
const webglBuffer = destinationBuffer;
|
|
3672
3865
|
const sourceWidth = width || framebuffer.width;
|
|
3673
3866
|
const sourceHeight = height || framebuffer.height;
|
|
3674
|
-
const
|
|
3867
|
+
const colorAttachment0 = (0, import_core17.assertDefined)(framebuffer.colorAttachments[0]);
|
|
3868
|
+
const sourceParams = getTextureFormatWebGL(colorAttachment0.texture.props.format);
|
|
3675
3869
|
const sourceFormat = sourceParams.format;
|
|
3676
3870
|
const sourceType = sourceParams.type;
|
|
3677
3871
|
device.gl.bindBuffer(35051, webglBuffer.handle);
|
|
@@ -3698,7 +3892,7 @@ function _copyTextureToTexture(device, options) {
|
|
|
3698
3892
|
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy from. */
|
|
3699
3893
|
origin = [0, 0],
|
|
3700
3894
|
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to. */
|
|
3701
|
-
destinationOrigin = [0, 0],
|
|
3895
|
+
destinationOrigin = [0, 0, 0],
|
|
3702
3896
|
/** Texture to copy to/from. */
|
|
3703
3897
|
destinationTexture
|
|
3704
3898
|
/** Mip-map level of the texture to copy to/from. (Default 0) */
|
|
@@ -3714,7 +3908,7 @@ function _copyTextureToTexture(device, options) {
|
|
|
3714
3908
|
// depthOrArrayLayers = 0
|
|
3715
3909
|
} = options;
|
|
3716
3910
|
const { framebuffer, destroyFramebuffer } = getFramebuffer(sourceTexture);
|
|
3717
|
-
const [sourceX, sourceY] = origin;
|
|
3911
|
+
const [sourceX = 0, sourceY = 0] = origin;
|
|
3718
3912
|
const [destinationX, destinationY, destinationZ] = destinationOrigin;
|
|
3719
3913
|
const prevHandle = device.gl.bindFramebuffer(36160, framebuffer.handle);
|
|
3720
3914
|
let texture;
|
|
@@ -3748,7 +3942,7 @@ function _copyTextureToTexture(device, options) {
|
|
|
3748
3942
|
}
|
|
3749
3943
|
}
|
|
3750
3944
|
function getFramebuffer(source) {
|
|
3751
|
-
if (source instanceof
|
|
3945
|
+
if (source instanceof import_core17.Texture) {
|
|
3752
3946
|
const { width, height, id } = source;
|
|
3753
3947
|
const framebuffer = source.device.createFramebuffer({
|
|
3754
3948
|
id: `framebuffer-for-${id}`,
|
|
@@ -3760,15 +3954,15 @@ function getFramebuffer(source) {
|
|
|
3760
3954
|
}
|
|
3761
3955
|
return { framebuffer: source, destroyFramebuffer: false };
|
|
3762
3956
|
}
|
|
3763
|
-
var
|
|
3957
|
+
var import_core17, import_constants21, WEBGLCommandBuffer;
|
|
3764
3958
|
var init_webgl_command_buffer = __esm({
|
|
3765
3959
|
"dist/adapter/resources/webgl-command-buffer.js"() {
|
|
3766
3960
|
"use strict";
|
|
3767
|
-
|
|
3768
|
-
|
|
3961
|
+
import_core17 = require("@luma.gl/core");
|
|
3962
|
+
import_constants21 = require("@luma.gl/constants");
|
|
3769
3963
|
init_webgl_texture();
|
|
3770
3964
|
init_webgl_texture_table();
|
|
3771
|
-
WEBGLCommandBuffer = class extends
|
|
3965
|
+
WEBGLCommandBuffer = class extends import_core17.CommandBuffer {
|
|
3772
3966
|
device;
|
|
3773
3967
|
handle = null;
|
|
3774
3968
|
commands = [];
|
|
@@ -3801,16 +3995,16 @@ var init_webgl_command_buffer = __esm({
|
|
|
3801
3995
|
});
|
|
3802
3996
|
|
|
3803
3997
|
// dist/adapter/resources/webgl-render-pass.js
|
|
3804
|
-
var
|
|
3998
|
+
var import_core18, import_constants22, COLOR_CHANNELS, WEBGLRenderPass;
|
|
3805
3999
|
var init_webgl_render_pass = __esm({
|
|
3806
4000
|
"dist/adapter/resources/webgl-render-pass.js"() {
|
|
3807
4001
|
"use strict";
|
|
3808
|
-
|
|
3809
|
-
|
|
4002
|
+
import_core18 = require("@luma.gl/core");
|
|
4003
|
+
import_constants22 = require("@luma.gl/constants");
|
|
3810
4004
|
init_with_parameters();
|
|
3811
4005
|
init_unified_parameter_api();
|
|
3812
4006
|
COLOR_CHANNELS = [1, 2, 4, 8];
|
|
3813
|
-
WEBGLRenderPass = class extends
|
|
4007
|
+
WEBGLRenderPass = class extends import_core18.RenderPass {
|
|
3814
4008
|
device;
|
|
3815
4009
|
handle = null;
|
|
3816
4010
|
/** Parameters that should be applied before each draw call */
|
|
@@ -3819,6 +4013,9 @@ var init_webgl_render_pass = __esm({
|
|
|
3819
4013
|
var _a;
|
|
3820
4014
|
super(device, props);
|
|
3821
4015
|
this.device = device;
|
|
4016
|
+
if (!(props == null ? void 0 : props.framebuffer)) {
|
|
4017
|
+
device.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();
|
|
4018
|
+
}
|
|
3822
4019
|
let viewport;
|
|
3823
4020
|
if (!((_a = props == null ? void 0 : props.parameters) == null ? void 0 : _a.viewport)) {
|
|
3824
4021
|
if (props == null ? void 0 : props.framebuffer) {
|
|
@@ -3835,7 +4032,7 @@ var init_webgl_render_pass = __esm({
|
|
|
3835
4032
|
if (this.props.framebuffer && (webglFramebuffer == null ? void 0 : webglFramebuffer.handle)) {
|
|
3836
4033
|
const drawBuffers = this.props.framebuffer.colorAttachments.map((_, i) => 36064 + i);
|
|
3837
4034
|
this.device.gl.drawBuffers(drawBuffers);
|
|
3838
|
-
} else {
|
|
4035
|
+
} else if (!this.props.framebuffer) {
|
|
3839
4036
|
this.device.gl.drawBuffers([1029]);
|
|
3840
4037
|
}
|
|
3841
4038
|
this.clear();
|
|
@@ -3881,9 +4078,9 @@ var init_webgl_render_pass = __esm({
|
|
|
3881
4078
|
if (parameters.blendConstant) {
|
|
3882
4079
|
glParameters.blendColor = parameters.blendConstant;
|
|
3883
4080
|
}
|
|
3884
|
-
if (parameters.stencilReference) {
|
|
3885
|
-
console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL");
|
|
4081
|
+
if (parameters.stencilReference !== void 0) {
|
|
3886
4082
|
glParameters[2967] = parameters.stencilReference;
|
|
4083
|
+
glParameters[36003] = parameters.stencilReference;
|
|
3887
4084
|
}
|
|
3888
4085
|
if ("colorMask" in parameters) {
|
|
3889
4086
|
glParameters.colorMask = COLOR_CHANNELS.map((channel) => Boolean(channel & parameters.colorMask));
|
|
@@ -3961,14 +4158,14 @@ var init_webgl_render_pass = __esm({
|
|
|
3961
4158
|
});
|
|
3962
4159
|
|
|
3963
4160
|
// dist/adapter/resources/webgl-command-encoder.js
|
|
3964
|
-
var
|
|
4161
|
+
var import_core19, WEBGLCommandEncoder;
|
|
3965
4162
|
var init_webgl_command_encoder = __esm({
|
|
3966
4163
|
"dist/adapter/resources/webgl-command-encoder.js"() {
|
|
3967
4164
|
"use strict";
|
|
3968
|
-
|
|
4165
|
+
import_core19 = require("@luma.gl/core");
|
|
3969
4166
|
init_webgl_command_buffer();
|
|
3970
4167
|
init_webgl_render_pass();
|
|
3971
|
-
WEBGLCommandEncoder = class extends
|
|
4168
|
+
WEBGLCommandEncoder = class extends import_core19.CommandEncoder {
|
|
3972
4169
|
device;
|
|
3973
4170
|
handle = null;
|
|
3974
4171
|
commandBuffer;
|
|
@@ -4022,7 +4219,7 @@ function fillArray(options) {
|
|
|
4022
4219
|
const total = count * length;
|
|
4023
4220
|
let copied = 0;
|
|
4024
4221
|
for (let i = start; copied < length; copied++) {
|
|
4025
|
-
target2[i++] = source[copied];
|
|
4222
|
+
target2[i++] = source[copied] ?? 0;
|
|
4026
4223
|
}
|
|
4027
4224
|
while (copied < total) {
|
|
4028
4225
|
if (copied < total - copied) {
|
|
@@ -4059,16 +4256,16 @@ function compareConstantArrayValues(v1, v2) {
|
|
|
4059
4256
|
}
|
|
4060
4257
|
return true;
|
|
4061
4258
|
}
|
|
4062
|
-
var
|
|
4259
|
+
var import_core20, import_constants23, import_env2, WEBGLVertexArray;
|
|
4063
4260
|
var init_webgl_vertex_array = __esm({
|
|
4064
4261
|
"dist/adapter/resources/webgl-vertex-array.js"() {
|
|
4065
4262
|
"use strict";
|
|
4066
|
-
|
|
4067
|
-
|
|
4263
|
+
import_core20 = require("@luma.gl/core");
|
|
4264
|
+
import_constants23 = require("@luma.gl/constants");
|
|
4068
4265
|
import_env2 = require("@probe.gl/env");
|
|
4069
4266
|
init_webgl_vertex_formats();
|
|
4070
4267
|
init_fill_array();
|
|
4071
|
-
WEBGLVertexArray = class extends
|
|
4268
|
+
WEBGLVertexArray = class extends import_core20.VertexArray {
|
|
4072
4269
|
get [Symbol.toStringTag]() {
|
|
4073
4270
|
return "VertexArray";
|
|
4074
4271
|
}
|
|
@@ -4235,7 +4432,7 @@ var init_webgl_vertex_array = __esm({
|
|
|
4235
4432
|
this.buffer = this.buffer || this.device.createBuffer({ byteLength });
|
|
4236
4433
|
updateNeeded ||= !compareConstantArrayValues(constantValue, this.bufferValue);
|
|
4237
4434
|
if (updateNeeded) {
|
|
4238
|
-
const typedArray = (0,
|
|
4435
|
+
const typedArray = (0, import_core20.getScratchArray)(value.constructor, length);
|
|
4239
4436
|
fillArray({ target: typedArray, source: constantValue, start: 0, count: length });
|
|
4240
4437
|
this.buffer.write(typedArray);
|
|
4241
4438
|
this.bufferValue = value;
|
|
@@ -4253,15 +4450,15 @@ function isIndex(value) {
|
|
|
4253
4450
|
}
|
|
4254
4451
|
return /^\d+$/.test(value);
|
|
4255
4452
|
}
|
|
4256
|
-
var
|
|
4453
|
+
var import_core21, import_constants24, WEBGLTransformFeedback;
|
|
4257
4454
|
var init_webgl_transform_feedback = __esm({
|
|
4258
4455
|
"dist/adapter/resources/webgl-transform-feedback.js"() {
|
|
4259
4456
|
"use strict";
|
|
4260
|
-
|
|
4261
|
-
|
|
4457
|
+
import_core21 = require("@luma.gl/core");
|
|
4458
|
+
import_constants24 = require("@luma.gl/constants");
|
|
4262
4459
|
init_dist();
|
|
4263
4460
|
init_webgl_topology_utils();
|
|
4264
|
-
WEBGLTransformFeedback = class extends
|
|
4461
|
+
WEBGLTransformFeedback = class extends import_core21.TransformFeedback {
|
|
4265
4462
|
device;
|
|
4266
4463
|
gl;
|
|
4267
4464
|
handle;
|
|
@@ -4314,8 +4511,8 @@ var init_webgl_transform_feedback = __esm({
|
|
|
4314
4511
|
this.buffers = {};
|
|
4315
4512
|
this.unusedBuffers = {};
|
|
4316
4513
|
this.bind(() => {
|
|
4317
|
-
for (const bufferName
|
|
4318
|
-
this.setBuffer(bufferName,
|
|
4514
|
+
for (const [bufferName, buffer] of Object.entries(buffers)) {
|
|
4515
|
+
this.setBuffer(bufferName, buffer);
|
|
4319
4516
|
}
|
|
4320
4517
|
});
|
|
4321
4518
|
}
|
|
@@ -4324,7 +4521,7 @@ var init_webgl_transform_feedback = __esm({
|
|
|
4324
4521
|
const { buffer, byteLength, byteOffset } = this._getBufferRange(bufferOrRange);
|
|
4325
4522
|
if (location < 0) {
|
|
4326
4523
|
this.unusedBuffers[locationOrName] = buffer;
|
|
4327
|
-
|
|
4524
|
+
import_core21.log.warn(`${this.id} unusedBuffers varying buffer ${locationOrName}`)();
|
|
4328
4525
|
return;
|
|
4329
4526
|
}
|
|
4330
4527
|
this.buffers[location] = { buffer, byteLength, byteOffset };
|
|
@@ -4337,7 +4534,7 @@ var init_webgl_transform_feedback = __esm({
|
|
|
4337
4534
|
return this.buffers[locationOrName] || null;
|
|
4338
4535
|
}
|
|
4339
4536
|
const location = this._getVaryingIndex(locationOrName);
|
|
4340
|
-
return
|
|
4537
|
+
return this.buffers[location] ?? null;
|
|
4341
4538
|
}
|
|
4342
4539
|
bind(funcOrHandle = this.handle) {
|
|
4343
4540
|
if (typeof funcOrHandle !== "function") {
|
|
@@ -4384,8 +4581,8 @@ var init_webgl_transform_feedback = __esm({
|
|
|
4384
4581
|
* cannot be bound to 'TRANSFORM_FEEDBACK_BUFFER' target.
|
|
4385
4582
|
*/
|
|
4386
4583
|
_bindBuffers() {
|
|
4387
|
-
for (const bufferIndex
|
|
4388
|
-
const { buffer, byteLength, byteOffset } = this._getBufferRange(
|
|
4584
|
+
for (const [bufferIndex, bufferEntry] of Object.entries(this.buffers)) {
|
|
4585
|
+
const { buffer, byteLength, byteOffset } = this._getBufferRange(bufferEntry);
|
|
4389
4586
|
this._bindBuffer(Number(bufferIndex), buffer, byteOffset, byteLength);
|
|
4390
4587
|
}
|
|
4391
4588
|
}
|
|
@@ -4407,13 +4604,13 @@ var init_webgl_transform_feedback = __esm({
|
|
|
4407
4604
|
});
|
|
4408
4605
|
|
|
4409
4606
|
// dist/adapter/resources/webgl-query-set.js
|
|
4410
|
-
var
|
|
4607
|
+
var import_core22, import_constants25, WEBGLQuerySet;
|
|
4411
4608
|
var init_webgl_query_set = __esm({
|
|
4412
4609
|
"dist/adapter/resources/webgl-query-set.js"() {
|
|
4413
4610
|
"use strict";
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
WEBGLQuerySet = class extends
|
|
4611
|
+
import_core22 = require("@luma.gl/core");
|
|
4612
|
+
import_constants25 = require("@luma.gl/constants");
|
|
4613
|
+
WEBGLQuerySet = class extends import_core22.QuerySet {
|
|
4417
4614
|
device;
|
|
4418
4615
|
handle;
|
|
4419
4616
|
target = null;
|
|
@@ -4546,6 +4743,57 @@ var init_webgl_query_set = __esm({
|
|
|
4546
4743
|
}
|
|
4547
4744
|
});
|
|
4548
4745
|
|
|
4746
|
+
// dist/adapter/resources/webgl-fence.js
|
|
4747
|
+
var import_core23, WEBGLFence;
|
|
4748
|
+
var init_webgl_fence = __esm({
|
|
4749
|
+
"dist/adapter/resources/webgl-fence.js"() {
|
|
4750
|
+
"use strict";
|
|
4751
|
+
import_core23 = require("@luma.gl/core");
|
|
4752
|
+
WEBGLFence = class extends import_core23.Fence {
|
|
4753
|
+
device;
|
|
4754
|
+
gl;
|
|
4755
|
+
handle;
|
|
4756
|
+
signaled;
|
|
4757
|
+
_signaled = false;
|
|
4758
|
+
constructor(device, props = {}) {
|
|
4759
|
+
super(device, {});
|
|
4760
|
+
this.device = device;
|
|
4761
|
+
this.gl = device.gl;
|
|
4762
|
+
const sync = this.props.handle || this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
|
|
4763
|
+
if (!sync) {
|
|
4764
|
+
throw new Error("Failed to create WebGL fence");
|
|
4765
|
+
}
|
|
4766
|
+
this.handle = sync;
|
|
4767
|
+
this.signaled = new Promise((resolve) => {
|
|
4768
|
+
const poll = () => {
|
|
4769
|
+
const status = this.gl.clientWaitSync(this.handle, 0, 0);
|
|
4770
|
+
if (status === this.gl.ALREADY_SIGNALED || status === this.gl.CONDITION_SATISFIED) {
|
|
4771
|
+
this._signaled = true;
|
|
4772
|
+
resolve();
|
|
4773
|
+
} else {
|
|
4774
|
+
setTimeout(poll, 1);
|
|
4775
|
+
}
|
|
4776
|
+
};
|
|
4777
|
+
poll();
|
|
4778
|
+
});
|
|
4779
|
+
}
|
|
4780
|
+
isSignaled() {
|
|
4781
|
+
if (this._signaled) {
|
|
4782
|
+
return true;
|
|
4783
|
+
}
|
|
4784
|
+
const status = this.gl.getSyncParameter(this.handle, this.gl.SYNC_STATUS);
|
|
4785
|
+
this._signaled = status === this.gl.SIGNALED;
|
|
4786
|
+
return this._signaled;
|
|
4787
|
+
}
|
|
4788
|
+
destroy() {
|
|
4789
|
+
if (!this.destroyed) {
|
|
4790
|
+
this.gl.deleteSync(this.handle);
|
|
4791
|
+
}
|
|
4792
|
+
}
|
|
4793
|
+
};
|
|
4794
|
+
}
|
|
4795
|
+
});
|
|
4796
|
+
|
|
4549
4797
|
// dist/adapter/helpers/format-utils.js
|
|
4550
4798
|
function glFormatToComponents(format) {
|
|
4551
4799
|
switch (format) {
|
|
@@ -4586,41 +4834,11 @@ function glTypeToBytes(type) {
|
|
|
4586
4834
|
return 0;
|
|
4587
4835
|
}
|
|
4588
4836
|
}
|
|
4589
|
-
var
|
|
4837
|
+
var import_constants26;
|
|
4590
4838
|
var init_format_utils = __esm({
|
|
4591
4839
|
"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
4840
|
"use strict";
|
|
4605
4841
|
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
4842
|
}
|
|
4625
4843
|
});
|
|
4626
4844
|
|
|
@@ -4654,7 +4872,7 @@ function readPixelsToArray(source, options) {
|
|
|
4654
4872
|
sourceFormat ||= (texture == null ? void 0 : texture.glFormat) || 6408;
|
|
4655
4873
|
sourceType ||= (texture == null ? void 0 : texture.glType) || 5121;
|
|
4656
4874
|
target2 = getPixelArray(target2, sourceType, sourceFormat, sourceWidth, sourceHeight, sourceDepth);
|
|
4657
|
-
const signedType = (0,
|
|
4875
|
+
const signedType = (0, import_core24.getDataType)(target2);
|
|
4658
4876
|
sourceType = sourceType || convertDataTypeToGLDataType(signedType);
|
|
4659
4877
|
const prevHandle = gl.bindFramebuffer(36160, handle);
|
|
4660
4878
|
gl.readBuffer(36064 + sourceAttachment);
|
|
@@ -4697,7 +4915,7 @@ function readPixelsToBuffer(source, options) {
|
|
|
4697
4915
|
return webglBufferTarget;
|
|
4698
4916
|
}
|
|
4699
4917
|
function getFramebuffer2(source) {
|
|
4700
|
-
if (!(source instanceof
|
|
4918
|
+
if (!(source instanceof import_core24.Framebuffer)) {
|
|
4701
4919
|
return { framebuffer: toFramebuffer(source), deleteFramebuffer: true };
|
|
4702
4920
|
}
|
|
4703
4921
|
return { framebuffer: source, deleteFramebuffer: false };
|
|
@@ -4719,15 +4937,15 @@ function getPixelArray(pixelArray, glType, glFormat, width, height, depth) {
|
|
|
4719
4937
|
}
|
|
4720
4938
|
glType ||= 5121;
|
|
4721
4939
|
const shaderType = convertGLDataTypeToDataType(glType);
|
|
4722
|
-
const ArrayType = (0,
|
|
4940
|
+
const ArrayType = (0, import_core24.getTypedArrayConstructor)(shaderType);
|
|
4723
4941
|
const components = glFormatToComponents(glFormat);
|
|
4724
4942
|
return new ArrayType(width * height * components);
|
|
4725
4943
|
}
|
|
4726
|
-
var
|
|
4944
|
+
var import_core24, import_constants27;
|
|
4727
4945
|
var init_webgl_texture_utils = __esm({
|
|
4728
4946
|
"dist/adapter/helpers/webgl-texture-utils.js"() {
|
|
4729
4947
|
"use strict";
|
|
4730
|
-
|
|
4948
|
+
import_core24 = require("@luma.gl/core");
|
|
4731
4949
|
import_constants27 = require("@luma.gl/constants");
|
|
4732
4950
|
init_webgl_shadertypes();
|
|
4733
4951
|
init_format_utils();
|
|
@@ -4774,13 +4992,14 @@ function compareConstantArrayValues2(v1, v2) {
|
|
|
4774
4992
|
}
|
|
4775
4993
|
return true;
|
|
4776
4994
|
}
|
|
4777
|
-
var
|
|
4995
|
+
var import_core25, WebGLDevice;
|
|
4778
4996
|
var init_webgl_device = __esm({
|
|
4779
4997
|
"dist/adapter/webgl-device.js"() {
|
|
4780
4998
|
"use strict";
|
|
4781
|
-
|
|
4999
|
+
import_core25 = require("@luma.gl/core");
|
|
4782
5000
|
init_webgl_state_tracker();
|
|
4783
5001
|
init_create_browser_context();
|
|
5002
|
+
init_webgl_context_data();
|
|
4784
5003
|
init_webgl_device_info();
|
|
4785
5004
|
init_webgl_device_features();
|
|
4786
5005
|
init_webgl_device_limits();
|
|
@@ -4799,11 +5018,19 @@ var init_webgl_device = __esm({
|
|
|
4799
5018
|
init_webgl_vertex_array();
|
|
4800
5019
|
init_webgl_transform_feedback();
|
|
4801
5020
|
init_webgl_query_set();
|
|
5021
|
+
init_webgl_fence();
|
|
4802
5022
|
init_webgl_texture_utils();
|
|
4803
5023
|
init_unified_parameter_api();
|
|
4804
5024
|
init_with_parameters();
|
|
4805
5025
|
init_webgl_extensions();
|
|
4806
|
-
WebGLDevice = class extends
|
|
5026
|
+
WebGLDevice = class extends import_core25.Device {
|
|
5027
|
+
static getDeviceFromContext(gl) {
|
|
5028
|
+
var _a;
|
|
5029
|
+
if (!gl) {
|
|
5030
|
+
return null;
|
|
5031
|
+
}
|
|
5032
|
+
return ((_a = gl.luma) == null ? void 0 : _a.device) ?? null;
|
|
5033
|
+
}
|
|
4807
5034
|
// Public `Device` API
|
|
4808
5035
|
/** type of this device */
|
|
4809
5036
|
type = "webgl";
|
|
@@ -4825,7 +5052,7 @@ var init_webgl_device = __esm({
|
|
|
4825
5052
|
// @ts-ignore TODO fix
|
|
4826
5053
|
_constants;
|
|
4827
5054
|
/** State used by luma.gl classes - TODO - not used? */
|
|
4828
|
-
|
|
5055
|
+
extensions;
|
|
4829
5056
|
_polyfilled = false;
|
|
4830
5057
|
/** Instance of Spector.js (if initialized) */
|
|
4831
5058
|
spectorJS;
|
|
@@ -4847,13 +5074,14 @@ var init_webgl_device = __esm({
|
|
|
4847
5074
|
}
|
|
4848
5075
|
}
|
|
4849
5076
|
constructor(props) {
|
|
4850
|
-
var _a
|
|
5077
|
+
var _a;
|
|
4851
5078
|
super({ ...props, id: props.id || uid("webgl-device") });
|
|
4852
|
-
const canvasContextProps =
|
|
5079
|
+
const canvasContextProps = import_core25.Device._getCanvasContextProps(props);
|
|
4853
5080
|
if (!canvasContextProps) {
|
|
4854
5081
|
throw new Error("WebGLDevice requires props.createCanvasContext to be set");
|
|
4855
5082
|
}
|
|
4856
|
-
|
|
5083
|
+
const existingContext = ((_a = canvasContextProps.canvas) == null ? void 0 : _a.gl) ?? null;
|
|
5084
|
+
let device = WebGLDevice.getDeviceFromContext(existingContext);
|
|
4857
5085
|
if (device) {
|
|
4858
5086
|
throw new Error(`WebGL context already attached to device ${device.id}`);
|
|
4859
5087
|
}
|
|
@@ -4868,6 +5096,9 @@ var init_webgl_device = __esm({
|
|
|
4868
5096
|
if (props.powerPreference !== void 0) {
|
|
4869
5097
|
webglContextAttributes.powerPreference = props.powerPreference;
|
|
4870
5098
|
}
|
|
5099
|
+
if (props.failIfMajorPerformanceCaveat !== void 0) {
|
|
5100
|
+
webglContextAttributes.failIfMajorPerformanceCaveat = props.failIfMajorPerformanceCaveat;
|
|
5101
|
+
}
|
|
4871
5102
|
const externalGLContext = this.props._handle;
|
|
4872
5103
|
const gl = externalGLContext || createBrowserContext(this.canvasContext.canvas, {
|
|
4873
5104
|
onContextLost: (event) => {
|
|
@@ -4883,10 +5114,11 @@ var init_webgl_device = __esm({
|
|
|
4883
5114
|
if (!gl) {
|
|
4884
5115
|
throw new Error("WebGL context creation failed");
|
|
4885
5116
|
}
|
|
4886
|
-
device = gl
|
|
5117
|
+
device = WebGLDevice.getDeviceFromContext(gl);
|
|
4887
5118
|
if (device) {
|
|
4888
5119
|
if (props._reuseDevices) {
|
|
4889
|
-
|
|
5120
|
+
import_core25.log.log(1, `Not creating a new Device, instead returning a reference to Device ${device.id} already attached to WebGL context`, device)();
|
|
5121
|
+
this.canvasContext.destroy();
|
|
4890
5122
|
device._reused = true;
|
|
4891
5123
|
return device;
|
|
4892
5124
|
}
|
|
@@ -4895,26 +5127,25 @@ var init_webgl_device = __esm({
|
|
|
4895
5127
|
this.handle = gl;
|
|
4896
5128
|
this.gl = gl;
|
|
4897
5129
|
this.spectorJS = initializeSpectorJS({ ...this.props, gl: this.handle });
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
this.
|
|
5130
|
+
const contextData = getWebGLContextData(this.handle);
|
|
5131
|
+
contextData.device = this;
|
|
5132
|
+
this.extensions = contextData.extensions || (contextData.extensions = {});
|
|
5133
|
+
this.info = getDeviceInfo(this.gl, this.extensions);
|
|
4901
5134
|
this.limits = new WebGLDeviceLimits(this.gl);
|
|
4902
|
-
this.features = new WebGLDeviceFeatures(this.gl, this.
|
|
5135
|
+
this.features = new WebGLDeviceFeatures(this.gl, this.extensions, this.props._disabledFeatures);
|
|
4903
5136
|
if (this.props._initializeFeatures) {
|
|
4904
5137
|
this.features.initializeFeatures();
|
|
4905
5138
|
}
|
|
4906
5139
|
const glState = new WebGLStateTracker(this.gl, {
|
|
4907
|
-
log: (...args) =>
|
|
5140
|
+
log: (...args) => import_core25.log.log(1, ...args)()
|
|
4908
5141
|
});
|
|
4909
5142
|
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
|
-
}
|
|
5143
|
+
if (props.debug || props.debugWebGL) {
|
|
5144
|
+
this.gl = makeDebugContext(this.gl, { debugWebGL: true, traceWebGL: props.debugWebGL });
|
|
5145
|
+
import_core25.log.warn("WebGL debug mode activated. Performance reduced.")();
|
|
5146
|
+
}
|
|
5147
|
+
if (props.debugWebGL) {
|
|
5148
|
+
import_core25.log.level = Math.max(import_core25.log.level, 1);
|
|
4918
5149
|
}
|
|
4919
5150
|
this.commandEncoder = new WEBGLCommandEncoder(this, { id: `${this}-command-encoder` });
|
|
4920
5151
|
}
|
|
@@ -4930,16 +5161,14 @@ var init_webgl_device = __esm({
|
|
|
4930
5161
|
*/
|
|
4931
5162
|
destroy() {
|
|
4932
5163
|
if (!this.props._reuseDevices && !this._reused) {
|
|
4933
|
-
|
|
5164
|
+
const contextData = getWebGLContextData(this.handle);
|
|
5165
|
+
contextData.device = null;
|
|
4934
5166
|
}
|
|
4935
5167
|
}
|
|
4936
5168
|
get isLost() {
|
|
4937
5169
|
return this.gl.isContextLost();
|
|
4938
5170
|
}
|
|
4939
5171
|
// IMPLEMENTATION OF ABSTRACT DEVICE
|
|
4940
|
-
getTextureByteAlignment() {
|
|
4941
|
-
return 4;
|
|
4942
|
-
}
|
|
4943
5172
|
createCanvasContext(props) {
|
|
4944
5173
|
throw new Error("WebGL only supports a single canvas");
|
|
4945
5174
|
}
|
|
@@ -4971,6 +5200,9 @@ var init_webgl_device = __esm({
|
|
|
4971
5200
|
createQuerySet(props) {
|
|
4972
5201
|
return new WEBGLQuerySet(this, props);
|
|
4973
5202
|
}
|
|
5203
|
+
createFence() {
|
|
5204
|
+
return new WEBGLFence(this);
|
|
5205
|
+
}
|
|
4974
5206
|
createRenderPipeline(props) {
|
|
4975
5207
|
return new WEBGLRenderPipeline(this, props);
|
|
4976
5208
|
}
|
|
@@ -5014,11 +5246,11 @@ var init_webgl_device = __esm({
|
|
|
5014
5246
|
return withGLParameters(this.gl, parameters, func);
|
|
5015
5247
|
}
|
|
5016
5248
|
resetWebGL() {
|
|
5017
|
-
|
|
5249
|
+
import_core25.log.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")();
|
|
5018
5250
|
resetGLParameters(this.gl);
|
|
5019
5251
|
}
|
|
5020
5252
|
_getDeviceSpecificTextureFormatCapabilities(capabilities) {
|
|
5021
|
-
return getTextureFormatCapabilitiesWebGL(this.gl, capabilities, this.
|
|
5253
|
+
return getTextureFormatCapabilitiesWebGL(this.gl, capabilities, this.extensions);
|
|
5022
5254
|
}
|
|
5023
5255
|
//
|
|
5024
5256
|
// WebGL-only API (not part of `Device` API)
|
|
@@ -5087,7 +5319,7 @@ var init_webgl_device = __esm({
|
|
|
5087
5319
|
this._constants = this._constants || new Array(maxVertexAttributes).fill(null);
|
|
5088
5320
|
const currentConstant = this._constants[location];
|
|
5089
5321
|
if (currentConstant && compareConstantArrayValues2(currentConstant, constant)) {
|
|
5090
|
-
|
|
5322
|
+
import_core25.log.info(1, `setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`)();
|
|
5091
5323
|
}
|
|
5092
5324
|
this._constants[location] = constant;
|
|
5093
5325
|
switch (constant.constructor) {
|
|
@@ -5106,8 +5338,8 @@ var init_webgl_device = __esm({
|
|
|
5106
5338
|
}
|
|
5107
5339
|
/** Ensure extensions are only requested once */
|
|
5108
5340
|
getExtension(name) {
|
|
5109
|
-
getWebGLExtension(this.gl, name, this.
|
|
5110
|
-
return this.
|
|
5341
|
+
getWebGLExtension(this.gl, name, this.extensions);
|
|
5342
|
+
return this.extensions;
|
|
5111
5343
|
}
|
|
5112
5344
|
// INTERNAL SUPPORT METHODS FOR WEBGL RESOURCES
|
|
5113
5345
|
/**
|
|
@@ -5128,23 +5360,23 @@ function isWebGL(gl) {
|
|
|
5128
5360
|
if (typeof WebGL2RenderingContext !== "undefined" && gl instanceof WebGL2RenderingContext) {
|
|
5129
5361
|
return true;
|
|
5130
5362
|
}
|
|
5131
|
-
return Boolean(gl &&
|
|
5363
|
+
return Boolean(gl && typeof gl.createVertexArray === "function");
|
|
5132
5364
|
}
|
|
5133
|
-
var
|
|
5365
|
+
var import_core26, LOG_LEVEL2, WebGLAdapter, webgl2Adapter;
|
|
5134
5366
|
var init_webgl_adapter = __esm({
|
|
5135
5367
|
"dist/adapter/webgl-adapter.js"() {
|
|
5136
5368
|
"use strict";
|
|
5137
|
-
|
|
5369
|
+
import_core26 = require("@luma.gl/core");
|
|
5138
5370
|
init_polyfill_webgl1_extensions();
|
|
5139
5371
|
init_spector();
|
|
5140
5372
|
init_webgl_developer_tools();
|
|
5141
5373
|
LOG_LEVEL2 = 1;
|
|
5142
|
-
WebGLAdapter = class extends
|
|
5374
|
+
WebGLAdapter = class extends import_core26.Adapter {
|
|
5143
5375
|
/** type of device's created by this adapter */
|
|
5144
5376
|
type = "webgl";
|
|
5145
5377
|
constructor() {
|
|
5146
5378
|
super();
|
|
5147
|
-
|
|
5379
|
+
import_core26.Device.defaultProps = { ...import_core26.Device.defaultProps, ...DEFAULT_SPECTOR_PROPS };
|
|
5148
5380
|
}
|
|
5149
5381
|
/** Force any created WebGL contexts to be WebGL2 contexts, polyfilled with WebGL1 extensions */
|
|
5150
5382
|
enforceWebGL2(enable2) {
|
|
@@ -5159,7 +5391,7 @@ var init_webgl_adapter = __esm({
|
|
|
5159
5391
|
return true;
|
|
5160
5392
|
}
|
|
5161
5393
|
if (typeof WebGLRenderingContext !== "undefined" && handle instanceof WebGLRenderingContext) {
|
|
5162
|
-
|
|
5394
|
+
import_core26.log.warn("WebGL1 is not supported", handle)();
|
|
5163
5395
|
}
|
|
5164
5396
|
return false;
|
|
5165
5397
|
}
|
|
@@ -5175,8 +5407,9 @@ var init_webgl_adapter = __esm({
|
|
|
5175
5407
|
if (gl instanceof WebGLDevice2) {
|
|
5176
5408
|
return gl;
|
|
5177
5409
|
}
|
|
5178
|
-
|
|
5179
|
-
|
|
5410
|
+
const existingDevice = WebGLDevice2.getDeviceFromContext(gl);
|
|
5411
|
+
if (existingDevice) {
|
|
5412
|
+
return existingDevice;
|
|
5180
5413
|
}
|
|
5181
5414
|
if (!isWebGL(gl)) {
|
|
5182
5415
|
throw new Error("Invalid WebGL2RenderingContext");
|
|
@@ -5190,28 +5423,29 @@ var init_webgl_adapter = __esm({
|
|
|
5190
5423
|
}
|
|
5191
5424
|
async create(props = {}) {
|
|
5192
5425
|
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
|
-
}
|
|
5426
|
+
const promises = [];
|
|
5427
|
+
if (props.debugWebGL || props.debug) {
|
|
5428
|
+
promises.push(loadWebGLDeveloperTools());
|
|
5429
|
+
}
|
|
5430
|
+
if (props.debugSpectorJS) {
|
|
5431
|
+
promises.push(loadSpectorJS(props));
|
|
5432
|
+
}
|
|
5433
|
+
const results = await Promise.allSettled(promises);
|
|
5434
|
+
for (const result of results) {
|
|
5435
|
+
if (result.status === "rejected") {
|
|
5436
|
+
import_core26.log.error(`Failed to initialize debug libraries ${result.reason}`)();
|
|
5207
5437
|
}
|
|
5438
|
+
}
|
|
5439
|
+
try {
|
|
5208
5440
|
const device = new WebGLDevice2(props);
|
|
5441
|
+
import_core26.log.groupCollapsed(LOG_LEVEL2, `WebGLDevice ${device.id} created`)();
|
|
5209
5442
|
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
|
-
|
|
5443
|
+
import_core26.log.probe(LOG_LEVEL2, message2)();
|
|
5444
|
+
import_core26.log.table(LOG_LEVEL2, device.info)();
|
|
5212
5445
|
return device;
|
|
5213
5446
|
} finally {
|
|
5214
|
-
|
|
5447
|
+
import_core26.log.groupEnd(LOG_LEVEL2)();
|
|
5448
|
+
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
5449
|
}
|
|
5216
5450
|
}
|
|
5217
5451
|
};
|
|
@@ -5224,6 +5458,7 @@ var dist_exports = {};
|
|
|
5224
5458
|
__export(dist_exports, {
|
|
5225
5459
|
WEBGLBuffer: () => WEBGLBuffer,
|
|
5226
5460
|
WEBGLCommandEncoder: () => WEBGLCommandEncoder,
|
|
5461
|
+
WEBGLFence: () => WEBGLFence,
|
|
5227
5462
|
WEBGLFramebuffer: () => WEBGLFramebuffer,
|
|
5228
5463
|
WEBGLRenderPass: () => WEBGLRenderPass,
|
|
5229
5464
|
WEBGLRenderPipeline: () => WEBGLRenderPipeline,
|
|
@@ -5255,6 +5490,7 @@ var init_dist = __esm({
|
|
|
5255
5490
|
init_webgl_shader();
|
|
5256
5491
|
init_webgl_sampler();
|
|
5257
5492
|
init_webgl_framebuffer();
|
|
5493
|
+
init_webgl_fence();
|
|
5258
5494
|
init_webgl_render_pipeline();
|
|
5259
5495
|
init_webgl_command_encoder();
|
|
5260
5496
|
init_webgl_render_pass();
|