@luma.gl/webgl 9.0.0-alpha.27 → 9.0.0-alpha.29
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.d.ts +8 -5
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +59 -16
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts +12 -0
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts.map +1 -0
- package/dist/adapter/helpers/get-vertex-buffer-layout.js +84 -0
- package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -0
- package/dist/adapter/objects/webgl-vertex-array-object.js +2 -2
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts +13 -4
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +23 -21
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-external-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +27 -4
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +25 -7
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +5 -2
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/buffer-with-accessor.d.ts +5 -15
- package/dist/classic/buffer-with-accessor.d.ts.map +1 -1
- package/dist/classic/buffer-with-accessor.js +25 -30
- package/dist/classic/buffer-with-accessor.js.map +1 -1
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +2 -2
- package/dist/classic/copy-and-blit.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +2 -1
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +2 -2
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/dist.dev.js +164 -83
- package/dist/index.cjs +207 -146
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist.min.js +22 -22
- package/package.json +5 -5
- package/src/adapter/helpers/get-shader-layout.ts +93 -33
- package/src/adapter/helpers/get-vertex-buffer-layout.ts +123 -0
- package/src/adapter/objects/webgl-vertex-array-object.ts +2 -2
- package/src/adapter/resources/webgl-buffer.ts +40 -41
- package/src/adapter/resources/webgl-external-texture.ts +1 -1
- package/src/adapter/resources/webgl-render-pipeline.ts +51 -35
- package/src/adapter/webgl-device.ts +4 -2
- package/src/classic/buffer-with-accessor.ts +42 -43
- package/src/classic/copy-and-blit.ts +2 -3
- package/src/context/debug/webgl-developer-tools.ts +8 -2
- package/src/context/parameters/webgl-parameter-tables.ts +2 -2
- package/src/index.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ShaderLayout,
|
|
1
|
+
import type { ShaderLayout, AttributeLayout, BufferMapping } from '@luma.gl/api';
|
|
2
2
|
/**
|
|
3
3
|
* Extract metadata describing binding information for a program's shaders
|
|
4
4
|
* Note: `linkProgram()` needs to have been called
|
|
@@ -6,11 +6,14 @@ import { ShaderLayout, ProgramBindings } from '@luma.gl/api';
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function getShaderLayout(gl: WebGLRenderingContext, program: WebGLProgram): ShaderLayout;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Merges an provided shader layout into a base shader layout
|
|
10
|
+
* In WebGL, this allows the auto generated shader layout to be overridden by the application
|
|
11
|
+
* Typically to change the format of the vertex attributes (from float32x4 to uint8x4 etc).
|
|
12
|
+
* @todo Drop this? This could also be done more clearly with bufferMapping
|
|
12
13
|
*/
|
|
13
|
-
export declare function
|
|
14
|
+
export declare function mergeShaderLayout(baseLayout: ShaderLayout, overrideLayout: ShaderLayout): ShaderLayout;
|
|
15
|
+
export declare function mergeBufferMap(baseLayout: ShaderLayout, bufferMap: BufferMapping[]): ShaderLayout;
|
|
16
|
+
export declare function getAttributeFromLayout(shaderLayout: ShaderLayout, name: string): AttributeLayout | null;
|
|
14
17
|
/**
|
|
15
18
|
* TODO - verify this is a copy of above and delete
|
|
16
19
|
* import type {TextureFormat} from '@luma.gl/api';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-shader-layout.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-shader-layout.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"get-shader-layout.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-shader-layout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EAMf,aAAa,EAEd,MAAM,cAAc,CAAC;AAStB;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,qBAAqB,EAAE,OAAO,EAAE,YAAY,GAAG,YAAY,CAwE9F;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,YAAY,EACxB,cAAc,EAAE,YAAY,GAC3B,YAAY,CAiBd;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,YAAY,CAsBjG;AAYD,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,MAAM,GACX,eAAe,GAAG,IAAI,CAMxB;AAkQD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { log } from '@luma.gl/api';
|
|
1
2
|
import { GL } from '@luma.gl/constants';
|
|
2
3
|
import { isWebGL2 } from "../../context/context/webgl-checks.js";
|
|
3
4
|
import { Accessor } from "../../classic/accessor.js";
|
|
@@ -5,13 +6,12 @@ import { decodeUniformType, decodeAttributeType } from "./uniforms.js";
|
|
|
5
6
|
import { getVertexFormat } from "../converters/vertex-formats.js";
|
|
6
7
|
import { isSamplerUniform } from "./uniforms.js";
|
|
7
8
|
export function getShaderLayout(gl, program) {
|
|
8
|
-
var _programBindings$unif, _programBindings$vary;
|
|
9
|
-
const programBindings = getProgramBindings(gl, program);
|
|
10
9
|
const shaderLayout = {
|
|
11
10
|
attributes: [],
|
|
12
11
|
bindings: []
|
|
13
12
|
};
|
|
14
|
-
|
|
13
|
+
const attributes = readAttributeBindings(gl, program);
|
|
14
|
+
for (const attribute of attributes) {
|
|
15
15
|
const size = Math.min(attribute.accessor.size, 4);
|
|
16
16
|
const format = getVertexFormat(attribute.accessor.type || GL.FLOAT, size);
|
|
17
17
|
shaderLayout.attributes.push({
|
|
@@ -21,7 +21,8 @@ export function getShaderLayout(gl, program) {
|
|
|
21
21
|
stepMode: attribute.accessor.divisor === 1 ? 'instance' : 'vertex'
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
const uniformBlocks = readUniformBlocks(gl, program);
|
|
25
|
+
for (const uniformBlock of uniformBlocks) {
|
|
25
26
|
const uniforms = uniformBlock.uniforms.map(uniform => ({
|
|
26
27
|
name: uniform.name,
|
|
27
28
|
format: uniform.format,
|
|
@@ -38,8 +39,9 @@ export function getShaderLayout(gl, program) {
|
|
|
38
39
|
uniforms
|
|
39
40
|
});
|
|
40
41
|
}
|
|
42
|
+
const uniforms = readUniformBindings(gl, program);
|
|
41
43
|
let textureUnit = 0;
|
|
42
|
-
for (const uniform of
|
|
44
|
+
for (const uniform of uniforms) {
|
|
43
45
|
if (isSamplerUniform(uniform.type)) {
|
|
44
46
|
const {
|
|
45
47
|
viewDimension,
|
|
@@ -56,24 +58,65 @@ export function getShaderLayout(gl, program) {
|
|
|
56
58
|
textureUnit += 1;
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
|
-
const uniforms = ((_programBindings$unif = programBindings.uniforms) === null || _programBindings$unif === void 0 ? void 0 : _programBindings$unif.filter(uniform => uniform.location !== null)) || [];
|
|
60
61
|
if (uniforms.length) {
|
|
61
62
|
shaderLayout.uniforms = uniforms;
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
const varyings = readVaryings(gl, program);
|
|
65
|
+
if (varyings !== null && varyings !== void 0 && varyings.length) {
|
|
66
|
+
shaderLayout.varyings = varyings;
|
|
65
67
|
}
|
|
66
68
|
return shaderLayout;
|
|
67
69
|
}
|
|
68
|
-
export function
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
export function mergeShaderLayout(baseLayout, overrideLayout) {
|
|
71
|
+
const mergedLayout = {
|
|
72
|
+
...baseLayout,
|
|
73
|
+
attributes: baseLayout.attributes.map(attribute => ({
|
|
74
|
+
...attribute
|
|
75
|
+
}))
|
|
74
76
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
for (const attribute of (overrideLayout === null || overrideLayout === void 0 ? void 0 : overrideLayout.attributes) || []) {
|
|
78
|
+
const baseAttribute = mergedLayout.attributes.find(attr => attr.name === attribute.name);
|
|
79
|
+
if (!baseAttribute) {
|
|
80
|
+
log.warn("shader layout attribute ".concat(attribute.name, " not present in shader"));
|
|
81
|
+
} else {
|
|
82
|
+
baseAttribute.format = attribute.format || baseAttribute.format;
|
|
83
|
+
baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return mergedLayout;
|
|
87
|
+
}
|
|
88
|
+
export function mergeBufferMap(baseLayout, bufferMap) {
|
|
89
|
+
const mergedLayout = {
|
|
90
|
+
...baseLayout,
|
|
91
|
+
attributes: baseLayout.attributes.map(attribute => ({
|
|
92
|
+
...attribute
|
|
93
|
+
}))
|
|
94
|
+
};
|
|
95
|
+
for (const bufferMapping of bufferMap) {
|
|
96
|
+
switch (bufferMapping.type) {
|
|
97
|
+
case 'interleave':
|
|
98
|
+
for (const attributeOverride of bufferMapping.attributes) {
|
|
99
|
+
overrideShaderLayoutAttribute(mergedLayout, attributeOverride);
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
default:
|
|
103
|
+
overrideShaderLayoutAttribute(mergedLayout, bufferMapping);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return mergedLayout;
|
|
107
|
+
}
|
|
108
|
+
function overrideShaderLayoutAttribute(layout, attributeOverride) {
|
|
109
|
+
const attribute = getAttributeFromLayout(layout, attributeOverride.name);
|
|
110
|
+
if (attribute && attributeOverride.format) {
|
|
111
|
+
attribute.format = attributeOverride.format;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export function getAttributeFromLayout(shaderLayout, name) {
|
|
115
|
+
const attribute = shaderLayout.attributes.find(attr => attr.name === name);
|
|
116
|
+
if (!attribute) {
|
|
117
|
+
log.warn("shader layout attribute \"".concat(name, "\" not present in shader"));
|
|
118
|
+
}
|
|
119
|
+
return attribute || null;
|
|
77
120
|
}
|
|
78
121
|
function readAttributeBindings(gl, program) {
|
|
79
122
|
const attributes = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-shader-layout.js","names":["GL","isWebGL2","Accessor","decodeUniformType","decodeAttributeType","getVertexFormat","isSamplerUniform","getShaderLayout","gl","program","_programBindings$unif","_programBindings$vary","programBindings","getProgramBindings","shaderLayout","attributes","bindings","attribute","size","Math","min","accessor","format","type","FLOAT","push","name","location","stepMode","divisor","uniformBlock","uniformBlocks","uniforms","map","uniform","byteOffset","byteStride","arrayLength","visibility","vertex","fragment","minBindingSize","byteLength","textureUnit","viewDimension","sampleType","getSamplerInfo","filter","length","varyings","config","readAttributeBindings","readUniformBindings","readUniformBlocks","readVaryings","Object","seal","count","getProgramParameter","ACTIVE_ATTRIBUTES","index","activeInfo","getActiveAttrib","Error","compositeType","getAttribLocation","glType","components","test","attributeInfo","sort","a","b","gl2","TRANSFORM_FEEDBACK_VARYINGS","getTransformFeedbackVarying","varying","uniformCount","ACTIVE_UNIFORMS","i","getActiveUniform","rawName","isArray","parseUniformName","webglLocation","getUniformLocation","uniformInfo","j","elementName","concat","arrayElementUniformInfo","getBlockParameter","blockIndex","pname","getActiveUniformBlockParameter","blockCount","ACTIVE_UNIFORM_BLOCKS","blockInfo","getActiveUniformBlockName","UNIFORM_BLOCK_BINDING","UNIFORM_BLOCK_DATA_SIZE","UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER","UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER","UNIFORM_BLOCK_ACTIVE_UNIFORMS","uniformIndices","UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES","uniformType","getActiveUniforms","UNIFORM_TYPE","uniformArrayLength","UNIFORM_SIZE","uniformOffset","UNIFORM_OFFSET","uniformStride","UNIFORM_ARRAY_STRIDE","SAMPLER_UNIFORMS_GL_TO_GPU","SAMPLER_2D","SAMPLER_CUBE","SAMPLER_3D","SAMPLER_2D_SHADOW","SAMPLER_2D_ARRAY","SAMPLER_2D_ARRAY_SHADOW","SAMPLER_CUBE_SHADOW","INT_SAMPLER_2D","INT_SAMPLER_3D","INT_SAMPLER_CUBE","INT_SAMPLER_2D_ARRAY","UNSIGNED_INT_SAMPLER_2D","UNSIGNED_INT_SAMPLER_3D","UNSIGNED_INT_SAMPLER_CUBE","UNSIGNED_INT_SAMPLER_2D_ARRAY","sampler","UNIFORM_NAME_REGEXP","matches","exec","Boolean"],"sources":["../../../src/adapter/helpers/get-shader-layout.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport {\n ShaderLayout,\n // BindingLayout,\n UniformBinding,\n UniformBlockBinding,\n ProgramBindings,\n AttributeBinding,\n VaryingBinding,\n // AttributeLayout,\n AccessorObject\n} from '@luma.gl/api';\nimport {GL} from '@luma.gl/constants';\nimport {isWebGL2} from '../../context/context/webgl-checks';\nimport {Accessor} from '../../classic/accessor'; // TODO - should NOT depend on classic API\nimport {decodeUniformType, decodeAttributeType} from './uniforms';\nimport {getVertexFormat} from '../converters/vertex-formats';\nimport {isSamplerUniform} from './uniforms';\n\n/**\n * Extract metadata describing binding information for a program's shaders\n * Note: `linkProgram()` needs to have been called\n * (although linking does not need to have been successful).\n */\nexport function getShaderLayout(gl: WebGLRenderingContext, program: WebGLProgram): ShaderLayout {\n const programBindings = getProgramBindings(gl, program);\n\n const shaderLayout: ShaderLayout = {\n attributes: [],\n bindings: []\n };\n\n for (const attribute of programBindings.attributes) {\n // TODO - multicolumn attributes like a matrix4 can be up to 16 elts...\n const size = Math.min(attribute.accessor.size, 4);\n const format =\n // attribute.accessor.format ||\n getVertexFormat(attribute.accessor.type || GL.FLOAT, size);\n shaderLayout.attributes.push({\n name: attribute.name,\n location: attribute.location,\n format,\n stepMode: attribute.accessor.divisor === 1 ? 'instance' : 'vertex'\n });\n }\n\n // Uniform blocks\n for (const uniformBlock of programBindings.uniformBlocks) {\n const uniforms = uniformBlock.uniforms.map((uniform) => ({\n name: uniform.name,\n format: uniform.format,\n byteOffset: uniform.byteOffset,\n byteStride: uniform.byteStride,\n arrayLength: uniform.arrayLength\n }));\n shaderLayout.bindings.push({\n type: 'uniform',\n name: uniformBlock.name,\n location: uniformBlock.location,\n visibility: (uniformBlock.vertex ? 0x1 : 0) & (uniformBlock.fragment ? 0x2 : 0),\n minBindingSize: uniformBlock.byteLength,\n uniforms\n });\n }\n\n let textureUnit = 0;\n for (const uniform of programBindings.uniforms) {\n if (isSamplerUniform(uniform.type)) {\n const {viewDimension, sampleType} = getSamplerInfo(uniform.type);\n shaderLayout.bindings.push({\n type: 'texture',\n name: uniform.name,\n location: textureUnit,\n viewDimension,\n sampleType\n });\n\n // @ts-expect-error\n uniform.textureUnit = textureUnit;\n textureUnit += 1;\n }\n }\n\n const uniforms = programBindings.uniforms?.filter((uniform) => uniform.location !== null) || [];\n if (uniforms.length) {\n shaderLayout.uniforms = uniforms;\n }\n if (programBindings.varyings?.length) {\n shaderLayout.varyings = programBindings.varyings;\n }\n\n return shaderLayout;\n}\n\n/**\n * Extract metadata describing binding information for a program's shaders\n * Note: `linkProgram()` needs to have been called\n * (although linking does not need to have been successful).\n */\nexport function getProgramBindings(\n gl: WebGLRenderingContext,\n program: WebGLProgram\n): ProgramBindings {\n const config: ProgramBindings = {\n attributes: readAttributeBindings(gl, program),\n uniforms: readUniformBindings(gl, program),\n uniformBlocks: readUniformBlocks(gl, program),\n varyings: readVaryings(gl, program)\n };\n\n Object.seal(config);\n return config;\n // generateWebGPUStyleBindings(bindings);\n}\n\n/**\n * Extract info about all transform feedback varyings\n *\n * linkProgram needs to have been called, although linking does not need to have been successful\n */\nfunction readAttributeBindings(\n gl: WebGLRenderingContext,\n program: WebGLProgram\n): AttributeBinding[] {\n const attributes: AttributeBinding[] = [];\n\n const count = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);\n\n for (let index = 0; index < count; index++) {\n const activeInfo = gl.getActiveAttrib(program, index);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const {name, type: compositeType, size} = activeInfo;\n const location = gl.getAttribLocation(program, name);\n // Add only user provided attributes, for built-in attributes like\n // `gl_InstanceID` locaiton will be < 0\n if (location >= 0) {\n const {glType, components} = decodeAttributeType(compositeType);\n const accessor: AccessorObject = {type: glType, size: size * components};\n // Any attribute name containing the word \"instance\" will be assumed to be instanced\n if (/instance/i.test(name)) {\n accessor.divisor = 1;\n }\n const attributeInfo = {location, name, accessor: new Accessor(accessor)}; // Base values\n attributes.push(attributeInfo);\n }\n }\n\n attributes.sort((a: AttributeBinding, b: AttributeBinding) => a.location - b.location);\n return attributes;\n}\n\n/**\n * Extract info about all transform feedback varyings\n *\n * linkProgram needs to have been called, although linking does not need to have been successful\n */\nfunction readVaryings(gl: WebGLRenderingContext, program: WebGLProgram): VaryingBinding[] {\n if (!isWebGL2(gl)) {\n return [];\n }\n const gl2 = gl as WebGL2RenderingContext;\n\n const varyings: VaryingBinding[] = [];\n\n const count = gl.getProgramParameter(program, GL.TRANSFORM_FEEDBACK_VARYINGS);\n for (let location = 0; location < count; location++) {\n const activeInfo = gl2.getTransformFeedbackVarying(program, location);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const {name, type: compositeType, size} = activeInfo;\n const {glType, components} = decodeUniformType(compositeType);\n const accessor = new Accessor({type: glType, size: size * components});\n const varying = {location, name, accessor}; // Base values\n varyings.push(varying);\n }\n\n varyings.sort((a, b) => a.location - b.location);\n return varyings;\n}\n\n/**\n * Extract info about all uniforms\n *\n * Query uniform locations and build name to setter map.\n */\nfunction readUniformBindings(gl: WebGLRenderingContext, program: WebGLProgram): UniformBinding[] {\n const uniforms: UniformBinding[] = [];\n\n const uniformCount = gl.getProgramParameter(program, GL.ACTIVE_UNIFORMS);\n for (let i = 0; i < uniformCount; i++) {\n const activeInfo = gl.getActiveUniform(program, i);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const {name: rawName, size, type} = activeInfo;\n const {name, isArray} = parseUniformName(rawName);\n let webglLocation = gl.getUniformLocation(program, name);\n const uniformInfo = {\n // WebGL locations are uniquely typed but just numbers\n location: webglLocation as number,\n name,\n size,\n type,\n isArray\n };\n uniforms.push(uniformInfo);\n\n // Array (e.g. matrix) uniforms can occupy several 4x4 byte banks\n if (uniformInfo.size > 1) {\n for (let j = 0; j < uniformInfo.size; j++) {\n const elementName = `${name}[${j}]`;\n\n webglLocation = gl.getUniformLocation(program, elementName);\n\n const arrayElementUniformInfo = {\n ...uniformInfo,\n name: elementName,\n location: webglLocation as number\n };\n\n uniforms.push(arrayElementUniformInfo);\n }\n }\n }\n return uniforms;\n}\n\n/**\n * Extract info about all \"active\" uniform blocks\n *\n * (\"Active\" just means that unused (aka inactive) blocks may have been\n * optimized away during linking)\n */\nfunction readUniformBlocks(\n gl: WebGLRenderingContext,\n program: WebGLProgram\n): UniformBlockBinding[] {\n if (!isWebGL2(gl)) {\n return [];\n }\n const gl2 = gl as WebGL2RenderingContext;\n\n const getBlockParameter = (blockIndex: number, pname: GL): any =>\n gl2.getActiveUniformBlockParameter(program, blockIndex, pname);\n\n const uniformBlocks: UniformBlockBinding[] = [];\n\n const blockCount = gl2.getProgramParameter(program, GL.ACTIVE_UNIFORM_BLOCKS);\n for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {\n const blockInfo: UniformBlockBinding = {\n name: gl2.getActiveUniformBlockName(program, blockIndex) || '',\n location: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_BINDING),\n byteLength: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_DATA_SIZE),\n vertex: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),\n fragment: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),\n uniformCount: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_ACTIVE_UNIFORMS),\n uniforms: [] as any[]\n };\n\n const uniformIndices = getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) as number[] || [];\n\n const uniformType = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_TYPE); // Array of GLenum indicating the types of the uniforms.\n const uniformArrayLength = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_SIZE); // Array of GLuint indicating the sizes of the uniforms.\n // const uniformBlockIndex = gl2.getActiveUniforms(\n // program,\n // uniformIndices,\n // GL.UNIFORM_BLOCK_INDEX\n // ); // Array of GLint indicating the block indices of the uniforms.\n const uniformOffset = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_OFFSET); // Array of GLint indicating the uniform buffer offsets.\n const uniformStride = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_ARRAY_STRIDE); // Array of GLint indicating the strides between the elements.\n // const uniformMatrixStride = gl2.getActiveUniforms(\n // program,\n // uniformIndices,\n // GL.UNIFORM_MATRIX_STRIDE\n // ); // Array of GLint indicating the strides between columns of a column-major matrix or a row-major matrix.\n // const uniformRowMajor = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_IS_ROW_MAJOR);\n for (let i = 0; i < blockInfo.uniformCount; ++i) {\n const activeInfo = gl2.getActiveUniform(program, uniformIndices[i]);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n \n blockInfo.uniforms.push({\n name: activeInfo.name,\n format: decodeUniformType(uniformType[i]).format,\n type: uniformType[i],\n arrayLength: uniformArrayLength[i],\n byteOffset: uniformOffset[i],\n byteStride: uniformStride[i],\n // matrixStride: uniformStride[i],\n // rowMajor: uniformRowMajor[i]\n });\n }\n\n uniformBlocks.push(blockInfo);\n }\n\n uniformBlocks.sort((a, b) => a.location - b.location);\n return uniformBlocks;\n}\n\nconst SAMPLER_UNIFORMS_GL_TO_GPU: Record<\n number,\n [\n '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d',\n 'float' | 'unfilterable-float' | 'depth' | 'sint' | 'uint'\n ]\n> = {\n [GL.SAMPLER_2D]: ['2d', 'float'],\n [GL.SAMPLER_CUBE]: ['cube', 'float'],\n [GL.SAMPLER_3D]: ['3d', 'float'],\n [GL.SAMPLER_2D_SHADOW]: ['3d', 'depth'],\n [GL.SAMPLER_2D_ARRAY]: ['2d-array', 'float'],\n [GL.SAMPLER_2D_ARRAY_SHADOW]: ['2d-array', 'depth'],\n [GL.SAMPLER_CUBE_SHADOW]: ['cube', 'float'],\n [GL.INT_SAMPLER_2D]: ['2d', 'sint'],\n [GL.INT_SAMPLER_3D]: ['3d', 'sint'],\n [GL.INT_SAMPLER_CUBE]: ['cube', 'sint'],\n [GL.INT_SAMPLER_2D_ARRAY]: ['2d-array', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_2D]: ['2d', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_3D]: ['3d', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_CUBE]: ['cube', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]: ['2d-array', 'uint']\n};\n\ntype SamplerInfo = | {\n viewDimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';\n sampleType: 'float' | 'unfilterable-float' | 'depth' | 'sint' | 'uint';\n};\n\nfunction getSamplerInfo(type: GL): SamplerInfo {\n const sampler = SAMPLER_UNIFORMS_GL_TO_GPU[type];\n if (!sampler) {\n throw new Error('sampler');\n }\n const [viewDimension, sampleType] = sampler;\n return {viewDimension, sampleType};\n}\n\n// HELPERS\n\nfunction parseUniformName(name: string): {name: string; length: number; isArray: boolean} {\n // Shortcut to avoid redundant or bad matches\n if (name[name.length - 1] !== ']') {\n return {\n name,\n length: 1,\n isArray: false\n };\n }\n\n // if array name then clean the array brackets\n const UNIFORM_NAME_REGEXP = /([^[]*)(\\[[0-9]+\\])?/;\n const matches = UNIFORM_NAME_REGEXP.exec(name);\n if (!matches || matches.length < 2) {\n throw new Error(`Failed to parse GLSL uniform name ${name}`);\n }\n\n return {\n name: matches[1],\n length: matches[2] ? 1 : 0,\n isArray: Boolean(matches[2])\n };\n}\n\n/**\n * TODO - verify this is a copy of above and delete\n * import type {TextureFormat} from '@luma.gl/api';\n* Extract info about all \"active\" uniform blocks\n * (\"Active\" just means that unused (inactive) blocks may have been optimized away during linking)\n *\n function getUniformBlockBindings(gl: WebGLRenderingContext, program): Binding[] {\n if (!isWebGL2(gl)) {\n return;\n }\n const bindings: Binding[] = [];\n const count = gl.getProgramParameter(program, gl.ACTIVE_UNIFORM_BLOCKS);\n for (let blockIndex = 0; blockIndex < count; blockIndex++) {\n const vertex = gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),\n const fragment = gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),\n const visibility = (vertex) + (fragment);\n const binding: BufferBinding = {\n location: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_BINDING),\n // name: gl.getActiveUniformBlockName(program, blockIndex),\n type: 'uniform',\n visibility,\n minBindingSize: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_DATA_SIZE),\n // uniformCount: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_ACTIVE_UNIFORMS),\n // uniformIndices: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES),\n }\n bindings.push(binding);\n }\n return bindings;\n}\n\nfunction setBindings(gl2: WebGL2RenderingContext, program: WebGLProgram, bindings: Binding[][]): void {\n for (const bindGroup of bindings) {\n for (const binding of bindGroup) {\n\n }\n }\n\n // Set up indirection table\n // this.gl2.uniformBlockBinding(this.handle, blockIndex, blockBinding);\n}\n */\n"],"mappings":"AAaA,SAAQA,EAAE,QAAO,oBAAoB;AAAC,SAC9BC,QAAQ;AAAA,SACRC,QAAQ;AAAA,SACRC,iBAAiB,EAAEC,mBAAmB;AAAA,SACtCC,eAAe;AAAA,SACfC,gBAAgB;AAOxB,OAAO,SAASC,eAAeA,CAACC,EAAyB,EAAEC,OAAqB,EAAgB;EAAA,IAAAC,qBAAA,EAAAC,qBAAA;EAC9F,MAAMC,eAAe,GAAGC,kBAAkB,CAACL,EAAE,EAAEC,OAAO,CAAC;EAEvD,MAAMK,YAA0B,GAAG;IACjCC,UAAU,EAAE,EAAE;IACdC,QAAQ,EAAE;EACZ,CAAC;EAED,KAAK,MAAMC,SAAS,IAAIL,eAAe,CAACG,UAAU,EAAE;IAElD,MAAMG,IAAI,GAAGC,IAAI,CAACC,GAAG,CAACH,SAAS,CAACI,QAAQ,CAACH,IAAI,EAAE,CAAC,CAAC;IACjD,MAAMI,MAAM,GAEVjB,eAAe,CAACY,SAAS,CAACI,QAAQ,CAACE,I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,CAAC;EAChD,IAAI,CAAC4G,OAAO,EAAE;IACZ,MAAM,IAAIpE,KAAK,CAAC,SAAS,CAAC;EAC5B;EACA,MAAM,CAACnB,aAAa,EAAEC,UAAU,CAAC,GAAGsF,OAAO;EAC3C,OAAO;IAACvF,aAAa;IAAEC;EAAU,CAAC;AACpC;AAIA,SAASsC,gBAAgBA,CAACzD,IAAY,EAAoD;EAExF,IAAIA,IAAI,CAACA,IAAI,CAACsB,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;IACjC,OAAO;MACLtB,IAAI;MACJsB,MAAM,EAAE,CAAC;MACTkC,OAAO,EAAE;IACX,CAAC;EACH;EAGA,MAAMkD,mBAAmB,GAAG,sBAAsB;EAClD,MAAMC,OAAO,GAAGD,mBAAmB,CAACE,IAAI,CAAC5G,IAAI,CAAC;EAC9C,IAAI,CAAC2G,OAAO,IAAIA,OAAO,CAACrF,MAAM,GAAG,CAAC,EAAE;IAClC,MAAM,IAAIe,KAAK,sCAAA0B,MAAA,CAAsC/D,IAAI,CAAE,CAAC;EAC9D;EAEA,OAAO;IACLA,IAAI,EAAE2G,OAAO,CAAC,CAAC,CAAC;IAChBrF,MAAM,EAAEqF,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAC1BnD,OAAO,EAAEqD,OAAO,CAACF,OAAO,CAAC,CAAC,CAAC;EAC7B,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"get-shader-layout.js","names":["log","GL","isWebGL2","Accessor","decodeUniformType","decodeAttributeType","getVertexFormat","isSamplerUniform","getShaderLayout","gl","program","shaderLayout","attributes","bindings","readAttributeBindings","attribute","size","Math","min","accessor","format","type","FLOAT","push","name","location","stepMode","divisor","uniformBlocks","readUniformBlocks","uniformBlock","uniforms","map","uniform","byteOffset","byteStride","arrayLength","visibility","vertex","fragment","minBindingSize","byteLength","readUniformBindings","textureUnit","viewDimension","sampleType","getSamplerInfo","length","varyings","readVaryings","mergeShaderLayout","baseLayout","overrideLayout","mergedLayout","baseAttribute","find","attr","warn","concat","mergeBufferMap","bufferMap","bufferMapping","attributeOverride","overrideShaderLayoutAttribute","layout","getAttributeFromLayout","count","getProgramParameter","ACTIVE_ATTRIBUTES","index","activeInfo","getActiveAttrib","Error","compositeType","getAttribLocation","glType","components","test","attributeInfo","sort","a","b","gl2","TRANSFORM_FEEDBACK_VARYINGS","getTransformFeedbackVarying","varying","uniformCount","ACTIVE_UNIFORMS","i","getActiveUniform","rawName","isArray","parseUniformName","webglLocation","getUniformLocation","uniformInfo","j","elementName","arrayElementUniformInfo","getBlockParameter","blockIndex","pname","getActiveUniformBlockParameter","blockCount","ACTIVE_UNIFORM_BLOCKS","blockInfo","getActiveUniformBlockName","UNIFORM_BLOCK_BINDING","UNIFORM_BLOCK_DATA_SIZE","UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER","UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER","UNIFORM_BLOCK_ACTIVE_UNIFORMS","uniformIndices","UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES","uniformType","getActiveUniforms","UNIFORM_TYPE","uniformArrayLength","UNIFORM_SIZE","uniformOffset","UNIFORM_OFFSET","uniformStride","UNIFORM_ARRAY_STRIDE","SAMPLER_UNIFORMS_GL_TO_GPU","SAMPLER_2D","SAMPLER_CUBE","SAMPLER_3D","SAMPLER_2D_SHADOW","SAMPLER_2D_ARRAY","SAMPLER_2D_ARRAY_SHADOW","SAMPLER_CUBE_SHADOW","INT_SAMPLER_2D","INT_SAMPLER_3D","INT_SAMPLER_CUBE","INT_SAMPLER_2D_ARRAY","UNSIGNED_INT_SAMPLER_2D","UNSIGNED_INT_SAMPLER_3D","UNSIGNED_INT_SAMPLER_CUBE","UNSIGNED_INT_SAMPLER_2D_ARRAY","sampler","UNIFORM_NAME_REGEXP","matches","exec","Boolean"],"sources":["../../../src/adapter/helpers/get-shader-layout.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {\n ShaderLayout,\n AttributeLayout,\n UniformBinding,\n UniformBlockBinding,\n AttributeBinding,\n VaryingBinding,\n AccessorObject,\n BufferMapping,\n VertexFormat\n} from '@luma.gl/api';\nimport {log} from '@luma.gl/api';\nimport {GL} from '@luma.gl/constants';\nimport {isWebGL2} from '../../context/context/webgl-checks';\nimport {Accessor} from '../../classic/accessor'; // TODO - should NOT depend on classic API\nimport {decodeUniformType, decodeAttributeType} from './uniforms';\nimport {getVertexFormat} from '../converters/vertex-formats';\nimport {isSamplerUniform} from './uniforms';\n\n/**\n * Extract metadata describing binding information for a program's shaders\n * Note: `linkProgram()` needs to have been called\n * (although linking does not need to have been successful).\n */\nexport function getShaderLayout(gl: WebGLRenderingContext, program: WebGLProgram): ShaderLayout {\n const shaderLayout: ShaderLayout = {\n attributes: [],\n bindings: []\n };\n\n const attributes: AttributeBinding[] = readAttributeBindings(gl, program);\n for (const attribute of attributes) {\n // TODO - multicolumn attributes like a matrix4 can be up to 16 elts...\n const size = Math.min(attribute.accessor.size, 4);\n const format =\n // attribute.accessor.format ||\n getVertexFormat(attribute.accessor.type || GL.FLOAT, size);\n shaderLayout.attributes.push({\n name: attribute.name,\n location: attribute.location,\n format,\n stepMode: attribute.accessor.divisor === 1 ? 'instance' : 'vertex'\n });\n }\n\n // Uniform blocks\n const uniformBlocks: UniformBlockBinding[] = readUniformBlocks(gl, program);\n for (const uniformBlock of uniformBlocks) {\n const uniforms = uniformBlock.uniforms.map(uniform => ({\n name: uniform.name,\n format: uniform.format,\n byteOffset: uniform.byteOffset,\n byteStride: uniform.byteStride,\n arrayLength: uniform.arrayLength\n }));\n shaderLayout.bindings.push({\n type: 'uniform',\n name: uniformBlock.name,\n location: uniformBlock.location,\n visibility: (uniformBlock.vertex ? 0x1 : 0) & (uniformBlock.fragment ? 0x2 : 0),\n minBindingSize: uniformBlock.byteLength,\n uniforms\n });\n }\n\n const uniforms: UniformBinding[] = readUniformBindings(gl, program);\n let textureUnit = 0;\n for (const uniform of uniforms) {\n if (isSamplerUniform(uniform.type)) {\n const {viewDimension, sampleType} = getSamplerInfo(uniform.type);\n shaderLayout.bindings.push({\n type: 'texture',\n name: uniform.name,\n location: textureUnit,\n viewDimension,\n sampleType\n });\n\n // @ts-expect-error\n uniform.textureUnit = textureUnit;\n textureUnit += 1;\n }\n }\n\n if (uniforms.length) {\n shaderLayout.uniforms = uniforms;\n }\n\n // Varyings\n const varyings: VaryingBinding[] = readVaryings(gl, program);\n // Note - samplers are always in unform bindings, even if uniform blocks are used\n if (varyings?.length) {\n shaderLayout.varyings = varyings;\n }\n\n return shaderLayout;\n}\n\n/**\n * Merges an provided shader layout into a base shader layout\n * In WebGL, this allows the auto generated shader layout to be overridden by the application\n * Typically to change the format of the vertex attributes (from float32x4 to uint8x4 etc).\n * @todo Drop this? This could also be done more clearly with bufferMapping\n */\nexport function mergeShaderLayout(\n baseLayout: ShaderLayout,\n overrideLayout: ShaderLayout\n): ShaderLayout {\n // Deep clone the base layout\n const mergedLayout: ShaderLayout = {\n ...baseLayout,\n attributes: baseLayout.attributes.map(attribute => ({...attribute}))\n };\n // Merge the attributes\n for (const attribute of overrideLayout?.attributes || []) {\n const baseAttribute = mergedLayout.attributes.find(attr => attr.name === attribute.name);\n if (!baseAttribute) {\n log.warn(`shader layout attribute ${attribute.name} not present in shader`);\n } else {\n baseAttribute.format = attribute.format || baseAttribute.format;\n baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;\n }\n }\n return mergedLayout;\n}\n\nexport function mergeBufferMap(baseLayout: ShaderLayout, bufferMap: BufferMapping[]): ShaderLayout {\n // Deep clone the base layout\n const mergedLayout: ShaderLayout = {\n ...baseLayout,\n attributes: baseLayout.attributes.map(attribute => ({...attribute}))\n };\n for (const bufferMapping of bufferMap) {\n // Handle interleave\n switch (bufferMapping.type) {\n case 'interleave':\n // Handle interleaved buffer mapping\n for (const attributeOverride of bufferMapping.attributes) {\n overrideShaderLayoutAttribute(mergedLayout, attributeOverride);\n }\n break;\n\n default:\n // Handle simple attribute overrides\n overrideShaderLayoutAttribute(mergedLayout, bufferMapping);\n }\n }\n return mergedLayout;\n}\n\nfunction overrideShaderLayoutAttribute(\n layout: ShaderLayout,\n attributeOverride: {name: string; format?: VertexFormat}\n): void {\n const attribute = getAttributeFromLayout(layout, attributeOverride.name);\n if (attribute && attributeOverride.format) {\n attribute.format = attributeOverride.format;\n }\n}\n\nexport function getAttributeFromLayout(\n shaderLayout: ShaderLayout,\n name: string\n): AttributeLayout | null {\n const attribute = shaderLayout.attributes.find(attr => attr.name === name);\n if (!attribute) {\n log.warn(`shader layout attribute \"${name}\" not present in shader`);\n }\n return attribute || null;\n}\n\n// HELPERS\n\n/**\n * Extract info about all transform feedback varyings\n *\n * linkProgram needs to have been called, although linking does not need to have been successful\n */\nfunction readAttributeBindings(\n gl: WebGLRenderingContext,\n program: WebGLProgram\n): AttributeBinding[] {\n const attributes: AttributeBinding[] = [];\n\n const count = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);\n\n for (let index = 0; index < count; index++) {\n const activeInfo = gl.getActiveAttrib(program, index);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const {name, type: compositeType, size} = activeInfo;\n const location = gl.getAttribLocation(program, name);\n // Add only user provided attributes, for built-in attributes like\n // `gl_InstanceID` locaiton will be < 0\n if (location >= 0) {\n const {glType, components} = decodeAttributeType(compositeType);\n const accessor: AccessorObject = {type: glType, size: size * components};\n // Any attribute name containing the word \"instance\" will be assumed to be instanced\n if (/instance/i.test(name)) {\n accessor.divisor = 1;\n }\n const attributeInfo = {location, name, accessor: new Accessor(accessor)}; // Base values\n attributes.push(attributeInfo);\n }\n }\n\n attributes.sort((a: AttributeBinding, b: AttributeBinding) => a.location - b.location);\n return attributes;\n}\n\n/**\n * Extract info about all transform feedback varyings\n *\n * linkProgram needs to have been called, although linking does not need to have been successful\n */\nfunction readVaryings(gl: WebGLRenderingContext, program: WebGLProgram): VaryingBinding[] {\n if (!isWebGL2(gl)) {\n return [];\n }\n const gl2 = gl as WebGL2RenderingContext;\n\n const varyings: VaryingBinding[] = [];\n\n const count = gl.getProgramParameter(program, GL.TRANSFORM_FEEDBACK_VARYINGS);\n for (let location = 0; location < count; location++) {\n const activeInfo = gl2.getTransformFeedbackVarying(program, location);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const {name, type: compositeType, size} = activeInfo;\n const {glType, components} = decodeUniformType(compositeType);\n const accessor = new Accessor({type: glType, size: size * components});\n const varying = {location, name, accessor}; // Base values\n varyings.push(varying);\n }\n\n varyings.sort((a, b) => a.location - b.location);\n return varyings;\n}\n\n/**\n * Extract info about all uniforms\n *\n * Query uniform locations and build name to setter map.\n */\nfunction readUniformBindings(gl: WebGLRenderingContext, program: WebGLProgram): UniformBinding[] {\n const uniforms: UniformBinding[] = [];\n\n const uniformCount = gl.getProgramParameter(program, GL.ACTIVE_UNIFORMS);\n for (let i = 0; i < uniformCount; i++) {\n const activeInfo = gl.getActiveUniform(program, i);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const {name: rawName, size, type} = activeInfo;\n const {name, isArray} = parseUniformName(rawName);\n let webglLocation = gl.getUniformLocation(program, name);\n const uniformInfo = {\n // WebGL locations are uniquely typed but just numbers\n location: webglLocation as number,\n name,\n size,\n type,\n isArray\n };\n uniforms.push(uniformInfo);\n\n // Array (e.g. matrix) uniforms can occupy several 4x4 byte banks\n if (uniformInfo.size > 1) {\n for (let j = 0; j < uniformInfo.size; j++) {\n const elementName = `${name}[${j}]`;\n\n webglLocation = gl.getUniformLocation(program, elementName);\n\n const arrayElementUniformInfo = {\n ...uniformInfo,\n name: elementName,\n location: webglLocation as number\n };\n\n uniforms.push(arrayElementUniformInfo);\n }\n }\n }\n return uniforms;\n}\n\n/**\n * Extract info about all \"active\" uniform blocks\n *\n * (\"Active\" just means that unused (aka inactive) blocks may have been\n * optimized away during linking)\n */\nfunction readUniformBlocks(\n gl: WebGLRenderingContext,\n program: WebGLProgram\n): UniformBlockBinding[] {\n if (!isWebGL2(gl)) {\n return [];\n }\n const gl2 = gl as WebGL2RenderingContext;\n\n const getBlockParameter = (blockIndex: number, pname: GL): any =>\n gl2.getActiveUniformBlockParameter(program, blockIndex, pname);\n\n const uniformBlocks: UniformBlockBinding[] = [];\n\n const blockCount = gl2.getProgramParameter(program, GL.ACTIVE_UNIFORM_BLOCKS);\n for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {\n const blockInfo: UniformBlockBinding = {\n name: gl2.getActiveUniformBlockName(program, blockIndex) || '',\n location: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_BINDING),\n byteLength: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_DATA_SIZE),\n vertex: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),\n fragment: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),\n uniformCount: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_ACTIVE_UNIFORMS),\n uniforms: [] as any[]\n };\n\n const uniformIndices =\n (getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) as number[]) || [];\n\n const uniformType = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_TYPE); // Array of GLenum indicating the types of the uniforms.\n const uniformArrayLength = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_SIZE); // Array of GLuint indicating the sizes of the uniforms.\n // const uniformBlockIndex = gl2.getActiveUniforms(\n // program,\n // uniformIndices,\n // GL.UNIFORM_BLOCK_INDEX\n // ); // Array of GLint indicating the block indices of the uniforms.\n const uniformOffset = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_OFFSET); // Array of GLint indicating the uniform buffer offsets.\n const uniformStride = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_ARRAY_STRIDE); // Array of GLint indicating the strides between the elements.\n // const uniformMatrixStride = gl2.getActiveUniforms(\n // program,\n // uniformIndices,\n // GL.UNIFORM_MATRIX_STRIDE\n // ); // Array of GLint indicating the strides between columns of a column-major matrix or a row-major matrix.\n // const uniformRowMajor = gl2.getActiveUniforms(program, uniformIndices, GL.UNIFORM_IS_ROW_MAJOR);\n for (let i = 0; i < blockInfo.uniformCount; ++i) {\n const activeInfo = gl2.getActiveUniform(program, uniformIndices[i]);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n\n blockInfo.uniforms.push({\n name: activeInfo.name,\n format: decodeUniformType(uniformType[i]).format,\n type: uniformType[i],\n arrayLength: uniformArrayLength[i],\n byteOffset: uniformOffset[i],\n byteStride: uniformStride[i]\n // matrixStride: uniformStride[i],\n // rowMajor: uniformRowMajor[i]\n });\n }\n\n uniformBlocks.push(blockInfo);\n }\n\n uniformBlocks.sort((a, b) => a.location - b.location);\n return uniformBlocks;\n}\n\nconst SAMPLER_UNIFORMS_GL_TO_GPU: Record<\n number,\n [\n '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d',\n 'float' | 'unfilterable-float' | 'depth' | 'sint' | 'uint'\n ]\n> = {\n [GL.SAMPLER_2D]: ['2d', 'float'],\n [GL.SAMPLER_CUBE]: ['cube', 'float'],\n [GL.SAMPLER_3D]: ['3d', 'float'],\n [GL.SAMPLER_2D_SHADOW]: ['3d', 'depth'],\n [GL.SAMPLER_2D_ARRAY]: ['2d-array', 'float'],\n [GL.SAMPLER_2D_ARRAY_SHADOW]: ['2d-array', 'depth'],\n [GL.SAMPLER_CUBE_SHADOW]: ['cube', 'float'],\n [GL.INT_SAMPLER_2D]: ['2d', 'sint'],\n [GL.INT_SAMPLER_3D]: ['3d', 'sint'],\n [GL.INT_SAMPLER_CUBE]: ['cube', 'sint'],\n [GL.INT_SAMPLER_2D_ARRAY]: ['2d-array', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_2D]: ['2d', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_3D]: ['3d', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_CUBE]: ['cube', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]: ['2d-array', 'uint']\n};\n\ntype SamplerInfo = {\n viewDimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';\n sampleType: 'float' | 'unfilterable-float' | 'depth' | 'sint' | 'uint';\n};\n\nfunction getSamplerInfo(type: GL): SamplerInfo {\n const sampler = SAMPLER_UNIFORMS_GL_TO_GPU[type];\n if (!sampler) {\n throw new Error('sampler');\n }\n const [viewDimension, sampleType] = sampler;\n return {viewDimension, sampleType};\n}\n\n// HELPERS\n\nfunction parseUniformName(name: string): {name: string; length: number; isArray: boolean} {\n // Shortcut to avoid redundant or bad matches\n if (name[name.length - 1] !== ']') {\n return {\n name,\n length: 1,\n isArray: false\n };\n }\n\n // if array name then clean the array brackets\n const UNIFORM_NAME_REGEXP = /([^[]*)(\\[[0-9]+\\])?/;\n const matches = UNIFORM_NAME_REGEXP.exec(name);\n if (!matches || matches.length < 2) {\n throw new Error(`Failed to parse GLSL uniform name ${name}`);\n }\n\n return {\n name: matches[1],\n length: matches[2] ? 1 : 0,\n isArray: Boolean(matches[2])\n };\n}\n\n/**\n * TODO - verify this is a copy of above and delete\n * import type {TextureFormat} from '@luma.gl/api';\n* Extract info about all \"active\" uniform blocks\n * (\"Active\" just means that unused (inactive) blocks may have been optimized away during linking)\n *\n function getUniformBlockBindings(gl: WebGLRenderingContext, program): Binding[] {\n if (!isWebGL2(gl)) {\n return;\n }\n const bindings: Binding[] = [];\n const count = gl.getProgramParameter(program, gl.ACTIVE_UNIFORM_BLOCKS);\n for (let blockIndex = 0; blockIndex < count; blockIndex++) {\n const vertex = gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),\n const fragment = gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),\n const visibility = (vertex) + (fragment);\n const binding: BufferBinding = {\n location: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_BINDING),\n // name: gl.getActiveUniformBlockName(program, blockIndex),\n type: 'uniform',\n visibility,\n minBindingSize: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_DATA_SIZE),\n // uniformCount: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_ACTIVE_UNIFORMS),\n // uniformIndices: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES),\n }\n bindings.push(binding);\n }\n return bindings;\n}\n\nfunction setBindings(gl2: WebGL2RenderingContext, program: WebGLProgram, bindings: Binding[][]): void {\n for (const bindGroup of bindings) {\n for (const binding of bindGroup) {\n\n }\n }\n\n // Set up indirection table\n // this.gl2.uniformBlockBinding(this.handle, blockIndex, blockBinding);\n}\n */\n"],"mappings":"AAaA,SAAQA,GAAG,QAAO,cAAc;AAChC,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAC9BC,QAAQ;AAAA,SACRC,QAAQ;AAAA,SACRC,iBAAiB,EAAEC,mBAAmB;AAAA,SACtCC,eAAe;AAAA,SACfC,gBAAgB;AAOxB,OAAO,SAASC,eAAeA,CAACC,EAAyB,EAAEC,OAAqB,EAAgB;EAC9F,MAAMC,YAA0B,GAAG;IACjCC,UAAU,EAAE,EAAE;IACdC,QAAQ,EAAE;EACZ,CAAC;EAED,MAAMD,UAA8B,GAAGE,qBAAqB,CAACL,EAAE,EAAEC,OAAO,CAAC;EACzE,KAAK,MAAMK,SAAS,IAAIH,UAAU,EAAE;IAElC,MAAMI,IAAI,GAAGC,IAAI,CAACC,GAAG,CAACH,SAAS,CAACI,QAAQ,CAACH,IAAI,EAAE,CAAC,CAAC;IACjD,MAAMI,MAAM,GAEVd,eAAe,CAACS,SAAS,CAACI,QAAQ,CAACE,IAAI,IAAIpB,EAAE,CAACqB,KAAK,EAAEN,IAAI,CAAC;IAC5DL,YAAY,CAACC,UAAU,CAACW,IAAI,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AE,MAAM;AACzD,CAAC;AAOD,SAAS5F,cAAcA,CAACzB,IAAQ,EAAe;EAC7C,MAAMsH,OAAO,GAAGhB,0BAA0B,CAACtG,IAAI,CAAC;EAChD,IAAI,CAACsH,OAAO,EAAE;IACZ,MAAM,IAAInE,KAAK,CAAC,SAAS,CAAC;EAC5B;EACA,MAAM,CAAC5B,aAAa,EAAEC,UAAU,CAAC,GAAG8F,OAAO;EAC3C,OAAO;IAAC/F,aAAa;IAAEC;EAAU,CAAC;AACpC;AAIA,SAAS+C,gBAAgBA,CAACpE,IAAY,EAAoD;EAExF,IAAIA,IAAI,CAACA,IAAI,CAACuB,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;IACjC,OAAO;MACLvB,IAAI;MACJuB,MAAM,EAAE,CAAC;MACT4C,OAAO,EAAE;IACX,CAAC;EACH;EAGA,MAAMiD,mBAAmB,GAAG,sBAAsB;EAClD,MAAMC,OAAO,GAAGD,mBAAmB,CAACE,IAAI,CAACtH,IAAI,CAAC;EAC9C,IAAI,CAACqH,OAAO,IAAIA,OAAO,CAAC9F,MAAM,GAAG,CAAC,EAAE;IAClC,MAAM,IAAIyB,KAAK,sCAAAd,MAAA,CAAsClC,IAAI,CAAE,CAAC;EAC9D;EAEA,OAAO;IACLA,IAAI,EAAEqH,OAAO,CAAC,CAAC,CAAC;IAChB9F,MAAM,EAAE8F,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAC1BlD,OAAO,EAAEoD,OAAO,CAACF,OAAO,CAAC,CAAC,CAAC;EAC7B,CAAC;AACH"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="dist" />
|
|
2
|
+
import type { ShaderLayout, BufferMapping } from '@luma.gl/api';
|
|
3
|
+
/**
|
|
4
|
+
* Build a WebGPU vertex buffer layout intended for use in a GPURenderPassDescriptor.
|
|
5
|
+
* Converts luma.gl attribute definitions to a WebGPU GPUVertexBufferLayout[] array
|
|
6
|
+
* @param layout
|
|
7
|
+
* @param bufferMap The buffer map is optional
|
|
8
|
+
* @returns WebGPU layout intended for a GPURenderPassDescriptor.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getVertexBufferLayout(layout: ShaderLayout, bufferMap: BufferMapping[]): GPUVertexBufferLayout[];
|
|
11
|
+
export declare function getBufferSlots(layout: ShaderLayout, bufferMap: BufferMapping[]): Record<string, number>;
|
|
12
|
+
//# sourceMappingURL=get-vertex-buffer-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-vertex-buffer-layout.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-vertex-buffer-layout.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAkB,MAAM,cAAc,CAAC;AAG/E;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,qBAAqB,EAAE,CAkE/G;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2BvG"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { decodeVertexFormat } from '@luma.gl/api';
|
|
2
|
+
export function getVertexBufferLayout(layout, bufferMap) {
|
|
3
|
+
const vertexBufferLayouts = [];
|
|
4
|
+
const usedAttributes = new Set();
|
|
5
|
+
for (const mapping of bufferMap) {
|
|
6
|
+
const vertexAttributes = [];
|
|
7
|
+
let stepMode = 'vertex';
|
|
8
|
+
let byteStride = 0;
|
|
9
|
+
const byteOffset = mapping.byteOffset || 0;
|
|
10
|
+
if ('attributes' in mapping) {
|
|
11
|
+
for (const interleaved of mapping.attributes) {
|
|
12
|
+
const attributeLayout = findAttributeLayout(layout, interleaved.name, usedAttributes);
|
|
13
|
+
stepMode = attributeLayout.stepMode || 'vertex';
|
|
14
|
+
vertexAttributes.push({
|
|
15
|
+
format: attributeLayout.format,
|
|
16
|
+
offset: byteOffset + byteStride,
|
|
17
|
+
shaderLocation: attributeLayout.location
|
|
18
|
+
});
|
|
19
|
+
byteStride += decodeVertexFormat(attributeLayout.format).byteLength;
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
const attributeLayout = findAttributeLayout(layout, mapping.name, usedAttributes);
|
|
23
|
+
byteStride = decodeVertexFormat(attributeLayout.format).byteLength;
|
|
24
|
+
stepMode = attributeLayout.stepMode || 'vertex';
|
|
25
|
+
vertexAttributes.push({
|
|
26
|
+
format: attributeLayout.format,
|
|
27
|
+
offset: byteOffset,
|
|
28
|
+
shaderLocation: attributeLayout.location
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
vertexBufferLayouts.push({
|
|
32
|
+
arrayStride: mapping.byteStride || byteStride,
|
|
33
|
+
stepMode: stepMode || 'vertex',
|
|
34
|
+
attributes: vertexAttributes
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
for (const attribute of layout.attributes) {
|
|
38
|
+
if (!usedAttributes.has(attribute.name)) {
|
|
39
|
+
vertexBufferLayouts.push({
|
|
40
|
+
arrayStride: decodeVertexFormat(attribute.format).byteLength,
|
|
41
|
+
stepMode: attribute.stepMode || 'vertex',
|
|
42
|
+
attributes: [{
|
|
43
|
+
format: attribute.format,
|
|
44
|
+
offset: 0,
|
|
45
|
+
shaderLocation: attribute.location
|
|
46
|
+
}]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return vertexBufferLayouts;
|
|
51
|
+
}
|
|
52
|
+
export function getBufferSlots(layout, bufferMap) {
|
|
53
|
+
const usedAttributes = new Set();
|
|
54
|
+
let bufferSlot = 0;
|
|
55
|
+
const bufferSlots = {};
|
|
56
|
+
for (const mapping of bufferMap) {
|
|
57
|
+
if ('attributes' in mapping) {
|
|
58
|
+
for (const interleaved of mapping.attributes) {
|
|
59
|
+
usedAttributes.add(interleaved.name);
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
usedAttributes.add(mapping.name);
|
|
63
|
+
}
|
|
64
|
+
bufferSlots[mapping.name] = bufferSlot++;
|
|
65
|
+
}
|
|
66
|
+
for (const attribute of layout.attributes) {
|
|
67
|
+
if (!usedAttributes.has(attribute.name)) {
|
|
68
|
+
bufferSlots[attribute.name] = bufferSlot++;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return bufferSlots;
|
|
72
|
+
}
|
|
73
|
+
function findAttributeLayout(layout, name, attributeNames) {
|
|
74
|
+
const attribute = layout.attributes.find(attribute => attribute.name === name);
|
|
75
|
+
if (!attribute) {
|
|
76
|
+
throw new Error("Unknown attribute ".concat(name));
|
|
77
|
+
}
|
|
78
|
+
if (attributeNames.has(name)) {
|
|
79
|
+
throw new Error("Duplicate attribute ".concat(name));
|
|
80
|
+
}
|
|
81
|
+
attributeNames.add(name);
|
|
82
|
+
return attribute;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=get-vertex-buffer-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-vertex-buffer-layout.js","names":["decodeVertexFormat","getVertexBufferLayout","layout","bufferMap","vertexBufferLayouts","usedAttributes","Set","mapping","vertexAttributes","stepMode","byteStride","byteOffset","interleaved","attributes","attributeLayout","findAttributeLayout","name","push","format","offset","shaderLocation","location","byteLength","arrayStride","attribute","has","getBufferSlots","bufferSlot","bufferSlots","add","attributeNames","find","Error","concat"],"sources":["../../../src/adapter/helpers/get-vertex-buffer-layout.ts"],"sourcesContent":["import type {ShaderLayout, BufferMapping, AttributeLayout} from '@luma.gl/api';\nimport {decodeVertexFormat} from '@luma.gl/api';\n\n/**\n * Build a WebGPU vertex buffer layout intended for use in a GPURenderPassDescriptor.\n * Converts luma.gl attribute definitions to a WebGPU GPUVertexBufferLayout[] array\n * @param layout\n * @param bufferMap The buffer map is optional\n * @returns WebGPU layout intended for a GPURenderPassDescriptor.\n */\nexport function getVertexBufferLayout(layout: ShaderLayout, bufferMap: BufferMapping[]): GPUVertexBufferLayout[] {\n const vertexBufferLayouts: GPUVertexBufferLayout[] = [];\n const usedAttributes = new Set<string>();\n\n // First handle any buffers mentioned in `bufferMapping`\n for (const mapping of bufferMap) {\n // Build vertex attributes for one buffer\n const vertexAttributes: GPUVertexAttribute[] = [];\n\n // TODO verify that all stepModes for one buffer are the same\n let stepMode: 'vertex' | 'instance' = 'vertex';\n let byteStride = 0;\n const byteOffset = mapping.byteOffset || 0;\n\n // interleaved mapping {..., attributes: [{...}, ...]}\n if ('attributes' in mapping) {\n // const arrayStride = mapping.byteStride; TODO \n for (const interleaved of mapping.attributes) {\n const attributeLayout = findAttributeLayout(layout, interleaved.name, usedAttributes);\n\n stepMode = attributeLayout.stepMode || 'vertex';\n vertexAttributes.push({\n format: attributeLayout.format,\n offset: byteOffset + byteStride,\n shaderLocation: attributeLayout.location\n });\n\n byteStride += decodeVertexFormat(attributeLayout.format).byteLength;\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n const attributeLayout = findAttributeLayout(layout, mapping.name, usedAttributes);\n byteStride = decodeVertexFormat(attributeLayout.format).byteLength;\n\n stepMode = attributeLayout.stepMode || 'vertex';\n vertexAttributes.push({\n format: attributeLayout.format,\n offset: byteOffset,\n shaderLocation: attributeLayout.location\n });\n }\n\n // Store all the attribute bindings for one buffer\n vertexBufferLayouts.push({\n arrayStride: mapping.byteStride || byteStride,\n stepMode: stepMode || 'vertex',\n attributes: vertexAttributes\n });\n }\n\n // Add any non-mapped attributes\n for (const attribute of layout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n vertexBufferLayouts.push({\n arrayStride: decodeVertexFormat(attribute.format).byteLength,\n stepMode: attribute.stepMode || 'vertex',\n attributes: [{\n format: attribute.format,\n offset: 0,\n shaderLocation: attribute.location\n }]\n });\n }\n }\n\n return vertexBufferLayouts;\n}\n\nexport function getBufferSlots(layout: ShaderLayout, bufferMap: BufferMapping[]): Record<string, number> {\n const usedAttributes = new Set<string>();\n let bufferSlot = 0;\n const bufferSlots: Record<string, number> = {};\n\n // First handle any buffers mentioned in `bufferMapping`\n for (const mapping of bufferMap) {\n // interleaved mapping {..., attributes: [{...}, ...]}\n if ('attributes' in mapping) {\n for (const interleaved of mapping.attributes) {\n usedAttributes.add(interleaved.name);\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n usedAttributes.add(mapping.name);\n }\n bufferSlots[mapping.name] = bufferSlot++;\n }\n\n // Add any non-mapped attributes\n for (const attribute of layout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n bufferSlots[attribute.name] = bufferSlot++;\n }\n }\n\n return bufferSlots;\n}\n\n/**\n * Looks up an attribute in the ShaderLayout.\n * @throws if name is not in ShaderLayout\n * @throws if name has already been referenced\n */\nfunction findAttributeLayout(layout: ShaderLayout, name: string, attributeNames: Set<string>): AttributeLayout {\n const attribute = layout.attributes.find(attribute => attribute.name === name);\n if (!attribute) {\n throw new Error(`Unknown attribute ${name}`);\n }\n if (attributeNames.has(name)) {\n throw new Error(`Duplicate attribute ${name}`);\n }\n attributeNames.add(name);\n return attribute;\n}\n"],"mappings":"AACA,SAAQA,kBAAkB,QAAO,cAAc;AAS/C,OAAO,SAASC,qBAAqBA,CAACC,MAAoB,EAAEC,SAA0B,EAA2B;EAC/G,MAAMC,mBAA4C,GAAG,EAAE;EACvD,MAAMC,cAAc,GAAG,IAAIC,GAAG,CAAS,CAAC;EAGxC,KAAK,MAAMC,OAAO,IAAIJ,SAAS,EAAE;IAE/B,MAAMK,gBAAsC,GAAG,EAAE;IAGjD,IAAIC,QAA+B,GAAG,QAAQ;IAC9C,IAAIC,UAAU,GAAG,CAAC;IAClB,MAAMC,UAAU,GAAGJ,OAAO,CAACI,UAAU,IAAI,CAAC;IAG1C,IAAI,YAAY,IAAIJ,OAAO,EAAE;MAE3B,KAAK,MAAMK,WAAW,IAAIL,OAAO,CAACM,UAAU,EAAE;QAC5C,MAAMC,eA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,IAAI,CAAE,CAAC;EAC9C;EACA,IAAIc,cAAc,CAACL,GAAG,CAACT,IAAI,CAAC,EAAE;IAC5B,MAAM,IAAIgB,KAAK,wBAAAC,MAAA,CAAwBjB,IAAI,CAAE,CAAC;EAChD;EACAc,cAAc,CAACD,GAAG,CAACb,IAAI,CAAC;EACxB,OAAOQ,SAAS;AAClB"}
|
|
@@ -51,13 +51,13 @@ export class WEBGLVertexArrayObject extends WebGLResource {
|
|
|
51
51
|
setElementBuffer() {
|
|
52
52
|
let elementBuffer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
53
53
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
54
|
-
assert(!elementBuffer || elementBuffer.
|
|
54
|
+
assert(!elementBuffer || elementBuffer.glTarget === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);
|
|
55
55
|
this.bind(() => {
|
|
56
56
|
this.gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, elementBuffer ? elementBuffer.handle : null);
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
setBuffer(location, buffer, accessor) {
|
|
60
|
-
if (buffer.
|
|
60
|
+
if (buffer.glTarget === GL.ELEMENT_ARRAY_BUFFER) {
|
|
61
61
|
this.setElementBuffer(buffer, accessor);
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-vertex-array-object.js","names":["Resource","assert","getScratchArray","fillArray","GL","getBrowser","WebGLResource","ERR_ELEMENTS","_Symbol$toStringTag","Symbol","toStringTag","WEBGLVertexArrayObject","isConstantAttributeZeroSupported","device","info","type","constructor","props","defaultProps","constantAttributeZero","_defineProperty","Object","seal","destroy","buffer","_this$buffer","_createHandle","gl2","createVertexArray","_deleteHandle","deleteVertexArray","handle","elements","_bindHandle","bindVertexArray","enable","location","arguments","length","undefined","canDisableAttributeZero","isWebGL2","canDisableAttribute","Number","bind","gl","enableVertexAttribArray","disableVertexAttribArray","setElementBuffer","elementBuffer","opts","target","ELEMENT_ARRAY_BUFFER","bindBuffer","setBuffer","accessor","size","stride","offset","normalized","integer","divisor","ARRAY_BUFFER","assertWebGL2","vertexAttribIPointer","vertexAttribPointer","vertexAttribDivisor","setConstant","array","Float32Array","setConstantFloatArray","Int32Array","setConstantIntArray","Uint32Array","setConstantUintArray","getConstantBuffer","elementCount","value","constantValue","normalizeConstantArrayValue","byteLength","updateNeeded","createBuffer","reallocate","compareConstantArrayValues","bufferValue","typedArray","source","start","count","subData","vertexAttrib1fv","vertexAttrib2fv","vertexAttrib3fv","vertexAttrib4fv","_device$gl","vertexAttribI4iv","_device$gl2","vertexAttribI4uiv","arrayValue","Array","isArray","v1","v2","i"],"sources":["../../../src/adapter/objects/webgl-vertex-array-object.ts"],"sourcesContent":["import type {Device, Buffer, ResourceProps, TypedArray, NumericArray} from '@luma.gl/api';\nimport {Resource, assert, getScratchArray, fillArray} from '@luma.gl/api';\nimport {GL} from '@luma.gl/constants';\nimport {getBrowser} from '@probe.gl/env';\n\nimport {WebGLDevice} from '../webgl-device';\nimport {WebGLResource} from './webgl-resource';\nimport {WEBGLBuffer} from '../resources/webgl-buffer';\n\nimport {BufferWithAccessor} from '../../classic/buffer-with-accessor';\n\nconst ERR_ELEMENTS = 'elements must be GL.ELEMENT_ARRAY_BUFFER';\n\n/**\n * VertexArrayObject properties\n * @param constantAttributeZero Attribute 0 can not be disable on most desktop OpenGL based browsers\n * and on iOS Safari browser.\n */\nexport type VertexArrayObjectProps = ResourceProps & {\n constantAttributeZero?: boolean;\n};\n\n/** VertexArrayObject wrapper */\nexport class WEBGLVertexArrayObject extends WebGLResource<VertexArrayObjectProps> {\n override get [Symbol.toStringTag](): string {\n return 'BaseVertexArrayObject';\n }\n\n /** Buffer constant */\n private buffer: BufferWithAccessor | null = null;\n private bufferValue = null;\n\n static isConstantAttributeZeroSupported(device: Device): boolean {\n return device.info.type === 'webgl2' || getBrowser() === 'Chrome';\n }\n\n // Create a VertexArray\n constructor(device: Device, props?: VertexArrayObjectProps) {\n super(device, props, {...Resource.defaultProps, constantAttributeZero: false});\n Object.seal(this);\n }\n\n override destroy(): void {\n super.destroy();\n if (this.buffer) {\n this.buffer?.destroy();\n } }\n\n override _createHandle() {\n return this.gl2.createVertexArray();\n }\n\n override _deleteHandle(): void {\n this.gl2.deleteVertexArray(this.handle);\n // @ts-expect-error\n return [this.elements];\n // return [this.elements, ...this.buffers];\n }\n\n override _bindHandle(handle: WEBGLVertexArrayObject): void {\n this.gl2.bindVertexArray(handle);\n }\n\n /**\n * Enabling an attribute location makes it reference the currently bound buffer\n * Disabling an attribute location makes it reference the global constant value\n * TODO - handle single values for size 1 attributes?\n * TODO - convert classic arrays based on known type?\n */\n enable(location: number, enable = true): void {\n // Attribute 0 cannot be disabled in most desktop OpenGL based browsers...\n const canDisableAttributeZero = this.device.isWebGL2 || getBrowser() === 'Chrome';\n const canDisableAttribute = canDisableAttributeZero || location !== 0;\n\n if (enable || canDisableAttribute) {\n location = Number(location);\n this.bind(() =>\n enable\n ? this.gl.enableVertexAttribArray(location)\n : this.gl.disableVertexAttribArray(location)\n );\n } }\n\n // Set (bind) an elements buffer, for indexed rendering.\n // Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported\n setElementBuffer(elementBuffer: WEBGLBuffer | null = null, opts = {}) {\n assert(!elementBuffer || elementBuffer.target === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);\n\n // The GL.ELEMENT_ARRAY_BUFFER_BINDING is stored on the VertexArrayObject...\n this.bind(() => {\n this.gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, elementBuffer ? elementBuffer.handle : null);\n });\n }\n\n /** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */\n setBuffer(location: number, buffer: WEBGLBuffer, accessor: any): void {\n // Check target\n if (buffer.target === GL.ELEMENT_ARRAY_BUFFER) {\n this.setElementBuffer(buffer, accessor);\n return;\n }\n\n const {size, type, stride, offset, normalized, integer, divisor} = accessor;\n\n const {gl, gl2} = this;\n location = Number(location);\n\n this.bind(() => {\n // A non-zero buffer object must be bound to the GL_ARRAY_BUFFER target\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer.handle);\n\n // WebGL2 supports *integer* data formats, i.e. GPU will see integer values\n if (integer) {\n this.device.assertWebGL2();\n gl2.vertexAttribIPointer(location, size, type, stride, offset);\n } else {\n // Attaches ARRAY_BUFFER with specified buffer format to location\n gl.vertexAttribPointer(location, size, type, normalized, stride, offset);\n }\n gl.enableVertexAttribArray(location);\n gl2.vertexAttribDivisor(location, divisor || 0);\n\n // NOTE We don't unbind buffer here, typically another buffer will be bound just after\n });\n }\n\n /**\n * Set an attribute to a constant value\n * @param device\n * @param location\n * @param array\n * \n * @note Constants are stored globally on the WebGL context, not the VAO\n * so they need to be updated before every render\n * @todo - use known type (in configuration or passed in) to allow non-typed arrays?\n * @todo - remember/cache values to avoid setting them unnecessarily?\n */\n setConstant(location: any, array: TypedArray): void {\n switch (array.constructor) {\n case Float32Array:\n setConstantFloatArray(this.device, location, array as Float32Array);\n break;\n case Int32Array:\n setConstantIntArray(this.device, location, array as Int32Array);\n break;\n case Uint32Array:\n setConstantUintArray(this.device, location, array as Uint32Array);\n break;\n default:\n assert(false);\n }\n }\n\n /**\n * Provide a means to create a buffer that is equivalent to a constant.\n * NOTE: Desktop OpenGL cannot disable attribute 0.\n * https://stackoverflow.com/questions/20305231/webgl-warning-attribute-0-is-disabled-\n * this-has-significant-performance-penalty\n */\n getConstantBuffer(elementCount: number, value): Buffer {\n // Create buffer only when needed, and reuse it (avoids inflating buffer creation statistics)\n\n const constantValue = normalizeConstantArrayValue(value);\n\n const byteLength = constantValue.byteLength * elementCount;\n const length = constantValue.length * elementCount;\n\n let updateNeeded = !this.buffer;\n\n this.buffer = this.buffer || this.device.createBuffer({byteLength}) as BufferWithAccessor;\n updateNeeded = updateNeeded || this.buffer.reallocate(byteLength);\n\n // Reallocate and update contents if needed\n updateNeeded =\n updateNeeded || !compareConstantArrayValues(constantValue, this.bufferValue);\n\n if (updateNeeded) {\n // Create a typed array that is big enough, and fill it with the required data\n const typedArray = getScratchArray(value.constructor, length);\n fillArray({target: typedArray, source: constantValue, start: 0, count: length});\n this.buffer.subData(typedArray);\n this.bufferValue = value;\n }\n\n return this.buffer;\n }\n}\n\nfunction setConstantFloatArray(device: WebGLDevice, location: number, array: Float32Array): void {\n switch (array.length) {\n case 1:\n device.gl.vertexAttrib1fv(location, array);\n break;\n case 2:\n device.gl.vertexAttrib2fv(location, array);\n break;\n case 3:\n device.gl.vertexAttrib3fv(location, array);\n break;\n case 4:\n device.gl.vertexAttrib4fv(location, array);\n break;\n default:\n assert(false);\n }\n}\n\nfunction setConstantIntArray(device: WebGLDevice, location: number, array: Int32Array): void {\n device.assertWebGL2();\n device.gl2?.vertexAttribI4iv(location, array);\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1iv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2iv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3iv(location, array);\n // break;\n // case 4:\n // break;\n // default:\n // assert(false);\n // }\n}\n\nfunction setConstantUintArray(device: WebGLDevice, location: number, array: Uint32Array) {\n device.assertWebGL2();\n device.gl2?.vertexAttribI4uiv(location, array);\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1uiv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2uiv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3uiv(location, array);\n // break;\n // case 4:\n // gl.vertexAttribI4uiv(location, array);\n // break;\n // default:\n // assert(false);\n // }\n}\n\n// HELPERS\n\n/**\n * TODO - convert Arrays based on known type? (read type from accessor, don't assume Float32Array)\n * TODO - handle single values for size 1 attributes?\n */\nfunction normalizeConstantArrayValue(arrayValue: NumericArray) {\n if (Array.isArray(arrayValue)) {\n return new Float32Array(arrayValue);\n }\n return arrayValue;\n}\n\n/**\n * \n */\nfunction compareConstantArrayValues(v1: NumericArray, v2: NumericArray): boolean {\n if (!v1 || !v2 || v1.length !== v2.length || v1.constructor !== v2.constructor) {\n return false;\n }\n for (let i = 0; i < v1.length; ++i) {\n if (v1[i] !== v2[i]) {\n return false;\n }\n }\n return true;\n}\n"],"mappings":";;AACA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,eAAe,EAAEC,SAAS,QAAO,cAAc;AACzE,SAAQC,EAAE,QAAO,oBAAoB;AACrC,SAAQC,UAAU,QAAO,eAAe;AAAC,SAGjCC,aAAa;AAKrB,MAAMC,YAAY,GAAG,0CAA0C;AAACC,mBAAA,GAahDC,MAAM,CAACC,WAAW;AADlC,OAAO,MAAMC,sBAAsB,SAASL,aAAa,CAAyB;EAChF,KAAAE,mBAAA,IAA4C;IAC1C,OAAO,uBAAuB;EAChC;EAMA,OAAOI,gCAAgCA,CAACC,MAAc,EAAW;IAC/D,OAAOA,MAAM,CAACC,IAAI,CAACC,IAAI,KAAK,QAAQ,IAAIV,UAAU,CAAC,CAAC,KAAK,QAAQ;EACnE;EAGAW,WAAWA,CAACH,MAAc,EAAEI,KAA8B,EAAE;IAC1D,KAAK,CAACJ,MAAM,EAAEI,KAAK,EAAE;MAAC,GAAGjB,QAAQ,CAACkB,YAAY;MAAEC,qBAAqB,EAAE;IAAK,CAAC,CAAC;IAACC,eAAA,iBATrC,IAAI;IAAAA,eAAA,sBAC1B,IAAI;IASxBC,MAAM,CAACC,IAAI,CAAC,IAAI,CAAC;EACnB;EAESC,OAAOA,CAAA,EAAS;IACvB,KAAK,CAACA,OAAO,CAAC,CAAC;IACf,IAAI,IAAI,CAACC,MAAM,EAAE;MAAA,IAAAC,YAAA;MACf,CAAAA,YAAA,OAAI,CAACD,MAAM,cAAAC,YAAA,uBAAXA,YAAA,CAAaF,OAAO,CAAC,CAAC;IACxB;EAAG;EAEIG,aAAaA,CAAA,EAAG;IACvB,OAAO,IAAI,CAACC,GAAG,CAACC,iBAAiB,CAAC,CAAC;EACrC;EAESC,aAAaA,C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IC,KAAK,CAACC,OAAO,CAACF,UAAU,CAAC,EAAE;IAC7B,OAAO,IAAI9B,YAAY,CAAC8B,UAAU,CAAC;EACrC;EACA,OAAOA,UAAU;AACnB;AAKA,SAASf,0BAA0BA,CAACkB,EAAgB,EAAEC,EAAgB,EAAW;EAC/E,IAAI,CAACD,EAAE,IAAI,CAACC,EAAE,IAAID,EAAE,CAAChE,MAAM,KAAKiE,EAAE,CAACjE,MAAM,IAAIgE,EAAE,CAACtF,WAAW,KAAKuF,EAAE,CAACvF,WAAW,EAAE;IAC9E,OAAO,KAAK;EACd;EACA,KAAK,IAAIwF,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,EAAE,CAAChE,MAAM,EAAE,EAAEkE,CAAC,EAAE;IAClC,IAAIF,EAAE,CAACE,CAAC,CAAC,KAAKD,EAAE,CAACC,CAAC,CAAC,EAAE;MACnB,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb"}
|
|
1
|
+
{"version":3,"file":"webgl-vertex-array-object.js","names":["Resource","assert","getScratchArray","fillArray","GL","getBrowser","WebGLResource","ERR_ELEMENTS","_Symbol$toStringTag","Symbol","toStringTag","WEBGLVertexArrayObject","isConstantAttributeZeroSupported","device","info","type","constructor","props","defaultProps","constantAttributeZero","_defineProperty","Object","seal","destroy","buffer","_this$buffer","_createHandle","gl2","createVertexArray","_deleteHandle","deleteVertexArray","handle","elements","_bindHandle","bindVertexArray","enable","location","arguments","length","undefined","canDisableAttributeZero","isWebGL2","canDisableAttribute","Number","bind","gl","enableVertexAttribArray","disableVertexAttribArray","setElementBuffer","elementBuffer","opts","glTarget","ELEMENT_ARRAY_BUFFER","bindBuffer","setBuffer","accessor","size","stride","offset","normalized","integer","divisor","ARRAY_BUFFER","assertWebGL2","vertexAttribIPointer","vertexAttribPointer","vertexAttribDivisor","setConstant","array","Float32Array","setConstantFloatArray","Int32Array","setConstantIntArray","Uint32Array","setConstantUintArray","getConstantBuffer","elementCount","value","constantValue","normalizeConstantArrayValue","byteLength","updateNeeded","createBuffer","reallocate","compareConstantArrayValues","bufferValue","typedArray","target","source","start","count","subData","vertexAttrib1fv","vertexAttrib2fv","vertexAttrib3fv","vertexAttrib4fv","_device$gl","vertexAttribI4iv","_device$gl2","vertexAttribI4uiv","arrayValue","Array","isArray","v1","v2","i"],"sources":["../../../src/adapter/objects/webgl-vertex-array-object.ts"],"sourcesContent":["import type {Device, Buffer, ResourceProps, TypedArray, NumericArray} from '@luma.gl/api';\nimport {Resource, assert, getScratchArray, fillArray} from '@luma.gl/api';\nimport {GL} from '@luma.gl/constants';\nimport {getBrowser} from '@probe.gl/env';\n\nimport {WebGLDevice} from '../webgl-device';\nimport {WebGLResource} from './webgl-resource';\nimport {WEBGLBuffer} from '../resources/webgl-buffer';\n\nimport {BufferWithAccessor} from '../../classic/buffer-with-accessor';\n\nconst ERR_ELEMENTS = 'elements must be GL.ELEMENT_ARRAY_BUFFER';\n\n/**\n * VertexArrayObject properties\n * @param constantAttributeZero Attribute 0 can not be disable on most desktop OpenGL based browsers\n * and on iOS Safari browser.\n */\nexport type VertexArrayObjectProps = ResourceProps & {\n constantAttributeZero?: boolean;\n};\n\n/** VertexArrayObject wrapper */\nexport class WEBGLVertexArrayObject extends WebGLResource<VertexArrayObjectProps> {\n override get [Symbol.toStringTag](): string {\n return 'BaseVertexArrayObject';\n }\n\n /** Buffer constant */\n private buffer: BufferWithAccessor | null = null;\n private bufferValue = null;\n\n static isConstantAttributeZeroSupported(device: Device): boolean {\n return device.info.type === 'webgl2' || getBrowser() === 'Chrome';\n }\n\n // Create a VertexArray\n constructor(device: Device, props?: VertexArrayObjectProps) {\n super(device, props, {...Resource.defaultProps, constantAttributeZero: false});\n Object.seal(this);\n }\n\n override destroy(): void {\n super.destroy();\n if (this.buffer) {\n this.buffer?.destroy();\n } }\n\n override _createHandle() {\n return this.gl2.createVertexArray();\n }\n\n override _deleteHandle(): void {\n this.gl2.deleteVertexArray(this.handle);\n // @ts-expect-error\n return [this.elements];\n // return [this.elements, ...this.buffers];\n }\n\n override _bindHandle(handle: WEBGLVertexArrayObject): void {\n this.gl2.bindVertexArray(handle);\n }\n\n /**\n * Enabling an attribute location makes it reference the currently bound buffer\n * Disabling an attribute location makes it reference the global constant value\n * TODO - handle single values for size 1 attributes?\n * TODO - convert classic arrays based on known type?\n */\n enable(location: number, enable = true): void {\n // Attribute 0 cannot be disabled in most desktop OpenGL based browsers...\n const canDisableAttributeZero = this.device.isWebGL2 || getBrowser() === 'Chrome';\n const canDisableAttribute = canDisableAttributeZero || location !== 0;\n\n if (enable || canDisableAttribute) {\n location = Number(location);\n this.bind(() =>\n enable\n ? this.gl.enableVertexAttribArray(location)\n : this.gl.disableVertexAttribArray(location)\n );\n } }\n\n // Set (bind) an elements buffer, for indexed rendering.\n // Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported\n setElementBuffer(elementBuffer: WEBGLBuffer | null = null, opts = {}) {\n assert(!elementBuffer || elementBuffer.glTarget === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);\n\n // The GL.ELEMENT_ARRAY_BUFFER_BINDING is stored on the VertexArrayObject...\n this.bind(() => {\n this.gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, elementBuffer ? elementBuffer.handle : null);\n });\n }\n\n /** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */\n setBuffer(location: number, buffer: WEBGLBuffer, accessor: any): void {\n // Check target\n if (buffer.glTarget === GL.ELEMENT_ARRAY_BUFFER) {\n this.setElementBuffer(buffer, accessor);\n return;\n }\n\n const {size, type, stride, offset, normalized, integer, divisor} = accessor;\n\n const {gl, gl2} = this;\n location = Number(location);\n\n this.bind(() => {\n // A non-zero buffer object must be bound to the GL_ARRAY_BUFFER target\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer.handle);\n\n // WebGL2 supports *integer* data formats, i.e. GPU will see integer values\n if (integer) {\n this.device.assertWebGL2();\n gl2.vertexAttribIPointer(location, size, type, stride, offset);\n } else {\n // Attaches ARRAY_BUFFER with specified buffer format to location\n gl.vertexAttribPointer(location, size, type, normalized, stride, offset);\n }\n gl.enableVertexAttribArray(location);\n gl2.vertexAttribDivisor(location, divisor || 0);\n\n // NOTE We don't unbind buffer here, typically another buffer will be bound just after\n });\n }\n\n /**\n * Set an attribute to a constant value\n * @param device\n * @param location\n * @param array\n * \n * @note Constants are stored globally on the WebGL context, not the VAO\n * so they need to be updated before every render\n * @todo - use known type (in configuration or passed in) to allow non-typed arrays?\n * @todo - remember/cache values to avoid setting them unnecessarily?\n */\n setConstant(location: any, array: TypedArray): void {\n switch (array.constructor) {\n case Float32Array:\n setConstantFloatArray(this.device, location, array as Float32Array);\n break;\n case Int32Array:\n setConstantIntArray(this.device, location, array as Int32Array);\n break;\n case Uint32Array:\n setConstantUintArray(this.device, location, array as Uint32Array);\n break;\n default:\n assert(false);\n }\n }\n\n /**\n * Provide a means to create a buffer that is equivalent to a constant.\n * NOTE: Desktop OpenGL cannot disable attribute 0.\n * https://stackoverflow.com/questions/20305231/webgl-warning-attribute-0-is-disabled-\n * this-has-significant-performance-penalty\n */\n getConstantBuffer(elementCount: number, value): Buffer {\n // Create buffer only when needed, and reuse it (avoids inflating buffer creation statistics)\n\n const constantValue = normalizeConstantArrayValue(value);\n\n const byteLength = constantValue.byteLength * elementCount;\n const length = constantValue.length * elementCount;\n\n let updateNeeded = !this.buffer;\n\n this.buffer = this.buffer || this.device.createBuffer({byteLength}) as BufferWithAccessor;\n updateNeeded = updateNeeded || this.buffer.reallocate(byteLength);\n\n // Reallocate and update contents if needed\n updateNeeded =\n updateNeeded || !compareConstantArrayValues(constantValue, this.bufferValue);\n\n if (updateNeeded) {\n // Create a typed array that is big enough, and fill it with the required data\n const typedArray = getScratchArray(value.constructor, length);\n fillArray({target: typedArray, source: constantValue, start: 0, count: length});\n this.buffer.subData(typedArray);\n this.bufferValue = value;\n }\n\n return this.buffer;\n }\n}\n\nfunction setConstantFloatArray(device: WebGLDevice, location: number, array: Float32Array): void {\n switch (array.length) {\n case 1:\n device.gl.vertexAttrib1fv(location, array);\n break;\n case 2:\n device.gl.vertexAttrib2fv(location, array);\n break;\n case 3:\n device.gl.vertexAttrib3fv(location, array);\n break;\n case 4:\n device.gl.vertexAttrib4fv(location, array);\n break;\n default:\n assert(false);\n }\n}\n\nfunction setConstantIntArray(device: WebGLDevice, location: number, array: Int32Array): void {\n device.assertWebGL2();\n device.gl2?.vertexAttribI4iv(location, array);\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1iv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2iv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3iv(location, array);\n // break;\n // case 4:\n // break;\n // default:\n // assert(false);\n // }\n}\n\nfunction setConstantUintArray(device: WebGLDevice, location: number, array: Uint32Array) {\n device.assertWebGL2();\n device.gl2?.vertexAttribI4uiv(location, array);\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1uiv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2uiv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3uiv(location, array);\n // break;\n // case 4:\n // gl.vertexAttribI4uiv(location, array);\n // break;\n // default:\n // assert(false);\n // }\n}\n\n// HELPERS\n\n/**\n * TODO - convert Arrays based on known type? (read type from accessor, don't assume Float32Array)\n * TODO - handle single values for size 1 attributes?\n */\nfunction normalizeConstantArrayValue(arrayValue: NumericArray) {\n if (Array.isArray(arrayValue)) {\n return new Float32Array(arrayValue);\n }\n return arrayValue;\n}\n\n/**\n * \n */\nfunction compareConstantArrayValues(v1: NumericArray, v2: NumericArray): boolean {\n if (!v1 || !v2 || v1.length !== v2.length || v1.constructor !== v2.constructor) {\n return false;\n }\n for (let i = 0; i < v1.length; ++i) {\n if (v1[i] !== v2[i]) {\n return false;\n }\n }\n return true;\n}\n"],"mappings":";;AACA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,eAAe,EAAEC,SAAS,QAAO,cAAc;AACzE,SAAQC,EAAE,QAAO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E,CAAClE,MAAM,IAAIiE,EAAE,CAACvF,WAAW,KAAKwF,EAAE,CAACxF,WAAW,EAAE;IAC9E,OAAO,KAAK;EACd;EACA,KAAK,IAAIyF,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,EAAE,CAACjE,MAAM,EAAE,EAAEmE,CAAC,EAAE;IAClC,IAAIF,EAAE,CAACE,CAAC,CAAC,KAAKD,EAAE,CAACC,CAAC,CAAC,EAAE;MACnB,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BufferProps } from '@luma.gl/api';
|
|
2
2
|
import { Buffer } from '@luma.gl/api';
|
|
3
|
+
import { GL } from '@luma.gl/constants';
|
|
3
4
|
import { WebGLDevice } from '../webgl-device';
|
|
4
5
|
/** WebGL Buffer interface */
|
|
5
6
|
export declare class WEBGLBuffer extends Buffer {
|
|
@@ -7,12 +8,20 @@ export declare class WEBGLBuffer extends Buffer {
|
|
|
7
8
|
readonly gl: WebGLRenderingContext;
|
|
8
9
|
readonly gl2: WebGL2RenderingContext | null;
|
|
9
10
|
readonly handle: WebGLBuffer;
|
|
10
|
-
|
|
11
|
+
/** Target in OpenGL defines the type of buffer */
|
|
12
|
+
readonly glTarget: GL.ARRAY_BUFFER | GL.ELEMENT_ARRAY_BUFFER | GL.UNIFORM_BUFFER;
|
|
13
|
+
/** Usage is a hint on how frequently the buffer will be updates */
|
|
14
|
+
readonly glUsage: GL.STATIC_DRAW | GL.DYNAMIC_DRAW;
|
|
15
|
+
/** Index type is needed when issuing draw calls, so we pre-compute it */
|
|
16
|
+
readonly glIndexType: GL.UNSIGNED_SHORT | GL.UNSIGNED_INT;
|
|
17
|
+
/** Number of bytes allocated on the GPU for this buffer */
|
|
11
18
|
byteLength: number;
|
|
19
|
+
/** Number of bytes used */
|
|
12
20
|
bytesUsed: number;
|
|
21
|
+
/** A partial CPU-side copy of the data in this buffer, for debugging purposes */
|
|
13
22
|
debugData: ArrayBuffer | null;
|
|
14
|
-
webglUsage: number;
|
|
15
23
|
constructor(device: WebGLDevice, props?: BufferProps);
|
|
24
|
+
/** Allocate a new buffer and initialize to contents of typed array */
|
|
16
25
|
_initWithData(data: any, byteOffset?: number, byteLength?: number): this;
|
|
17
26
|
_initWithByteLength(byteLength: number): this;
|
|
18
27
|
destroy(): void;
|
|
@@ -20,7 +29,7 @@ export declare class WEBGLBuffer extends Buffer {
|
|
|
20
29
|
/** Read data from the buffer */
|
|
21
30
|
readAsync(byteOffset?: number, byteLength?: number): Promise<ArrayBuffer>;
|
|
22
31
|
_invalidateDebugData(): void;
|
|
23
|
-
_getWriteTarget():
|
|
24
|
-
_getReadTarget():
|
|
32
|
+
_getWriteTarget(): GL.ARRAY_BUFFER | GL.ELEMENT_ARRAY_BUFFER | GL.UNIFORM_BUFFER;
|
|
33
|
+
_getReadTarget(): GL.ARRAY_BUFFER | GL.ELEMENT_ARRAY_BUFFER | GL.UNIFORM_BUFFER;
|
|
25
34
|
}
|
|
26
35
|
//# sourceMappingURL=webgl-buffer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAC,MAAM,EAAS,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAC,MAAM,EAAS,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AACtC,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAI5C,6BAA6B;AAC7B,qBAAa,WAA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