@luma.gl/webgl 9.0.0-alpha.20 → 9.0.0-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/converters/device-parameters.d.ts +1 -1
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +10 -10
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/sampler-parameters.d.ts +1 -1
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +1 -1
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/converters/texture-formats.d.ts +27 -38
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +152 -114
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/helpers/attribute-utils.d.ts +1 -1
- package/dist/adapter/helpers/attribute-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/attribute-utils.js +1 -1
- package/dist/adapter/helpers/attribute-utils.js.map +1 -1
- package/dist/adapter/helpers/get-shader-info.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-info.js.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +1 -1
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/helpers/uniforms.d.ts +7 -8
- package/dist/adapter/helpers/uniforms.d.ts.map +1 -1
- package/dist/adapter/helpers/uniforms.js +4 -4
- package/dist/adapter/helpers/uniforms.js.map +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts +0 -2
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +0 -20
- package/dist/adapter/objects/constants-to-keys.js.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +14 -11
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +31 -21
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts +2 -3
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +6 -9
- package/dist/adapter/objects/webgl-resource.js.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts +6 -6
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js +2 -2
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts +2 -2
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +4 -3
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +9 -3
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +168 -25
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.d.ts +5 -4
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +7 -3
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-external-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +18 -21
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +36 -86
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts +18 -3
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +81 -1
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +5 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +7 -8
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts +3 -3
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +2 -2
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.d.ts +2 -2
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +1 -1
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +41 -21
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +35 -33
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.d.ts +4 -5
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +2 -2
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +22 -15
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +29 -11
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/accessor.d.ts +1 -1
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +1 -1
- package/dist/classic/accessor.js.map +1 -1
- package/dist/classic/buffer.d.ts +3 -4
- package/dist/classic/buffer.d.ts.map +1 -1
- package/dist/classic/buffer.js +4 -10
- package/dist/classic/buffer.js.map +1 -1
- package/dist/classic/typed-array-utils.d.ts +15 -17
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +1 -1
- package/dist/classic/typed-array-utils.js.map +1 -1
- package/dist/context/context/create-browser-context.js.map +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +1 -1
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts +1 -2
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +1 -1
- package/dist/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/dist.dev.js +1107 -676
- package/dist/index.cjs +1088 -901
- package/dist/index.d.ts +18 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -16
- package/dist/index.js.map +1 -1
- package/dist.min.js +22 -21
- package/package.json +7 -4
- package/src/adapter/converters/device-parameters.ts +47 -23
- package/src/adapter/converters/sampler-parameters.ts +1 -2
- package/src/adapter/converters/texture-formats.ts +242 -161
- package/src/adapter/helpers/attribute-utils.ts +1 -2
- package/src/adapter/helpers/get-shader-info.ts +3 -0
- package/src/adapter/helpers/get-shader-layout.ts +1 -1
- package/src/adapter/helpers/uniforms.ts +9 -10
- package/src/adapter/objects/constants-to-keys.ts +0 -25
- package/src/adapter/objects/webgl-renderbuffer.ts +35 -32
- package/src/adapter/objects/webgl-resource.ts +6 -10
- package/src/adapter/objects/webgl-vertex-array-object.ts +6 -6
- package/src/adapter/resources/webgl-buffer.ts +6 -7
- package/src/adapter/resources/webgl-command-buffer.ts +330 -23
- package/src/adapter/resources/webgl-command-encoder.ts +9 -4
- package/src/adapter/resources/webgl-external-texture.ts +1 -1
- package/src/adapter/resources/webgl-framebuffer.ts +75 -123
- package/src/adapter/resources/webgl-render-pass.ts +148 -4
- package/src/adapter/resources/webgl-render-pipeline.ts +12 -9
- package/src/adapter/resources/webgl-sampler.ts +3 -4
- package/src/adapter/resources/webgl-shader.ts +2 -2
- package/src/adapter/resources/webgl-texture.ts +64 -46
- package/src/adapter/webgl-canvas-context.ts +5 -5
- package/src/adapter/webgl-device.ts +47 -18
- package/src/classic/accessor.ts +1 -1
- package/src/classic/buffer.ts +7 -7
- package/src/classic/typed-array-utils.ts +15 -26
- package/src/context/context/create-browser-context.ts +2 -2
- package/src/context/parameters/unified-parameter-api.ts +2 -2
- package/src/context/parameters/webgl-parameter-tables.ts +2 -2
- package/src/context/state-tracker/with-parameters.ts +1 -1
- package/src/index.ts +24 -22
- package/dist/adapter/converters/renderbuffer-formats.d.ts +0 -16
- package/dist/adapter/converters/renderbuffer-formats.d.ts.map +0 -1
- package/dist/adapter/converters/renderbuffer-formats.js +0 -181
- package/dist/adapter/converters/renderbuffer-formats.js.map +0 -1
- package/dist/types/webgl.d.ts +0 -145
- package/dist/types/webgl.d.ts.map +0 -1
- package/dist/types/webgl.js +0 -2
- package/dist/types/webgl.js.map +0 -1
- package/src/adapter/converters/renderbuffer-formats.ts +0 -92
- package/src/types/webgl.ts +0 -286
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import GL from '@luma.gl/constants';
|
|
1
|
+
import { GL } from '@luma.gl/constants';
|
|
2
2
|
export function isSamplerUniform(type) {
|
|
3
3
|
return SAMPLER_TYPES.includes(type);
|
|
4
4
|
}
|
|
@@ -54,8 +54,8 @@ export function decodeAttributeType(attributeType) {
|
|
|
54
54
|
glType
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
export function
|
|
58
|
-
const typeAndSize = COMPOSITE_GL_TYPES[
|
|
57
|
+
export function decomposeCompositeGLDataType(compositeGLDataType) {
|
|
58
|
+
const typeAndSize = COMPOSITE_GL_TYPES[compositeGLDataType];
|
|
59
59
|
if (!typeAndSize) {
|
|
60
60
|
return null;
|
|
61
61
|
}
|
|
@@ -65,7 +65,7 @@ export function decomposeCompositeGLType(compositeGLType) {
|
|
|
65
65
|
components
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
-
export function
|
|
68
|
+
export function getCompositeGLDataType(type, components) {
|
|
69
69
|
switch (type) {
|
|
70
70
|
case GL.BYTE:
|
|
71
71
|
case GL.UNSIGNED_BYTE:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniforms.js","names":["GL","isSamplerUniform","type","SAMPLER_TYPES","includes","SAMPLER_2D","SAMPLER_CUBE","SAMPLER_3D","SAMPLER_2D_SHADOW","SAMPLER_2D_ARRAY","SAMPLER_2D_ARRAY_SHADOW","SAMPLER_CUBE_SHADOW","INT_SAMPLER_2D","INT_SAMPLER_3D","INT_SAMPLER_CUBE","INT_SAMPLER_2D_ARRAY","UNSIGNED_INT_SAMPLER_2D","UNSIGNED_INT_SAMPLER_3D","UNSIGNED_INT_SAMPLER_CUBE","UNSIGNED_INT_SAMPLER_2D_ARRAY","COMPOSITE_GL_TYPES","FLOAT","FLOAT_VEC2","FLOAT_VEC3","FLOAT_VEC4","INT","INT_VEC2","INT_VEC3","INT_VEC4","UNSIGNED_INT","UNSIGNED_INT_VEC2","UNSIGNED_INT_VEC3","UNSIGNED_INT_VEC4","BOOL","BOOL_VEC2","BOOL_VEC3","BOOL_VEC4","FLOAT_MAT2","FLOAT_MAT2x3","FLOAT_MAT2x4","FLOAT_MAT3x2","FLOAT_MAT3","FLOAT_MAT3x4","FLOAT_MAT4x2","FLOAT_MAT4x3","FLOAT_MAT4","decodeUniformType","uniformType","typeAndSize","Error","glType","components","format","decodeAttributeType","attributeType","
|
|
1
|
+
{"version":3,"file":"uniforms.js","names":["GL","isSamplerUniform","type","SAMPLER_TYPES","includes","SAMPLER_2D","SAMPLER_CUBE","SAMPLER_3D","SAMPLER_2D_SHADOW","SAMPLER_2D_ARRAY","SAMPLER_2D_ARRAY_SHADOW","SAMPLER_CUBE_SHADOW","INT_SAMPLER_2D","INT_SAMPLER_3D","INT_SAMPLER_CUBE","INT_SAMPLER_2D_ARRAY","UNSIGNED_INT_SAMPLER_2D","UNSIGNED_INT_SAMPLER_3D","UNSIGNED_INT_SAMPLER_CUBE","UNSIGNED_INT_SAMPLER_2D_ARRAY","COMPOSITE_GL_TYPES","FLOAT","FLOAT_VEC2","FLOAT_VEC3","FLOAT_VEC4","INT","INT_VEC2","INT_VEC3","INT_VEC4","UNSIGNED_INT","UNSIGNED_INT_VEC2","UNSIGNED_INT_VEC3","UNSIGNED_INT_VEC4","BOOL","BOOL_VEC2","BOOL_VEC3","BOOL_VEC4","FLOAT_MAT2","FLOAT_MAT2x3","FLOAT_MAT2x4","FLOAT_MAT3x2","FLOAT_MAT3","FLOAT_MAT3x4","FLOAT_MAT4x2","FLOAT_MAT4x3","FLOAT_MAT4","decodeUniformType","uniformType","typeAndSize","Error","glType","components","format","decodeAttributeType","attributeType","decomposeCompositeGLDataType","compositeGLDataType","getCompositeGLDataType","BYTE","UNSIGNED_BYTE","SHORT","UNSIGNED_SHORT","compType","compComponents","name","Number"],"sources":["../../../src/adapter/helpers/uniforms.ts"],"sourcesContent":["import {UniformFormat, VertexFormat} from '@luma.gl/api';\nimport {GL, GLUniformType, GLSamplerType, GLCompositeType, GLDataType} from '@luma.gl/constants';\n\n/** Check is uniform is of sampler type */\nexport function isSamplerUniform(type: GLUniformType): boolean {\n return SAMPLER_TYPES.includes(type as GLSamplerType);\n}\n\nconst SAMPLER_TYPES: GLSamplerType[] = [\n GL.SAMPLER_2D,\n GL.SAMPLER_CUBE,\n GL.SAMPLER_3D,\n GL.SAMPLER_2D_SHADOW,\n GL.SAMPLER_2D_ARRAY,\n GL.SAMPLER_2D_ARRAY_SHADOW,\n GL.SAMPLER_CUBE_SHADOW,\n GL.INT_SAMPLER_2D,\n GL.INT_SAMPLER_3D,\n GL.INT_SAMPLER_CUBE,\n GL.INT_SAMPLER_2D_ARRAY,\n GL.UNSIGNED_INT_SAMPLER_2D,\n GL.UNSIGNED_INT_SAMPLER_3D,\n GL.UNSIGNED_INT_SAMPLER_CUBE,\n GL.UNSIGNED_INT_SAMPLER_2D_ARRAY\n];\n\n// Composite types table\nconst COMPOSITE_GL_TYPES: Record<\n GLCompositeType,\n [GLDataType, number, string, UniformFormat, VertexFormat?]\n> = {\n [GL.FLOAT]: [GL.FLOAT, 1, 'float', 'f32', 'float32'],\n [GL.FLOAT_VEC2]: [GL.FLOAT, 2, 'vec2', 'vec2<f32>', 'float32x2'],\n [GL.FLOAT_VEC3]: [GL.FLOAT, 3, 'vec3', 'vec3<f32>', 'float32x3'],\n [GL.FLOAT_VEC4]: [GL.FLOAT, 4, 'vec4', 'vec4<f32>', 'float32x4'],\n\n [GL.INT]: [GL.INT, 1, 'int', 'i32', 'sint32'],\n [GL.INT_VEC2]: [GL.INT, 2, 'ivec2', 'vec2<i32>', 'sint32x2'],\n [GL.INT_VEC3]: [GL.INT, 3, 'ivec3', 'vec3<i32>', 'sint32x3'],\n [GL.INT_VEC4]: [GL.INT, 4, 'ivec4', 'vec4<i32>', 'sint32x4'],\n\n [GL.UNSIGNED_INT]: [GL.UNSIGNED_INT, 1, 'uint', 'u32', 'uint32'],\n [GL.UNSIGNED_INT_VEC2]: [GL.UNSIGNED_INT, 2, 'uvec2', 'vec2<u32>', 'uint32x2'],\n [GL.UNSIGNED_INT_VEC3]: [GL.UNSIGNED_INT, 3, 'uvec3', 'vec3<u32>', 'uint32x3'],\n [GL.UNSIGNED_INT_VEC4]: [GL.UNSIGNED_INT, 4, 'uvec4', 'vec4<u32>', 'uint32x4'],\n\n [GL.BOOL]: [GL.FLOAT, 1, 'bool', 'f32', 'float32x2'],\n [GL.BOOL_VEC2]: [GL.FLOAT, 2, 'bvec2', 'vec2<f32>'],\n [GL.BOOL_VEC3]: [GL.FLOAT, 3, 'bvec3', 'vec3<f32>'],\n [GL.BOOL_VEC4]: [GL.FLOAT, 4, 'bvec4', 'vec4<f32>'],\n\n [GL.FLOAT_MAT2]: [GL.FLOAT, 8, 'mat2', 'mat2x2<f32>'], // 4\n [GL.FLOAT_MAT2x3]: [GL.FLOAT, 8, 'mat2x3', 'mat2x3<f32>'], // 6\n [GL.FLOAT_MAT2x4]: [GL.FLOAT, 8, 'mat2x4', 'mat2x4<f32>'], // 8\n\n [GL.FLOAT_MAT3x2]: [GL.FLOAT, 12, 'mat3x2', 'mat3x2<f32>'], // 6\n [GL.FLOAT_MAT3]: [GL.FLOAT, 12, 'mat3', 'mat3x3<f32>'], // 9\n [GL.FLOAT_MAT3x4]: [GL.FLOAT, 12, 'mat3x4', 'mat3x4<f32>'], // 12\n\n [GL.FLOAT_MAT4x2]: [GL.FLOAT, 16, 'mat4x2', 'mat4x2<f32>'], // 8\n [GL.FLOAT_MAT4x3]: [GL.FLOAT, 16, 'mat4x3', 'mat4x3<f32>'], // 12\n [GL.FLOAT_MAT4]: [GL.FLOAT, 16, 'mat4', 'mat4x4<f32>'] // 16\n};\n\n/** Decomposes a composite type GL.VEC3 into a basic type (GL.FLOAT) and components (3) */\nexport function decodeUniformType(\n uniformType: GL\n): {format: UniformFormat; components: number; glType: GLDataType} {\n const typeAndSize = COMPOSITE_GL_TYPES[uniformType];\n if (!typeAndSize) {\n throw new Error('uniform');\n }\n const [glType, components, , format] = typeAndSize;\n return {format, components, glType};\n}\n\nexport function decodeAttributeType(attributeType: GL): {\n format: VertexFormat;\n components: number;\n glType: GLDataType;\n} {\n const typeAndSize = COMPOSITE_GL_TYPES[attributeType];\n if (!typeAndSize) {\n throw new Error('attribute')\n }\n const [glType, components, , , format] = typeAndSize;\n return {format, components, glType};\n}\n\n/** Decomposes a composite type GL.VEC3 into a basic type (GL.FLOAT) and components (3) */\nexport function decomposeCompositeGLDataType(\n compositeGLDataType: GLCompositeType\n): {type: GLDataType; components: number} | null {\n const typeAndSize = COMPOSITE_GL_TYPES[compositeGLDataType];\n if (!typeAndSize) {\n return null;\n }\n const [type, components] = typeAndSize;\n return {type, components};\n}\n\nexport function getCompositeGLDataType(type: GL, components): {glType: GLDataType; name: string} | null {\n switch (type) {\n case GL.BYTE:\n case GL.UNSIGNED_BYTE:\n case GL.SHORT:\n case GL.UNSIGNED_SHORT:\n type = GL.FLOAT;\n break;\n default:\n }\n\n for (const glType in COMPOSITE_GL_TYPES) {\n const [compType, compComponents, name] = COMPOSITE_GL_TYPES[glType];\n if (compType === type && compComponents === components) {\n return {glType: Number(glType), name};\n }\n }\n return null;\n}\n"],"mappings":"AACA,SAAQA,EAAE,QAAkE,oBAAoB;AAGhG,OAAO,SAASC,gBAAgBA,CAACC,IAAmB,EAAW;EAC7D,OAAOC,aAAa,CAACC,QAAQ,CAACF,IAAI,CAAkB;AACtD;AAEA,MAAMC,aAA8B,GAAG,CACrCH,EAAE,CAACK,UAAU,EACbL,EAAE,CAACM,YAAY,EACfN,EAAE,CAACO,UAAU,EACbP,EAAE,CAACQ,iBAAiB,EACpBR,EAAE,CAACS,gBAAgB,EACnBT,EAAE,CAACU,uBAAuB,EAC1BV,EAAE,CAACW,mBAAmB,EACtBX,EAAE,CAACY,cAAc,EACjBZ,EAAE,CAACa,cAAc,EACjBb,EAAE,CAACc,gBAAgB,EACnBd,EAAE,CAACe,oBAAoB,EACvBf,EAAE,CAACgB,uBAAuB,EAC1BhB,EAAE,CAACiB,uBAAuB,EAC1BjB,EAAE,CAACkB,yBAAyB,EAC5BlB,EAAE,CAACmB,6BAA6B,CACjC;AAGD,MAAMC,kBAGL,GAAG;EACF,CAACpB,EAAE,CAACqB,KAAK,GAAG,CAACrB,EAAE,CAACqB,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC;EACpD,CAACrB,EAAE,CAACsB,UAAU,GAAG,CAACtB,EAAE,CAACqB,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,CAAC;EAChE,CAACrB,EAAE,CAACuB,UAAU,GAAG,CAACvB,EAAE,CAACqB,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,CAAC;EAChE,CAACrB,EAAE,CAACwB,UAAU,GAAG,CAACxB,EAAE,CAACqB,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,CAAC;EAEhE,CAACrB,EAAE,CAACyB,GAAG,GAAG,CAACzB,EAAE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B,MAAM,CAAC;IACnE,IAAIY,QAAQ,KAAK5D,IAAI,IAAI6D,cAAc,KAAKZ,UAAU,EAAE;MACtD,OAAO;QAACD,MAAM,EAAEe,MAAM,CAACf,MAAM,CAAC;QAAEc;MAAI,CAAC;IACvC;EACF;EACA,OAAO,IAAI;AACb"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import GL from '@luma.gl/constants';
|
|
2
2
|
export declare function getKeyValue(gl: WebGLRenderingContext, name: string | GL): GL;
|
|
3
|
-
export declare function getKey(gl: WebGLRenderingContext, value: any): string;
|
|
4
|
-
export declare function getKeyType(gl: WebGLRenderingContext, value: any): string;
|
|
5
3
|
//# sourceMappingURL=constants-to-keys.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants-to-keys.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/constants-to-keys.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGpC,wBAAgB,WAAW,CAAC,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,MAAM,GAAG,EAAE,GAAG,EAAE,CAkB5E
|
|
1
|
+
{"version":3,"file":"constants-to-keys.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/constants-to-keys.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGpC,wBAAgB,WAAW,CAAC,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,MAAM,GAAG,EAAE,GAAG,EAAE,CAkB5E"}
|
|
@@ -12,24 +12,4 @@ export function getKeyValue(gl, name) {
|
|
|
12
12
|
assert(value !== undefined, "Accessing undefined constant GL.".concat(name));
|
|
13
13
|
return value;
|
|
14
14
|
}
|
|
15
|
-
export function getKey(gl, value) {
|
|
16
|
-
gl = gl.gl || gl;
|
|
17
|
-
value = Number(value);
|
|
18
|
-
for (const key in gl) {
|
|
19
|
-
if (gl[key] === value) {
|
|
20
|
-
return "GL.".concat(key);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return String(value);
|
|
24
|
-
}
|
|
25
|
-
export function getKeyType(gl, value) {
|
|
26
|
-
assert(value !== undefined, 'undefined key');
|
|
27
|
-
value = Number(value);
|
|
28
|
-
for (const key in gl) {
|
|
29
|
-
if (gl[key] === value) {
|
|
30
|
-
return "GL.".concat(key);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return String(value);
|
|
34
|
-
}
|
|
35
15
|
//# sourceMappingURL=constants-to-keys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants-to-keys.js","names":["assert","getKeyValue","gl","name","number","Number","isNaN","replace","value","undefined","concat"
|
|
1
|
+
{"version":3,"file":"constants-to-keys.js","names":["assert","getKeyValue","gl","name","number","Number","isNaN","replace","value","undefined","concat"],"sources":["../../../src/adapter/objects/constants-to-keys.ts"],"sourcesContent":["import {assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\n\n// Resolve a WebGL enumeration name (returns itself if already a number)\nexport function getKeyValue(gl: WebGLRenderingContext, name: string | GL): GL {\n // If not a string, return (assume number)\n if (typeof name !== 'string') {\n return name;\n }\n\n // If string converts to number, return number\n const number = Number(name);\n if (!isNaN(number)) {\n return number;\n }\n\n // Look up string, after removing any 'GL.' or 'gl.' prefix\n name = name.replace(/^.*\\./, '');\n // @ts-ignore expect-error depends on settings\n const value = gl[name];\n assert(value !== undefined, `Accessing undefined constant GL.${name}`);\n return value;\n}\n"],"mappings":"AAAA,SAAQA,MAAM,QAAO,cAAc;AAInC,OAAO,SAASC,WAAWA,CAACC,EAAyB,EAAEC,IAAiB,EAAM;EAE5E,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAOA,IAAI;EACb;EAGA,MAAMC,MAAM,GAAGC,MAAM,CAACF,IAAI,CAAC;EAC3B,IAAI,CAACG,KAAK,CAACF,MAAM,CAAC,EAAE;IAClB,OAAOA,MAAM;EACf;EAGAD,IAAI,GAAGA,IAAI,CAACI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;EAEhC,MAAMC,KAAK,GAAGN,EAAE,CAACC,IAAI,CAAC;EACtBH,MAAM,CAACQ,KAAK,KAAKC,SAAS,qCAAAC,MAAA,CAAqCP,IAAI,EAAG;EACtE,OAAOK,KAAK;AACd"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ResourceProps } from '@luma.gl/api';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { ResourceProps, TextureFormat } from '@luma.gl/api';
|
|
2
|
+
import GL from '@luma.gl/constants';
|
|
3
|
+
import { WebGLDevice } from '../webgl-device';
|
|
4
|
+
import { WebGLResource } from './webgl-resource';
|
|
4
5
|
export declare type RenderbufferProps = ResourceProps & {
|
|
5
|
-
format:
|
|
6
|
+
format: TextureFormat;
|
|
6
7
|
width?: number;
|
|
7
8
|
height?: number;
|
|
8
9
|
samples?: number;
|
|
@@ -17,22 +18,24 @@ export declare type RenderbufferProps = ResourceProps & {
|
|
|
17
18
|
* use Textures instead.
|
|
18
19
|
* Renderbuffer objects also natively accommodate Multisampling (MSAA).
|
|
19
20
|
*/
|
|
20
|
-
export
|
|
21
|
+
export declare class WEBGLRenderbuffer extends WebGLResource<RenderbufferProps> {
|
|
22
|
+
static readonly defaultProps: Required<RenderbufferProps>;
|
|
21
23
|
get [Symbol.toStringTag](): string;
|
|
22
24
|
get width(): number;
|
|
23
25
|
get height(): number;
|
|
24
|
-
get format():
|
|
26
|
+
get format(): TextureFormat;
|
|
25
27
|
get samples(): number;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
get attachment(): void;
|
|
29
|
+
/** WebGL format constant */
|
|
30
|
+
glFormat: GL;
|
|
31
|
+
static isTextureFormatSupported(device: WebGLDevice, format: TextureFormat): boolean;
|
|
29
32
|
constructor(device: WebGLDevice, props: RenderbufferProps);
|
|
30
33
|
resize(size: {
|
|
31
34
|
width: number;
|
|
32
35
|
height: number;
|
|
33
|
-
}):
|
|
36
|
+
}): void;
|
|
34
37
|
/** Creates and initializes a renderbuffer object's data store */
|
|
35
|
-
protected _initialize(props: Required<RenderbufferProps>):
|
|
38
|
+
protected _initialize(props: Required<RenderbufferProps>): void;
|
|
36
39
|
_createHandle(): WebGLRenderbuffer;
|
|
37
40
|
_deleteHandle(): void;
|
|
38
41
|
_bindHandle(handle: WEBGLRenderbuffer): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-renderbuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/webgl-renderbuffer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgl-renderbuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/webgl-renderbuffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,aAAa,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACpC,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAI/C,oBAAY,iBAAiB,GAAG,aAAa,GAAG;IAC9C,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;;;GASG;AACH,qBAAa,iBAAkB,SAAQ,aAAa,CAAC,iBAAiB,CAAC;IACrE,gBAAyB,YAAY,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAQhE;IAEF,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAA2B;IAEtE,IAAI,KAAK,IAAI,MAAM,CAA6B;IAChD,IAAI,MAAM,IAAI,MAAM,CAA8B;IAClD,IAAI,MAAM,IAAI,aAAa,CAA8B;IACzD,IAAI,OAAO,IAAI,MAAM,CAA+B;IACpD,IAAI,UAAU,SAAc;IAE5B,4BAA4B;IAC5B,QAAQ,EAAE,EAAE,CAAC;IAEb,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO;gBAIxE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,iBAAiB;IAUzD,MAAM,CAAC,IAAI,EAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,GAAG,IAAI;IAUnD,iEAAiE;IACjE,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAuBtD,aAAa;IAIb,aAAa,IAAI,IAAI;IAKrB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;CAGtD"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
let _Symbol$toStringTag;
|
|
1
3
|
import { assert } from '@luma.gl/api';
|
|
2
4
|
import GL from '@luma.gl/constants';
|
|
3
|
-
import WebGLResource from "./webgl-resource.js";
|
|
4
|
-
import { isRenderbufferFormatSupported
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
format: 0,
|
|
10
|
-
width: 1,
|
|
11
|
-
height: 1,
|
|
12
|
-
samples: 0
|
|
13
|
-
};
|
|
14
|
-
export default class WEBGLRenderbuffer extends WebGLResource {
|
|
15
|
-
get [Symbol.toStringTag]() {
|
|
5
|
+
import { WebGLResource } from "./webgl-resource.js";
|
|
6
|
+
import { isRenderbufferFormatSupported } from "../converters/texture-formats.js";
|
|
7
|
+
import { convertTextureFormatToGL, getTextureFormatBytesPerPixel } from "../converters/texture-formats.js";
|
|
8
|
+
_Symbol$toStringTag = Symbol.toStringTag;
|
|
9
|
+
export class WEBGLRenderbuffer extends WebGLResource {
|
|
10
|
+
get [_Symbol$toStringTag]() {
|
|
16
11
|
return 'Renderbuffer';
|
|
17
12
|
}
|
|
18
13
|
get width() {
|
|
@@ -27,11 +22,19 @@ export default class WEBGLRenderbuffer extends WebGLResource {
|
|
|
27
22
|
get samples() {
|
|
28
23
|
return this.props.samples;
|
|
29
24
|
}
|
|
30
|
-
|
|
31
|
-
return
|
|
25
|
+
get attachment() {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
static isTextureFormatSupported(device, format) {
|
|
29
|
+
return isRenderbufferFormatSupported(device.gl, format);
|
|
32
30
|
}
|
|
33
31
|
constructor(device, props) {
|
|
34
|
-
|
|
32
|
+
if (typeof props.format === 'number') {
|
|
33
|
+
throw new Error('Renderbuffer');
|
|
34
|
+
}
|
|
35
|
+
super(device, props, WEBGLRenderbuffer.defaultProps);
|
|
36
|
+
_defineProperty(this, "glFormat", void 0);
|
|
37
|
+
this.glFormat = convertTextureFormatToGL(this.props.format, device.isWebGL2);
|
|
35
38
|
this._initialize(this.props);
|
|
36
39
|
}
|
|
37
40
|
resize(size) {
|
|
@@ -43,7 +46,6 @@ export default class WEBGLRenderbuffer extends WebGLResource {
|
|
|
43
46
|
});
|
|
44
47
|
this._initialize(this.props);
|
|
45
48
|
}
|
|
46
|
-
return this;
|
|
47
49
|
}
|
|
48
50
|
_initialize(props) {
|
|
49
51
|
const {
|
|
@@ -56,13 +58,12 @@ export default class WEBGLRenderbuffer extends WebGLResource {
|
|
|
56
58
|
this.trackDeallocatedMemory();
|
|
57
59
|
this.gl.bindRenderbuffer(GL.RENDERBUFFER, this.handle);
|
|
58
60
|
if (samples !== 0 && this.device.isWebGL2) {
|
|
59
|
-
this.
|
|
61
|
+
this.gl2.renderbufferStorageMultisample(GL.RENDERBUFFER, samples, this.glFormat, width, height);
|
|
60
62
|
} else {
|
|
61
|
-
this.gl.renderbufferStorage(GL.RENDERBUFFER,
|
|
63
|
+
this.gl.renderbufferStorage(GL.RENDERBUFFER, this.glFormat, width, height);
|
|
62
64
|
}
|
|
63
65
|
this.gl.bindRenderbuffer(GL.RENDERBUFFER, null);
|
|
64
|
-
this.trackAllocatedMemory(width * height * (samples || 1) *
|
|
65
|
-
return this;
|
|
66
|
+
this.trackAllocatedMemory(width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat, this.device.isWebGL2));
|
|
66
67
|
}
|
|
67
68
|
_createHandle() {
|
|
68
69
|
return this.gl.createRenderbuffer();
|
|
@@ -75,4 +76,13 @@ export default class WEBGLRenderbuffer extends WebGLResource {
|
|
|
75
76
|
this.gl.bindRenderbuffer(GL.RENDERBUFFER, handle);
|
|
76
77
|
}
|
|
77
78
|
}
|
|
79
|
+
_defineProperty(WEBGLRenderbuffer, "defaultProps", {
|
|
80
|
+
id: undefined,
|
|
81
|
+
handle: undefined,
|
|
82
|
+
userData: undefined,
|
|
83
|
+
format: undefined,
|
|
84
|
+
width: 1,
|
|
85
|
+
height: 1,
|
|
86
|
+
samples: 0
|
|
87
|
+
});
|
|
78
88
|
//# sourceMappingURL=webgl-renderbuffer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-renderbuffer.js","names":["assert","GL","WebGLResource","isRenderbufferFormatSupported","
|
|
1
|
+
{"version":3,"file":"webgl-renderbuffer.js","names":["assert","GL","WebGLResource","isRenderbufferFormatSupported","convertTextureFormatToGL","getTextureFormatBytesPerPixel","_Symbol$toStringTag","Symbol","toStringTag","WEBGLRenderbuffer","width","props","height","format","samples","attachment","isTextureFormatSupported","device","gl","constructor","Error","defaultProps","_defineProperty","glFormat","isWebGL2","_initialize","resize","size","Object","assign","trackDeallocatedMemory","bindRenderbuffer","RENDERBUFFER","handle","gl2","renderbufferStorageMultisample","renderbufferStorage","trackAllocatedMemory","_createHandle","createRenderbuffer","_deleteHandle","deleteRenderbuffer","_bindHandle","id","undefined","userData"],"sources":["../../../src/adapter/objects/webgl-renderbuffer.ts"],"sourcesContent":["import {assert, ResourceProps, TextureFormat} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\nimport {WebGLResource} from './webgl-resource';\nimport {isRenderbufferFormatSupported} from '../converters/texture-formats';\nimport {convertTextureFormatToGL, getTextureFormatBytesPerPixel} from '../converters/texture-formats';\n\nexport type RenderbufferProps = ResourceProps & {\n format: TextureFormat;\n width?: number;\n height?: number;\n samples?: number;\n};\n\n/**\n * Renderbuffers are GPU objects that contain images.\n * In contrast to Textures they are optimized for use as render targets, with Framebuffers.\n * while Textures may not be, and are the logical choice when\n * you do not need to sample (i.e. in a post-pass shader)\n * from the produced image. If you need to resample\n * (such as when reading depth back in a second shader pass),\n * use Textures instead.\n * Renderbuffer objects also natively accommodate Multisampling (MSAA).\n */\nexport class WEBGLRenderbuffer extends WebGLResource<RenderbufferProps> {\n static override readonly defaultProps: Required<RenderbufferProps> = {\n id: undefined,\n handle: undefined,\n userData: undefined,\n format: undefined, // 'depth16unorm'\n width: 1,\n height: 1, \n samples: 0\n }; \n\n override get [Symbol.toStringTag](): string { return 'Renderbuffer'; }\n\n get width(): number { return this.props.width; }\n get height(): number { return this.props.height; }\n get format(): TextureFormat { return this.props.format; }\n get samples(): number { return this.props.samples; }\n get attachment() { return }\n\n /** WebGL format constant */\n glFormat: GL;\n\n static isTextureFormatSupported(device: WebGLDevice, format: TextureFormat): boolean {\n return isRenderbufferFormatSupported(device.gl, format);\n }\n\n constructor(device: WebGLDevice, props: RenderbufferProps) {\n // TODO - remove temporary sanity check\n if (typeof props.format === 'number') {\n throw new Error('Renderbuffer');\n }\n super(device, props, WEBGLRenderbuffer.defaultProps);\n this.glFormat = convertTextureFormatToGL(this.props.format, device.isWebGL2);\n this._initialize(this.props);\n }\n\n resize(size: {width: number, height: number}): void {\n // Don't resize if width/height haven't changed\n if (size.width !== this.width || size.height !== this.height) {\n Object.assign(this.props, {...size, format: this.format, samples: this.samples});\n this._initialize(this.props);\n }\n }\n\n // PRIVATE METHODS\n\n /** Creates and initializes a renderbuffer object's data store */\n protected _initialize(props: Required<RenderbufferProps>): void {\n const {format, width, height, samples} = props;\n assert(format, 'Needs format');\n\n this.trackDeallocatedMemory();\n\n this.gl.bindRenderbuffer(GL.RENDERBUFFER, this.handle);\n\n if (samples !== 0 && this.device.isWebGL2) {\n this.gl2.renderbufferStorageMultisample(GL.RENDERBUFFER, samples, this.glFormat, width, height);\n } else {\n this.gl.renderbufferStorage(GL.RENDERBUFFER, this.glFormat, width, height);\n }\n\n this.gl.bindRenderbuffer(GL.RENDERBUFFER, null);\n\n this.trackAllocatedMemory(\n width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat, this.device.isWebGL2)\n );\n }\n\n // RESOURCE IMPLEMENTATION\n\n override _createHandle() {\n return this.gl.createRenderbuffer();\n }\n\n override _deleteHandle(): void {\n this.gl.deleteRenderbuffer(this.handle);\n this.trackDeallocatedMemory();\n }\n\n override _bindHandle(handle: WEBGLRenderbuffer): void {\n this.gl.bindRenderbuffer(GL.RENDERBUFFER, handle);\n }\n}\n"],"mappings":";;AAAA,SAAQA,MAAM,QAAqC,cAAc;AACjE,OAAOC,EAAE,MAAM,oBAAoB;AAAC,SAE5BC,aAAa;AAAA,SACbC,6BAA6B;AAAA,SAC7BC,wBAAwB,EAAEC,6BAA6B;AAAAC,mBAAA,GA8B/CC,MAAM,CAACC,WAAW;AAXlC,OAAO,MAAMC,iBAAiB,SAASP,aAAa,CAAoB;EAWtE,KAAAI,mBAAA,IAA4C;IAAE,OAAO,cAAc;EAAE;EAErE,IAAII,KAAKA,CAAA,EAAW;IAAE,OAAO,IAAI,CAACC,KAAK,CAACD,KAAK;EAAE;EAC/C,IAAIE,MAAMA,CAAA,EAAW;IAAE,OAAO,IAAI,CAACD,KAAK,CAACC,MAAM;EAAE;EACjD,IAAIC,MAAMA,CAAA,EAAkB;IAAE,OAAO,IAAI,CAACF,KAAK,CAACE,MAAM;EAAE;EACxD,IAAIC,OAAOA,CAAA,EAAW;IAAE,OAAO,IAAI,CAACH,KAAK,CAACG,OAAO;EAA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ACX,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Resource } from '@luma.gl/api';
|
|
2
2
|
import type { Device, ResourceProps } from '@luma.gl/api';
|
|
3
3
|
import GL from '@luma.gl/constants';
|
|
4
|
-
import WebGLDevice from '../webgl-device';
|
|
4
|
+
import { WebGLDevice } from '../webgl-device';
|
|
5
5
|
/**
|
|
6
6
|
* Base class for WebGL object wrappers
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export declare abstract class WebGLResource<Props extends ResourceProps> extends Resource<Props> {
|
|
9
9
|
readonly device: WebGLDevice;
|
|
10
10
|
readonly gl: WebGLRenderingContext;
|
|
11
11
|
readonly gl2: WebGL2RenderingContext;
|
|
@@ -15,7 +15,6 @@ export default abstract class WebGLResource<Props extends ResourceProps> extends
|
|
|
15
15
|
constructor(device: Device, props: Props, defaultProps: Required<Props>);
|
|
16
16
|
toString(): string;
|
|
17
17
|
get handle(): any;
|
|
18
|
-
destroy(): void;
|
|
19
18
|
delete({ deleteChildren }?: {
|
|
20
19
|
deleteChildren?: boolean;
|
|
21
20
|
}): this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-resource.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/webgl-resource.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAkC,MAAM,cAAc,CAAC;AACvE,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEpC,OAAO,WAAW,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-resource.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/webgl-resource.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAkC,MAAM,cAAc,CAAC;AACvE,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,MA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EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM;IAI5D,aAAa,CAAC,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,GAAG;CAuC7C"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { Resource, assert, uid, stubRemovedMethods } from '@luma.gl/api';
|
|
3
3
|
import { isWebGL2, assertWebGLContext } from "../../context/context/webgl-checks.js";
|
|
4
|
-
import WebGLDevice from "../webgl-device.js";
|
|
5
|
-
import {
|
|
4
|
+
import { WebGLDevice } from "../webgl-device.js";
|
|
5
|
+
import { getKeyValue } from "./constants-to-keys.js";
|
|
6
6
|
const ERR_RESOURCE_METHOD_UNDEFINED = 'Resource subclass must define virtual methods';
|
|
7
|
-
export
|
|
7
|
+
export class WebGLResource extends Resource {
|
|
8
8
|
constructor(device, props, defaultProps) {
|
|
9
9
|
super(device, props, defaultProps);
|
|
10
10
|
_defineProperty(this, "device", void 0);
|
|
@@ -34,9 +34,6 @@ export default class WebGLResource extends Resource {
|
|
|
34
34
|
get handle() {
|
|
35
35
|
return this._handle;
|
|
36
36
|
}
|
|
37
|
-
destroy() {
|
|
38
|
-
this.delete();
|
|
39
|
-
}
|
|
40
37
|
delete() {
|
|
41
38
|
let {
|
|
42
39
|
deleteChildren = false
|
|
@@ -47,7 +44,7 @@ export default class WebGLResource extends Resource {
|
|
|
47
44
|
}
|
|
48
45
|
this._handle = null;
|
|
49
46
|
if (children && deleteChildren) {
|
|
50
|
-
children.filter(Boolean).forEach(child => child.
|
|
47
|
+
children.filter(Boolean).forEach(child => child.destroy());
|
|
51
48
|
}
|
|
52
49
|
return this;
|
|
53
50
|
}
|
|
@@ -104,10 +101,10 @@ export default class WebGLResource extends Resource {
|
|
|
104
101
|
const parameter = PARAMETERS[pname];
|
|
105
102
|
const parameterAvailable = parameter && (!('webgl2' in parameter) || isWebgl2) && (!('extension' in parameter) || this.gl.getExtension(parameter.extension));
|
|
106
103
|
if (parameterAvailable) {
|
|
107
|
-
const key = keys ?
|
|
104
|
+
const key = keys ? this.device.getGLKey(pname) : pname;
|
|
108
105
|
values[key] = this.getParameter(pname, options);
|
|
109
106
|
if (keys && parameter.type === 'GLenum') {
|
|
110
|
-
values[key] =
|
|
107
|
+
values[key] = this.device.getGLKey(values[key]);
|
|
111
108
|
}
|
|
112
109
|
}
|
|
113
110
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-resource.js","names":["Resource","assert","uid","stubRemovedMethods","isWebGL2","assertWebGLContext","WebGLDevice","getKey","getKeyValue","ERR_RESOURCE_METHOD_UNDEFINED","WebGLResource","constructor","device","props","defaultProps","_defineProperty","attach","gl","id","gl2","name","_handle","handle","undefined","_createHandle","byteLength","toString","concat","destroy","delete","deleteChildren","arguments","length","children","_deleteHandle","removeStats","filter","Boolean","forEach","child","bind","funcOrHandle","_bindHandle","value","_bound","unbind","getParameter","pname","parameters","PARAMETERS","parameter","isWebgl2","parameterAvailable","getExtension","extension","webgl1Default","webgl1","webgl2Default","webgl2","defaultValue","_getParameter","getParameters","options","keys","values","parameterKeys","Object","key","type","setParameter","Error","_setParameter","setParameters","className","version","methodNames","initialize","_getOptsFromHandle"],"sources":["../../../src/adapter/objects/webgl-resource.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {Resource, assert, uid, stubRemovedMethods} from '@luma.gl/api';\nimport type {Device, ResourceProps} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {isWebGL2, assertWebGLContext} from '../../context/context/webgl-checks';\nimport WebGLDevice from '../webgl-device';\n\n// Requires full GL enum to be bundled... Make these bindings dependent on dynamic import (debug)?\nimport {getKey, getKeyValue} from './constants-to-keys';\n\nconst ERR_RESOURCE_METHOD_UNDEFINED = 'Resource subclass must define virtual methods';\n\n/**\n * Base class for WebGL object wrappers\n */\nexport default abstract class WebGLResource<Props extends ResourceProps> extends Resource<Props> {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext;\n private _handle: any;\n\n private _bound = false;\n // Only meaningful for resources that allocate GPU memory\n byteLength = 0;\n\n constructor(device: Device, props: Props, defaultProps: Required<Props>) {\n super(device, props, defaultProps);\n\n this.device = WebGLDevice.attach(device);\n const gl = this.device.gl;\n\n assertWebGLContext(gl);\n\n // extends \n const {id} = props || {};\n this.gl = gl;\n this.gl2 = gl as WebGL2RenderingContext;\n this.id = id || uid(this.constructor.name);\n\n // Set the handle\n // If handle was provided, use it, otherwise create a new handle\n\n // TODO - Stores the handle with context loss information\n // this.glCount = glGetContextLossCount(this.gl);\n\n // Default VertexArray needs to be created with null handle, so compare against undefined\n this._handle = props?.handle;\n if (this._handle === undefined) {\n this._handle = this._createHandle();\n }\n\n this.byteLength = 0;\n }\n\n override toString(): string {\n return `${this.constructor.name}(${this.id})`;\n }\n\n get handle() {\n // TODO - Add context loss handling\n // Will regenerate and reinitialize the handle if necessary\n // const glCount = glGetContextLossCount(this.gl);\n // if (this.glCount !== glCount) {\n // this._handle = this._createHandle(this.props);\n // this._glCount = glCount;\n // // Reinitialize object\n // this.initialize(this.props);\n // }\n return this._handle;\n }\n\n override destroy(): void {\n this.delete();\n }\n\n override delete({deleteChildren = false} = {}) {\n // Delete this object, and get refs to any children\n // @ts-expect-error\n const children = this._handle && this._deleteHandle(this._handle);\n if (this._handle) {\n this.removeStats();\n }\n this._handle = null;\n\n // Optionally, recursively delete the children\n // @ts-expect-error\n if (children && deleteChildren) {\n // @ts-expect-error\n children.filter(Boolean).forEach((child) => child.delete());\n }\n\n return this;\n }\n\n bind(funcOrHandle = this.handle) {\n if (typeof funcOrHandle !== 'function') {\n this._bindHandle(funcOrHandle);\n return this;\n }\n\n let value;\n\n if (!this._bound) {\n this._bindHandle(this.handle);\n this._bound = true;\n\n value = funcOrHandle();\n\n this._bound = false;\n this._bindHandle(null);\n } else {\n value = funcOrHandle();\n }\n\n return value;\n }\n\n unbind() {\n this.bind(null);\n }\n\n /**\n * Query a Resource parameter\n *\n * @param name\n * @return param\n */\n getParameter(pname: number, props: any = {}): any {\n pname = getKeyValue(this.gl, pname);\n assert(pname);\n\n // @ts-expect-error\n const parameters = this.constructor.PARAMETERS || {};\n\n // Use parameter definitions to handle unsupported parameters\n const parameter = parameters[pname];\n if (parameter) {\n const isWebgl2 = isWebGL2(this.gl);\n\n // Check if we can query for this parameter\n const parameterAvailable =\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (!parameterAvailable) {\n const webgl1Default = parameter.webgl1;\n const webgl2Default = 'webgl2' in parameter ? parameter.webgl2 : parameter.webgl1;\n const defaultValue = isWebgl2 ? webgl2Default : webgl1Default;\n return defaultValue;\n }\n }\n\n // If unknown parameter - Could be a valid parameter not covered by PARAMS\n // Attempt to query for it and let WebGL report errors\n return this._getParameter(pname, props);\n }\n\n // Many resources support a getParameter call -\n // getParameters will get all parameters - slow but useful for debugging\n // eslint-disable-next-line complexity\n getParameters(options: {parameters?: any, keys?: any} = {}) {\n const {parameters, keys} = options;\n\n // Get parameter definitions for this Resource\n // @ts-expect-error\n const PARAMETERS = this.constructor.PARAMETERS || {};\n\n const isWebgl2 = isWebGL2(this.gl);\n\n const values: Record<string, any> = {};\n\n // Query all parameters if no list provided\n const parameterKeys = parameters || Object.keys(PARAMETERS);\n\n // WEBGL limits\n for (const pname of parameterKeys) {\n const parameter = PARAMETERS[pname];\n\n // Check if this parameter is available on this platform\n const parameterAvailable =\n parameter &&\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (parameterAvailable) {\n const key = keys ? getKey(this.gl, pname) : pname;\n values[key] = this.getParameter(pname, options);\n if (keys && parameter.type === 'GLenum') {\n values[key] = getKey(this.gl, values[key]);\n }\n }\n }\n\n return values;\n }\n\n /**\n * Update a Resource setting\n *\n * @todo - cache parameter to avoid issuing WebGL calls?\n *\n * @param pname - parameter (GL constant, value or key)\n * @param value {GLint|GLfloat|GLenum} \n * @return returns self to enable chaining\n */\n setParameter(pname: GL | string, value: any): this {\n pname = getKeyValue(this.gl, pname);\n assert(pname);\n\n // @ts-expect-error\n const parameters = this.constructor.PARAMETERS || {};\n\n const parameter = parameters[pname];\n if (parameter) {\n const isWebgl2 = isWebGL2(this.gl);\n\n // Check if this parameter is available on this platform\n const parameterAvailable =\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (!parameterAvailable) {\n throw new Error('Parameter not available on this platform');\n }\n\n // Handle string keys\n if (parameter.type === 'GLenum') {\n // @ts-expect-error\n value = getKeyValue(value);\n }\n }\n\n // If unknown parameter - Could be a valid parameter not covered by PARAMS\n // attempt to set it and let WebGL report errors\n this._setParameter(pname, value);\n return this;\n }\n\n /*\n * Batch update resource parameters\n * Assumes the subclass supports a setParameter call\n */\n setParameters(parameters: Record<GL, any>) {\n for (const pname in parameters) {\n this.setParameter(pname, parameters[pname]);\n }\n return this;\n }\n\n // Install stubs for removed methods\n stubRemovedMethods(className: string, version: string, methodNames: string[]) {\n return stubRemovedMethods(this, className, version, methodNames);\n }\n\n // PUBLIC VIRTUAL METHODS\n initialize(props: ResourceProps) {}\n\n // PROTECTED METHODS - These must be overridden by subclass\n _createHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _deleteHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _bindHandle(handle: any) {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _getOptsFromHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _getParameter(pname: GL, props: Record<string, any>): number {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _setParameter(pname: GL | string, value: any) {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n // PRIVATE METHODS\n\n /*\n _addStats() {\n const name = this.constructor.name;\n const stats = lumaStats.get('Resource Counts');\n\n stats.get('Resources Created').incrementCount();\n stats.get(`${name}s Created`).incrementCount();\n stats.get(`${name}s Active`).incrementCount();\n }\n\n _removeStats() {\n const name = this.constructor.name;\n const stats = lumaStats.get('Resource Counts');\n\n stats.get(`${name}s Active`).decrementCount();\n }\n\n trackAllocatedMemory(bytes, name = this.constructor.name) {\n const stats = lumaStats.get('Memory Usage');\n\n stats.get('GPU Memory').addCount(bytes);\n stats.get(`${name} Memory`).addCount(bytes);\n this.byteLength = bytes;\n }\n\n trackDeallocatedMemory(name = this.constructor.name) {\n const stats = lumaStats.get('Memory Usage');\n\n stats.get('GPU Memory').subtractCount(this.byteLength);\n stats.get(`${name} Memory`).subtractCount(this.byteLength);\n this.byteLength = 0;\n }\n */\n}\n"],"mappings":";AACA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,GAAG,EAAEC,kBAAkB,QAAO,cAAc;AAAC,SAG/DC,QAAQ,EAAEC,kBAAkB;AAAA,OAC7BC,WAAW;AAAA,SAGVC,MAAM,EAAEC,WAAW;AAE3B,MAAMC,6BAA6B,GAAG,+CAA+C;AAKrF,eAAe,MAAeC,aAAa,SAAsCV,QAAQ,CAAQ;EAU/FW,WAAWA,CAACC,MAAc,EAAEC,KAAY,EAAEC,YAA6B,EAAE;IACvE,KAAK,CAACF,MAAM,EAAEC,KAAK,EAAEC,YAAY,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,iBALpB,KAAK;IAAAA,eAAA,qBAET,CAAC;IAKZ,IAAI,CAACH,MAAM,GAAGN,WAAW,CAACU,MAAM,CAACJ,MAAM,CAAC;IACxC,MAAMK,EAAE,GAAG,IAAI,CAACL,MAAM,CAACK,EAAE;IAEzBZ,kBAAkB,CAACY,EAAE,CAAC;IAGtB,MAAM;MAACC;IAAE,CAAC,GAAGL,KAAK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;EACb;EAMA6B,aAAaA,CAACxB,UAA2B,EAAE;IACzC,KAAK,MAAMD,KAAK,IAAIC,UAAU,EAAE;MAC9B,IAAI,CAACqB,YAAY,CAACtB,KAAK,EAAEC,UAAU,CAACD,KAAK,CAAC,CAAC;IAC7C;IACA,OAAO,IAAI;EACb;EAGA5C,kBAAkBA,CAACsE,SAAiB,EAAEC,OAAe,EAAEC,WAAqB,EAAE;IAC5E,OAAOxE,kBAAkB,CAAC,IAAI,EAAEsE,SAAS,EAAEC,OAAO,EAAEC,WAAW,CAAC;EAClE;EAGAC,UAAUA,CAAC/D,KAAoB,EAAE,CAAC;EAGlCW,aAAaA,CAAA,EAAG;IACd,MAAM,IAAI8C,KAAK,CAAC7D,6BAA6B,CAAC;EAChD;EAEAyB,aAAaA,CAAA,EAAG;IACd,MAAM,IAAIoC,KAAK,CAAC7D,6BAA6B,CAAC;EAChD;EAEAiC,WAAWA,CAACpB,MAAW,EAAE;IACvB,MAAM,IAAIgD,KAAK,CAAC7D,6BAA6B,CAAC;EAChD;EAEAoE,kBAAkBA,CAAA,EAAG;IACnB,MAAM,IAAIP,KAAK,CAAC7D,6BAA6B,CAAC;EAChD;EAEAmD,aAAaA,CAACb,KAAS,EAAElC,KAA0B,EAAU;IAC3D,MAAM,IAAIyD,KAAK,CAAC7D,6BAA6B,CAAC;EAChD;EAEA8D,aAAaA,CAACxB,KAAkB,EAAEJ,KAAU,EAAE;IAC5C,MAAM,IAAI2B,KAAK,CAAC7D,6BAA6B,CAAC;EAChD;AAqCF"}
|
|
1
|
+
{"version":3,"file":"webgl-resource.js","names":["Resource","assert","uid","stubRemovedMethods","isWebGL2","assertWebGLContext","WebGLDevice","getKeyValue","ERR_RESOURCE_METHOD_UNDEFINED","WebGLResource","constructor","device","props","defaultProps","_defineProperty","attach","gl","id","gl2","name","_handle","handle","undefined","_createHandle","byteLength","toString","concat","delete","deleteChildren","arguments","length","children","_deleteHandle","removeStats","filter","Boolean","forEach","child","destroy","bind","funcOrHandle","_bindHandle","value","_bound","unbind","getParameter","pname","parameters","PARAMETERS","parameter","isWebgl2","parameterAvailable","getExtension","extension","webgl1Default","webgl1","webgl2Default","webgl2","defaultValue","_getParameter","getParameters","options","keys","values","parameterKeys","Object","key","getGLKey","type","setParameter","Error","_setParameter","setParameters","className","version","methodNames","initialize","_getOptsFromHandle"],"sources":["../../../src/adapter/objects/webgl-resource.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {Resource, assert, uid, stubRemovedMethods} from '@luma.gl/api';\nimport type {Device, ResourceProps} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {isWebGL2, assertWebGLContext} from '../../context/context/webgl-checks';\nimport {WebGLDevice} from '../webgl-device';\n\n// Requires full GL enum to be bundled... Make these bindings dependent on dynamic import (debug)?\nimport {getKeyValue} from './constants-to-keys';\n\nconst ERR_RESOURCE_METHOD_UNDEFINED = 'Resource subclass must define virtual methods';\n\n/**\n * Base class for WebGL object wrappers\n */\nexport abstract class WebGLResource<Props extends ResourceProps> extends Resource<Props> {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext;\n private _handle: any;\n\n private _bound = false;\n // Only meaningful for resources that allocate GPU memory\n byteLength = 0;\n\n constructor(device: Device, props: Props, defaultProps: Required<Props>) {\n super(device, props, defaultProps);\n\n this.device = WebGLDevice.attach(device);\n const gl = this.device.gl;\n\n assertWebGLContext(gl);\n\n // extends \n const {id} = props || {};\n this.gl = gl;\n this.gl2 = gl as WebGL2RenderingContext;\n this.id = id || uid(this.constructor.name);\n\n // Set the handle\n // If handle was provided, use it, otherwise create a new handle\n\n // TODO - Stores the handle with context loss information\n // this.glCount = glGetContextLossCount(this.gl);\n\n // Default VertexArray needs to be created with null handle, so compare against undefined\n this._handle = props?.handle;\n if (this._handle === undefined) {\n this._handle = this._createHandle();\n }\n\n this.byteLength = 0;\n }\n\n override toString(): string {\n return `${this.constructor.name}(${this.id})`;\n }\n\n get handle() {\n // TODO - Add context loss handling\n // Will regenerate and reinitialize the handle if necessary\n // const glCount = glGetContextLossCount(this.gl);\n // if (this.glCount !== glCount) {\n // this._handle = this._createHandle(this.props);\n // this._glCount = glCount;\n // // Reinitialize object\n // this.initialize(this.props);\n // }\n return this._handle;\n }\n\n override delete({deleteChildren = false} = {}) {\n // Delete this object, and get refs to any children\n // @ts-expect-error\n const children = this._handle && this._deleteHandle(this._handle);\n if (this._handle) {\n this.removeStats();\n }\n this._handle = null;\n\n // Optionally, recursively delete the children\n // @ts-expect-error\n if (children && deleteChildren) {\n // @ts-expect-error\n children.filter(Boolean).forEach((child) => child.destroy());\n }\n\n return this;\n }\n\n bind(funcOrHandle = this.handle) {\n if (typeof funcOrHandle !== 'function') {\n this._bindHandle(funcOrHandle);\n return this;\n }\n\n let value;\n\n if (!this._bound) {\n this._bindHandle(this.handle);\n this._bound = true;\n\n value = funcOrHandle();\n\n this._bound = false;\n this._bindHandle(null);\n } else {\n value = funcOrHandle();\n }\n\n return value;\n }\n\n unbind() {\n this.bind(null);\n }\n\n /**\n * Query a Resource parameter\n *\n * @param name\n * @return param\n */\n getParameter(pname: number, props: any = {}): any {\n pname = getKeyValue(this.gl, pname);\n assert(pname);\n\n // @ts-expect-error\n const parameters = this.constructor.PARAMETERS || {};\n\n // Use parameter definitions to handle unsupported parameters\n const parameter = parameters[pname];\n if (parameter) {\n const isWebgl2 = isWebGL2(this.gl);\n\n // Check if we can query for this parameter\n const parameterAvailable =\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (!parameterAvailable) {\n const webgl1Default = parameter.webgl1;\n const webgl2Default = 'webgl2' in parameter ? parameter.webgl2 : parameter.webgl1;\n const defaultValue = isWebgl2 ? webgl2Default : webgl1Default;\n return defaultValue;\n }\n }\n\n // If unknown parameter - Could be a valid parameter not covered by PARAMS\n // Attempt to query for it and let WebGL report errors\n return this._getParameter(pname, props);\n }\n\n // Many resources support a getParameter call -\n // getParameters will get all parameters - slow but useful for debugging\n // eslint-disable-next-line complexity\n getParameters(options: {parameters?: any, keys?: any} = {}) {\n const {parameters, keys} = options;\n\n // Get parameter definitions for this Resource\n // @ts-expect-error\n const PARAMETERS = this.constructor.PARAMETERS || {};\n\n const isWebgl2 = isWebGL2(this.gl);\n\n const values: Record<string, any> = {};\n\n // Query all parameters if no list provided\n const parameterKeys = parameters || Object.keys(PARAMETERS);\n\n // WEBGL limits\n for (const pname of parameterKeys) {\n const parameter = PARAMETERS[pname];\n\n // Check if this parameter is available on this platform\n const parameterAvailable =\n parameter &&\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (parameterAvailable) {\n const key = keys ? this.device.getGLKey(pname) : pname;\n values[key] = this.getParameter(pname, options);\n if (keys && parameter.type === 'GLenum') {\n values[key] = this.device.getGLKey(values[key]);\n }\n }\n }\n\n return values;\n }\n\n /**\n * Update a Resource setting\n *\n * @todo - cache parameter to avoid issuing WebGL calls?\n *\n * @param pname - parameter (GL constant, value or key)\n * @param value {GLint|GLfloat|GLenum} \n * @return returns self to enable chaining\n */\n setParameter(pname: GL | string, value: any): this {\n pname = getKeyValue(this.gl, pname);\n assert(pname);\n\n // @ts-expect-error\n const parameters = this.constructor.PARAMETERS || {};\n\n const parameter = parameters[pname];\n if (parameter) {\n const isWebgl2 = isWebGL2(this.gl);\n\n // Check if this parameter is available on this platform\n const parameterAvailable =\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (!parameterAvailable) {\n throw new Error('Parameter not available on this platform');\n }\n\n // Handle string keys\n if (parameter.type === 'GLenum') {\n // @ts-expect-error\n value = getKeyValue(value);\n }\n }\n\n // If unknown parameter - Could be a valid parameter not covered by PARAMS\n // attempt to set it and let WebGL report errors\n this._setParameter(pname, value);\n return this;\n }\n\n /*\n * Batch update resource parameters\n * Assumes the subclass supports a setParameter call\n */\n setParameters(parameters: Record<GL, any>) {\n for (const pname in parameters) {\n this.setParameter(pname, parameters[pname]);\n }\n return this;\n }\n\n // Install stubs for removed methods\n stubRemovedMethods(className: string, version: string, methodNames: string[]) {\n return stubRemovedMethods(this, className, version, methodNames);\n }\n\n // PUBLIC VIRTUAL METHODS\n initialize(props: ResourceProps) {}\n\n // PROTECTED METHODS - These must be overridden by subclass\n _createHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _deleteHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _bindHandle(handle: any) {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _getOptsFromHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _getParameter(pname: GL, props: Record<string, any>): number {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _setParameter(pname: GL | string, value: any) {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n // PRIVATE METHODS\n\n /*\n _addStats() {\n const name = this.constructor.name;\n const stats = lumaStats.get('Resource Counts');\n\n stats.get('Resources Created').incrementCount();\n stats.get(`${name}s Created`).incrementCount();\n stats.get(`${name}s Active`).incrementCount();\n }\n\n _removeStats() {\n const name = this.constructor.name;\n const stats = lumaStats.get('Resource Counts');\n\n stats.get(`${name}s Active`).decrementCount();\n }\n\n trackAllocatedMemory(bytes, name = this.constructor.name) {\n const stats = lumaStats.get('Memory Usage');\n\n stats.get('GPU Memory').addCount(bytes);\n stats.get(`${name} Memory`).addCount(bytes);\n this.byteLength = bytes;\n }\n\n trackDeallocatedMemory(name = this.constructor.name) {\n const stats = lumaStats.get('Memory Usage');\n\n stats.get('GPU Memory').subtractCount(this.byteLength);\n stats.get(`${name} Memory`).subtractCount(this.byteLength);\n this.byteLength = 0;\n }\n */\n}\n"],"mappings":";AACA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,GAAG,EAAEC,kBAAkB,QAAO,cAAc;AAA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AAC;EAChD;EAEAmD,aAAaA,CAACb,KAAS,EAAElC,KAA0B,EAAU;IAC3D,MAAM,IAAI0D,KAAK,CAAC9D,6BAA6B,CAAC;EAChD;EAEA+D,aAAaA,CAACzB,KAAkB,EAAEJ,KAAU,EAAE;IAC5C,MAAM,IAAI4B,KAAK,CAAC9D,6BAA6B,CAAC;EAChD;AAqCF"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { ResourceProps } from '@luma.gl/api';
|
|
2
|
-
import WebGLDevice from '../webgl-device';
|
|
3
|
-
import WebGLResource from './webgl-resource';
|
|
4
|
-
import
|
|
2
|
+
import { WebGLDevice } from '../webgl-device';
|
|
3
|
+
import { WebGLResource } from './webgl-resource';
|
|
4
|
+
import { WEBGLBuffer } from '../resources/webgl-buffer';
|
|
5
5
|
/**
|
|
6
6
|
* VertexArrayObject properties
|
|
7
7
|
*/
|
|
8
8
|
export declare type VertexArrayObjectProps = ResourceProps & {};
|
|
9
9
|
/** VertexArrayObject wrapper */
|
|
10
|
-
export
|
|
10
|
+
export declare class WEBGLVertexArrayObject extends WebGLResource<VertexArrayObjectProps> {
|
|
11
11
|
get [Symbol.toStringTag](): string;
|
|
12
12
|
constructor(device: WebGLDevice, props?: VertexArrayObjectProps);
|
|
13
13
|
_createHandle(): WebGLVertexArrayObject;
|
|
14
14
|
_deleteHandle(): void;
|
|
15
15
|
_bindHandle(handle: WEBGLVertexArrayObject): void;
|
|
16
|
-
setElementBuffer(elementBuffer?:
|
|
16
|
+
setElementBuffer(elementBuffer?: WEBGLBuffer | null, opts?: {}): this;
|
|
17
17
|
/** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */
|
|
18
|
-
setBuffer(location: number, buffer:
|
|
18
|
+
setBuffer(location: number, buffer: WEBGLBuffer, accessor: any): this;
|
|
19
19
|
/**
|
|
20
20
|
* Enabling an attribute location makes it reference the currently bound buffer
|
|
21
21
|
* Disabling an attribute location makes it reference the global constant value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-vertex-array-object.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/webgl-vertex-array-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,aAAa,EAAC,MAAM,cAAc,CAAC;AAInD,OAAO,WAAW,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-vertex-array-object.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/webgl-vertex-array-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,aAAa,EAAC,MAAM,cAAc,CAAC;AAInD,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC;AAItD;;GAEG;AACH,oBAAY,sBAAsB,GAAG,aAAa,GAAG,EACpD,CAAC;AAEF,gCAAgC;AAChC,qBAAa,sBAAuB,SAAQ,aAAa,CAAC,sBAAsB,CAAC;IAC/E,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAE1C;gBAEW,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,sBAAsB;IAKtD,aAAa;IAIb,aAAa,IAAI,IAAI;IAOrB,WAAW,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI;IAM1D,gBAAgB,CAAC,aAAa,GAAE,WAAW,GAAG,IAAW,EAAE,IAAI,KAAK;IAWpE,gGAAgG;IAChG,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI;IAgCrE;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAO,GAAG,IAAI;CAe9C"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { assert } from '@luma.gl/api';
|
|
2
2
|
import GL from '@luma.gl/constants';
|
|
3
3
|
import { getBrowser } from '@probe.gl/env';
|
|
4
|
-
import WebGLResource from "./webgl-resource.js";
|
|
4
|
+
import { WebGLResource } from "./webgl-resource.js";
|
|
5
5
|
const ERR_ELEMENTS = 'elements must be GL.ELEMENT_ARRAY_BUFFER';
|
|
6
|
-
export
|
|
6
|
+
export class WEBGLVertexArrayObject extends WebGLResource {
|
|
7
7
|
get [Symbol.toStringTag]() {
|
|
8
8
|
return 'BaseVertexArrayObject';
|
|
9
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-vertex-array-object.js","names":["assert","GL","getBrowser","WebGLResource","ERR_ELEMENTS","WEBGLVertexArrayObject","Symbol","toStringTag","constructor","device","props","_createHandle","gl2","createVertexArray","_deleteHandle","deleteVertexArray","handle","elements","_bindHandle","bindVertexArray","setElementBuffer","elementBuffer","arguments","length","undefined","opts","target","ELEMENT_ARRAY_BUFFER","bind","gl","bindBuffer","setBuffer","location","buffer","accessor","size","type","stride","offset","normalized","integer","divisor","Number","ARRAY_BUFFER","assertWebGL2","vertexAttribIPointer","vertexAttribPointer","enableVertexAttribArray","vertexAttribDivisor","enable","canDisableAttributeZero","isWebGL2","canDisableAttribute","disableVertexAttribArray"],"sources":["../../../src/adapter/objects/webgl-vertex-array-object.ts"],"sourcesContent":["import {assert, ResourceProps} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {getBrowser} from '@probe.gl/env';\n\nimport WebGLDevice from '../webgl-device';\nimport WebGLResource from './webgl-resource';\n\nimport
|
|
1
|
+
{"version":3,"file":"webgl-vertex-array-object.js","names":["assert","GL","getBrowser","WebGLResource","ERR_ELEMENTS","WEBGLVertexArrayObject","Symbol","toStringTag","constructor","device","props","_createHandle","gl2","createVertexArray","_deleteHandle","deleteVertexArray","handle","elements","_bindHandle","bindVertexArray","setElementBuffer","elementBuffer","arguments","length","undefined","opts","target","ELEMENT_ARRAY_BUFFER","bind","gl","bindBuffer","setBuffer","location","buffer","accessor","size","type","stride","offset","normalized","integer","divisor","Number","ARRAY_BUFFER","assertWebGL2","vertexAttribIPointer","vertexAttribPointer","enableVertexAttribArray","vertexAttribDivisor","enable","canDisableAttributeZero","isWebGL2","canDisableAttribute","disableVertexAttribArray"],"sources":["../../../src/adapter/objects/webgl-vertex-array-object.ts"],"sourcesContent":["import {assert, ResourceProps} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {getBrowser} from '@probe.gl/env';\n\nimport {WebGLDevice} from '../webgl-device';\nimport {WebGLResource} from './webgl-resource';\n\nimport {WEBGLBuffer} from '../resources/webgl-buffer';\n\nconst ERR_ELEMENTS = 'elements must be GL.ELEMENT_ARRAY_BUFFER';\n\n/**\n * VertexArrayObject properties\n */\nexport type VertexArrayObjectProps = ResourceProps & {\n};\n\n/** VertexArrayObject wrapper */\nexport class WEBGLVertexArrayObject extends WebGLResource<VertexArrayObjectProps> {\n override get [Symbol.toStringTag](): string {\n return 'BaseVertexArrayObject';\n }\n\n constructor(device: WebGLDevice, props?: VertexArrayObjectProps) {\n // @ts-expect-error\n super(device, props, {});\n }\n\n override _createHandle() {\n return this.gl2.createVertexArray();\n }\n\n override _deleteHandle(): void {\n this.gl2.deleteVertexArray(this.handle);\n // @ts-expect-error\n return [this.elements];\n // return [this.elements, ...this.buffers];\n }\n\n override _bindHandle(handle: WEBGLVertexArrayObject): void {\n this.gl2.bindVertexArray(handle);\n }\n\n // Set (bind) an elements buffer, for indexed rendering.\n // Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported\n setElementBuffer(elementBuffer: WEBGLBuffer | null = null, opts = {}) {\n assert(!elementBuffer || elementBuffer.target === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);\n\n // The GL.ELEMENT_ARRAY_BUFFER_BINDING is stored on the VertexArrayObject...\n this.bind(() => {\n this.gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, elementBuffer ? elementBuffer.handle : null);\n });\n\n return this;\n }\n\n /** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */\n setBuffer(location: number, buffer: WEBGLBuffer, accessor: any): this {\n // Check target\n if (buffer.target === GL.ELEMENT_ARRAY_BUFFER) {\n return this.setElementBuffer(buffer, accessor);\n }\n\n const {size, type, stride, offset, normalized, integer, divisor} = accessor;\n\n const {gl, gl2} = this;\n location = Number(location);\n\n this.bind(() => {\n // A non-zero buffer object must be bound to the GL_ARRAY_BUFFER target\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer.handle);\n\n // WebGL2 supports *integer* data formats, i.e. GPU will see integer values\n if (integer) {\n this.device.assertWebGL2();\n gl2.vertexAttribIPointer(location, size, type, stride, offset);\n } else {\n // Attaches ARRAY_BUFFER with specified buffer format to location\n gl.vertexAttribPointer(location, size, type, normalized, stride, offset);\n }\n gl.enableVertexAttribArray(location);\n gl2.vertexAttribDivisor(location, divisor || 0);\n\n // NOTE We don't unbind buffer here, typically another buffer will be bound just after\n });\n\n return this;\n }\n\n /**\n * Enabling an attribute location makes it reference the currently bound buffer\n * Disabling an attribute location makes it reference the global constant value\n * TODO - handle single values for size 1 attributes?\n * TODO - convert classic arrays based on known type?\n */\n enable(location: number, enable = true): this {\n // Attribute 0 cannot be disabled in most desktop OpenGL based browsers...\n const canDisableAttributeZero = this.device.isWebGL2 || getBrowser() === 'Chrome';\n const canDisableAttribute = canDisableAttributeZero || location !== 0;\n\n if (enable || canDisableAttribute) {\n location = Number(location);\n this.bind(() =>\n enable\n ? this.gl.enableVertexAttribArray(location)\n : this.gl.disableVertexAttribArray(location)\n );\n }\n return this;\n }\n}\n"],"mappings":"AAAA,SAAQA,MAAM,QAAsB,cAAc;AAClD,OAAOC,EAAE,MAAM,oBAAoB;AACnC,SAAQC,UAAU,QAAO,eAAe;AAAC,SAGjCC,aAAa;AAIrB,MAAMC,YAAY,GAAG,0CAA0C;AAS/D,OAAO,MAAMC,sBAAsB,SAASF,aAAa,CAAyB;EAChF,KAAcG,MAAM,CAACC,WAAW,IAAY;IAC1C,OAAO,uBAAuB;EAChC;EAE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ACpB,EAAE,CAACkB,uBAAuB,CAACf,QAAQ,CAAC,GACzC,IAAI,CAACH,EAAE,CAACwB,wBAAwB,CAACrB,QAAQ,CAAC,CAC/C;IACH;IACA,OAAO,IAAI;EACb;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { BufferProps } from '@luma.gl/api';
|
|
2
2
|
import { Buffer } from '@luma.gl/api';
|
|
3
|
-
import WebGLDevice from '../webgl-device';
|
|
3
|
+
import { WebGLDevice } from '../webgl-device';
|
|
4
4
|
/** WebGL Buffer interface */
|
|
5
|
-
export
|
|
5
|
+
export declare class WEBGLBuffer extends Buffer {
|
|
6
6
|
readonly device: WebGLDevice;
|
|
7
7
|
readonly gl: WebGLRenderingContext;
|
|
8
8
|
readonly gl2: WebGL2RenderingContext | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAC,MAAM,EAAS,MAAM,cAAc,CAAC;AAE5C,OAAO,WAAW,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAC,MAAM,EAAS,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAI5C,6BAA6B;AAC7B,qBAAa,WAAY,SAAQ,MAAM;IACrC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,EAAE,EAAE,qBAAqB,CAAC;IACnC,QAAQ,CAAC,GAAG,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAC5C,QAAQ,CAAC,M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