@deck.gl/arcgis 9.4.0-beta.3 → 9.4.0-beta.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/dist.dev.js +509 -307
- package/dist/index.cjs +2346 -9137
- package/dist/index.cjs.map +3 -3
- package/dist.min.js +4 -4
- package/package.json +6 -6
package/dist/dist.dev.js
CHANGED
|
@@ -3213,6 +3213,498 @@ Source: ${sourceLine}` : "";
|
|
|
3213
3213
|
}
|
|
3214
3214
|
});
|
|
3215
3215
|
|
|
3216
|
+
// ../../node_modules/@luma.gl/webgl/dist/adapter/converters/webgl-shadertypes.js
|
|
3217
|
+
function convertDataTypeToGLDataType(normalizedType) {
|
|
3218
|
+
return NORMALIZED_SHADER_TYPE_TO_WEBGL[normalizedType];
|
|
3219
|
+
}
|
|
3220
|
+
function convertGLUniformTypeToShaderVariableType(glUniformType) {
|
|
3221
|
+
return WEBGL_SHADER_TYPES[glUniformType];
|
|
3222
|
+
}
|
|
3223
|
+
function isGLSamplerType(type) {
|
|
3224
|
+
return Boolean(WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[type]);
|
|
3225
|
+
}
|
|
3226
|
+
function getTextureBindingFromGLSamplerType(glSamplerType) {
|
|
3227
|
+
return WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[glSamplerType];
|
|
3228
|
+
}
|
|
3229
|
+
var WEBGL_SHADER_TYPES, WEBGL_SAMPLER_TO_TEXTURE_BINDINGS, NORMALIZED_SHADER_TYPE_TO_WEBGL;
|
|
3230
|
+
var init_webgl_shadertypes = __esm({
|
|
3231
|
+
"../../node_modules/@luma.gl/webgl/dist/adapter/converters/webgl-shadertypes.js"() {
|
|
3232
|
+
WEBGL_SHADER_TYPES = {
|
|
3233
|
+
[5126]: "f32",
|
|
3234
|
+
[35664]: "vec2<f32>",
|
|
3235
|
+
[35665]: "vec3<f32>",
|
|
3236
|
+
[35666]: "vec4<f32>",
|
|
3237
|
+
[5124]: "i32",
|
|
3238
|
+
[35667]: "vec2<i32>",
|
|
3239
|
+
[35668]: "vec3<i32>",
|
|
3240
|
+
[35669]: "vec4<i32>",
|
|
3241
|
+
[5125]: "u32",
|
|
3242
|
+
[36294]: "vec2<u32>",
|
|
3243
|
+
[36295]: "vec3<u32>",
|
|
3244
|
+
[36296]: "vec4<u32>",
|
|
3245
|
+
[35670]: "f32",
|
|
3246
|
+
[35671]: "vec2<f32>",
|
|
3247
|
+
[35672]: "vec3<f32>",
|
|
3248
|
+
[35673]: "vec4<f32>",
|
|
3249
|
+
// TODO - are sizes/components below correct?
|
|
3250
|
+
[35674]: "mat2x2<f32>",
|
|
3251
|
+
[35685]: "mat2x3<f32>",
|
|
3252
|
+
[35686]: "mat2x4<f32>",
|
|
3253
|
+
[35687]: "mat3x2<f32>",
|
|
3254
|
+
[35675]: "mat3x3<f32>",
|
|
3255
|
+
[35688]: "mat3x4<f32>",
|
|
3256
|
+
[35689]: "mat4x2<f32>",
|
|
3257
|
+
[35690]: "mat4x3<f32>",
|
|
3258
|
+
[35676]: "mat4x4<f32>"
|
|
3259
|
+
};
|
|
3260
|
+
WEBGL_SAMPLER_TO_TEXTURE_BINDINGS = {
|
|
3261
|
+
[35678]: { viewDimension: "2d", sampleType: "float" },
|
|
3262
|
+
[35680]: { viewDimension: "cube", sampleType: "float" },
|
|
3263
|
+
[35679]: { viewDimension: "3d", sampleType: "float" },
|
|
3264
|
+
[35682]: { viewDimension: "3d", sampleType: "depth" },
|
|
3265
|
+
[36289]: { viewDimension: "2d-array", sampleType: "float" },
|
|
3266
|
+
[36292]: { viewDimension: "2d-array", sampleType: "depth" },
|
|
3267
|
+
[36293]: { viewDimension: "cube", sampleType: "float" },
|
|
3268
|
+
[36298]: { viewDimension: "2d", sampleType: "sint" },
|
|
3269
|
+
[36299]: { viewDimension: "3d", sampleType: "sint" },
|
|
3270
|
+
[36300]: { viewDimension: "cube", sampleType: "sint" },
|
|
3271
|
+
[36303]: { viewDimension: "2d-array", sampleType: "uint" },
|
|
3272
|
+
[36306]: { viewDimension: "2d", sampleType: "uint" },
|
|
3273
|
+
[36307]: { viewDimension: "3d", sampleType: "uint" },
|
|
3274
|
+
[36308]: { viewDimension: "cube", sampleType: "uint" },
|
|
3275
|
+
[36311]: { viewDimension: "2d-array", sampleType: "uint" }
|
|
3276
|
+
};
|
|
3277
|
+
NORMALIZED_SHADER_TYPE_TO_WEBGL = {
|
|
3278
|
+
uint8: 5121,
|
|
3279
|
+
sint8: 5120,
|
|
3280
|
+
unorm8: 5121,
|
|
3281
|
+
snorm8: 5120,
|
|
3282
|
+
uint16: 5123,
|
|
3283
|
+
sint16: 5122,
|
|
3284
|
+
unorm16: 5123,
|
|
3285
|
+
snorm16: 5122,
|
|
3286
|
+
uint32: 5125,
|
|
3287
|
+
sint32: 5124,
|
|
3288
|
+
// WebGPU does not support normalized 32 bit integer attributes
|
|
3289
|
+
// 'unorm32': GL.UNSIGNED_INT,
|
|
3290
|
+
// 'snorm32': GL.INT,
|
|
3291
|
+
float16: 5131,
|
|
3292
|
+
float32: 5126
|
|
3293
|
+
};
|
|
3294
|
+
}
|
|
3295
|
+
});
|
|
3296
|
+
|
|
3297
|
+
// ../../node_modules/@luma.gl/webgl/dist/adapter/helpers/get-shader-layout-from-glsl.js
|
|
3298
|
+
function getShaderLayoutFromGLSL(gl, program, options = {}) {
|
|
3299
|
+
const shaderLayout = {
|
|
3300
|
+
attributes: [],
|
|
3301
|
+
bindings: []
|
|
3302
|
+
};
|
|
3303
|
+
shaderLayout.attributes = readAttributeDeclarations(gl, program);
|
|
3304
|
+
const uniformBlocks = readUniformBlocks(gl, program, options);
|
|
3305
|
+
for (const uniformBlock of uniformBlocks) {
|
|
3306
|
+
const uniforms2 = uniformBlock.uniforms.map((uniform) => ({
|
|
3307
|
+
name: uniform.name,
|
|
3308
|
+
format: uniform.format,
|
|
3309
|
+
byteOffset: uniform.byteOffset,
|
|
3310
|
+
byteStride: uniform.byteStride,
|
|
3311
|
+
arrayLength: uniform.arrayLength
|
|
3312
|
+
}));
|
|
3313
|
+
shaderLayout.bindings.push({
|
|
3314
|
+
type: "uniform",
|
|
3315
|
+
name: uniformBlock.name,
|
|
3316
|
+
group: 0,
|
|
3317
|
+
location: uniformBlock.location,
|
|
3318
|
+
visibility: (uniformBlock.vertex ? 1 : 0) | (uniformBlock.fragment ? 2 : 0),
|
|
3319
|
+
minBindingSize: uniformBlock.byteLength,
|
|
3320
|
+
uniforms: uniforms2
|
|
3321
|
+
});
|
|
3322
|
+
}
|
|
3323
|
+
const uniforms = readUniformBindings(gl, program);
|
|
3324
|
+
let textureUnit = 0;
|
|
3325
|
+
for (const uniform of uniforms) {
|
|
3326
|
+
if (isGLSamplerType(uniform.type)) {
|
|
3327
|
+
const { viewDimension, sampleType } = getTextureBindingFromGLSamplerType(uniform.type);
|
|
3328
|
+
shaderLayout.bindings.push({
|
|
3329
|
+
type: "texture",
|
|
3330
|
+
name: uniform.name,
|
|
3331
|
+
group: 0,
|
|
3332
|
+
location: textureUnit,
|
|
3333
|
+
viewDimension,
|
|
3334
|
+
sampleType
|
|
3335
|
+
});
|
|
3336
|
+
uniform.textureUnit = textureUnit;
|
|
3337
|
+
textureUnit += 1;
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
if (uniforms.length) {
|
|
3341
|
+
shaderLayout.uniforms = uniforms;
|
|
3342
|
+
}
|
|
3343
|
+
const varyings = readVaryings(gl, program);
|
|
3344
|
+
if (varyings?.length) {
|
|
3345
|
+
shaderLayout.varyings = varyings;
|
|
3346
|
+
}
|
|
3347
|
+
return shaderLayout;
|
|
3348
|
+
}
|
|
3349
|
+
function readAttributeDeclarations(gl, program) {
|
|
3350
|
+
const attributes = [];
|
|
3351
|
+
const count = gl.getProgramParameter(program, 35721);
|
|
3352
|
+
for (let index = 0; index < count; index++) {
|
|
3353
|
+
const activeInfo = gl.getActiveAttrib(program, index);
|
|
3354
|
+
if (!activeInfo) {
|
|
3355
|
+
throw new Error("activeInfo");
|
|
3356
|
+
}
|
|
3357
|
+
const {
|
|
3358
|
+
name,
|
|
3359
|
+
type: compositeType
|
|
3360
|
+
/* , size*/
|
|
3361
|
+
} = activeInfo;
|
|
3362
|
+
const location = gl.getAttribLocation(program, name);
|
|
3363
|
+
if (location >= 0) {
|
|
3364
|
+
const attributeType = convertGLUniformTypeToShaderVariableType(compositeType);
|
|
3365
|
+
const stepMode = /instance/i.test(name) ? "instance" : "vertex";
|
|
3366
|
+
attributes.push({
|
|
3367
|
+
name,
|
|
3368
|
+
location,
|
|
3369
|
+
stepMode,
|
|
3370
|
+
type: attributeType
|
|
3371
|
+
// size - for arrays, size is the number of elements in the array
|
|
3372
|
+
});
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
attributes.sort((a, b) => a.location - b.location);
|
|
3376
|
+
return attributes;
|
|
3377
|
+
}
|
|
3378
|
+
function readVaryings(gl, program) {
|
|
3379
|
+
const varyings = [];
|
|
3380
|
+
const count = gl.getProgramParameter(program, 35971);
|
|
3381
|
+
for (let location = 0; location < count; location++) {
|
|
3382
|
+
const activeInfo = gl.getTransformFeedbackVarying(program, location);
|
|
3383
|
+
if (!activeInfo) {
|
|
3384
|
+
throw new Error("activeInfo");
|
|
3385
|
+
}
|
|
3386
|
+
const { name, type: glUniformType, size } = activeInfo;
|
|
3387
|
+
const uniformType = convertGLUniformTypeToShaderVariableType(glUniformType);
|
|
3388
|
+
const { type, components } = (0, import_core15.getVariableShaderTypeInfo)(uniformType);
|
|
3389
|
+
varyings.push({ location, name, type, size: size * components });
|
|
3390
|
+
}
|
|
3391
|
+
varyings.sort((a, b) => a.location - b.location);
|
|
3392
|
+
return varyings;
|
|
3393
|
+
}
|
|
3394
|
+
function readUniformBindings(gl, program) {
|
|
3395
|
+
const uniforms = [];
|
|
3396
|
+
const uniformCount = gl.getProgramParameter(program, 35718);
|
|
3397
|
+
for (let i = 0; i < uniformCount; i++) {
|
|
3398
|
+
const activeInfo = gl.getActiveUniform(program, i);
|
|
3399
|
+
if (!activeInfo) {
|
|
3400
|
+
throw new Error("activeInfo");
|
|
3401
|
+
}
|
|
3402
|
+
const { name: rawName, size, type } = activeInfo;
|
|
3403
|
+
const { name, isArray: isArray4 } = parseUniformName(rawName);
|
|
3404
|
+
let webglLocation = gl.getUniformLocation(program, name);
|
|
3405
|
+
const uniformInfo = {
|
|
3406
|
+
// WebGL locations are uniquely typed but just numbers
|
|
3407
|
+
location: webglLocation,
|
|
3408
|
+
name,
|
|
3409
|
+
size,
|
|
3410
|
+
type,
|
|
3411
|
+
isArray: isArray4
|
|
3412
|
+
};
|
|
3413
|
+
uniforms.push(uniformInfo);
|
|
3414
|
+
if (uniformInfo.size > 1) {
|
|
3415
|
+
for (let j = 0; j < uniformInfo.size; j++) {
|
|
3416
|
+
const elementName = `${name}[${j}]`;
|
|
3417
|
+
webglLocation = gl.getUniformLocation(program, elementName);
|
|
3418
|
+
const arrayElementUniformInfo = {
|
|
3419
|
+
...uniformInfo,
|
|
3420
|
+
name: elementName,
|
|
3421
|
+
location: webglLocation
|
|
3422
|
+
};
|
|
3423
|
+
uniforms.push(arrayElementUniformInfo);
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
return uniforms;
|
|
3428
|
+
}
|
|
3429
|
+
function readUniformBlocks(gl, program, options) {
|
|
3430
|
+
const uniformBlocks = [];
|
|
3431
|
+
const knownBlocksByIndex = getKnownUniformBlocksByIndex(gl, program, options);
|
|
3432
|
+
for (const [blockIndex, uniformBlock] of knownBlocksByIndex) {
|
|
3433
|
+
uniformBlocks.push(uniformBlock);
|
|
3434
|
+
try {
|
|
3435
|
+
const reflectedUniformBlock = readReflectedUniformBlock(gl, program, blockIndex, uniformBlock.name);
|
|
3436
|
+
validateReflectedUniformBlock(reflectedUniformBlock, uniformBlock);
|
|
3437
|
+
} catch (error) {
|
|
3438
|
+
const message2 = error instanceof Error ? error.message : String(error);
|
|
3439
|
+
import_core15.log.once(0, `WebGL uniform block reflection failed for "${uniformBlock.name}"; using supplied std140 metadata. ${message2}`)();
|
|
3440
|
+
}
|
|
3441
|
+
}
|
|
3442
|
+
const blockCount = gl.getProgramParameter(program, 35382);
|
|
3443
|
+
if (!Number.isInteger(blockCount) || blockCount < 0) {
|
|
3444
|
+
throw new Error(`Failed to reflect WebGL uniform blocks: ACTIVE_UNIFORM_BLOCKS returned ${String(blockCount)}`);
|
|
3445
|
+
}
|
|
3446
|
+
for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {
|
|
3447
|
+
if (!knownBlocksByIndex.has(blockIndex)) {
|
|
3448
|
+
uniformBlocks.push(readReflectedUniformBlock(gl, program, blockIndex));
|
|
3449
|
+
}
|
|
3450
|
+
}
|
|
3451
|
+
uniformBlocks.sort((a, b) => a.location - b.location);
|
|
3452
|
+
return uniformBlocks;
|
|
3453
|
+
}
|
|
3454
|
+
function validateReflectedUniformBlock(reflectedUniformBlock, knownUniformBlock) {
|
|
3455
|
+
for (const reflectedUniform of reflectedUniformBlock.uniforms) {
|
|
3456
|
+
const knownUniform = knownUniformBlock.uniforms.find((uniform) => reflectedUniform.name === uniform.name || reflectedUniform.name.endsWith(`.${uniform.name}`));
|
|
3457
|
+
if (!knownUniform) {
|
|
3458
|
+
throw new Error(`Failed to validate WebGL uniform block "${knownUniformBlock.name}": reflected unexpected member "${reflectedUniform.name}"`);
|
|
3459
|
+
}
|
|
3460
|
+
if (reflectedUniform.format !== knownUniform.format || reflectedUniform.arrayLength !== knownUniform.arrayLength || reflectedUniform.byteOffset !== knownUniform.byteOffset || reflectedUniform.byteStride !== knownUniform.byteStride) {
|
|
3461
|
+
throw new Error(`Failed to validate WebGL uniform block "${knownUniformBlock.name}": reflected layout for "${reflectedUniform.name}" does not match supplied std140 metadata`);
|
|
3462
|
+
}
|
|
3463
|
+
}
|
|
3464
|
+
}
|
|
3465
|
+
function getKnownUniformBlocksByIndex(gl, program, options) {
|
|
3466
|
+
const knownUniformBlocks = /* @__PURE__ */ new Map();
|
|
3467
|
+
for (const uniformBlockLayout of options.uniformBlockLayouts || []) {
|
|
3468
|
+
knownUniformBlocks.set(uniformBlockLayout.name, makeUniformBlockBindingFromTypes(uniformBlockLayout));
|
|
3469
|
+
}
|
|
3470
|
+
for (const binding of options.shaderLayout?.bindings || []) {
|
|
3471
|
+
if (isUsableUniformBlockBinding(binding)) {
|
|
3472
|
+
knownUniformBlocks.set(binding.name, binding);
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
const knownBlocksByIndex = /* @__PURE__ */ new Map();
|
|
3476
|
+
for (const binding of knownUniformBlocks.values()) {
|
|
3477
|
+
const resolvedBlock = getActiveUniformBlockIndex(gl, program, binding.name);
|
|
3478
|
+
if (!resolvedBlock) {
|
|
3479
|
+
continue;
|
|
3480
|
+
}
|
|
3481
|
+
const { blockIndex, blockName } = resolvedBlock;
|
|
3482
|
+
if (knownBlocksByIndex.has(blockIndex)) {
|
|
3483
|
+
throw new Error(`Multiple supplied uniform block layouts resolve to active WebGL block "${blockName}"`);
|
|
3484
|
+
}
|
|
3485
|
+
knownBlocksByIndex.set(blockIndex, {
|
|
3486
|
+
name: blockName,
|
|
3487
|
+
location: blockIndex,
|
|
3488
|
+
byteLength: binding.minBindingSize,
|
|
3489
|
+
vertex: Boolean(binding.visibility && binding.visibility & 1),
|
|
3490
|
+
fragment: Boolean(binding.visibility && binding.visibility & 2),
|
|
3491
|
+
uniformCount: binding.uniforms.length,
|
|
3492
|
+
uniforms: binding.uniforms.map((uniform) => ({ ...uniform }))
|
|
3493
|
+
});
|
|
3494
|
+
}
|
|
3495
|
+
return knownBlocksByIndex;
|
|
3496
|
+
}
|
|
3497
|
+
function getActiveUniformBlockIndex(gl, program, blockName) {
|
|
3498
|
+
const blockNames = blockName.endsWith("Uniforms") ? [blockName, blockName.slice(0, -"Uniforms".length)] : [blockName, `${blockName}Uniforms`];
|
|
3499
|
+
for (const candidateBlockName of blockNames) {
|
|
3500
|
+
const blockIndex = gl.getUniformBlockIndex(program, candidateBlockName);
|
|
3501
|
+
if (blockIndex !== 4294967295) {
|
|
3502
|
+
if (!Number.isInteger(blockIndex) || blockIndex < 0) {
|
|
3503
|
+
throw new Error(`Failed to resolve WebGL uniform block "${candidateBlockName}": getUniformBlockIndex returned ${String(blockIndex)}`);
|
|
3504
|
+
}
|
|
3505
|
+
return { blockIndex, blockName: candidateBlockName };
|
|
3506
|
+
}
|
|
3507
|
+
}
|
|
3508
|
+
return null;
|
|
3509
|
+
}
|
|
3510
|
+
function readReflectedUniformBlock(gl, program, blockIndex, knownBlockName) {
|
|
3511
|
+
const blockName = knownBlockName || gl.getActiveUniformBlockName(program, blockIndex);
|
|
3512
|
+
if (!blockName) {
|
|
3513
|
+
throw new Error(`Failed to reflect WebGL uniform block at index ${blockIndex}: missing block name`);
|
|
3514
|
+
}
|
|
3515
|
+
const getBlockParameter = (pname, label) => {
|
|
3516
|
+
const value = gl.getActiveUniformBlockParameter(program, blockIndex, pname);
|
|
3517
|
+
if (value === null || value === void 0) {
|
|
3518
|
+
throw new Error(`Failed to reflect WebGL uniform block "${blockName}": ${label} returned null`);
|
|
3519
|
+
}
|
|
3520
|
+
return value;
|
|
3521
|
+
};
|
|
3522
|
+
const location = getFiniteInteger(getBlockParameter(35391, "UNIFORM_BLOCK_BINDING"), blockName, "UNIFORM_BLOCK_BINDING", 0);
|
|
3523
|
+
const byteLength = getFiniteInteger(getBlockParameter(35392, "UNIFORM_BLOCK_DATA_SIZE"), blockName, "UNIFORM_BLOCK_DATA_SIZE", 0);
|
|
3524
|
+
const uniformCount = getFiniteInteger(getBlockParameter(35394, "UNIFORM_BLOCK_ACTIVE_UNIFORMS"), blockName, "UNIFORM_BLOCK_ACTIVE_UNIFORMS", 0);
|
|
3525
|
+
const uniformIndices = getNumericArray(getBlockParameter(35395, "UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"), blockName, "UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES", uniformCount);
|
|
3526
|
+
const uniformTypes = getActiveUniformValues(gl, program, uniformIndices, 35383, "UNIFORM_TYPE", blockName, uniformCount);
|
|
3527
|
+
const uniformArrayLengths = getActiveUniformValues(gl, program, uniformIndices, 35384, "UNIFORM_SIZE", blockName, uniformCount);
|
|
3528
|
+
const uniformBlockIndices = getActiveUniformValues(gl, program, uniformIndices, 35386, "UNIFORM_BLOCK_INDEX", blockName, uniformCount);
|
|
3529
|
+
const uniformOffsets = getActiveUniformValues(gl, program, uniformIndices, 35387, "UNIFORM_OFFSET", blockName, uniformCount);
|
|
3530
|
+
const uniformStrides = getActiveUniformValues(gl, program, uniformIndices, 35388, "UNIFORM_ARRAY_STRIDE", blockName, uniformCount);
|
|
3531
|
+
const uniforms = [];
|
|
3532
|
+
for (let uniformPosition = 0; uniformPosition < uniformCount; uniformPosition++) {
|
|
3533
|
+
if (uniformBlockIndices[uniformPosition] !== blockIndex) {
|
|
3534
|
+
throw new Error(`Failed to reflect WebGL uniform block "${blockName}": active uniform index ${uniformIndices[uniformPosition]} belongs to block ${uniformBlockIndices[uniformPosition]}, expected ${blockIndex}`);
|
|
3535
|
+
}
|
|
3536
|
+
const uniformIndex = uniformIndices[uniformPosition];
|
|
3537
|
+
const activeInfo = gl.getActiveUniform(program, uniformIndex);
|
|
3538
|
+
if (!activeInfo) {
|
|
3539
|
+
throw new Error(`Failed to reflect WebGL uniform block "${blockName}": getActiveUniform(${uniformIndex}) returned null`);
|
|
3540
|
+
}
|
|
3541
|
+
const uniformType = getFiniteInteger(uniformTypes[uniformPosition], blockName, `UNIFORM_TYPE[${uniformPosition}]`, 1);
|
|
3542
|
+
const arrayLength = getFiniteInteger(uniformArrayLengths[uniformPosition], blockName, `UNIFORM_SIZE[${uniformPosition}]`, 1);
|
|
3543
|
+
const byteOffset = getFiniteInteger(uniformOffsets[uniformPosition], blockName, `UNIFORM_OFFSET[${uniformPosition}]`, 0);
|
|
3544
|
+
const byteStride = getFiniteInteger(uniformStrides[uniformPosition], blockName, `UNIFORM_ARRAY_STRIDE[${uniformPosition}]`, 0);
|
|
3545
|
+
if (activeInfo.type !== uniformType || activeInfo.size !== arrayLength) {
|
|
3546
|
+
throw new Error(`Failed to reflect WebGL uniform block "${blockName}": getActiveUniform(${uniformIndex}) disagrees with getActiveUniforms`);
|
|
3547
|
+
}
|
|
3548
|
+
uniforms.push({
|
|
3549
|
+
name: activeInfo.name,
|
|
3550
|
+
format: convertGLUniformTypeToShaderVariableType(uniformType),
|
|
3551
|
+
arrayLength,
|
|
3552
|
+
byteOffset,
|
|
3553
|
+
byteStride
|
|
3554
|
+
});
|
|
3555
|
+
}
|
|
3556
|
+
const blockInfo = {
|
|
3557
|
+
name: blockName,
|
|
3558
|
+
location,
|
|
3559
|
+
byteLength,
|
|
3560
|
+
vertex: Boolean(getBlockParameter(35396, "UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER")),
|
|
3561
|
+
fragment: Boolean(getBlockParameter(35398, "UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER")),
|
|
3562
|
+
uniformCount,
|
|
3563
|
+
uniforms
|
|
3564
|
+
};
|
|
3565
|
+
const uniformInstancePrefixes = new Set(blockInfo.uniforms.map((uniform) => uniform.name.split(".")[0]).filter((instanceName) => Boolean(instanceName)));
|
|
3566
|
+
const blockAlias = blockInfo.name.replace(/Uniforms$/, "");
|
|
3567
|
+
if (uniformInstancePrefixes.size === 1 && !uniformInstancePrefixes.has(blockInfo.name) && !uniformInstancePrefixes.has(blockAlias)) {
|
|
3568
|
+
const [instanceName] = uniformInstancePrefixes;
|
|
3569
|
+
import_core15.log.warn(`Uniform block "${blockInfo.name}" uses GLSL instance "${instanceName}". luma.gl binds uniform buffers by block name ("${blockInfo.name}") and alias ("${blockAlias}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)();
|
|
3570
|
+
}
|
|
3571
|
+
return blockInfo;
|
|
3572
|
+
}
|
|
3573
|
+
function getActiveUniformValues(gl, program, uniformIndices, pname, label, blockName, expectedLength) {
|
|
3574
|
+
const values = gl.getActiveUniforms(program, uniformIndices, pname);
|
|
3575
|
+
if (values === null) {
|
|
3576
|
+
throw new Error(`Failed to reflect WebGL uniform block "${blockName}": ${label} returned null`);
|
|
3577
|
+
}
|
|
3578
|
+
return getNumericArray(values, blockName, label, expectedLength);
|
|
3579
|
+
}
|
|
3580
|
+
function getNumericArray(value, blockName, label, expectedLength) {
|
|
3581
|
+
if (!Array.isArray(value) && !ArrayBuffer.isView(value)) {
|
|
3582
|
+
throw new Error(`Failed to reflect WebGL uniform block "${blockName}": ${label} returned a non-array value`);
|
|
3583
|
+
}
|
|
3584
|
+
const values = Array.from(value);
|
|
3585
|
+
if (values.length !== expectedLength || values.some((item) => !Number.isInteger(item))) {
|
|
3586
|
+
throw new Error(`Failed to reflect WebGL uniform block "${blockName}": ${label} returned ${values.length} invalid values, expected ${expectedLength}`);
|
|
3587
|
+
}
|
|
3588
|
+
return values;
|
|
3589
|
+
}
|
|
3590
|
+
function getFiniteInteger(value, blockName, label, minimum) {
|
|
3591
|
+
if (!Number.isInteger(value) || value < minimum) {
|
|
3592
|
+
throw new Error(`Failed to reflect WebGL uniform block "${blockName}": ${label} returned ${String(value)}`);
|
|
3593
|
+
}
|
|
3594
|
+
return value;
|
|
3595
|
+
}
|
|
3596
|
+
function makeUniformBlockBindingFromTypes(uniformBlockLayout) {
|
|
3597
|
+
const shaderBlockLayout = (0, import_core15.makeShaderBlockLayout)(uniformBlockLayout.uniformTypes, {
|
|
3598
|
+
layout: "std140"
|
|
3599
|
+
});
|
|
3600
|
+
const uniforms = getUniformInfosFromTypes(uniformBlockLayout.uniformTypes, shaderBlockLayout.fields);
|
|
3601
|
+
return {
|
|
3602
|
+
type: "uniform",
|
|
3603
|
+
name: uniformBlockLayout.name,
|
|
3604
|
+
group: 0,
|
|
3605
|
+
location: 0,
|
|
3606
|
+
minBindingSize: shaderBlockLayout.byteLength,
|
|
3607
|
+
uniforms
|
|
3608
|
+
};
|
|
3609
|
+
}
|
|
3610
|
+
function getUniformInfosFromTypes(uniformTypes, fields) {
|
|
3611
|
+
const uniforms = [];
|
|
3612
|
+
const addType = (name, type) => {
|
|
3613
|
+
if (typeof type === "string") {
|
|
3614
|
+
const field = fields[name];
|
|
3615
|
+
if (!field) {
|
|
3616
|
+
throw new Error(`Missing std140 layout field ${name}`);
|
|
3617
|
+
}
|
|
3618
|
+
uniforms.push({
|
|
3619
|
+
name,
|
|
3620
|
+
format: field.shaderType,
|
|
3621
|
+
arrayLength: 1,
|
|
3622
|
+
byteOffset: field.offset * 4,
|
|
3623
|
+
byteStride: 0
|
|
3624
|
+
});
|
|
3625
|
+
return;
|
|
3626
|
+
}
|
|
3627
|
+
if (Array.isArray(type)) {
|
|
3628
|
+
addArrayType(name, type[0], type[1]);
|
|
3629
|
+
return;
|
|
3630
|
+
}
|
|
3631
|
+
for (const [memberName, memberType] of Object.entries(type)) {
|
|
3632
|
+
addType(`${name}.${memberName}`, memberType);
|
|
3633
|
+
}
|
|
3634
|
+
};
|
|
3635
|
+
const addArrayType = (name, type, arrayLength) => {
|
|
3636
|
+
if (typeof type === "string") {
|
|
3637
|
+
const firstField = fields[`${name}[0]`];
|
|
3638
|
+
const secondField = arrayLength > 1 ? fields[`${name}[1]`] : void 0;
|
|
3639
|
+
if (!firstField) {
|
|
3640
|
+
throw new Error(`Missing std140 array layout field ${name}[0]`);
|
|
3641
|
+
}
|
|
3642
|
+
uniforms.push({
|
|
3643
|
+
name: `${name}[0]`,
|
|
3644
|
+
format: firstField.shaderType,
|
|
3645
|
+
arrayLength,
|
|
3646
|
+
byteOffset: firstField.offset * 4,
|
|
3647
|
+
byteStride: secondField ? (secondField.offset - firstField.offset) * 4 : 0
|
|
3648
|
+
});
|
|
3649
|
+
return;
|
|
3650
|
+
}
|
|
3651
|
+
if (Array.isArray(type)) {
|
|
3652
|
+
throw new Error(`Nested uniform arrays are not supported for ${name}`);
|
|
3653
|
+
}
|
|
3654
|
+
for (const [memberName, memberType] of Object.entries(type)) {
|
|
3655
|
+
if (typeof memberType !== "string") {
|
|
3656
|
+
throw new Error(`Composite uniform array members are not supported for ${name}`);
|
|
3657
|
+
}
|
|
3658
|
+
const firstName = `${name}[0].${memberName}`;
|
|
3659
|
+
const secondName = `${name}[1].${memberName}`;
|
|
3660
|
+
const firstField = fields[firstName];
|
|
3661
|
+
const secondField = arrayLength > 1 ? fields[secondName] : void 0;
|
|
3662
|
+
if (!firstField) {
|
|
3663
|
+
throw new Error(`Missing std140 array layout field ${firstName}`);
|
|
3664
|
+
}
|
|
3665
|
+
uniforms.push({
|
|
3666
|
+
name: firstName,
|
|
3667
|
+
format: firstField.shaderType,
|
|
3668
|
+
arrayLength,
|
|
3669
|
+
byteOffset: firstField.offset * 4,
|
|
3670
|
+
byteStride: secondField ? (secondField.offset - firstField.offset) * 4 : 0
|
|
3671
|
+
});
|
|
3672
|
+
}
|
|
3673
|
+
};
|
|
3674
|
+
for (const [uniformName, uniformType] of Object.entries(uniformTypes)) {
|
|
3675
|
+
addType(uniformName, uniformType);
|
|
3676
|
+
}
|
|
3677
|
+
return uniforms;
|
|
3678
|
+
}
|
|
3679
|
+
function isUsableUniformBlockBinding(binding) {
|
|
3680
|
+
return binding.type === "uniform" && Number.isInteger(binding.minBindingSize) && binding.minBindingSize >= 0 && Array.isArray(binding.uniforms) && binding.uniforms.every((uniform) => typeof uniform.name === "string" && typeof uniform.format === "string" && Number.isInteger(uniform.arrayLength) && uniform.arrayLength > 0 && Number.isInteger(uniform.byteOffset) && uniform.byteOffset >= 0 && Number.isInteger(uniform.byteStride) && uniform.byteStride >= 0);
|
|
3681
|
+
}
|
|
3682
|
+
function parseUniformName(name) {
|
|
3683
|
+
if (name[name.length - 1] !== "]") {
|
|
3684
|
+
return {
|
|
3685
|
+
name,
|
|
3686
|
+
length: 1,
|
|
3687
|
+
isArray: false
|
|
3688
|
+
};
|
|
3689
|
+
}
|
|
3690
|
+
const UNIFORM_NAME_REGEXP = /([^[]*)(\[[0-9]+\])?/;
|
|
3691
|
+
const matches = UNIFORM_NAME_REGEXP.exec(name);
|
|
3692
|
+
const uniformName = (0, import_core15.assertDefined)(matches?.[1], `Failed to parse GLSL uniform name ${name}`);
|
|
3693
|
+
return {
|
|
3694
|
+
name: uniformName,
|
|
3695
|
+
// TODO - is this a bug, shouldn't we return the value?
|
|
3696
|
+
length: matches?.[2] ? 1 : 0,
|
|
3697
|
+
isArray: Boolean(matches?.[2])
|
|
3698
|
+
};
|
|
3699
|
+
}
|
|
3700
|
+
var import_core15;
|
|
3701
|
+
var init_get_shader_layout_from_glsl = __esm({
|
|
3702
|
+
"../../node_modules/@luma.gl/webgl/dist/adapter/helpers/get-shader-layout-from-glsl.js"() {
|
|
3703
|
+
import_core15 = __toESM(require_core2(), 1);
|
|
3704
|
+
init_webgl_shadertypes();
|
|
3705
|
+
}
|
|
3706
|
+
});
|
|
3707
|
+
|
|
3216
3708
|
// ../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-render-pipeline.js
|
|
3217
3709
|
function mergeShaderLayout(baseLayout, overrideLayout) {
|
|
3218
3710
|
const mergedLayout = {
|
|
@@ -3223,7 +3715,7 @@ Source: ${sourceLine}` : "";
|
|
|
3223
3715
|
for (const attribute of overrideLayout?.attributes || []) {
|
|
3224
3716
|
const baseAttribute = mergedLayout.attributes.find((attr) => attr.name === attribute.name);
|
|
3225
3717
|
if (!baseAttribute) {
|
|
3226
|
-
|
|
3718
|
+
import_core16.log.warn(`shader layout attribute ${attribute.name} not present in shader`);
|
|
3227
3719
|
} else {
|
|
3228
3720
|
baseAttribute.type = attribute.type || baseAttribute.type;
|
|
3229
3721
|
baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;
|
|
@@ -3232,7 +3724,7 @@ Source: ${sourceLine}` : "";
|
|
|
3232
3724
|
for (const binding of overrideLayout?.bindings || []) {
|
|
3233
3725
|
const baseBinding = getShaderLayoutBindingByName(mergedLayout, binding.name);
|
|
3234
3726
|
if (!baseBinding) {
|
|
3235
|
-
|
|
3727
|
+
import_core16.log.warn(`shader layout binding ${binding.name} not present in shader`);
|
|
3236
3728
|
continue;
|
|
3237
3729
|
}
|
|
3238
3730
|
Object.assign(baseBinding, binding);
|
|
@@ -3245,16 +3737,17 @@ Source: ${sourceLine}` : "";
|
|
|
3245
3737
|
function getBindingValueForLayoutBinding(bindings, bindingName) {
|
|
3246
3738
|
return bindings[bindingName] || bindings[`${bindingName}Uniforms`] || bindings[bindingName.replace(/Uniforms$/, "")];
|
|
3247
3739
|
}
|
|
3248
|
-
var
|
|
3740
|
+
var import_core16, WEBGLRenderPipeline;
|
|
3249
3741
|
var init_webgl_render_pipeline = __esm({
|
|
3250
3742
|
"../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-render-pipeline.js"() {
|
|
3251
|
-
|
|
3743
|
+
import_core16 = __toESM(require_core2(), 1);
|
|
3252
3744
|
init_set_uniform();
|
|
3253
3745
|
init_webgl_buffer();
|
|
3254
3746
|
init_webgl_framebuffer();
|
|
3255
3747
|
init_webgl_texture();
|
|
3256
3748
|
init_webgl_texture_view();
|
|
3257
|
-
|
|
3749
|
+
init_get_shader_layout_from_glsl();
|
|
3750
|
+
WEBGLRenderPipeline = class extends import_core16.RenderPipeline {
|
|
3258
3751
|
/** The WebGL device that created this render pipeline */
|
|
3259
3752
|
device;
|
|
3260
3753
|
/** Handle to underlying WebGL program */
|
|
@@ -3286,7 +3779,10 @@ Source: ${sourceLine}` : "";
|
|
|
3286
3779
|
this.vs = webglSharedRenderPipeline.vs;
|
|
3287
3780
|
this.fs = webglSharedRenderPipeline.fs;
|
|
3288
3781
|
this.linkStatus = webglSharedRenderPipeline.linkStatus;
|
|
3289
|
-
this.introspectedLayout =
|
|
3782
|
+
this.introspectedLayout = getShaderLayoutFromGLSL(this.device.gl, this.handle, {
|
|
3783
|
+
uniformBlockLayouts: props._uniformBlockLayouts,
|
|
3784
|
+
shaderLayout: props.shaderLayout
|
|
3785
|
+
});
|
|
3290
3786
|
this.device._setWebGLDebugMetadata(this.handle, this, { spector: { id: this.props.id } });
|
|
3291
3787
|
this.shaderLayout = props.shaderLayout ? mergeShaderLayout(this.introspectedLayout, props.shaderLayout) : this.introspectedLayout;
|
|
3292
3788
|
}
|
|
@@ -3301,17 +3797,17 @@ Source: ${sourceLine}` : "";
|
|
|
3301
3797
|
}
|
|
3302
3798
|
/** @deprecated Set bindings on RenderPass instead. Will be removed in the next major release. */
|
|
3303
3799
|
setBindings(bindings, options) {
|
|
3304
|
-
const flatBindings = (0,
|
|
3800
|
+
const flatBindings = (0, import_core16.flattenBindingsByGroup)((0, import_core16.normalizeBindingsByGroup)(this.shaderLayout, bindings));
|
|
3305
3801
|
for (const [name, value] of Object.entries(flatBindings)) {
|
|
3306
3802
|
const binding = getShaderLayoutBindingByName(this.shaderLayout, name);
|
|
3307
3803
|
if (!binding) {
|
|
3308
3804
|
const validBindings = this.shaderLayout.bindings.map((binding_) => `"${binding_.name}"`).join(", ");
|
|
3309
3805
|
if (!options?.disableWarnings) {
|
|
3310
|
-
|
|
3806
|
+
import_core16.log.warn(`No binding "${name}" in render pipeline "${this.id}", expected one of ${validBindings}`, value)();
|
|
3311
3807
|
}
|
|
3312
3808
|
} else {
|
|
3313
3809
|
if (!value) {
|
|
3314
|
-
|
|
3810
|
+
import_core16.log.warn(`Unsetting binding "${name}" in render pipeline "${this.id}"`)();
|
|
3315
3811
|
}
|
|
3316
3812
|
switch (binding.type) {
|
|
3317
3813
|
case "uniform":
|
|
@@ -3325,7 +3821,7 @@ Source: ${sourceLine}` : "";
|
|
|
3325
3821
|
}
|
|
3326
3822
|
break;
|
|
3327
3823
|
case "sampler":
|
|
3328
|
-
|
|
3824
|
+
import_core16.log.warn(`Ignoring sampler ${name}`)();
|
|
3329
3825
|
break;
|
|
3330
3826
|
default:
|
|
3331
3827
|
throw new Error(binding.type);
|
|
@@ -3340,7 +3836,7 @@ Source: ${sourceLine}` : "";
|
|
|
3340
3836
|
*/
|
|
3341
3837
|
draw(options) {
|
|
3342
3838
|
const webglRenderPass = options.renderPass;
|
|
3343
|
-
const drawBindings = options.bindGroups ? (0,
|
|
3839
|
+
const drawBindings = options.bindGroups ? (0, import_core16.flattenBindingsByGroup)(options.bindGroups) : options.bindings || this.bindings;
|
|
3344
3840
|
webglRenderPass.setPipeline(this);
|
|
3345
3841
|
webglRenderPass.setBindings(drawBindings);
|
|
3346
3842
|
webglRenderPass.setVertexArray(options.vertexArray);
|
|
@@ -3368,7 +3864,7 @@ Source: ${sourceLine}` : "";
|
|
|
3368
3864
|
let texturesRenderable = true;
|
|
3369
3865
|
for (const bindingInfo of this.shaderLayout.bindings) {
|
|
3370
3866
|
if (!getBindingValueForLayoutBinding(bindings, bindingInfo.name)) {
|
|
3371
|
-
|
|
3867
|
+
import_core16.log.warn(`Binding ${bindingInfo.name} not found in ${this.id}`)();
|
|
3372
3868
|
texturesRenderable = false;
|
|
3373
3869
|
}
|
|
3374
3870
|
}
|
|
@@ -3415,7 +3911,7 @@ Source: ${sourceLine}` : "";
|
|
|
3415
3911
|
} else if (value instanceof WEBGLTexture) {
|
|
3416
3912
|
texture = value;
|
|
3417
3913
|
} else if (value instanceof WEBGLFramebuffer && value.colorAttachments[0] instanceof WEBGLTextureView) {
|
|
3418
|
-
|
|
3914
|
+
import_core16.log.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")();
|
|
3419
3915
|
texture = value.colorAttachments[0].texture;
|
|
3420
3916
|
} else {
|
|
3421
3917
|
throw new Error("No texture");
|
|
@@ -3452,301 +3948,11 @@ Source: ${sourceLine}` : "";
|
|
|
3452
3948
|
}
|
|
3453
3949
|
});
|
|
3454
3950
|
|
|
3455
|
-
// ../../node_modules/@luma.gl/webgl/dist/adapter/converters/webgl-shadertypes.js
|
|
3456
|
-
function convertDataTypeToGLDataType(normalizedType) {
|
|
3457
|
-
return NORMALIZED_SHADER_TYPE_TO_WEBGL[normalizedType];
|
|
3458
|
-
}
|
|
3459
|
-
function convertGLUniformTypeToShaderVariableType(glUniformType) {
|
|
3460
|
-
return WEBGL_SHADER_TYPES[glUniformType];
|
|
3461
|
-
}
|
|
3462
|
-
function isGLSamplerType(type) {
|
|
3463
|
-
return Boolean(WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[type]);
|
|
3464
|
-
}
|
|
3465
|
-
function getTextureBindingFromGLSamplerType(glSamplerType) {
|
|
3466
|
-
return WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[glSamplerType];
|
|
3467
|
-
}
|
|
3468
|
-
var WEBGL_SHADER_TYPES, WEBGL_SAMPLER_TO_TEXTURE_BINDINGS, NORMALIZED_SHADER_TYPE_TO_WEBGL;
|
|
3469
|
-
var init_webgl_shadertypes = __esm({
|
|
3470
|
-
"../../node_modules/@luma.gl/webgl/dist/adapter/converters/webgl-shadertypes.js"() {
|
|
3471
|
-
WEBGL_SHADER_TYPES = {
|
|
3472
|
-
[5126]: "f32",
|
|
3473
|
-
[35664]: "vec2<f32>",
|
|
3474
|
-
[35665]: "vec3<f32>",
|
|
3475
|
-
[35666]: "vec4<f32>",
|
|
3476
|
-
[5124]: "i32",
|
|
3477
|
-
[35667]: "vec2<i32>",
|
|
3478
|
-
[35668]: "vec3<i32>",
|
|
3479
|
-
[35669]: "vec4<i32>",
|
|
3480
|
-
[5125]: "u32",
|
|
3481
|
-
[36294]: "vec2<u32>",
|
|
3482
|
-
[36295]: "vec3<u32>",
|
|
3483
|
-
[36296]: "vec4<u32>",
|
|
3484
|
-
[35670]: "f32",
|
|
3485
|
-
[35671]: "vec2<f32>",
|
|
3486
|
-
[35672]: "vec3<f32>",
|
|
3487
|
-
[35673]: "vec4<f32>",
|
|
3488
|
-
// TODO - are sizes/components below correct?
|
|
3489
|
-
[35674]: "mat2x2<f32>",
|
|
3490
|
-
[35685]: "mat2x3<f32>",
|
|
3491
|
-
[35686]: "mat2x4<f32>",
|
|
3492
|
-
[35687]: "mat3x2<f32>",
|
|
3493
|
-
[35675]: "mat3x3<f32>",
|
|
3494
|
-
[35688]: "mat3x4<f32>",
|
|
3495
|
-
[35689]: "mat4x2<f32>",
|
|
3496
|
-
[35690]: "mat4x3<f32>",
|
|
3497
|
-
[35676]: "mat4x4<f32>"
|
|
3498
|
-
};
|
|
3499
|
-
WEBGL_SAMPLER_TO_TEXTURE_BINDINGS = {
|
|
3500
|
-
[35678]: { viewDimension: "2d", sampleType: "float" },
|
|
3501
|
-
[35680]: { viewDimension: "cube", sampleType: "float" },
|
|
3502
|
-
[35679]: { viewDimension: "3d", sampleType: "float" },
|
|
3503
|
-
[35682]: { viewDimension: "3d", sampleType: "depth" },
|
|
3504
|
-
[36289]: { viewDimension: "2d-array", sampleType: "float" },
|
|
3505
|
-
[36292]: { viewDimension: "2d-array", sampleType: "depth" },
|
|
3506
|
-
[36293]: { viewDimension: "cube", sampleType: "float" },
|
|
3507
|
-
[36298]: { viewDimension: "2d", sampleType: "sint" },
|
|
3508
|
-
[36299]: { viewDimension: "3d", sampleType: "sint" },
|
|
3509
|
-
[36300]: { viewDimension: "cube", sampleType: "sint" },
|
|
3510
|
-
[36303]: { viewDimension: "2d-array", sampleType: "uint" },
|
|
3511
|
-
[36306]: { viewDimension: "2d", sampleType: "uint" },
|
|
3512
|
-
[36307]: { viewDimension: "3d", sampleType: "uint" },
|
|
3513
|
-
[36308]: { viewDimension: "cube", sampleType: "uint" },
|
|
3514
|
-
[36311]: { viewDimension: "2d-array", sampleType: "uint" }
|
|
3515
|
-
};
|
|
3516
|
-
NORMALIZED_SHADER_TYPE_TO_WEBGL = {
|
|
3517
|
-
uint8: 5121,
|
|
3518
|
-
sint8: 5120,
|
|
3519
|
-
unorm8: 5121,
|
|
3520
|
-
snorm8: 5120,
|
|
3521
|
-
uint16: 5123,
|
|
3522
|
-
sint16: 5122,
|
|
3523
|
-
unorm16: 5123,
|
|
3524
|
-
snorm16: 5122,
|
|
3525
|
-
uint32: 5125,
|
|
3526
|
-
sint32: 5124,
|
|
3527
|
-
// WebGPU does not support normalized 32 bit integer attributes
|
|
3528
|
-
// 'unorm32': GL.UNSIGNED_INT,
|
|
3529
|
-
// 'snorm32': GL.INT,
|
|
3530
|
-
float16: 5131,
|
|
3531
|
-
float32: 5126
|
|
3532
|
-
};
|
|
3533
|
-
}
|
|
3534
|
-
});
|
|
3535
|
-
|
|
3536
|
-
// ../../node_modules/@luma.gl/webgl/dist/adapter/helpers/get-shader-layout-from-glsl.js
|
|
3537
|
-
function getShaderLayoutFromGLSL(gl, program) {
|
|
3538
|
-
const shaderLayout = {
|
|
3539
|
-
attributes: [],
|
|
3540
|
-
bindings: []
|
|
3541
|
-
};
|
|
3542
|
-
shaderLayout.attributes = readAttributeDeclarations(gl, program);
|
|
3543
|
-
const uniformBlocks = readUniformBlocks(gl, program);
|
|
3544
|
-
for (const uniformBlock of uniformBlocks) {
|
|
3545
|
-
const uniforms2 = uniformBlock.uniforms.map((uniform) => ({
|
|
3546
|
-
name: uniform.name,
|
|
3547
|
-
format: uniform.format,
|
|
3548
|
-
byteOffset: uniform.byteOffset,
|
|
3549
|
-
byteStride: uniform.byteStride,
|
|
3550
|
-
arrayLength: uniform.arrayLength
|
|
3551
|
-
}));
|
|
3552
|
-
shaderLayout.bindings.push({
|
|
3553
|
-
type: "uniform",
|
|
3554
|
-
name: uniformBlock.name,
|
|
3555
|
-
group: 0,
|
|
3556
|
-
location: uniformBlock.location,
|
|
3557
|
-
visibility: (uniformBlock.vertex ? 1 : 0) & (uniformBlock.fragment ? 2 : 0),
|
|
3558
|
-
minBindingSize: uniformBlock.byteLength,
|
|
3559
|
-
uniforms: uniforms2
|
|
3560
|
-
});
|
|
3561
|
-
}
|
|
3562
|
-
const uniforms = readUniformBindings(gl, program);
|
|
3563
|
-
let textureUnit = 0;
|
|
3564
|
-
for (const uniform of uniforms) {
|
|
3565
|
-
if (isGLSamplerType(uniform.type)) {
|
|
3566
|
-
const { viewDimension, sampleType } = getTextureBindingFromGLSamplerType(uniform.type);
|
|
3567
|
-
shaderLayout.bindings.push({
|
|
3568
|
-
type: "texture",
|
|
3569
|
-
name: uniform.name,
|
|
3570
|
-
group: 0,
|
|
3571
|
-
location: textureUnit,
|
|
3572
|
-
viewDimension,
|
|
3573
|
-
sampleType
|
|
3574
|
-
});
|
|
3575
|
-
uniform.textureUnit = textureUnit;
|
|
3576
|
-
textureUnit += 1;
|
|
3577
|
-
}
|
|
3578
|
-
}
|
|
3579
|
-
if (uniforms.length) {
|
|
3580
|
-
shaderLayout.uniforms = uniforms;
|
|
3581
|
-
}
|
|
3582
|
-
const varyings = readVaryings(gl, program);
|
|
3583
|
-
if (varyings?.length) {
|
|
3584
|
-
shaderLayout.varyings = varyings;
|
|
3585
|
-
}
|
|
3586
|
-
return shaderLayout;
|
|
3587
|
-
}
|
|
3588
|
-
function readAttributeDeclarations(gl, program) {
|
|
3589
|
-
const attributes = [];
|
|
3590
|
-
const count = gl.getProgramParameter(program, 35721);
|
|
3591
|
-
for (let index = 0; index < count; index++) {
|
|
3592
|
-
const activeInfo = gl.getActiveAttrib(program, index);
|
|
3593
|
-
if (!activeInfo) {
|
|
3594
|
-
throw new Error("activeInfo");
|
|
3595
|
-
}
|
|
3596
|
-
const {
|
|
3597
|
-
name,
|
|
3598
|
-
type: compositeType
|
|
3599
|
-
/* , size*/
|
|
3600
|
-
} = activeInfo;
|
|
3601
|
-
const location = gl.getAttribLocation(program, name);
|
|
3602
|
-
if (location >= 0) {
|
|
3603
|
-
const attributeType = convertGLUniformTypeToShaderVariableType(compositeType);
|
|
3604
|
-
const stepMode = /instance/i.test(name) ? "instance" : "vertex";
|
|
3605
|
-
attributes.push({
|
|
3606
|
-
name,
|
|
3607
|
-
location,
|
|
3608
|
-
stepMode,
|
|
3609
|
-
type: attributeType
|
|
3610
|
-
// size - for arrays, size is the number of elements in the array
|
|
3611
|
-
});
|
|
3612
|
-
}
|
|
3613
|
-
}
|
|
3614
|
-
attributes.sort((a, b) => a.location - b.location);
|
|
3615
|
-
return attributes;
|
|
3616
|
-
}
|
|
3617
|
-
function readVaryings(gl, program) {
|
|
3618
|
-
const varyings = [];
|
|
3619
|
-
const count = gl.getProgramParameter(program, 35971);
|
|
3620
|
-
for (let location = 0; location < count; location++) {
|
|
3621
|
-
const activeInfo = gl.getTransformFeedbackVarying(program, location);
|
|
3622
|
-
if (!activeInfo) {
|
|
3623
|
-
throw new Error("activeInfo");
|
|
3624
|
-
}
|
|
3625
|
-
const { name, type: glUniformType, size } = activeInfo;
|
|
3626
|
-
const uniformType = convertGLUniformTypeToShaderVariableType(glUniformType);
|
|
3627
|
-
const { type, components } = (0, import_core16.getVariableShaderTypeInfo)(uniformType);
|
|
3628
|
-
varyings.push({ location, name, type, size: size * components });
|
|
3629
|
-
}
|
|
3630
|
-
varyings.sort((a, b) => a.location - b.location);
|
|
3631
|
-
return varyings;
|
|
3632
|
-
}
|
|
3633
|
-
function readUniformBindings(gl, program) {
|
|
3634
|
-
const uniforms = [];
|
|
3635
|
-
const uniformCount = gl.getProgramParameter(program, 35718);
|
|
3636
|
-
for (let i = 0; i < uniformCount; i++) {
|
|
3637
|
-
const activeInfo = gl.getActiveUniform(program, i);
|
|
3638
|
-
if (!activeInfo) {
|
|
3639
|
-
throw new Error("activeInfo");
|
|
3640
|
-
}
|
|
3641
|
-
const { name: rawName, size, type } = activeInfo;
|
|
3642
|
-
const { name, isArray: isArray4 } = parseUniformName(rawName);
|
|
3643
|
-
let webglLocation = gl.getUniformLocation(program, name);
|
|
3644
|
-
const uniformInfo = {
|
|
3645
|
-
// WebGL locations are uniquely typed but just numbers
|
|
3646
|
-
location: webglLocation,
|
|
3647
|
-
name,
|
|
3648
|
-
size,
|
|
3649
|
-
type,
|
|
3650
|
-
isArray: isArray4
|
|
3651
|
-
};
|
|
3652
|
-
uniforms.push(uniformInfo);
|
|
3653
|
-
if (uniformInfo.size > 1) {
|
|
3654
|
-
for (let j = 0; j < uniformInfo.size; j++) {
|
|
3655
|
-
const elementName = `${name}[${j}]`;
|
|
3656
|
-
webglLocation = gl.getUniformLocation(program, elementName);
|
|
3657
|
-
const arrayElementUniformInfo = {
|
|
3658
|
-
...uniformInfo,
|
|
3659
|
-
name: elementName,
|
|
3660
|
-
location: webglLocation
|
|
3661
|
-
};
|
|
3662
|
-
uniforms.push(arrayElementUniformInfo);
|
|
3663
|
-
}
|
|
3664
|
-
}
|
|
3665
|
-
}
|
|
3666
|
-
return uniforms;
|
|
3667
|
-
}
|
|
3668
|
-
function readUniformBlocks(gl, program) {
|
|
3669
|
-
const getBlockParameter = (blockIndex, pname) => gl.getActiveUniformBlockParameter(program, blockIndex, pname);
|
|
3670
|
-
const uniformBlocks = [];
|
|
3671
|
-
const blockCount = gl.getProgramParameter(program, 35382);
|
|
3672
|
-
for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {
|
|
3673
|
-
const blockInfo = {
|
|
3674
|
-
name: gl.getActiveUniformBlockName(program, blockIndex) || "",
|
|
3675
|
-
location: getBlockParameter(blockIndex, 35391),
|
|
3676
|
-
byteLength: getBlockParameter(blockIndex, 35392),
|
|
3677
|
-
vertex: getBlockParameter(blockIndex, 35396),
|
|
3678
|
-
fragment: getBlockParameter(blockIndex, 35398),
|
|
3679
|
-
uniformCount: getBlockParameter(blockIndex, 35394),
|
|
3680
|
-
uniforms: []
|
|
3681
|
-
};
|
|
3682
|
-
const uniformIndices = getBlockParameter(blockIndex, 35395) || [];
|
|
3683
|
-
const uniformType = gl.getActiveUniforms(program, uniformIndices, 35383);
|
|
3684
|
-
const uniformArrayLength = gl.getActiveUniforms(program, uniformIndices, 35384);
|
|
3685
|
-
const uniformOffset = gl.getActiveUniforms(program, uniformIndices, 35387);
|
|
3686
|
-
const uniformStride = gl.getActiveUniforms(program, uniformIndices, 35388);
|
|
3687
|
-
for (let i = 0; i < blockInfo.uniformCount; ++i) {
|
|
3688
|
-
const uniformIndex = uniformIndices[i];
|
|
3689
|
-
if (uniformIndex !== void 0) {
|
|
3690
|
-
const activeInfo = gl.getActiveUniform(program, uniformIndex);
|
|
3691
|
-
if (!activeInfo) {
|
|
3692
|
-
throw new Error("activeInfo");
|
|
3693
|
-
}
|
|
3694
|
-
const format = convertGLUniformTypeToShaderVariableType(uniformType[i]);
|
|
3695
|
-
blockInfo.uniforms.push({
|
|
3696
|
-
name: activeInfo.name,
|
|
3697
|
-
format,
|
|
3698
|
-
type: uniformType[i],
|
|
3699
|
-
arrayLength: uniformArrayLength[i],
|
|
3700
|
-
byteOffset: uniformOffset[i],
|
|
3701
|
-
byteStride: uniformStride[i]
|
|
3702
|
-
// matrixStride: uniformStride[i],
|
|
3703
|
-
// rowMajor: uniformRowMajor[i]
|
|
3704
|
-
});
|
|
3705
|
-
}
|
|
3706
|
-
}
|
|
3707
|
-
const uniformInstancePrefixes = new Set(blockInfo.uniforms.map((uniform) => uniform.name.split(".")[0]).filter((instanceName) => Boolean(instanceName)));
|
|
3708
|
-
const blockAlias = blockInfo.name.replace(/Uniforms$/, "");
|
|
3709
|
-
if (uniformInstancePrefixes.size === 1 && !uniformInstancePrefixes.has(blockInfo.name) && !uniformInstancePrefixes.has(blockAlias)) {
|
|
3710
|
-
const [instanceName] = uniformInstancePrefixes;
|
|
3711
|
-
import_core16.log.warn(`Uniform block "${blockInfo.name}" uses GLSL instance "${instanceName}". luma.gl binds uniform buffers by block name ("${blockInfo.name}") and alias ("${blockAlias}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)();
|
|
3712
|
-
}
|
|
3713
|
-
uniformBlocks.push(blockInfo);
|
|
3714
|
-
}
|
|
3715
|
-
uniformBlocks.sort((a, b) => a.location - b.location);
|
|
3716
|
-
return uniformBlocks;
|
|
3717
|
-
}
|
|
3718
|
-
function parseUniformName(name) {
|
|
3719
|
-
if (name[name.length - 1] !== "]") {
|
|
3720
|
-
return {
|
|
3721
|
-
name,
|
|
3722
|
-
length: 1,
|
|
3723
|
-
isArray: false
|
|
3724
|
-
};
|
|
3725
|
-
}
|
|
3726
|
-
const UNIFORM_NAME_REGEXP = /([^[]*)(\[[0-9]+\])?/;
|
|
3727
|
-
const matches = UNIFORM_NAME_REGEXP.exec(name);
|
|
3728
|
-
const uniformName = (0, import_core16.assertDefined)(matches?.[1], `Failed to parse GLSL uniform name ${name}`);
|
|
3729
|
-
return {
|
|
3730
|
-
name: uniformName,
|
|
3731
|
-
// TODO - is this a bug, shouldn't we return the value?
|
|
3732
|
-
length: matches?.[2] ? 1 : 0,
|
|
3733
|
-
isArray: Boolean(matches?.[2])
|
|
3734
|
-
};
|
|
3735
|
-
}
|
|
3736
|
-
var import_core16;
|
|
3737
|
-
var init_get_shader_layout_from_glsl = __esm({
|
|
3738
|
-
"../../node_modules/@luma.gl/webgl/dist/adapter/helpers/get-shader-layout-from-glsl.js"() {
|
|
3739
|
-
import_core16 = __toESM(require_core2(), 1);
|
|
3740
|
-
init_webgl_shadertypes();
|
|
3741
|
-
}
|
|
3742
|
-
});
|
|
3743
|
-
|
|
3744
3951
|
// ../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-shared-render-pipeline.js
|
|
3745
3952
|
var import_core17, LOG_PROGRAM_PERF_PRIORITY, WEBGLSharedRenderPipeline;
|
|
3746
3953
|
var init_webgl_shared_render_pipeline = __esm({
|
|
3747
3954
|
"../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-shared-render-pipeline.js"() {
|
|
3748
3955
|
import_core17 = __toESM(require_core2(), 1);
|
|
3749
|
-
init_get_shader_layout_from_glsl();
|
|
3750
3956
|
init_webgl_shadertypes();
|
|
3751
3957
|
LOG_PROGRAM_PERF_PRIORITY = 4;
|
|
3752
3958
|
WEBGLSharedRenderPipeline = class extends import_core17.SharedRenderPipeline {
|
|
@@ -3754,7 +3960,6 @@ Source: ${sourceLine}` : "";
|
|
|
3754
3960
|
handle;
|
|
3755
3961
|
vs;
|
|
3756
3962
|
fs;
|
|
3757
|
-
introspectedLayout = { attributes: [], bindings: [], uniforms: [] };
|
|
3758
3963
|
linkStatus = "pending";
|
|
3759
3964
|
constructor(device, props) {
|
|
3760
3965
|
super(device, props);
|
|
@@ -3766,9 +3971,6 @@ Source: ${sourceLine}` : "";
|
|
|
3766
3971
|
this.device.gl.transformFeedbackVaryings(this.handle, props.varyings, props.bufferMode || 35981);
|
|
3767
3972
|
}
|
|
3768
3973
|
this._linkShaders();
|
|
3769
|
-
import_core17.log.time(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
3770
|
-
this.introspectedLayout = getShaderLayoutFromGLSL(this.device.gl, this.handle);
|
|
3771
|
-
import_core17.log.timeEnd(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
3772
3974
|
}
|
|
3773
3975
|
destroy() {
|
|
3774
3976
|
if (this.destroyed) {
|