@luma.gl/core 9.0.0-alpha.34 → 9.0.0-alpha.36
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/README.md +1 -1
- package/dist/adapter/attribute-utils/get-attribute-from-layouts.d.ts +9 -1
- package/dist/adapter/attribute-utils/get-attribute-from-layouts.d.ts.map +1 -1
- package/dist/adapter/attribute-utils/get-attribute-from-layouts.js +9 -0
- package/dist/adapter/attribute-utils/get-attribute-from-layouts.js.map +1 -1
- package/dist/adapter/device.d.ts +4 -1
- package/dist/adapter/device.d.ts.map +1 -1
- package/dist/adapter/device.js.map +1 -1
- package/dist/adapter/resources/buffer.d.ts +4 -0
- package/dist/adapter/resources/buffer.d.ts.map +1 -1
- package/dist/adapter/resources/buffer.js.map +1 -1
- package/dist/adapter/resources/render-pass.d.ts +2 -2
- package/dist/adapter/resources/render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/render-pass.js.map +1 -1
- package/dist/adapter/resources/render-pipeline.d.ts +9 -14
- package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/render-pipeline.js +4 -2
- package/dist/adapter/resources/render-pipeline.js.map +1 -1
- package/dist/adapter/resources/shader.d.ts +2 -8
- package/dist/adapter/resources/shader.d.ts.map +1 -1
- package/dist/adapter/resources/shader.js +1 -1
- package/dist/adapter/resources/shader.js.map +1 -1
- package/dist/adapter/resources/vertex-array.d.ts +38 -0
- package/dist/adapter/resources/vertex-array.d.ts.map +1 -0
- package/dist/adapter/resources/vertex-array.js +24 -0
- package/dist/adapter/resources/vertex-array.js.map +1 -0
- package/dist/adapter/type-utils/decode-attribute-type.d.ts +1 -1
- package/dist/adapter/type-utils/decode-attribute-type.d.ts.map +1 -1
- package/dist/adapter/type-utils/decode-attribute-type.js.map +1 -1
- package/dist/adapter/type-utils/{decode-uniform-type.d.ts → decode-shader-types.d.ts} +2 -2
- package/dist/adapter/type-utils/decode-shader-types.d.ts.map +1 -0
- package/dist/adapter/type-utils/{decode-uniform-type.js → decode-shader-types.js} +1 -1
- package/dist/adapter/type-utils/decode-shader-types.js.map +1 -0
- package/dist/adapter/type-utils/wgsl-utils.d.ts +1 -1
- package/dist/adapter/type-utils/wgsl-utils.d.ts.map +1 -1
- package/dist/adapter/type-utils/wgsl-utils.js.map +1 -1
- package/dist/adapter/types/shader-layout.d.ts +1 -1
- package/dist/adapter/types/shader-layout.d.ts.map +1 -1
- package/dist/adapter/types/shader-layout.js.map +1 -1
- package/dist/adapter/types/{shader-formats.d.ts → shader-types.d.ts} +1 -1
- package/dist/adapter/types/shader-types.d.ts.map +1 -0
- package/dist/adapter/types/shader-types.js +2 -0
- package/dist/adapter/types/shader-types.js.map +1 -0
- package/dist/adapter/types/types.d.ts +2 -2
- package/dist/adapter/types/types.d.ts.map +1 -1
- package/dist/adapter/types/types.js.map +1 -1
- package/dist/dist.dev.js +664 -460
- package/dist/index.cjs +544 -354
- package/dist/index.d.ts +10 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/uniforms/uniform-block.d.ts +29 -0
- package/dist/lib/uniforms/uniform-block.d.ts.map +1 -0
- package/dist/lib/uniforms/uniform-block.js +48 -0
- package/dist/lib/uniforms/uniform-block.js.map +1 -0
- package/dist/lib/uniforms/uniform-buffer-layout.d.ts +27 -0
- package/dist/lib/uniforms/uniform-buffer-layout.d.ts.map +1 -0
- package/dist/lib/uniforms/uniform-buffer-layout.js +76 -0
- package/dist/lib/uniforms/uniform-buffer-layout.js.map +1 -0
- package/dist/lib/uniforms/uniform-store.d.ts +49 -0
- package/dist/lib/uniforms/uniform-store.d.ts.map +1 -0
- package/dist/lib/uniforms/uniform-store.js +79 -0
- package/dist/lib/uniforms/uniform-store.js.map +1 -0
- package/dist/lib/utils/array-equal.d.ts +3 -0
- package/dist/lib/utils/array-equal.d.ts.map +1 -0
- package/dist/lib/utils/array-equal.js +21 -0
- package/dist/lib/utils/array-equal.js.map +1 -0
- package/dist/lib/utils/is-array.d.ts +16 -0
- package/dist/lib/utils/is-array.d.ts.map +1 -0
- package/dist/lib/utils/is-array.js +10 -0
- package/dist/lib/utils/is-array.js.map +1 -0
- package/dist/lib/utils/random.d.ts +1 -1
- package/dist/lib/utils/random.d.ts.map +1 -1
- package/dist/lib/utils/random.js +2 -2
- package/dist/lib/utils/random.js.map +1 -1
- package/dist/types.d.ts +2 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist/types.js.map +1 -1
- package/dist.min.js +10 -10
- package/package.json +2 -2
- package/src/adapter/attribute-utils/get-attribute-from-layouts.ts +22 -2
- package/src/adapter/device.ts +5 -1
- package/src/adapter/resources/buffer.ts +4 -0
- package/src/adapter/resources/render-pass.ts +2 -2
- package/src/adapter/resources/render-pipeline.ts +11 -16
- package/src/adapter/resources/shader.ts +4 -12
- package/src/adapter/resources/vertex-array.ts +63 -0
- package/src/adapter/type-utils/decode-attribute-type.ts +1 -1
- package/src/adapter/type-utils/{decode-uniform-type.ts → decode-shader-types.ts} +4 -1
- package/src/adapter/type-utils/wgsl-utils.ts +1 -1
- package/src/adapter/types/shader-layout.ts +1 -1
- package/src/adapter/types/types.ts +2 -2
- package/src/index.ts +14 -8
- package/src/lib/uniforms/uniform-block.ts +75 -0
- package/src/lib/uniforms/uniform-buffer-layout.ts +106 -0
- package/src/lib/uniforms/uniform-store.ts +128 -0
- package/src/lib/utils/array-equal.ts +23 -0
- package/src/lib/utils/is-array.ts +24 -0
- package/src/lib/utils/random.ts +2 -2
- package/src/types.ts +3 -15
- package/dist/adapter/type-utils/decode-uniform-type.d.ts.map +0 -1
- package/dist/adapter/type-utils/decode-uniform-type.js.map +0 -1
- package/dist/adapter/types/shader-formats.d.ts.map +0 -1
- package/dist/adapter/types/shader-formats.js +0 -2
- package/dist/adapter/types/shader-formats.js.map +0 -1
- package/dist/lib/uniform-block.d.ts +0 -21
- package/dist/lib/uniform-block.d.ts.map +0 -1
- package/dist/lib/uniform-block.js +0 -49
- package/dist/lib/uniform-block.js.map +0 -1
- package/dist/lib/uniform-buffer-layout.d.ts +0 -23
- package/dist/lib/uniform-buffer-layout.d.ts.map +0 -1
- package/dist/lib/uniform-buffer-layout.js +0 -34
- package/dist/lib/uniform-buffer-layout.js.map +0 -1
- package/src/lib/uniform-block.ts +0 -76
- package/src/lib/uniform-buffer-layout.ts +0 -45
- /package/src/adapter/types/{shader-formats.ts → shader-types.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ShaderLayout } from '../types/shader-layout';
|
|
2
2
|
import type { BufferLayout } from '../types/buffer-layout';
|
|
3
|
-
import type { ShaderDataType, ShaderAttributeType } from '../types/shader-
|
|
3
|
+
import type { ShaderDataType, ShaderAttributeType } from '../types/shader-types';
|
|
4
4
|
import type { VertexFormat, VertexType } from '../types/vertex-formats';
|
|
5
5
|
/** Resolved info for a buffer / attribute combination to help backend configure it correctly */
|
|
6
6
|
export type AttributeInfo = {
|
|
@@ -33,7 +33,15 @@ export type AttributeInfo = {
|
|
|
33
33
|
/** The byteStride is encoded in or calculated from the buffer layout */
|
|
34
34
|
byteStride: number;
|
|
35
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* Map from "attribute names" to "resolved attribute infos"
|
|
38
|
+
* containing information about both buffer layouts and shader attribute declarations
|
|
39
|
+
*/
|
|
36
40
|
export declare function getAttributeInfosFromLayouts(shaderLayout: ShaderLayout, bufferLayout: BufferLayout[]): Record<string, AttributeInfo>;
|
|
41
|
+
/**
|
|
42
|
+
* Array indexed by "location" holding "resolved attribute infos"
|
|
43
|
+
*/
|
|
44
|
+
export declare function getAttributeInfosByLocation(shaderLayout: ShaderLayout, bufferLayout: BufferLayout[], maxVertexAttributes?: number): AttributeInfo[];
|
|
37
45
|
/**
|
|
38
46
|
* Merges an provided shader layout into a base shader layout
|
|
39
47
|
* In WebGL, this allows the auto generated shader layout to be overridden by the application
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-attribute-from-layouts.d.ts","sourceRoot":"","sources":["../../../src/adapter/attribute-utils/get-attribute-from-layouts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAuB,MAAM,wBAAwB,CAAC;AAC/E,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"get-attribute-from-layouts.d.ts","sourceRoot":"","sources":["../../../src/adapter/attribute-utils/get-attribute-from-layouts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAuB,MAAM,wBAAwB,CAAC;AAC/E,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAE/E,OAAO,KAAK,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,yBAAyB,CAAC;AAGtE,gGAAgG;AAChG,MAAM,MAAM,aAAa,GAAG;IAC1B,qBAAqB;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,UAAU,EAAE,mBAAmB,CAAC;IAChC,+EAA+E;IAC/E,cAAc,EAAE,cAAc,CAAC;IAC/B,yFAAyF;IACzF,gBAAgB,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,0GAA0G;IAC1G,OAAO,EAAE,OAAO,CAAC;IAEjB,iBAAiB;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,YAAY,EAAE,YAAY,CAAC;IAC3B,6DAA6D;IAC7D,cAAc,EAAE,UAAU,CAAC;IAC3B,iFAAiF;IACjF,gBAAgB,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,uEAAuE;IACvE,UAAU,EAAE,OAAO,CAAC;IAEpB,mHAAmH;IACnH,QAAQ,EAAE,QAAQ,GAAG,UAAU,CAAC;IAEhC,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAWF;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAAE,GAC3B,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAU/B;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAAE,EAC5B,mBAAmB,GAAE,MAAW,GAC/B,aAAa,EAAE,CAOjB;AAgJD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,YAAY,EACxB,cAAc,EAAE,YAAY,GAC3B,YAAY,CAiBd"}
|
|
@@ -8,6 +8,15 @@ export function getAttributeInfosFromLayouts(shaderLayout, bufferLayout) {
|
|
|
8
8
|
}
|
|
9
9
|
return attributeInfos;
|
|
10
10
|
}
|
|
11
|
+
export function getAttributeInfosByLocation(shaderLayout, bufferLayout) {
|
|
12
|
+
let maxVertexAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 16;
|
|
13
|
+
const attributeInfos = getAttributeInfosFromLayouts(shaderLayout, bufferLayout);
|
|
14
|
+
const locationInfos = new Array(maxVertexAttributes).fill(null);
|
|
15
|
+
for (const attributeInfo of Object.values(attributeInfos)) {
|
|
16
|
+
locationInfos[attributeInfo.location] = attributeInfo;
|
|
17
|
+
}
|
|
18
|
+
return locationInfos;
|
|
19
|
+
}
|
|
11
20
|
function getAttributeInfoFromLayouts(shaderLayout, bufferLayout, name) {
|
|
12
21
|
const shaderDeclaration = getAttributeFromShaderLayout(shaderLayout, name);
|
|
13
22
|
const bufferMapping = getAttributeFromBufferLayout(bufferLayout, name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-attribute-from-layouts.js","names":["log","decodeShaderAttributeType","decodeVertexFormat","getAttributeInfosFromLayouts","shaderLayout","bufferLayout","attributeInfos","attribute","attributes","name","getAttributeInfoFromLayouts","shaderDeclaration","getAttributeFromShaderLayout","bufferMapping","getAttributeFromBufferLayout","attributeTypeInfo","type","vertexFormat","defaultVertexFormat","vertexFormatInfo","attributeName","bufferName","location","shaderType","shaderDataType","dataType","shaderComponents","components","bufferDataType","bufferComponents","normalized","integer","stepMode","byteOffset","byteStride","find","attr","warn","bufferLayouts","checkBufferLayouts","bufferLayoutInfo","getAttributeFromShortHand","getAttributeFromAttributesList","format","_bufferLayout$attribu","attributeMapping","info","byteLength","mapping","mergeShaderLayout","baseLayout","overrideLayout","mergedLayout","map","baseAttribute"],"sources":["../../../src/adapter/attribute-utils/get-attribute-from-layouts.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport {log} from '../../lib/utils/log';\nimport type {ShaderLayout, AttributeDeclaration} from '../types/shader-layout';\nimport type {BufferLayout} from '../types/buffer-layout';\nimport type {ShaderDataType, ShaderAttributeType} from '../types/shader-formats';\nimport {decodeShaderAttributeType} from '../type-utils/decode-attribute-type';\nimport type {VertexFormat, VertexType} from '../types/vertex-formats';\nimport {decodeVertexFormat} from '../type-utils/decode-vertex-format';\n\n/** Resolved info for a buffer / attribute combination to help backend configure it correctly */\nexport type AttributeInfo = {\n /** Attribute name */\n attributeName: string;\n /** Location in shader */\n location: number;\n /** Type / precision used in shader (buffer values may be converted) */\n shaderType: ShaderAttributeType;\n /** Calculations are done in this type in the shader's attribute declaration */\n shaderDataType: ShaderDataType;\n /** Components refer to the number of components in the shader's attribute declaration */\n shaderComponents: 1 | 2 | 3 | 4;\n /** It is the shader attribute declaration that determines whether GPU will process as integer or float */\n integer: boolean;\n\n /** BufferName */\n bufferName: string;\n /** Format of buffer data */\n vertexFormat: VertexFormat;\n /** Memory data type refers to the data type in the buffer */\n bufferDataType: VertexType;\n /** Components refer to the number of components in the buffer's vertex format */\n bufferComponents: 1 | 2 | 3 | 4;\n /** Normalization is encoded in the buffer layout's vertex format... */\n normalized: boolean;\n\n /** If not specified, the step mode is inferred from the attribute name in the shader (contains string instance) */\n stepMode: 'vertex' | 'instance';\n\n /** The byteOffset is encoded in or calculated from the buffer layout */\n byteOffset: number;\n /** The byteStride is encoded in or calculated from the buffer layout */\n byteStride: number;\n};\n\ntype BufferAttributeInfo = {\n attributeName: string;\n bufferName: string;\n stepMode?: 'vertex' | 'instance';\n vertexFormat: VertexFormat;\n byteOffset: number;\n byteStride: number;\n};\n\nexport function getAttributeInfosFromLayouts(\n shaderLayout: ShaderLayout,\n bufferLayout: BufferLayout[]\n): Record<string, AttributeInfo> {\n const attributeInfos: Record<string, ReturnType<typeof getAttributeInfoFromLayouts>> = {};\n for (const attribute of shaderLayout.attributes) {\n attributeInfos[attribute.name] = getAttributeInfoFromLayouts(\n shaderLayout,\n bufferLayout,\n attribute.name\n );\n }\n return attributeInfos;\n}\n\n/**\n * Get the combined information from a shader layout and a buffer layout for a specific attribute\n */\nfunction getAttributeInfoFromLayouts(\n shaderLayout: ShaderLayout,\n bufferLayout: BufferLayout[],\n name: string\n): AttributeInfo | null {\n const shaderDeclaration = getAttributeFromShaderLayout(shaderLayout, name);\n const bufferMapping: BufferAttributeInfo = getAttributeFromBufferLayout(bufferLayout, name);\n\n // TODO should no longer happen\n if (!shaderDeclaration) {\n // || !bufferMapping\n return null;\n }\n\n const attributeTypeInfo = decodeShaderAttributeType(shaderDeclaration.type);\n const vertexFormat = bufferMapping?.vertexFormat || attributeTypeInfo.defaultVertexFormat;\n const vertexFormatInfo = decodeVertexFormat(vertexFormat);\n\n return {\n attributeName: bufferMapping?.attributeName || shaderDeclaration.name,\n bufferName: bufferMapping?.bufferName || shaderDeclaration.name,\n location: shaderDeclaration.location,\n shaderType: shaderDeclaration.type,\n shaderDataType: attributeTypeInfo.dataType,\n shaderComponents: attributeTypeInfo.components,\n vertexFormat,\n bufferDataType: vertexFormatInfo.type,\n bufferComponents: vertexFormatInfo.components,\n // normalized is a property of the buffer's vertex format\n normalized: vertexFormatInfo.normalized,\n // integer is a property of the shader declaration\n integer: attributeTypeInfo.integer,\n stepMode: bufferMapping?.stepMode || shaderDeclaration.stepMode,\n byteOffset: bufferMapping?.byteOffset || 0,\n byteStride: bufferMapping?.byteStride || 0\n };\n}\n\nfunction getAttributeFromShaderLayout(\n shaderLayout: ShaderLayout,\n name: string\n): AttributeDeclaration | 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\nfunction getAttributeFromBufferLayout(\n bufferLayouts: BufferLayout[],\n name: string\n): BufferAttributeInfo | null {\n // Check that bufferLayouts are valid (each either has format or attribute)\n checkBufferLayouts(bufferLayouts);\n\n let bufferLayoutInfo = getAttributeFromShortHand(bufferLayouts, name);\n if (bufferLayoutInfo) {\n return bufferLayoutInfo;\n }\n\n bufferLayoutInfo = getAttributeFromAttributesList(bufferLayouts, name);\n if (bufferLayoutInfo) {\n return bufferLayoutInfo;\n }\n\n // Didn't find...\n log.warn(`layout for attribute \"${name}\" not present in buffer layout`);\n return null;\n}\n\n/** Check that bufferLayouts are valid (each either has format or attribute) */\nfunction checkBufferLayouts(bufferLayouts: BufferLayout[]) {\n for (const bufferLayout of bufferLayouts) {\n if (\n (bufferLayout.attributes && bufferLayout.format) ||\n (!bufferLayout.attributes && !bufferLayout.format)\n ) {\n log.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`);\n }\n }\n}\n\n/** Get attribute from format shorthand if specified */\nfunction getAttributeFromShortHand(\n bufferLayouts: BufferLayout[],\n name: string\n): BufferAttributeInfo | null {\n for (const bufferLayout of bufferLayouts) {\n if (bufferLayout.format && bufferLayout.name === name) {\n return {\n attributeName: bufferLayout.name,\n bufferName: name,\n stepMode: bufferLayout.stepMode,\n vertexFormat: bufferLayout.format,\n // If offset is needed, use `attributes` field.\n byteOffset: 0,\n byteStride: bufferLayout.byteStride || 0\n };\n }\n }\n return null;\n}\n\n/**\n * Search attribute mappings (e.g. interleaved attributes) for buffer mapping.\n * Not the name of the buffer might be the same as one of the interleaved attributes.\n */\nfunction getAttributeFromAttributesList(\n bufferLayouts: BufferLayout[],\n name: string\n): BufferAttributeInfo | null {\n for (const bufferLayout of bufferLayouts) {\n let byteStride: number | undefined = bufferLayout.byteStride;\n\n // Calculate a default byte stride if not provided\n if (typeof bufferLayout.byteStride !== 'number') {\n for (const attributeMapping of bufferLayout.attributes || []) {\n const info = decodeVertexFormat(attributeMapping.format);\n byteStride += info.byteLength;\n }\n }\n\n const attributeMapping = bufferLayout.attributes?.find(mapping => mapping.attribute === name);\n if (attributeMapping) {\n return {\n attributeName: attributeMapping.attribute,\n bufferName: bufferLayout.name,\n stepMode: bufferLayout.stepMode,\n vertexFormat: attributeMapping.format,\n byteOffset: attributeMapping.byteOffset,\n byteStride\n };\n }\n }\n\n return null;\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? Aren't all use cases covered by mergeBufferLayout()?\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.type = attribute.type || baseAttribute.type;\n baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;\n }\n }\n return mergedLayout;\n}\n"],"mappings":"SAEQA,GAAG;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AOoB,YAAY;AACrB"}
|
|
1
|
+
{"version":3,"file":"get-attribute-from-layouts.js","names":["log","decodeShaderAttributeType","decodeVertexFormat","getAttributeInfosFromLayouts","shaderLayout","bufferLayout","attributeInfos","attribute","attributes","name","getAttributeInfoFromLayouts","getAttributeInfosByLocation","maxVertexAttributes","arguments","length","undefined","locationInfos","Array","fill","attributeInfo","Object","values","location","shaderDeclaration","getAttributeFromShaderLayout","bufferMapping","getAttributeFromBufferLayout","attributeTypeInfo","type","vertexFormat","defaultVertexFormat","vertexFormatInfo","attributeName","bufferName","shaderType","shaderDataType","dataType","shaderComponents","components","bufferDataType","bufferComponents","normalized","integer","stepMode","byteOffset","byteStride","find","attr","warn","bufferLayouts","checkBufferLayouts","bufferLayoutInfo","getAttributeFromShortHand","getAttributeFromAttributesList","format","_bufferLayout$attribu","attributeMapping","info","byteLength","mapping","mergeShaderLayout","baseLayout","overrideLayout","mergedLayout","map","baseAttribute"],"sources":["../../../src/adapter/attribute-utils/get-attribute-from-layouts.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport {log} from '../../lib/utils/log';\nimport type {ShaderLayout, AttributeDeclaration} from '../types/shader-layout';\nimport type {BufferLayout} from '../types/buffer-layout';\nimport type {ShaderDataType, ShaderAttributeType} from '../types/shader-types';\nimport {decodeShaderAttributeType} from '../type-utils/decode-attribute-type';\nimport type {VertexFormat, VertexType} from '../types/vertex-formats';\nimport {decodeVertexFormat} from '../type-utils/decode-vertex-format';\n\n/** Resolved info for a buffer / attribute combination to help backend configure it correctly */\nexport type AttributeInfo = {\n /** Attribute name */\n attributeName: string;\n /** Location in shader */\n location: number;\n /** Type / precision used in shader (buffer values may be converted) */\n shaderType: ShaderAttributeType;\n /** Calculations are done in this type in the shader's attribute declaration */\n shaderDataType: ShaderDataType;\n /** Components refer to the number of components in the shader's attribute declaration */\n shaderComponents: 1 | 2 | 3 | 4;\n /** It is the shader attribute declaration that determines whether GPU will process as integer or float */\n integer: boolean;\n\n /** BufferName */\n bufferName: string;\n /** Format of buffer data */\n vertexFormat: VertexFormat;\n /** Memory data type refers to the data type in the buffer */\n bufferDataType: VertexType;\n /** Components refer to the number of components in the buffer's vertex format */\n bufferComponents: 1 | 2 | 3 | 4;\n /** Normalization is encoded in the buffer layout's vertex format... */\n normalized: boolean;\n\n /** If not specified, the step mode is inferred from the attribute name in the shader (contains string instance) */\n stepMode: 'vertex' | 'instance';\n\n /** The byteOffset is encoded in or calculated from the buffer layout */\n byteOffset: number;\n /** The byteStride is encoded in or calculated from the buffer layout */\n byteStride: number;\n};\n\ntype BufferAttributeInfo = {\n attributeName: string;\n bufferName: string;\n stepMode?: 'vertex' | 'instance';\n vertexFormat: VertexFormat;\n byteOffset: number;\n byteStride: number;\n};\n\n/** \n * Map from \"attribute names\" to \"resolved attribute infos\" \n * containing information about both buffer layouts and shader attribute declarations\n */\nexport function getAttributeInfosFromLayouts(\n shaderLayout: ShaderLayout,\n bufferLayout: BufferLayout[]\n): Record<string, AttributeInfo> {\n const attributeInfos: Record<string, AttributeInfo> = {};\n for (const attribute of shaderLayout.attributes) {\n attributeInfos[attribute.name] = getAttributeInfoFromLayouts(\n shaderLayout,\n bufferLayout,\n attribute.name\n );\n }\n return attributeInfos;\n}\n\n/** \n * Array indexed by \"location\" holding \"resolved attribute infos\" \n */\nexport function getAttributeInfosByLocation(\n shaderLayout: ShaderLayout,\n bufferLayout: BufferLayout[],\n maxVertexAttributes: number = 16\n): AttributeInfo[] {\n const attributeInfos = getAttributeInfosFromLayouts(shaderLayout, bufferLayout);\n const locationInfos: AttributeInfo[] = new Array(maxVertexAttributes).fill(null);\n for (const attributeInfo of Object.values(attributeInfos)) {\n locationInfos[attributeInfo.location] = attributeInfo;\n }\n return locationInfos;\n}\n\n/**\n * Get the combined information from a shader layout and a buffer layout for a specific attribute\n */\nfunction getAttributeInfoFromLayouts(\n shaderLayout: ShaderLayout,\n bufferLayout: BufferLayout[],\n name: string\n): AttributeInfo | null {\n const shaderDeclaration = getAttributeFromShaderLayout(shaderLayout, name);\n const bufferMapping: BufferAttributeInfo = getAttributeFromBufferLayout(bufferLayout, name);\n\n // TODO should no longer happen\n if (!shaderDeclaration) {\n // || !bufferMapping\n return null;\n }\n\n const attributeTypeInfo = decodeShaderAttributeType(shaderDeclaration.type);\n const vertexFormat = bufferMapping?.vertexFormat || attributeTypeInfo.defaultVertexFormat;\n const vertexFormatInfo = decodeVertexFormat(vertexFormat);\n\n return {\n attributeName: bufferMapping?.attributeName || shaderDeclaration.name,\n bufferName: bufferMapping?.bufferName || shaderDeclaration.name,\n location: shaderDeclaration.location,\n shaderType: shaderDeclaration.type,\n shaderDataType: attributeTypeInfo.dataType,\n shaderComponents: attributeTypeInfo.components,\n vertexFormat,\n bufferDataType: vertexFormatInfo.type,\n bufferComponents: vertexFormatInfo.components,\n // normalized is a property of the buffer's vertex format\n normalized: vertexFormatInfo.normalized,\n // integer is a property of the shader declaration\n integer: attributeTypeInfo.integer,\n stepMode: bufferMapping?.stepMode || shaderDeclaration.stepMode,\n byteOffset: bufferMapping?.byteOffset || 0,\n byteStride: bufferMapping?.byteStride || 0\n };\n}\n\nfunction getAttributeFromShaderLayout(\n shaderLayout: ShaderLayout,\n name: string\n): AttributeDeclaration | 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\nfunction getAttributeFromBufferLayout(\n bufferLayouts: BufferLayout[],\n name: string\n): BufferAttributeInfo | null {\n // Check that bufferLayouts are valid (each either has format or attribute)\n checkBufferLayouts(bufferLayouts);\n\n let bufferLayoutInfo = getAttributeFromShortHand(bufferLayouts, name);\n if (bufferLayoutInfo) {\n return bufferLayoutInfo;\n }\n\n bufferLayoutInfo = getAttributeFromAttributesList(bufferLayouts, name);\n if (bufferLayoutInfo) {\n return bufferLayoutInfo;\n }\n\n // Didn't find...\n log.warn(`layout for attribute \"${name}\" not present in buffer layout`);\n return null;\n}\n\n/** Check that bufferLayouts are valid (each either has format or attribute) */\nfunction checkBufferLayouts(bufferLayouts: BufferLayout[]) {\n for (const bufferLayout of bufferLayouts) {\n if (\n (bufferLayout.attributes && bufferLayout.format) ||\n (!bufferLayout.attributes && !bufferLayout.format)\n ) {\n log.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`);\n }\n }\n}\n\n/** Get attribute from format shorthand if specified */\nfunction getAttributeFromShortHand(\n bufferLayouts: BufferLayout[],\n name: string\n): BufferAttributeInfo | null {\n for (const bufferLayout of bufferLayouts) {\n if (bufferLayout.format && bufferLayout.name === name) {\n return {\n attributeName: bufferLayout.name,\n bufferName: name,\n stepMode: bufferLayout.stepMode,\n vertexFormat: bufferLayout.format,\n // If offset is needed, use `attributes` field.\n byteOffset: 0,\n byteStride: bufferLayout.byteStride || 0\n };\n }\n }\n return null;\n}\n\n/**\n * Search attribute mappings (e.g. interleaved attributes) for buffer mapping.\n * Not the name of the buffer might be the same as one of the interleaved attributes.\n */\nfunction getAttributeFromAttributesList(\n bufferLayouts: BufferLayout[],\n name: string\n): BufferAttributeInfo | null {\n for (const bufferLayout of bufferLayouts) {\n let byteStride: number | undefined = bufferLayout.byteStride;\n\n // Calculate a default byte stride if not provided\n if (typeof bufferLayout.byteStride !== 'number') {\n for (const attributeMapping of bufferLayout.attributes || []) {\n const info = decodeVertexFormat(attributeMapping.format);\n byteStride += info.byteLength;\n }\n }\n\n const attributeMapping = bufferLayout.attributes?.find(mapping => mapping.attribute === name);\n if (attributeMapping) {\n return {\n attributeName: attributeMapping.attribute,\n bufferName: bufferLayout.name,\n stepMode: bufferLayout.stepMode,\n vertexFormat: attributeMapping.format,\n byteOffset: attributeMapping.byteOffset,\n byteStride\n };\n }\n }\n\n return null;\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? Aren't all use cases covered by mergeBufferLayout()?\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.type = attribute.type || baseAttribute.type;\n baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;\n }\n }\n return mergedLayout;\n}\n"],"mappings":"SAEQA,GAAG;AAAA,SAIHC,yBAAyB;AAAA,SAEzBC,kBAAkB;AAkD1B,OAAO,SAASC,4BAA4BA,CAC1CC,YAA0B,EAC1BC,YAA4B,EACG;EAC/B,MAAMC,cAA6C,GAAG,CAAC,CAAC;EACxD,KAAK,MAAMC,SAAS,IAAIH,YAAY,CAACI,UAAU,EAAE;IAC/CF,cAAc,CAACC,SAAS,CAACE,IAAI,CAAC,GAAGC,2BAA2B,CAC1DN,YAAY,EACZC,YAAY,EACZE,SAAS,CAACE,IACZ,CAAC;EACH;EACA,OAAOH,cAAc;AACvB;AAKA,OAAO,SAASK,2BAA2BA,CACzCP,YAA0B,EAC1BC,YAA4B,EAEX;EAAA,IADjBO,mBAA2B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAEhC,MAAMP,cAAc,GAAGH,4BAA4B,CAACC,YAAY,EAAEC,YAAY,CAAC;EAC/E,MAAMW,aAA8B,GAAG,IAAIC,KAAK,CAACL,mBAAmB,CAAC,CAACM,IAAI,CAAC,IAAI,CAAC;EAChF,KAAK,MAAMC,aAAa,IAAIC,MAAM,CAACC,MAAM,CAACf,cAAc,CAAC,EAAE;IACzDU,aAAa,CAACG,aAAa,CAACG,QAAQ,CAAC,GAAGH,aAAa;EACvD;EAC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2B,gBAAgB,CAACF,MAAM;QACrCV,UAAU,EAAEY,gBAAgB,CAACZ,UAAU;QACvCC;MACF,CAAC;IACH;EACF;EAEA,OAAO,IAAI;AACb;AAQA,OAAO,SAASe,iBAAiBA,CAC/BC,UAAwB,EACxBC,cAA4B,EACd;EAEd,MAAMC,YAA0B,GAAG;IACjC,GAAGF,UAAU;IACbrD,UAAU,EAAEqD,UAAU,CAACrD,UAAU,CAACwD,GAAG,CAACzD,SAAS,KAAK;MAAC,GAAGA;IAAS,CAAC,CAAC;EACrE,CAAC;EAED,KAAK,MAAMA,SAAS,IAAI,CAAAuD,cAAc,aAAdA,cAAc,uBAAdA,cAAc,CAAEtD,UAAU,KAAI,EAAE,EAAE;IACxD,MAAMyD,aAAa,GAAGF,YAAY,CAACvD,UAAU,CAACsC,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACtC,IAAI,KAAKF,SAAS,CAACE,IAAI,CAAC;IACxF,IAAI,CAACwD,aAAa,EAAE;MAClBjE,GAAG,CAACgD,IAAI,CAAE,2BAA0BzC,SAAS,CAACE,IAAK,wBAAuB,CAAC;IAC7E,CAAC,MAAM;MACLwD,aAAa,CAACrC,IAAI,GAAGrB,SAAS,CAACqB,IAAI,IAAIqC,aAAa,CAACrC,IAAI;MACzDqC,aAAa,CAACtB,QAAQ,GAAGpC,SAAS,CAACoC,QAAQ,IAAIsB,aAAa,CAACtB,QAAQ;IACvE;EACF;EACA,OAAOoB,YAAY;AACrB"}
|
package/dist/adapter/device.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import type { Framebuffer, FramebufferProps } from './resources/framebuffer';
|
|
|
13
13
|
import type { RenderPass, RenderPassProps } from './resources/render-pass';
|
|
14
14
|
import type { ComputePass, ComputePassProps } from './resources/compute-pass';
|
|
15
15
|
import type { CommandEncoder, CommandEncoderProps } from './resources/command-encoder';
|
|
16
|
+
import type { VertexArray, VertexArrayProps } from './resources/vertex-array';
|
|
16
17
|
/** Device properties */
|
|
17
18
|
export type DeviceProps = {
|
|
18
19
|
id?: string;
|
|
@@ -65,7 +66,7 @@ export type DeviceLimits = {
|
|
|
65
66
|
readonly minUniformBufferOffsetAlignment?: number;
|
|
66
67
|
readonly minStorageBufferOffsetAlignment?: number;
|
|
67
68
|
readonly maxVertexBuffers?: number;
|
|
68
|
-
readonly maxVertexAttributes
|
|
69
|
+
readonly maxVertexAttributes: number;
|
|
69
70
|
readonly maxVertexBufferArrayStride?: number;
|
|
70
71
|
readonly maxInterStageShaderComponents?: number;
|
|
71
72
|
readonly maxComputeWorkgroupStorageSize?: number;
|
|
@@ -151,6 +152,8 @@ export declare abstract class Device {
|
|
|
151
152
|
/** Create a compute pipeline (aka program) */
|
|
152
153
|
abstract createComputePipeline(props: ComputePipelineProps): ComputePipeline;
|
|
153
154
|
createCommandEncoder(props?: CommandEncoderProps): CommandEncoder;
|
|
155
|
+
/** Create a vertex array */
|
|
156
|
+
abstract createVertexArray(props: VertexArrayProps): VertexArray;
|
|
154
157
|
/** Create a RenderPass */
|
|
155
158
|
abstract beginRenderPass(props?: RenderPassProps): RenderPass;
|
|
156
159
|
/** Create a ComputePass */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/adapter/device.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAY,MAAM,4BAA4B,CAAC;AAGnE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAC,aAAa,EAAE,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AACxE,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAC1C,OAAO,KAAK,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AACrF,OAAO,KAAK,EAAC,eAAe,EAAE,oBAAoB,EAAC,MAAM,8BAA8B,CAAC;AACxF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G,cAAc;IAIrE,4BAA4B;IAC5B,QAAQ,CAAC,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,WAAW;IAEhE,0BAA0B;IAC1B,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,eAAe,GAAG,UAAU;IAE7D,2BAA2B;IAC3B,QAAQ,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,gBAAgB,GAAG,WAAW;IAEhE,6EAA6E;IAC7E,QAAQ,CAAC,oBAAoB,IAAI,UAAU;IAI3C,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,GAAG,eAAe,GAAG,WAAW;CAsB3F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.js","names":["VERSION","lumaStats","log","uid","Buffer","DEFAULT_DEVICE_PROPS","id","type","canvas","container","webgl2","webgl1","manageState","width","height","debug","Boolean","get","break","gl","_Symbol$toStringTag","Symbol","toStringTag","Device","constructor","props","statsManager","userData","_lumaData","info","lost","canvasContext","toLowerCase","loseDevice","createTexture","Promise","data","_createTexture","createCommandEncoder","arguments","length","undefined","Error","_getBufferProps","ArrayBuffer","isView","newProps","usage","INDEX","indexType","Uint32Array","Uint16Array","warn"],"sources":["../../src/adapter/device.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {VERSION} from '../init';\nimport {StatsManager, lumaStats} from '../lib/utils/stats-manager';\nimport {log} from '../lib/utils/log';\nimport {uid} from '../lib/utils/utils';\nimport type {TextureFormat} from './types/texture-formats';\nimport type {CanvasContext, CanvasContextProps} from './canvas-context';\nimport type {BufferProps} from './resources/buffer';\nimport {Buffer} from './resources/buffer';\nimport type {RenderPipeline, RenderPipelineProps} from './resources/render-pipeline';\nimport type {ComputePipeline, ComputePipelineProps} from './resources/compute-pipeline';\nimport type {Sampler, SamplerProps} from './resources/sampler';\nimport type {Shader, ShaderProps} from './resources/shader';\nimport type {Texture, TextureProps, TextureData} from './resources/texture';\nimport type {ExternalTexture, ExternalTextureProps} from './resources/external-texture';\nimport type {Framebuffer, FramebufferProps} from './resources/framebuffer';\nimport type {RenderPass, RenderPassProps} from './resources/render-pass';\nimport type {ComputePass, ComputePassProps} from './resources/compute-pass';\nimport type {CommandEncoder, CommandEncoderProps} from './resources/command-encoder';\n\n/** Device properties */\nexport type DeviceProps = {\n id?: string;\n\n type?: 'webgl' | 'webgl1' | 'webgl2' | 'webgpu' | 'best-available';\n\n // Common parameters\n canvas?: HTMLCanvasElement | OffscreenCanvas | string | null; // A canvas element or a canvas string id\n container?: HTMLElement | string | null;\n width?: number /** width is only used when creating a new canvas */;\n height?: number /** height is only used when creating a new canvas */;\n\n // WebGLDevice parameters\n webgl2?: boolean; // Set to false to not create a WebGL2 context (force webgl1)\n webgl1?: boolean; // set to false to not create a WebGL1 context (fails if webgl2 not available)\n\n // WebGLContext PARAMETERS - Can only be set on context creation...\n // alpha?: boolean; // Default render target has an alpha buffer.\n // depth?: boolean; // Default render target has a depth buffer of at least 16 bits.\n // stencil?: boolean; // Default render target has a stencil buffer of at least 8 bits.\n // antialias?: boolean; // Boolean that indicates whether or not to perform anti-aliasing.\n // premultipliedAlpha?: boolean; // Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n // preserveDrawingBuffer?: boolean; // Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten\n // failIfMajorPerformanceCaveat?: boolean; // Do not create if the system performance is low.\n\n // Unclear if these are still supported\n debug?: boolean; // Instrument context (at the expense of performance)\n manageState?: boolean; // Set to false to disable WebGL state management instrumentation\n break?: string[]; // TODO: types\n\n // @deprecated Attach to existing context\n gl?: WebGLRenderingContext | WebGL2RenderingContext | null;\n};\n\nexport const DEFAULT_DEVICE_PROPS: Required<DeviceProps> = {\n id: null!,\n type: 'best-available',\n canvas: null,\n container: null,\n webgl2: true, // Attempt to create a WebGL2 context\n webgl1: true, // Attempt to create a WebGL1 context (false to fail if webgl2 not available)\n manageState: true,\n width: 800, // width are height are only used by headless gl\n height: 600,\n debug: Boolean(log.get('debug')), // Instrument context (at the expense of performance)\n break: [],\n\n // alpha: undefined,\n // depth: undefined,\n // stencil: undefined,\n // antialias: undefined,\n // premultipliedAlpha: undefined,\n // preserveDrawingBuffer: undefined,\n // failIfMajorPerformanceCaveat: undefined\n\n gl: null\n};\n\nexport type ShadingLanguage = 'glsl' | 'wgsl';\n\n/**\n * Identifies the GPU vendor and driver.\n * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_debug_renderer_info/\n * @note Current WebGPU support is very limited\n */\nexport type DeviceInfo = {\n type: 'webgl' | 'webgl2' | 'webgpu';\n vendor: string;\n renderer: string;\n version: string;\n gpu: 'nvidia' | 'amd' | 'intel' | 'apple' | 'software' | 'unknown';\n shadingLanguages: ShadingLanguage[];\n shadingLanguageVersions: Record<string, string>;\n vendorMasked?: string;\n rendererMasked?: string;\n};\n\n/** Limits for a device */\nexport type DeviceLimits = {\n readonly maxTextureDimension1D?: number;\n readonly maxTextureDimension2D?: number;\n readonly maxTextureDimension3D?: number;\n readonly maxTextureArrayLayers?: number;\n readonly maxBindGroups: number;\n readonly maxDynamicUniformBuffersPerPipelineLayout: number;\n readonly maxDynamicStorageBuffersPerPipelineLayout: number;\n readonly maxSampledTexturesPerShaderStage: number;\n readonly maxSamplersPerShaderStage: number;\n readonly maxStorageBuffersPerShaderStage: number;\n readonly maxStorageTexturesPerShaderStage: number;\n readonly maxUniformBuffersPerShaderStage: number;\n readonly maxUniformBufferBindingSize: number;\n readonly maxStorageBufferBindingSize?: number;\n readonly minUniformBufferOffsetAlignment?: number;\n readonly minStorageBufferOffsetAlignment?: number;\n readonly maxVertexBuffers?: number;\n readonly maxVertexAttributes?: number;\n readonly maxVertexBufferArrayStride?: number;\n readonly maxInterStageShaderComponents?: number;\n readonly maxComputeWorkgroupStorageSize?: number;\n readonly maxComputeInvocationsPerWorkgroup?: number;\n readonly maxComputeWorkgroupSizeX?: number;\n readonly maxComputeWorkgroupSizeY?: number;\n readonly maxComputeWorkgroupSizeZ?: number;\n readonly maxComputeWorkgroupsPerDimension?: number;\n};\n\nexport type WebGPUDeviceFeature =\n | 'depth-clip-control'\n | 'depth24unorm-stencil8'\n | 'depth32float-stencil8'\n | 'timestamp-query'\n | 'indirect-first-instance'\n | 'texture-compression-bc'\n | 'texture-compression-etc2'\n | 'texture-compression-astc';\n\n// obsolete...\n// 'depth-clamping' |\n// 'depth24unorm-stencil8' |\n// 'depth32float-stencil8' |\n// 'pipeline-statistics-query' |\n// 'timestamp-query' |\n// 'texture-compression-bc'\n\nexport type WebGLDeviceFeature =\n | 'webgpu'\n | 'webgl2'\n | 'webgl'\n\n // api support (unify with WebGPU timestamp-query?)\n | 'timer-query-webgl'\n | 'uniform-buffers-webgl'\n | 'uniforms-webgl'\n\n // texture filtering\n | 'texture-filter-linear-float32-webgl'\n | 'texture-filter-linear-float16-webgl'\n | 'texture-filter-anisotropic-webgl'\n\n // texture rendering\n | 'texture-renderable-float32-webgl'\n | 'texture-renderable-float16-webgl'\n | 'texture-renderable-rgba32float-webgl' // TODO - remove\n\n // texture blending\n | 'texture-blend-float-webgl1'\n\n // texture format support\n | 'texture-formats-norm16-webgl'\n | 'texture-formats-srgb-webgl1'\n | 'texture-formats-depth-webgl1'\n | 'texture-formats-float32-webgl1'\n | 'texture-formats-float16-webgl1'\n\n // api support\n | 'vertex-array-object-webgl1'\n | 'instanced-rendering-webgl1'\n | 'multiple-render-targets-webgl1'\n | 'index-uint32-webgl1'\n | 'blend-minmax-webgl1'\n\n // glsl extensions\n | 'glsl-frag-data'\n | 'glsl-frag-depth'\n | 'glsl-derivatives'\n | 'glsl-texture-lod';\n\ntype WebGLCompressedTextureFeatures =\n | 'texture-compression-bc5-webgl'\n | 'texture-compression-etc1-webgl'\n | 'texture-compression-pvrtc-webgl'\n | 'texture-compression-atc-webgl';\n\n/** Valid feature strings */\nexport type DeviceFeature =\n | WebGPUDeviceFeature\n | WebGLDeviceFeature\n | WebGLCompressedTextureFeatures;\n\n/**\n * WebGPU Device/WebGL context abstraction\n */\nexport abstract class Device {\n get [Symbol.toStringTag](): string {\n return 'Device';\n }\n\n static VERSION = VERSION;\n\n constructor(props: DeviceProps) {\n this.props = {...DEFAULT_DEVICE_PROPS, ...props};\n this.id = this.props.id || uid(this[Symbol.toStringTag].toLowerCase());\n }\n\n /** id of this device, primarily for debugging */\n readonly id: string;\n /** stats */\n readonly statsManager: StatsManager = lumaStats;\n /** A copy of the device props */\n readonly props: Required<DeviceProps>;\n /** Available for the application to store data on the device */\n userData: {[key: string]: unknown} = {};\n /** Used by other luma.gl modules to store data on the device */\n _lumaData: {[key: string]: unknown} = {};\n\n // Capabilities\n\n /** Information about the device (vendor, versions etc) */\n abstract info: DeviceInfo;\n\n /** Optional capability discovery */\n abstract get features(): Set<DeviceFeature>;\n\n /** WebGPU style device limits */\n abstract get limits(): DeviceLimits;\n\n /** Check if device supports a specific texture format (creation and `nearest` sampling) */\n abstract isTextureFormatSupported(format: TextureFormat): boolean;\n\n /** Check if linear filtering (sampler interpolation) is supported for a specific texture format */\n abstract isTextureFormatFilterable(format: TextureFormat): boolean;\n\n /** Check if device supports rendering to a specific texture format */\n abstract isTextureFormatRenderable(format: TextureFormat): boolean;\n\n // Device loss\n\n /** `true` if device is already lost */\n abstract get isLost(): boolean;\n\n /** Promise that resolves when device is lost */\n abstract readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n\n /** \n * Trigger device loss. \n * @returns `true` if context loss could actually be triggered. \n * @note primarily intended for testing how application reacts to device loss \n */\n loseDevice(): boolean {\n return false;\n }\n\n // Canvas context\n\n /** Default / primary canvas context. Can be null as WebGPU devices can be created without a CanvasContext */\n abstract canvasContext: CanvasContext | null;\n\n /** Creates a new CanvasContext (WebGPU only) */\n abstract createCanvasContext(props?: CanvasContextProps): CanvasContext;\n\n /** Call after rendering a frame (necessary e.g. on WebGL OffscreenCanvas) */\n abstract submit(): void;\n\n // Resource creation\n\n /** Create a buffer */\n abstract createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): Buffer;\n\n /** Create a texture */\n abstract _createTexture(props: TextureProps): Texture;\n createTexture(props: TextureProps): Texture;\n createTexture(data: Promise<TextureData>): Texture;\n createTexture(url: string): Texture;\n\n createTexture(props: TextureProps | Promise<TextureData> | string): Texture {\n // Signature: new Texture2D(gl, url | Promise)\n if (props instanceof Promise || typeof props === 'string') {\n props = {data: props};\n }\n return this._createTexture(props);\n }\n\n /** Create a temporary texture view of a video source */\n abstract createExternalTexture(props: ExternalTextureProps): ExternalTexture;\n\n /** Create a sampler */\n abstract createSampler(props: SamplerProps): Sampler;\n\n abstract createFramebuffer(props: FramebufferProps): Framebuffer;\n\n /** Create a shader */\n abstract createShader(props: ShaderProps): Shader;\n\n /** Create a render pipeline (aka program) */\n abstract createRenderPipeline(props: RenderPipelineProps): RenderPipeline;\n\n /** Create a compute pipeline (aka program) */\n abstract createComputePipeline(props: ComputePipelineProps): ComputePipeline;\n\n createCommandEncoder(props: CommandEncoderProps = {}): CommandEncoder {\n throw new Error('not implemented');\n }\n\n /** Create a RenderPass */\n abstract beginRenderPass(props?: RenderPassProps): RenderPass;\n\n /** Create a ComputePass */\n abstract beginComputePass(props?: ComputePassProps): ComputePass;\n\n /** Get a renderpass that is set up to render to the primary CanvasContext */\n abstract getDefaultRenderPass(): RenderPass;\n\n // Resource creation helpers\n\n protected _getBufferProps(props: BufferProps | ArrayBuffer | ArrayBufferView): BufferProps {\n\n if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) {\n props = {data: props};\n }\n\n // TODO - fragile, as this is done before we merge with default options\n // inside the Buffer constructor\n\n const newProps = {...props};\n // Deduce indexType\n if ((props.usage || 0) & Buffer.INDEX && !props.indexType) {\n if (props.data instanceof Uint32Array) {\n newProps.indexType = 'uint32';\n } else if (props.data instanceof Uint16Array) {\n newProps.indexType = 'uint16';\n } else {\n log.warn('indices buffer content must be of integer type')();\n }\n }\n return newProps; \n }\n}\n"],"mappings":";SACQA,OAAO;AAAA,SACOC,SAAS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GAAG;QAACW,IAAI,EAAEX;MAAK,CAAC;IACvB;IACA,OAAO,IAAI,CAACY,cAAc,CAACZ,KAAK,CAAC;EACnC;EAmBAa,oBAAoBA,CAAA,EAAkD;IAAA,IAAjDb,KAA0B,GAAAc,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAClD,MAAM,IAAIG,KAAK,CAAC,iBAAiB,CAAC;EACpC;EAaUC,eAAeA,CAAClB,KAAkD,EAAe;IAEzF,IAAIA,KAAK,YAAYmB,WAAW,IAAIA,WAAW,CAACC,MAAM,CAACpB,KAAK,CAAC,EAAE;MAC7DA,KAAK,GAAG;QAACW,IAAI,EAAEX;MAAK,CAAC;IACvB;IAKA,MAAMqB,QAAQ,GAAG;MAAC,GAAGrB;IAAK,CAAC;IAE3B,IAAI,CAACA,KAAK,CAACsB,KAAK,IAAI,CAAC,IAAI3C,MAAM,CAAC4C,KAAK,IAAI,CAACvB,KAAK,CAACwB,SAAS,EAAE;MACzD,IAAIxB,KAAK,CAACW,IAAI,YAAYc,WAAW,EAAE;QACrCJ,QAAQ,CAACG,SAAS,GAAG,QAAQ;MAC/B,CAAC,MAAM,IAAIxB,KAAK,CAACW,IAAI,YAAYe,WAAW,EAAE;QAC5CL,QAAQ,CAACG,SAAS,GAAG,QAAQ;MAC/B,CAAC,MAAM;QACL/C,GAAG,CAACkD,IAAI,CAAC,gDAAgD,CAAC,CAAC,CAAC;MAC9D;IACF;IACA,OAAON,QAAQ;EACjB;AACF;AAhJsBvB,MAAM,CAKnBvB,OAAO,GAAGA,OAAO"}
|
|
1
|
+
{"version":3,"file":"device.js","names":["VERSION","lumaStats","log","uid","Buffer","DEFAULT_DEVICE_PROPS","id","type","canvas","container","webgl2","webgl1","manageState","width","height","debug","Boolean","get","break","gl","_Symbol$toStringTag","Symbol","toStringTag","Device","constructor","props","statsManager","userData","_lumaData","info","lost","canvasContext","toLowerCase","loseDevice","createTexture","Promise","data","_createTexture","createCommandEncoder","arguments","length","undefined","Error","_getBufferProps","ArrayBuffer","isView","newProps","usage","INDEX","indexType","Uint32Array","Uint16Array","warn"],"sources":["../../src/adapter/device.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {VERSION} from '../init';\nimport {StatsManager, lumaStats} from '../lib/utils/stats-manager';\nimport {log} from '../lib/utils/log';\nimport {uid} from '../lib/utils/utils';\nimport type {TextureFormat} from './types/texture-formats';\nimport type {CanvasContext, CanvasContextProps} from './canvas-context';\nimport type {BufferProps} from './resources/buffer';\nimport {Buffer} from './resources/buffer';\nimport type {RenderPipeline, RenderPipelineProps} from './resources/render-pipeline';\nimport type {ComputePipeline, ComputePipelineProps} from './resources/compute-pipeline';\nimport type {Sampler, SamplerProps} from './resources/sampler';\nimport type {Shader, ShaderProps} from './resources/shader';\nimport type {Texture, TextureProps, TextureData} from './resources/texture';\nimport type {ExternalTexture, ExternalTextureProps} from './resources/external-texture';\nimport type {Framebuffer, FramebufferProps} from './resources/framebuffer';\nimport type {RenderPass, RenderPassProps} from './resources/render-pass';\nimport type {ComputePass, ComputePassProps} from './resources/compute-pass';\nimport type {CommandEncoder, CommandEncoderProps} from './resources/command-encoder';\nimport type {VertexArray, VertexArrayProps} from './resources/vertex-array';\n\n/** Device properties */\nexport type DeviceProps = {\n id?: string;\n\n type?: 'webgl' | 'webgl1' | 'webgl2' | 'webgpu' | 'best-available';\n\n // Common parameters\n canvas?: HTMLCanvasElement | OffscreenCanvas | string | null; // A canvas element or a canvas string id\n container?: HTMLElement | string | null;\n width?: number /** width is only used when creating a new canvas */;\n height?: number /** height is only used when creating a new canvas */;\n\n // WebGLDevice parameters\n webgl2?: boolean; // Set to false to not create a WebGL2 context (force webgl1)\n webgl1?: boolean; // set to false to not create a WebGL1 context (fails if webgl2 not available)\n\n // WebGLContext PARAMETERS - Can only be set on context creation...\n // alpha?: boolean; // Default render target has an alpha buffer.\n // depth?: boolean; // Default render target has a depth buffer of at least 16 bits.\n // stencil?: boolean; // Default render target has a stencil buffer of at least 8 bits.\n // antialias?: boolean; // Boolean that indicates whether or not to perform anti-aliasing.\n // premultipliedAlpha?: boolean; // Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n // preserveDrawingBuffer?: boolean; // Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten\n // failIfMajorPerformanceCaveat?: boolean; // Do not create if the system performance is low.\n\n // Unclear if these are still supported\n debug?: boolean; // Instrument context (at the expense of performance)\n manageState?: boolean; // Set to false to disable WebGL state management instrumentation\n break?: string[]; // TODO: types\n\n // @deprecated Attach to existing context\n gl?: WebGLRenderingContext | WebGL2RenderingContext | null;\n};\n\nexport const DEFAULT_DEVICE_PROPS: Required<DeviceProps> = {\n id: null!,\n type: 'best-available',\n canvas: null,\n container: null,\n webgl2: true, // Attempt to create a WebGL2 context\n webgl1: true, // Attempt to create a WebGL1 context (false to fail if webgl2 not available)\n manageState: true,\n width: 800, // width are height are only used by headless gl\n height: 600,\n debug: Boolean(log.get('debug')), // Instrument context (at the expense of performance)\n break: [],\n\n // alpha: undefined,\n // depth: undefined,\n // stencil: undefined,\n // antialias: undefined,\n // premultipliedAlpha: undefined,\n // preserveDrawingBuffer: undefined,\n // failIfMajorPerformanceCaveat: undefined\n\n gl: null\n};\n\nexport type ShadingLanguage = 'glsl' | 'wgsl';\n\n/**\n * Identifies the GPU vendor and driver.\n * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_debug_renderer_info/\n * @note Current WebGPU support is very limited\n */\nexport type DeviceInfo = {\n type: 'webgl' | 'webgl2' | 'webgpu';\n vendor: string;\n renderer: string;\n version: string;\n gpu: 'nvidia' | 'amd' | 'intel' | 'apple' | 'software' | 'unknown';\n shadingLanguages: ShadingLanguage[];\n shadingLanguageVersions: Record<string, string>;\n vendorMasked?: string;\n rendererMasked?: string;\n};\n\n/** Limits for a device */\nexport type DeviceLimits = {\n readonly maxTextureDimension1D?: number;\n readonly maxTextureDimension2D?: number;\n readonly maxTextureDimension3D?: number;\n readonly maxTextureArrayLayers?: number;\n readonly maxBindGroups: number;\n readonly maxDynamicUniformBuffersPerPipelineLayout: number;\n readonly maxDynamicStorageBuffersPerPipelineLayout: number;\n readonly maxSampledTexturesPerShaderStage: number;\n readonly maxSamplersPerShaderStage: number;\n readonly maxStorageBuffersPerShaderStage: number;\n readonly maxStorageTexturesPerShaderStage: number;\n readonly maxUniformBuffersPerShaderStage: number;\n readonly maxUniformBufferBindingSize: number;\n readonly maxStorageBufferBindingSize?: number;\n readonly minUniformBufferOffsetAlignment?: number;\n readonly minStorageBufferOffsetAlignment?: number;\n readonly maxVertexBuffers?: number;\n readonly maxVertexAttributes: number;\n readonly maxVertexBufferArrayStride?: number;\n readonly maxInterStageShaderComponents?: number;\n readonly maxComputeWorkgroupStorageSize?: number;\n readonly maxComputeInvocationsPerWorkgroup?: number;\n readonly maxComputeWorkgroupSizeX?: number;\n readonly maxComputeWorkgroupSizeY?: number;\n readonly maxComputeWorkgroupSizeZ?: number;\n readonly maxComputeWorkgroupsPerDimension?: number;\n};\n\nexport type WebGPUDeviceFeature =\n | 'depth-clip-control'\n | 'depth24unorm-stencil8'\n | 'depth32float-stencil8'\n | 'timestamp-query'\n | 'indirect-first-instance'\n | 'texture-compression-bc'\n | 'texture-compression-etc2'\n | 'texture-compression-astc';\n\n// obsolete...\n// 'depth-clamping' |\n// 'depth24unorm-stencil8' |\n// 'depth32float-stencil8' |\n// 'pipeline-statistics-query' |\n// 'timestamp-query' |\n// 'texture-compression-bc'\n\nexport type WebGLDeviceFeature =\n | 'webgpu'\n | 'webgl2'\n | 'webgl'\n\n // api support (unify with WebGPU timestamp-query?)\n | 'timer-query-webgl'\n | 'uniform-buffers-webgl'\n | 'uniforms-webgl'\n\n // texture filtering\n | 'texture-filter-linear-float32-webgl'\n | 'texture-filter-linear-float16-webgl'\n | 'texture-filter-anisotropic-webgl'\n\n // texture rendering\n | 'texture-renderable-float32-webgl'\n | 'texture-renderable-float16-webgl'\n | 'texture-renderable-rgba32float-webgl' // TODO - remove\n\n // texture blending\n | 'texture-blend-float-webgl1'\n\n // texture format support\n | 'texture-formats-norm16-webgl'\n | 'texture-formats-srgb-webgl1'\n | 'texture-formats-depth-webgl1'\n | 'texture-formats-float32-webgl1'\n | 'texture-formats-float16-webgl1'\n\n // api support\n | 'vertex-array-object-webgl1'\n | 'instanced-rendering-webgl1'\n | 'multiple-render-targets-webgl1'\n | 'index-uint32-webgl1'\n | 'blend-minmax-webgl1'\n\n // glsl extensions\n | 'glsl-frag-data'\n | 'glsl-frag-depth'\n | 'glsl-derivatives'\n | 'glsl-texture-lod';\n\ntype WebGLCompressedTextureFeatures =\n | 'texture-compression-bc5-webgl'\n | 'texture-compression-etc1-webgl'\n | 'texture-compression-pvrtc-webgl'\n | 'texture-compression-atc-webgl';\n\n/** Valid feature strings */\nexport type DeviceFeature =\n | WebGPUDeviceFeature\n | WebGLDeviceFeature\n | WebGLCompressedTextureFeatures;\n\n/**\n * WebGPU Device/WebGL context abstraction\n */\nexport abstract class Device {\n get [Symbol.toStringTag](): string {\n return 'Device';\n }\n\n static VERSION = VERSION;\n\n constructor(props: DeviceProps) {\n this.props = {...DEFAULT_DEVICE_PROPS, ...props};\n this.id = this.props.id || uid(this[Symbol.toStringTag].toLowerCase());\n }\n\n /** id of this device, primarily for debugging */\n readonly id: string;\n /** stats */\n readonly statsManager: StatsManager = lumaStats;\n /** A copy of the device props */\n readonly props: Required<DeviceProps>;\n /** Available for the application to store data on the device */\n userData: {[key: string]: unknown} = {};\n /** Used by other luma.gl modules to store data on the device */\n _lumaData: {[key: string]: unknown} = {};\n\n // Capabilities\n\n /** Information about the device (vendor, versions etc) */\n abstract info: DeviceInfo;\n\n /** Optional capability discovery */\n abstract get features(): Set<DeviceFeature>;\n\n /** WebGPU style device limits */\n abstract get limits(): DeviceLimits;\n\n /** Check if device supports a specific texture format (creation and `nearest` sampling) */\n abstract isTextureFormatSupported(format: TextureFormat): boolean;\n\n /** Check if linear filtering (sampler interpolation) is supported for a specific texture format */\n abstract isTextureFormatFilterable(format: TextureFormat): boolean;\n\n /** Check if device supports rendering to a specific texture format */\n abstract isTextureFormatRenderable(format: TextureFormat): boolean;\n\n // Device loss\n\n /** `true` if device is already lost */\n abstract get isLost(): boolean;\n\n /** Promise that resolves when device is lost */\n abstract readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n\n /** \n * Trigger device loss. \n * @returns `true` if context loss could actually be triggered. \n * @note primarily intended for testing how application reacts to device loss \n */\n loseDevice(): boolean {\n return false;\n }\n\n // Canvas context\n\n /** Default / primary canvas context. Can be null as WebGPU devices can be created without a CanvasContext */\n abstract canvasContext: CanvasContext | null;\n\n /** Creates a new CanvasContext (WebGPU only) */\n abstract createCanvasContext(props?: CanvasContextProps): CanvasContext;\n\n /** Call after rendering a frame (necessary e.g. on WebGL OffscreenCanvas) */\n abstract submit(): void;\n\n // Resource creation\n\n /** Create a buffer */\n abstract createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): Buffer;\n\n /** Create a texture */\n abstract _createTexture(props: TextureProps): Texture;\n createTexture(props: TextureProps): Texture;\n createTexture(data: Promise<TextureData>): Texture;\n createTexture(url: string): Texture;\n\n createTexture(props: TextureProps | Promise<TextureData> | string): Texture {\n // Signature: new Texture2D(gl, url | Promise)\n if (props instanceof Promise || typeof props === 'string') {\n props = {data: props};\n }\n return this._createTexture(props);\n }\n\n /** Create a temporary texture view of a video source */\n abstract createExternalTexture(props: ExternalTextureProps): ExternalTexture;\n\n /** Create a sampler */\n abstract createSampler(props: SamplerProps): Sampler;\n\n abstract createFramebuffer(props: FramebufferProps): Framebuffer;\n\n /** Create a shader */\n abstract createShader(props: ShaderProps): Shader;\n\n /** Create a render pipeline (aka program) */\n abstract createRenderPipeline(props: RenderPipelineProps): RenderPipeline;\n\n /** Create a compute pipeline (aka program) */\n abstract createComputePipeline(props: ComputePipelineProps): ComputePipeline;\n\n createCommandEncoder(props: CommandEncoderProps = {}): CommandEncoder {\n throw new Error('not implemented');\n }\n\n /** Create a vertex array */\n abstract createVertexArray(props: VertexArrayProps): VertexArray;\n\n /** Create a RenderPass */\n abstract beginRenderPass(props?: RenderPassProps): RenderPass;\n\n /** Create a ComputePass */\n abstract beginComputePass(props?: ComputePassProps): ComputePass;\n\n /** Get a renderpass that is set up to render to the primary CanvasContext */\n abstract getDefaultRenderPass(): RenderPass;\n\n // Resource creation helpers\n\n protected _getBufferProps(props: BufferProps | ArrayBuffer | ArrayBufferView): BufferProps {\n\n if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) {\n props = {data: props};\n }\n\n // TODO - fragile, as this is done before we merge with default options\n // inside the Buffer constructor\n\n const newProps = {...props};\n // Deduce indexType\n if ((props.usage || 0) & Buffer.INDEX && !props.indexType) {\n if (props.data instanceof Uint32Array) {\n newProps.indexType = 'uint32';\n } else if (props.data instanceof Uint16Array) {\n newProps.indexType = 'uint16';\n } else {\n log.warn('indices buffer content must be of integer type')();\n }\n }\n return newProps; \n }\n}\n"],"mappings":";SACQA,OAAO;AAAA,SACOC,SAAS;AAAA,SACvBC,GAAG;AAAA,SACHC,GAAG;AAAA,SAIHC,MAAM;AA+Cd,OAAO,MAAMC,oBAA2C,GAAG;EACzDC,EAAE,EAAE,IAAK;EACTC,IAAI,EAAE,gBAAgB;EACtBC,MAAM,EAAE,IAAI;EACZC,SAAS,EAAE,IAAI;EACfC,MAAM,EAAE,IAAI;EACZC,MAAM,EAAE,IAAI;EACZC,WAAW,EAAE,IAAI;EACjBC,KAAK,EAAE,GAAG;EACVC,MAAM,EAAE,GAAG;EACXC,KAAK,EAAEC,OAAO,CAACd,GAAG,CAACe,GAAG,CAAC,OAAO,CAAC,CAAC;EAChCC,KAAK,EAAE,EAAE;EAUTC,EAAE,EAAE;AACN,CAAC;AAACC,mBAAA,GAgIKC,MAAM,CAACC,WAAW;AADzB,OAAO,MAAeC,MAAM,CAAC;EAC3B,KAAAH,mBAAA,IAAmC;IACjC,OAAO,QAAQ;EACjB;EAIAI,WA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AAM,CAAC4C,KAAK,IAAI,CAACvB,KAAK,CAACwB,SAAS,EAAE;MACzD,IAAIxB,KAAK,CAACW,IAAI,YAAYc,WAAW,EAAE;QACrCJ,QAAQ,CAACG,SAAS,GAAG,QAAQ;MAC/B,CAAC,MAAM,IAAIxB,KAAK,CAACW,IAAI,YAAYe,WAAW,EAAE;QAC5CL,QAAQ,CAACG,SAAS,GAAG,QAAQ;MAC/B,CAAC,MAAM;QACL/C,GAAG,CAACkD,IAAI,CAAC,gDAAgD,CAAC,CAAC,CAAC;MAC9D;IACF;IACA,OAAON,QAAQ;EACjB;AACF;AAnJsBvB,MAAM,CAKnBvB,OAAO,GAAGA,OAAO"}
|
|
@@ -23,9 +23,13 @@ export declare abstract class Buffer extends Resource<BufferProps> {
|
|
|
23
23
|
static MAP_WRITE: number;
|
|
24
24
|
static COPY_SRC: number;
|
|
25
25
|
static COPY_DST: number;
|
|
26
|
+
/** Index buffer */
|
|
26
27
|
static INDEX: number;
|
|
28
|
+
/** Vertex buffer */
|
|
27
29
|
static VERTEX: number;
|
|
30
|
+
/** Uniform buffer */
|
|
28
31
|
static UNIFORM: number;
|
|
32
|
+
/** Storage buffer */
|
|
29
33
|
static STORAGE: number;
|
|
30
34
|
static INDIRECT: number;
|
|
31
35
|
static QUERY_RESOLVE: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/buffer.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACtC,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAEnD,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG;IACxC,uEAAuE;IACvE,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,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AAC,WAAW,CAAC,IAAI,MAAM,CAAqB;IAEhE,mDAAmD;IACnD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACzC,gCAAgC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW;IAkB9C,KAAK,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IACvD,SAAS,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAEzE,OAAO,IAAI,UAAU;CAoDtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.js","names":["Resource","_Symbol$toStringTag","Symbol","toStringTag","Buffer","constructor","device","props","deducedProps","usage","INDEX","indexType","data","Uint32Array","Uint16Array","defaultProps","byteLength","write","byteOffset","Error","readAsync","getData","mappedAtCreation","MAP_READ","MAP_WRITE","COPY_SRC","COPY_DST","VERTEX","UNIFORM","STORAGE","INDIRECT","QUERY_RESOLVE"],"sources":["../../../src/adapter/resources/buffer.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {TypedArray} from '../..';\nimport type {Device} from '../device';\nimport {Resource, ResourceProps} from './resource';\n\nexport type BufferProps = ResourceProps & {\n /** Supply a handle to connect to an existing device-specific buffer */\n handle?: WebGLBuffer;\n /** Specifies how this buffer can be used */\n usage?: number;\n /** Length in bytes of memory to be allocated. If not specified, `byteLength` of `props.data` will be used. */\n byteLength?: number;\n /** Data to initialize the buffer with. */\n data?: ArrayBuffer | ArrayBufferView | null;\n /** Byte offset into the newly created Buffer to store data at */\n byteOffset?: number;\n /** If props.usage includes Buffer.INDEX */\n indexType?: 'uint16' | 'uint32';\n\n // TBD\n mappedAtCreation?: boolean;\n}\n\n/** Abstract GPU buffer */\nexport abstract class Buffer extends Resource<BufferProps> {\n static override defaultProps: Required<BufferProps> = {\n ...Resource.defaultProps,\n usage: 0, // Buffer.COPY_DST | Buffer.COPY_SRC\n byteLength: 0,\n byteOffset: 0,\n data: null,\n indexType: 'uint16',\n mappedAtCreation: false\n };\n\n // Usage Flags\n static MAP_READ = 0x01;\n static MAP_WRITE = 0x02;\n static COPY_SRC = 0x0004;\n static COPY_DST = 0x0008;\n static INDEX = 0x0010;\n static VERTEX = 0x0020;\n static UNIFORM = 0x0040;\n static STORAGE = 0x0080;\n static INDIRECT = 0x0100;\n static QUERY_RESOLVE = 0x0200;\n\n override get [Symbol.toStringTag](): string { return 'Buffer'; }\n\n /** The usage with which this buffer was created */\n readonly usage: number;\n /** For index buffers, whether indices are 16 or 32 bit */\n readonly indexType?: 'uint16' | 'uint32';\n /** Length of buffer in bytes */\n abstract byteLength: number;\n\n constructor(device: Device, props: BufferProps) {\n const deducedProps = {...props};\n\n // Deduce indexType\n if ((props.usage || 0) & Buffer.INDEX && !props.indexType) {\n if (props.data instanceof Uint32Array) {\n deducedProps.indexType = 'uint32';\n } else if (props.data instanceof Uint16Array) {\n deducedProps.indexType = 'uint16';\n }\n }\n\n super(device, deducedProps, Buffer.defaultProps);\n\n this.usage = props.usage || 0;\n this.indexType = deducedProps.indexType;\n }\n\n write(data: ArrayBufferView, byteOffset?: number): void { throw new Error('not implemented'); }\n readAsync(byteOffset?: number, byteLength?: number): Promise<ArrayBuffer> { throw new Error('not implemented'); }\n // TODO - can sync read be supported in WebGPU?\n getData(): TypedArray { throw new Error('not implemented'); }\n\n // Convenience API\n\n /** Read data from the buffer *\n async readAsync(options: {\n byteOffset?: number,\n byteLength?: number,\n map?: boolean,\n unmap?: boolean\n }): Promise<ArrayBuffer> {\n if (options.map ?? true) {\n await this.mapAsync(Buffer.MAP_READ, options.byteOffset, options.byteLength);\n }\n const arrayBuffer = this.getMappedRange(options.byteOffset, options.byteLength);\n if (options.unmap ?? true) {\n this.unmap();\n }\n return arrayBuffer;\n }\n\n /** Write data to the buffer *\n async writeAsync(options: {\n data: ArrayBuffer,\n byteOffset?: number,\n byteLength?: number,\n map?: boolean,\n unmap?: boolean\n }): Promise<void> {\n if (options.map ?? true) {\n await this.mapAsync(Buffer.MAP_WRITE, options.byteOffset, options.byteLength);\n }\n const arrayBuffer = this.getMappedRange(options.byteOffset, options.byteLength);\n const destArray = new Uint8Array(arrayBuffer);\n const srcArray = new Uint8Array(options.data);\n destArray.set(srcArray);\n if (options.unmap ?? true) {\n this.unmap();\n }\n }\n */\n\n // Mapped API (WebGPU)\n\n /** Maps the memory so that it can be read */\n // abstract mapAsync(mode, byteOffset, byteLength): Promise<void>\n\n /** Get the mapped range of data for reading or writing */\n // abstract getMappedRange(byteOffset, byteLength): ArrayBuffer;\n\n /** unmap makes the contents of the buffer available to the GPU again */\n // abstract unmap(): void;\n}\n"],"mappings":";SAGQA,QAAQ;AAAAC,mBAAA,
|
|
1
|
+
{"version":3,"file":"buffer.js","names":["Resource","_Symbol$toStringTag","Symbol","toStringTag","Buffer","constructor","device","props","deducedProps","usage","INDEX","indexType","data","Uint32Array","Uint16Array","defaultProps","byteLength","write","byteOffset","Error","readAsync","getData","mappedAtCreation","MAP_READ","MAP_WRITE","COPY_SRC","COPY_DST","VERTEX","UNIFORM","STORAGE","INDIRECT","QUERY_RESOLVE"],"sources":["../../../src/adapter/resources/buffer.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {TypedArray} from '../..';\nimport type {Device} from '../device';\nimport {Resource, ResourceProps} from './resource';\n\nexport type BufferProps = ResourceProps & {\n /** Supply a handle to connect to an existing device-specific buffer */\n handle?: WebGLBuffer;\n /** Specifies how this buffer can be used */\n usage?: number;\n /** Length in bytes of memory to be allocated. If not specified, `byteLength` of `props.data` will be used. */\n byteLength?: number;\n /** Data to initialize the buffer with. */\n data?: ArrayBuffer | ArrayBufferView | null;\n /** Byte offset into the newly created Buffer to store data at */\n byteOffset?: number;\n /** If props.usage includes Buffer.INDEX */\n indexType?: 'uint16' | 'uint32';\n\n // TBD\n mappedAtCreation?: boolean;\n}\n\n/** Abstract GPU buffer */\nexport abstract class Buffer extends Resource<BufferProps> {\n static override defaultProps: Required<BufferProps> = {\n ...Resource.defaultProps,\n usage: 0, // Buffer.COPY_DST | Buffer.COPY_SRC\n byteLength: 0,\n byteOffset: 0,\n data: null,\n indexType: 'uint16',\n mappedAtCreation: false\n };\n\n // Usage Flags\n static MAP_READ = 0x01;\n static MAP_WRITE = 0x02;\n static COPY_SRC = 0x0004;\n static COPY_DST = 0x0008;\n /** Index buffer */\n static INDEX = 0x0010;\n /** Vertex buffer */\n static VERTEX = 0x0020;\n /** Uniform buffer */\n static UNIFORM = 0x0040;\n /** Storage buffer */\n static STORAGE = 0x0080;\n static INDIRECT = 0x0100;\n static QUERY_RESOLVE = 0x0200;\n\n override get [Symbol.toStringTag](): string { return 'Buffer'; }\n\n /** The usage with which this buffer was created */\n readonly usage: number;\n /** For index buffers, whether indices are 16 or 32 bit */\n readonly indexType?: 'uint16' | 'uint32';\n /** Length of buffer in bytes */\n abstract byteLength: number;\n\n constructor(device: Device, props: BufferProps) {\n const deducedProps = {...props};\n\n // Deduce indexType\n if ((props.usage || 0) & Buffer.INDEX && !props.indexType) {\n if (props.data instanceof Uint32Array) {\n deducedProps.indexType = 'uint32';\n } else if (props.data instanceof Uint16Array) {\n deducedProps.indexType = 'uint16';\n }\n }\n\n super(device, deducedProps, Buffer.defaultProps);\n\n this.usage = props.usage || 0;\n this.indexType = deducedProps.indexType;\n }\n\n write(data: ArrayBufferView, byteOffset?: number): void { throw new Error('not implemented'); }\n readAsync(byteOffset?: number, byteLength?: number): Promise<ArrayBuffer> { throw new Error('not implemented'); }\n // TODO - can sync read be supported in WebGPU?\n getData(): TypedArray { throw new Error('not implemented'); }\n\n // Convenience API\n\n /** Read data from the buffer *\n async readAsync(options: {\n byteOffset?: number,\n byteLength?: number,\n map?: boolean,\n unmap?: boolean\n }): Promise<ArrayBuffer> {\n if (options.map ?? true) {\n await this.mapAsync(Buffer.MAP_READ, options.byteOffset, options.byteLength);\n }\n const arrayBuffer = this.getMappedRange(options.byteOffset, options.byteLength);\n if (options.unmap ?? true) {\n this.unmap();\n }\n return arrayBuffer;\n }\n\n /** Write data to the buffer *\n async writeAsync(options: {\n data: ArrayBuffer,\n byteOffset?: number,\n byteLength?: number,\n map?: boolean,\n unmap?: boolean\n }): Promise<void> {\n if (options.map ?? true) {\n await this.mapAsync(Buffer.MAP_WRITE, options.byteOffset, options.byteLength);\n }\n const arrayBuffer = this.getMappedRange(options.byteOffset, options.byteLength);\n const destArray = new Uint8Array(arrayBuffer);\n const srcArray = new Uint8Array(options.data);\n destArray.set(srcArray);\n if (options.unmap ?? true) {\n this.unmap();\n }\n }\n */\n\n // Mapped API (WebGPU)\n\n /** Maps the memory so that it can be read */\n // abstract mapAsync(mode, byteOffset, byteLength): Promise<void>\n\n /** Get the mapped range of data for reading or writing */\n // abstract getMappedRange(byteOffset, byteLength): ArrayBuffer;\n\n /** unmap makes the contents of the buffer available to the GPU again */\n // abstract unmap(): void;\n}\n"],"mappings":";SAGQA,QAAQ;AAAAC,mBAAA,GAgDAC,MAAM,CAACC,WAAW;AA3BlC,OAAO,MAAeC,MAAM,SAASJ,QAAQ,CAAc;EA2BzD,KAAAC,mBAAA,IAA4C;IAAE,OAAO,QAAQ;EAAE;EAS/DI,WAAWA,CAACC,MAAc,EAAEC,KAAkB,EAAE;IAC9C,MAAMC,YAAY,GAAG;MAAC,GAAGD;IAAK,CAAC;IAG/B,IAAI,CAACA,KAAK,CAACE,KAAK,IAAI,CAAC,IAAIL,MAAM,CAACM,KAAK,IAAI,CAACH,KAAK,CAACI,SAAS,EAAE;MACzD,IAAIJ,KAAK,CAACK,IAAI,YAAYC,WAAW,EAAE;QACrCL,YAAY,CAACG,SAAS,GAAG,QAAQ;MACnC,CAAC,MAAM,IAAIJ,KAAK,CAACK,IAAI,YAAYE,WAAW,EAA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Aa,GAAG,MAAM"}
|
|
@@ -2,7 +2,7 @@ import type { Device } from '../device';
|
|
|
2
2
|
import type { RenderPassParameters } from '../types/parameters';
|
|
3
3
|
import { Resource, ResourceProps } from './resource';
|
|
4
4
|
import { Framebuffer } from './framebuffer';
|
|
5
|
-
import {
|
|
5
|
+
import { NumberArray } from '../..';
|
|
6
6
|
/**
|
|
7
7
|
* Properties for a RenderPass instance is a required parameter to all draw calls.
|
|
8
8
|
*/
|
|
@@ -12,7 +12,7 @@ export type RenderPassProps = ResourceProps & {
|
|
|
12
12
|
/** Control viewport, scissor rect, blend constant and stencil ref */
|
|
13
13
|
parameters?: RenderPassParameters;
|
|
14
14
|
/** Clear value for color attachment, or `load` to preserve the previous value */
|
|
15
|
-
clearColor?:
|
|
15
|
+
clearColor?: NumberArray | false;
|
|
16
16
|
/** Clear value for depth attachment, or `load` to preserve the previous value */
|
|
17
17
|
clearDepth?: number | false;
|
|
18
18
|
/** Clear value for stencil attachment, or `load` to preserve the previous value */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/render-pass.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAInD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"render-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/render-pass.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY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,"file":"render-pass.js","names":["Resource","_Symbol$toStringTag","Symbol","toStringTag","RenderPass","constructor","device","props","defaultProps","framebuffer","parameters","undefined","clearColor","clearDepth","clearStencil","depthReadOnly","stencilReadOnly","discard"],"sources":["../../../src/adapter/resources/render-pass.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {Device} from '../device'\nimport type { RenderPassParameters } from '../types/parameters';\n// import {Binding} from '../types/shader-layout';\nimport {Resource, ResourceProps} from './resource';\n// import {Buffer} from './buffer';\n// import {RenderPipeline} from './render-pipeline';\n// import {CommandEncoder} from './command-encoder';\nimport {Framebuffer} from './framebuffer';\nimport {
|
|
1
|
+
{"version":3,"file":"render-pass.js","names":["Resource","_Symbol$toStringTag","Symbol","toStringTag","RenderPass","constructor","device","props","defaultProps","framebuffer","parameters","undefined","clearColor","clearDepth","clearStencil","depthReadOnly","stencilReadOnly","discard"],"sources":["../../../src/adapter/resources/render-pass.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {Device} from '../device'\nimport type { RenderPassParameters } from '../types/parameters';\n// import {Binding} from '../types/shader-layout';\nimport {Resource, ResourceProps} from './resource';\n// import {Buffer} from './buffer';\n// import {RenderPipeline} from './render-pipeline';\n// import {CommandEncoder} from './command-encoder';\nimport {Framebuffer} from './framebuffer';\nimport {NumberArray} from '../..';\n\n/**\n * Properties for a RenderPass instance is a required parameter to all draw calls.\n */\nexport type RenderPassProps = ResourceProps & {\n /** Framebuffer specifies which textures to render into. Default gets framebuffer from canvas context. */\n framebuffer?: Framebuffer | null;\n /** Control viewport, scissor rect, blend constant and stencil ref */\n parameters?: RenderPassParameters;\n /** Clear value for color attachment, or `load` to preserve the previous value */\n clearColor?: NumberArray | false;\n /** Clear value for depth attachment, or `load` to preserve the previous value */\n clearDepth?: number | false;\n /** Clear value for stencil attachment, or `load` to preserve the previous value */\n clearStencil?: number | false;\n /** Indicates that the depth component is read only. */\n depthReadOnly?: boolean;\n /** Indicates that the stencil component is read only. */\n stencilReadOnly?: boolean;\n /** Whether to disable / discard the output of the rasterizer */\n discard?: boolean; \n};\n\n/**\n * A RenderPass instance is a required parameter to all draw calls.\n * \n * It holds a combination of \n * - render targets (specified via a framebuffer)\n * - clear colors, read/write, discard information for the framebuffer attachments\n * - a couple of mutable parameters ()\n */\nexport abstract class RenderPass extends Resource<RenderPassProps> {\n\n /** Default properties for RenderPass */\n static override defaultProps: Required<RenderPassProps> = {\n ...Resource.defaultProps,\n framebuffer: null,\n parameters: undefined,\n clearColor: [0, 0, 0, 0],\n clearDepth: 1,\n clearStencil: 0,\n depthReadOnly: false,\n stencilReadOnly: false,\n discard: false\n };\n\n override get [Symbol.toStringTag](): string {\n return 'RenderPass';\n }\n\n constructor(device: Device, props: RenderPassProps) {\n super(device, props, RenderPass.defaultProps);\n }\n\n /** Call when rendering is done in this pass. */\n abstract end(): void;\n\n /** \n * A small set of parameters can be changed between every draw call \n * (viewport, scissorRect, blendColor, stencilReference) \n */\n abstract setParameters(parameters: RenderPassParameters): void;\n\n abstract pushDebugGroup(groupLabel: string): void;\n abstract popDebugGroup(): void;\n abstract insertDebugMarker(markerLabel: string): void;\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n\n // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n\n // In WebGPU the following methods are on the renderpass.\n // luma.gl keeps them on the pipeline for now\n\n /*\n setPipeline(pipeline: RenderPipeline): void {}\n\n setIndexBuffer(\n buffer: Buffer,\n indexFormat: 'uint16' | 'uint32',\n offset?: number,\n size?: number\n ): void {}\n\n abstract setVertexBuffer(slot: number, buffer: Buffer, offset: number): void;\n\n abstract setBindings(bindings: Record<string, Binding>): void;\n\n abstract setParameters(parameters: RenderPassParameters);\n\n draw(options: {\n vertexCount?: number; // Either vertexCount or indexCount must be provided\n indexCount?: number; // Activates indexed drawing (call setIndexBuffer())\n instanceCount?: number; //\n firstVertex?: number;\n firstIndex?: number; // requires device.features.has('indirect-first-instance')?\n firstInstance?: number;\n baseVertex?: number;\n }): void {}\n\n drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n */\n}\n"],"mappings":";SAIQA,QAAQ;AAAAC,mBAAA,GAoDAC,MAAM,CAACC,WAAW;AAflC,OAAO,MAAeC,UAAU,SAASJ,QAAQ,CAAkB;EAejE,KAAAC,mBAAA,IAA4C;IAC1C,OAAO,YAAY;EACrB;EAEAI,WAAWA,CAACC,MAAc,EAAEC,KAAsB,EAAE;IAClD,KAAK,CAACD,MAAM,EAAEC,KAAK,EAAEH,UAAU,CAACI,YAAY,CAAC;EAC/C;AAsDF;AA3EsBJ,UAAU,CAGdI,YAAY,GAA8B;EACxD,GAAGR,QAAQ,CAACQ,YAAY;EACxBC,WAAW,EAAE,IAAI;EACjBC,UAAU,EAAEC,SAAS;EACrBC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;EACxBC,UAAU,EAAE,CAAC;EACbC,YAAY,EAAE,CAAC;EACfC,aAAa,EAAE,KAAK;EACpBC,eAAe,EAAE,KAAK;EACtBC,OAAO,EAAE;AACX,CAAC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { Device } from '../device';
|
|
2
|
-
import type { TypedArray } from '../../types';
|
|
3
2
|
import type { UniformValue } from '../types/types';
|
|
4
3
|
import type { PrimitiveTopology, RenderPipelineParameters } from '../types/parameters';
|
|
5
4
|
import type { ShaderLayout, Binding } from '../types/shader-layout';
|
|
6
5
|
import type { BufferLayout } from '../types/buffer-layout';
|
|
7
6
|
import { Resource, ResourceProps } from './resource';
|
|
8
|
-
import type { Buffer } from './buffer';
|
|
9
7
|
import type { Shader } from './shader';
|
|
10
8
|
import type { RenderPass } from './render-pass';
|
|
9
|
+
import { VertexArray } from './vertex-array';
|
|
11
10
|
export type RenderPipelineProps = ResourceProps & {
|
|
12
11
|
/** Compiled vertex shader */
|
|
13
12
|
vs?: Shader | null;
|
|
@@ -36,10 +35,6 @@ export type RenderPipelineProps = ResourceProps & {
|
|
|
36
35
|
vertexCount?: number;
|
|
37
36
|
/** Number of instances */
|
|
38
37
|
instanceCount?: number;
|
|
39
|
-
/** Optional index buffer */
|
|
40
|
-
indices?: Buffer | null;
|
|
41
|
-
/** Buffers for attributes */
|
|
42
|
-
attributes?: Record<string, Buffer>;
|
|
43
38
|
/** Buffers, Textures, Samplers for the shader bindings */
|
|
44
39
|
bindings?: Record<string, Binding>;
|
|
45
40
|
/** @deprecated uniforms (WebGL only) */
|
|
@@ -52,15 +47,13 @@ export declare abstract class RenderPipeline extends Resource<RenderPipelineProp
|
|
|
52
47
|
static defaultProps: Required<RenderPipelineProps>;
|
|
53
48
|
get [Symbol.toStringTag](): string;
|
|
54
49
|
hash: string;
|
|
55
|
-
abstract vs: Shader;
|
|
56
|
-
abstract fs: Shader | null;
|
|
50
|
+
abstract readonly vs: Shader;
|
|
51
|
+
abstract readonly fs: Shader | null;
|
|
52
|
+
/** The merged layout */
|
|
53
|
+
shaderLayout: ShaderLayout;
|
|
54
|
+
/** Buffer map describing buffer interleaving etc */
|
|
55
|
+
readonly bufferLayout: BufferLayout[];
|
|
57
56
|
constructor(device: Device, props: RenderPipelineProps);
|
|
58
|
-
/** Set attributes (stored on pipeline and set before each call) */
|
|
59
|
-
abstract setIndexBuffer(indices: Buffer | null): void;
|
|
60
|
-
/** Set attributes (stored on pipeline and set before each call) */
|
|
61
|
-
abstract setAttributes(attributes: Record<string, Buffer>): void;
|
|
62
|
-
/** Set constant attributes (WebGL only) */
|
|
63
|
-
abstract setConstantAttributes(attributes: Record<string, TypedArray>): void;
|
|
64
57
|
/** Set bindings (stored on pipeline and set before each call) */
|
|
65
58
|
abstract setBindings(bindings: Record<string, Binding>): void;
|
|
66
59
|
/** Uniforms
|
|
@@ -73,6 +66,8 @@ export declare abstract class RenderPipeline extends Resource<RenderPipelineProp
|
|
|
73
66
|
abstract draw(options: {
|
|
74
67
|
/** Render pass to draw into (targeting screen or framebuffer) */
|
|
75
68
|
renderPass?: RenderPass;
|
|
69
|
+
/** vertex attributes */
|
|
70
|
+
vertexArray: VertexArray;
|
|
76
71
|
/** Number of "rows" in 'vertex' buffers */
|
|
77
72
|
vertexCount?: number;
|
|
78
73
|
/** Number of "rows" in 'instance' buffers */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/render-pipeline.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/render-pipeline.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAC,iBAAiB,EAAE,wBAAwB,EAAC,MAAM,qBAAqB,CAAC;AACrF,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAC,MAAM,wBAAwB,CAAC;AAClE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE3C,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG;IAGhD,6BAA6B;IAC7B,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+DAA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gBAE1B,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB;IAMtD,iEAAiE;IACjE,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAC7D;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAI;IAElE,gBAAgB;IAChB,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE;QACrB,iEAAiE;QACjE,UAAU,CAAC,EAAE,UAAU,CAAC;QACxB,wBAAwB;QACxB,WAAW,EAAE,WAAW,CAAC;QACzB,2CAA2C;QAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,6CAA6C;QAC7C,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,gCAAgC;QAChC,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,+BAA+B;QAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,kCAAkC;QAClC,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,IAAI;CACT"}
|
|
@@ -10,6 +10,10 @@ export class RenderPipeline extends Resource {
|
|
|
10
10
|
this.hash = '';
|
|
11
11
|
this.vs = void 0;
|
|
12
12
|
this.fs = void 0;
|
|
13
|
+
this.shaderLayout = void 0;
|
|
14
|
+
this.bufferLayout = void 0;
|
|
15
|
+
this.shaderLayout = this.props.shaderLayout;
|
|
16
|
+
this.bufferLayout = this.props.bufferLayout || [];
|
|
13
17
|
}
|
|
14
18
|
}
|
|
15
19
|
RenderPipeline.defaultProps = {
|
|
@@ -26,8 +30,6 @@ RenderPipeline.defaultProps = {
|
|
|
26
30
|
parameters: {},
|
|
27
31
|
vertexCount: 0,
|
|
28
32
|
instanceCount: 0,
|
|
29
|
-
indices: null,
|
|
30
|
-
attributes: {},
|
|
31
33
|
bindings: {},
|
|
32
34
|
uniforms: {}
|
|
33
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-pipeline.js","names":["Resource","_Symbol$toStringTag","Symbol","toStringTag","RenderPipeline","constructor","device","props","defaultProps","hash","vs","fs","
|
|
1
|
+
{"version":3,"file":"render-pipeline.js","names":["Resource","_Symbol$toStringTag","Symbol","toStringTag","RenderPipeline","constructor","device","props","defaultProps","hash","vs","fs","shaderLayout","bufferLayout","vsEntryPoint","vsConstants","fsEntryPoint","fsConstants","topology","parameters","vertexCount","instanceCount","bindings","uniforms"],"sources":["../../../src/adapter/resources/render-pipeline.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {Device} from '../device';\nimport type {UniformValue} from '../types/types';\nimport type {PrimitiveTopology, RenderPipelineParameters} from '../types/parameters';\nimport type {ShaderLayout, Binding} from '../types/shader-layout';\nimport type {BufferLayout} from '../types/buffer-layout';\n// import {normalizeAttributeMap} from '../helpers/attribute-bindings';\nimport {Resource, ResourceProps} from './resource';\nimport type {Shader} from './shader';\nimport type {RenderPass} from './render-pass';\nimport {VertexArray} from './vertex-array';\n\nexport type RenderPipelineProps = ResourceProps & {\n // Shaders and shader layout\n\n /** Compiled vertex shader */\n vs?: Shader | null;\n /** Vertex shader entry point (defaults to 'main'). WGSL only */\n vsEntryPoint?: string; //\n /** Constants to apply to compiled vertex shader (WGSL only) */\n vsConstants?: Record<string, number>; // WGSL only\n /** Compiled fragment shader */\n fs?: Shader | null;\n /** Fragment shader entry point (defaults to 'main'). WGSL only */\n fsEntryPoint?: string; // WGSL only\n /** Constants to apply to compiled fragment shader (WGSL only) */\n fsConstants?: Record<string, number>;\n\n /** Describes the attributes and bindings exposed by the pipeline shader(s). */\n shaderLayout?: ShaderLayout | null;\n /**\n * Describes the buffers accepted by this pipeline and how they are mapped to shader attributes.\n * A default mapping of one buffer per attribute is always created.\n */\n bufferLayout?: BufferLayout[], // Record<string, Omit<BufferLayout, 'name'>\n\n /** Determines how vertices are read from the 'vertex' attributes */\n topology?: PrimitiveTopology;\n /** Parameters that are controlled by pipeline */\n parameters?: RenderPipelineParameters;\n\n // Can be changed after creation\n // TODO make pipeline immutable? these could be supplied to draw as parameters, in WebGPU they are set on the render pass \n\n /** Number of vertices */\n vertexCount?: number;\n /** Number of instances */\n instanceCount?: number;\n\n /** Buffers, Textures, Samplers for the shader bindings */\n bindings?: Record<string, Binding>;\n /** @deprecated uniforms (WebGL only) */\n uniforms?: Record<string, UniformValue>;\n};\n\n/**\n * A compiled and linked shader program\n */\nexport abstract class RenderPipeline extends Resource<RenderPipelineProps> {\n static override defaultProps: Required<RenderPipelineProps> = {\n ...Resource.defaultProps,\n \n vs: null,\n vsEntryPoint: '', // main\n vsConstants: {},\n \n fs: null,\n fsEntryPoint: '', // main\n fsConstants: {},\n \n shaderLayout: null,\n bufferLayout: [],\n topology: 'triangle-list',\n parameters: {},\n \n vertexCount: 0,\n instanceCount: 0,\n \n bindings: {},\n uniforms: {}\n }; \n\n override get [Symbol.toStringTag](): string { return 'RenderPipeline'; }\n\n hash: string = '';\n abstract readonly vs: Shader;\n abstract readonly fs: Shader | null;\n /** The merged layout */\n shaderLayout: ShaderLayout;\n /** Buffer map describing buffer interleaving etc */\n readonly bufferLayout: BufferLayout[];\n\n constructor(device: Device, props: RenderPipelineProps) {\n super(device, props, RenderPipeline.defaultProps);\n this.shaderLayout = this.props.shaderLayout;\n this.bufferLayout = this.props.bufferLayout || [];\n }\n\n /** Set bindings (stored on pipeline and set before each call) */\n abstract setBindings(bindings: Record<string, Binding>): void;\n /** Uniforms \n * @deprecated Only supported on WebGL devices.\n * @note textures, samplers and uniform buffers should be set via `setBindings()`, these are not considered uniforms.\n * @note In WebGL uniforms have a performance penalty, they are reset before each call to enable pipeline sharing. \n */\n abstract setUniforms(bindings: Record<string, UniformValue>): void;\n\n /** Draw call */ \n abstract draw(options: {\n /** Render pass to draw into (targeting screen or framebuffer) */\n renderPass?: RenderPass;\n /** vertex attributes */\n vertexArray: VertexArray;\n /** Number of \"rows\" in 'vertex' buffers */\n vertexCount?: number;\n /** Number of \"rows\" in 'instance' buffers */\n instanceCount?: number;\n /** First vertex to draw from */\n firstVertex?: number;\n /** First index to draw from */\n firstIndex?: number;\n /** First instance to draw from */\n firstInstance?: number;\n baseVertex?: number;\n }): void;\n}\n"],"mappings":";SAOQA,QAAQ;AAAAC,mBAAA,GA2EAC,MAAM,CAACC,WAAW;AAxBlC,OAAO,MAAeC,cAAc,SAASJ,QAAQ,CAAsB;EAwBzE,KAAAC,mBAAA,IAA4C;IAAE,OAAO,gBAAgB;EAAE;EAUvEI,WAAWA,CAACC,MAAc,EAAEC,KAA0B,EAAE;IACtD,KAAK,CAACD,MAAM,EAAEC,KAAK,EAAEH,cAAc,CAACI,YAAY,CAAC;IAAC,KATpDC,IAAI,GAAW,EAAE;IAAA,KACCC,EAAE;IAAA,KACFC,EAAE;IAAA,KAEpBC,YAAY;IAAA,KAEHC,YAAY;IAInB,IAAI,CAACD,YAAY,GAAG,IAAI,CAACL,KAAK,CAACK,YAAY;IAC3C,IAAI,CAACC,YAAY,GAAG,IAAI,CAACN,KAAK,CAACM,YAAY,IAAI,EAAE;EACnD;AA6BF;AAnEsBT,cAAc,CAClBI,YAAY,GAAkC;EAC5D,GAAGR,QAAQ,CAACQ,YAAY;EAExBE,EAAE,EAAE,IAAI;EACRI,YAAY,EAAE,EAAE;EAChBC,WAAW,EAAE,CAAC,CAAC;EAEfJ,EAAE,EAAE,IAAI;EACRK,YAAY,EAAE,EAAE;EAChBC,WAAW,EAAE,CAAC,CAAC;EAEfL,YAAY,EAAE,IAAI;EAClBC,YAAY,EAAE,EAAE;EAChBK,QAAQ,EAAE,eAAe;EACzBC,UAAU,EAAE,CAAC,CAAC;EAEdC,WAAW,EAAE,CAAC;EACdC,aAAa,EAAE,CAAC;EAEhBC,QAAQ,EAAE,CAAC,CAAC;EACZC,QAAQ,EAAE,CAAC;AACb,CAAC"}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import type { Device } from '../device';
|
|
2
2
|
import { Resource, ResourceProps } from './resource';
|
|
3
|
-
|
|
4
|
-
export type CompilerMessage = {
|
|
5
|
-
type: CompilerMessageType;
|
|
6
|
-
message: string;
|
|
7
|
-
lineNum: number;
|
|
8
|
-
linePos: number;
|
|
9
|
-
};
|
|
3
|
+
import { CompilerMessage } from '../../lib/compiler-log/compiler-message';
|
|
10
4
|
/**
|
|
11
5
|
* Properties for a Shader
|
|
12
6
|
*/
|
|
@@ -14,7 +8,7 @@ export type ShaderProps = ResourceProps & {
|
|
|
14
8
|
stage: 'vertex' | 'fragment' | 'compute';
|
|
15
9
|
source: string;
|
|
16
10
|
sourceMap?: string | null;
|
|
17
|
-
language?: 'glsl' | 'wgsl';
|
|
11
|
+
language?: 'glsl' | 'wgsl' | 'auto';
|
|
18
12
|
/** @deprecated use props.stage */
|
|
19
13
|
shaderType?: 0x8b30 | 0x8b31 | 0;
|
|
20
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/shader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACtC,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/shader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACtC,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACnD,OAAO,EAAC,eAAe,EAAC,MAAM,yCAAyC,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG;IACxC,KAAK,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;IAEzC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAIpC,kCAAkC;IAClC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC;CAClC,CAAC;AAEF;;;GAGG;AACH,8BAAsB,MAAO,SAAQ,QAAQ,CAAC,WAAW,CAAC;IACxD,OAAgB,YAAY,EAAE,QAAQ,CAAC,WAAW,CAAC,CAOjD;IAEF,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAAqB;IAEhE,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;IAClD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW;IAM9C,QAAQ,CAAC,eAAe,IAAI,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC;CAChE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader.js","names":["Resource","_Symbol$toStringTag","Symbol","toStringTag","Shader","constructor","device","props","defaultProps","stage","source","sourceMap","language","shaderType"],"sources":["../../../src/adapter/resources/shader.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {Device} from '../device';\nimport {Resource, ResourceProps} from './resource';\
|
|
1
|
+
{"version":3,"file":"shader.js","names":["Resource","_Symbol$toStringTag","Symbol","toStringTag","Shader","constructor","device","props","defaultProps","stage","source","sourceMap","language","shaderType"],"sources":["../../../src/adapter/resources/shader.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {Device} from '../device';\nimport {Resource, ResourceProps} from './resource';\nimport {CompilerMessage} from '../../lib/compiler-log/compiler-message';\n\n/**\n * Properties for a Shader\n */\nexport type ShaderProps = ResourceProps & {\n stage: 'vertex' | 'fragment' | 'compute'; // Required by WebGL and GLSL transpiler\n // code: string;\n source: string;\n sourceMap?: string | null; // WebGPU only\n language?: 'glsl' | 'wgsl' | 'auto'; // wgsl in WebGPU only\n // entryPoint?: string;\n\n // WEBGL\n /** @deprecated use props.stage */\n shaderType?: 0x8b30 | 0x8b31 | 0; // GL_FRAGMENT_SHADER | GL_VERTEX_SHADER\n};\n\n/**\n * Immutable Shader object\n * In WebGPU the handle can be copied between threads\n */\nexport abstract class Shader extends Resource<ShaderProps> {\n static override defaultProps: Required<ShaderProps> = {\n ...Resource.defaultProps,\n stage: 'vertex',\n source: '',\n sourceMap: null,\n language: 'auto',\n shaderType: 0\n };\n\n override get [Symbol.toStringTag](): string { return 'Shader'; }\n\n readonly stage: 'vertex' | 'fragment' | 'compute';\n readonly source: string;\n\n constructor(device: Device, props: ShaderProps) {\n super(device, props, Shader.defaultProps);\n this.stage = this.props.stage;\n this.source = this.props.source;\n }\n\n abstract compilationInfo(): Promise<readonly CompilerMessage[]>;\n}\n"],"mappings":";SAEQA,QAAQ;AAAAC,mBAAA,GAiCAC,MAAM,CAACC,WAAW;AAVlC,OAAO,MAAeC,MAAM,SAASJ,QAAQ,CAAc;EAUzD,KAAAC,mBAAA,IAA4C;IAAE,OAAO,QAAQ;EAAE;EAK/DI,WAAWA,CAACC,MAAc,EAAEC,KAAkB,EAAE;IAC9C,KAAK,CAACD,MAAM,EAAEC,KAAK,EAAEH,MAAM,CAACI,YAAY,CAAC;IAAC,KAJnCC,KAAK;IAAA,KACLC,MAAM;IAIb,IAAI,CAACD,KAAK,GAAG,IAAI,CAACF,KAAK,CAACE,KAAK;IAC7B,IAAI,CAACC,MAAM,GAAG,IAAI,CAACH,KAAK,CAACG,MAAM;EACjC;AAGF;AAtBsBN,MAAM,CACVI,YAAY,GAA0B;EACpD,GAAGR,QAAQ,CAACQ,YAAY;EACxBC,KAAK,EAAE,QAAQ;EACfC,MAAM,EAAE,EAAE;EACVC,SAAS,EAAE,IAAI;EACfC,QAAQ,EAAE,MAAM;EAChBC,UAAU,EAAE;AACd,CAAC"}
|