@luma.gl/webgl 8.6.0-alpha.2 → 8.6.0-alpha.3
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/LICENSE +8 -1
- package/dist/adapter/converters/set-device-parameters.d.ts +5 -0
- package/dist/adapter/converters/set-device-parameters.d.ts.map +1 -0
- package/dist/adapter/converters/set-device-parameters.js +124 -0
- package/dist/adapter/converters/set-device-parameters.js.map +1 -0
- package/dist/adapter/converters/webgpu-texture-formats.d.ts +281 -0
- package/dist/adapter/converters/webgpu-texture-formats.d.ts.map +1 -0
- package/dist/adapter/converters/webgpu-texture-formats.js +285 -0
- package/dist/adapter/converters/webgpu-texture-formats.js.map +1 -0
- package/dist/{device → adapter/device-helpers}/device-features.d.ts +0 -0
- package/dist/adapter/device-helpers/device-features.d.ts.map +1 -0
- package/dist/{esm/device → adapter/device-helpers}/device-features.js +2 -2
- package/dist/adapter/device-helpers/device-features.js.map +1 -0
- package/dist/{device → adapter/device-helpers}/device-limits.d.ts +0 -0
- package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -0
- package/dist/{esm/device → adapter/device-helpers}/device-limits.js +1 -1
- package/dist/adapter/device-helpers/device-limits.js.map +1 -0
- package/dist/{device → adapter/device-helpers}/get-device-info.d.ts +0 -0
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -0
- package/dist/{device → adapter/device-helpers}/get-device-info.js +1 -1
- package/dist/adapter/device-helpers/get-device-info.js.map +1 -0
- package/dist/{webgl-utils → adapter/device-helpers}/is-old-ie.d.ts +0 -0
- package/dist/adapter/device-helpers/is-old-ie.d.ts.map +1 -0
- package/dist/{esm/webgl-utils → adapter/device-helpers}/is-old-ie.js +0 -0
- package/dist/adapter/device-helpers/is-old-ie.js.map +1 -0
- package/dist/{device → adapter}/webgl-device.d.ts +3 -3
- package/dist/adapter/webgl-device.d.ts.map +1 -0
- package/dist/{esm/device → adapter}/webgl-device.js +6 -6
- package/dist/adapter/webgl-device.js.map +1 -0
- package/dist/adapter/webgl-shader.d.ts +18 -0
- package/dist/adapter/webgl-shader.d.ts.map +1 -0
- package/dist/adapter/webgl-shader.js +82 -0
- package/dist/adapter/webgl-shader.js.map +1 -0
- package/dist/classes/framebuffer.js +1 -1
- package/dist/classes/framebuffer.js.map +1 -1
- package/dist/classes/program-configuration.d.ts +14 -17
- package/dist/classes/program-configuration.d.ts.map +1 -1
- package/dist/classes/program-configuration.js +10 -97
- package/dist/classes/program-configuration.js.map +1 -1
- package/dist/classes/program.d.ts +20 -15
- package/dist/classes/program.d.ts.map +1 -1
- package/dist/classes/program.js +31 -22
- package/dist/classes/program.js.map +1 -1
- package/dist/classes/query.js +1 -1
- package/dist/classes/query.js.map +1 -1
- package/dist/classes/renderbuffer.js +1 -1
- package/dist/classes/renderbuffer.js.map +1 -1
- package/dist/classes/{webgl-shader.d.ts → shader.d.ts} +4 -15
- package/dist/classes/shader.d.ts.map +1 -0
- package/dist/{esm/classes/webgl-shader.js → classes/shader.js} +6 -81
- package/dist/classes/shader.js.map +1 -0
- package/dist/classes/texture-3d.js +1 -1
- package/dist/classes/texture-3d.js.map +1 -1
- package/dist/classes/texture-cube.js.map +1 -1
- package/dist/classes/texture.d.ts +1 -1
- package/dist/classes/texture.d.ts.map +1 -1
- package/dist/classes/texture.js +1 -1
- package/dist/classes/texture.js.map +1 -1
- package/dist/classes/transform-feedback.js +1 -1
- package/dist/classes/transform-feedback.js.map +1 -1
- package/dist/classes/vertex-array-object.d.ts +6 -5
- package/dist/classes/vertex-array-object.d.ts.map +1 -1
- package/dist/classes/vertex-array-object.js +5 -5
- package/dist/classes/vertex-array-object.js.map +1 -1
- package/dist/classes/vertex-array.d.ts +13 -13
- package/dist/classes/vertex-array.d.ts.map +1 -1
- package/dist/classes/vertex-array.js +2 -2
- package/dist/classes/vertex-array.js.map +1 -1
- package/dist/classes/webgl-buffer.d.ts +1 -1
- package/dist/classes/webgl-buffer.d.ts.map +1 -1
- package/dist/classes/webgl-buffer.js +1 -1
- package/dist/classes/webgl-buffer.js.map +1 -1
- package/dist/classes/webgl-resource.d.ts +1 -1
- package/dist/classes/webgl-resource.d.ts.map +1 -1
- package/dist/classes/webgl-resource.js +1 -1
- package/dist/classes/webgl-resource.js.map +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts +2 -1
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/parameters/webgl-parameters.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameters.js.map +1 -1
- package/dist/es5/adapter/converters/set-device-parameters.js +138 -0
- package/dist/es5/adapter/converters/set-device-parameters.js.map +1 -0
- package/dist/es5/adapter/converters/webgpu-texture-formats.js +296 -0
- package/dist/es5/adapter/converters/webgpu-texture-formats.js.map +1 -0
- package/dist/es5/{device → adapter/device-helpers}/device-features.js +2 -2
- package/dist/es5/adapter/device-helpers/device-features.js.map +1 -0
- package/dist/es5/{device → adapter/device-helpers}/device-limits.js +1 -1
- package/dist/es5/adapter/device-helpers/device-limits.js.map +1 -0
- package/dist/es5/{device → adapter/device-helpers}/get-device-info.js +1 -1
- package/dist/es5/adapter/device-helpers/get-device-info.js.map +1 -0
- package/dist/es5/{webgl-utils → adapter/device-helpers}/is-old-ie.js +0 -0
- package/dist/es5/adapter/device-helpers/is-old-ie.js.map +1 -0
- package/dist/es5/{device → adapter}/webgl-device.js +6 -6
- package/dist/es5/adapter/webgl-device.js.map +1 -0
- package/dist/es5/adapter/webgl-shader.js +155 -0
- package/dist/es5/adapter/webgl-shader.js.map +1 -0
- package/dist/es5/classes/framebuffer.js +1 -1
- package/dist/es5/classes/framebuffer.js.map +1 -1
- package/dist/es5/classes/program-configuration.js +34 -101
- package/dist/es5/classes/program-configuration.js.map +1 -1
- package/dist/es5/classes/program.js +38 -27
- package/dist/es5/classes/program.js.map +1 -1
- package/dist/es5/classes/query.js +1 -1
- package/dist/es5/classes/query.js.map +1 -1
- package/dist/es5/classes/renderbuffer.js +1 -1
- package/dist/es5/classes/renderbuffer.js.map +1 -1
- package/dist/es5/classes/{webgl-shader.js → shader.js} +18 -132
- package/dist/es5/classes/shader.js.map +1 -0
- package/dist/es5/classes/texture-3d.js +1 -1
- package/dist/es5/classes/texture-3d.js.map +1 -1
- package/dist/es5/classes/texture-cube.js.map +1 -1
- package/dist/es5/classes/texture.js +1 -1
- package/dist/es5/classes/texture.js.map +1 -1
- package/dist/es5/classes/transform-feedback.js +1 -1
- package/dist/es5/classes/transform-feedback.js.map +1 -1
- package/dist/es5/classes/vertex-array-object.js +5 -5
- package/dist/es5/classes/vertex-array-object.js.map +1 -1
- package/dist/es5/classes/vertex-array.js +5 -5
- package/dist/es5/classes/vertex-array.js.map +1 -1
- package/dist/es5/classes/webgl-buffer.js +1 -1
- package/dist/es5/classes/webgl-buffer.js.map +1 -1
- package/dist/es5/classes/webgl-resource.js +1 -1
- package/dist/es5/classes/webgl-resource.js.map +1 -1
- package/dist/es5/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/es5/context/parameters/webgl-parameters.js.map +1 -1
- package/dist/es5/helpers/get-program-bindings.js +274 -0
- package/dist/es5/helpers/get-program-bindings.js.map +1 -0
- package/dist/es5/helpers/program-bindings.js +2 -0
- package/dist/es5/helpers/program-bindings.js.map +1 -0
- package/dist/es5/index.js +31 -15
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/init.js +1 -1
- package/dist/es5/init.js.map +1 -1
- package/dist/es5/types/accessor.d.ts +29 -0
- package/dist/esm/adapter/converters/set-device-parameters.js +124 -0
- package/dist/esm/adapter/converters/set-device-parameters.js.map +1 -0
- package/dist/esm/adapter/converters/webgpu-texture-formats.js +285 -0
- package/dist/esm/adapter/converters/webgpu-texture-formats.js.map +1 -0
- package/dist/{device → esm/adapter/device-helpers}/device-features.js +2 -2
- package/dist/esm/adapter/device-helpers/device-features.js.map +1 -0
- package/dist/{device → esm/adapter/device-helpers}/device-limits.js +1 -1
- package/dist/esm/adapter/device-helpers/device-limits.js.map +1 -0
- package/dist/esm/{device → adapter/device-helpers}/get-device-info.js +1 -1
- package/dist/esm/adapter/device-helpers/get-device-info.js.map +1 -0
- package/dist/{webgl-utils → esm/adapter/device-helpers}/is-old-ie.js +0 -0
- package/dist/esm/adapter/device-helpers/is-old-ie.js.map +1 -0
- package/dist/{device → esm/adapter}/webgl-device.js +6 -6
- package/dist/esm/adapter/webgl-device.js.map +1 -0
- package/dist/esm/adapter/webgl-shader.js +82 -0
- package/dist/esm/adapter/webgl-shader.js.map +1 -0
- package/dist/esm/classes/framebuffer.js +1 -1
- package/dist/esm/classes/framebuffer.js.map +1 -1
- package/dist/esm/classes/program-configuration.js +10 -97
- package/dist/esm/classes/program-configuration.js.map +1 -1
- package/dist/esm/classes/program.js +31 -22
- package/dist/esm/classes/program.js.map +1 -1
- package/dist/esm/classes/query.js +1 -1
- package/dist/esm/classes/query.js.map +1 -1
- package/dist/esm/classes/renderbuffer.js +1 -1
- package/dist/esm/classes/renderbuffer.js.map +1 -1
- package/dist/{classes/webgl-shader.js → esm/classes/shader.js} +6 -81
- package/dist/esm/classes/shader.js.map +1 -0
- package/dist/esm/classes/texture-3d.js +1 -1
- package/dist/esm/classes/texture-3d.js.map +1 -1
- package/dist/esm/classes/texture-cube.js.map +1 -1
- package/dist/esm/classes/texture.js +1 -1
- package/dist/esm/classes/texture.js.map +1 -1
- package/dist/esm/classes/transform-feedback.js +1 -1
- package/dist/esm/classes/transform-feedback.js.map +1 -1
- package/dist/esm/classes/vertex-array-object.js +5 -5
- package/dist/esm/classes/vertex-array-object.js.map +1 -1
- package/dist/esm/classes/vertex-array.js +2 -2
- package/dist/esm/classes/vertex-array.js.map +1 -1
- package/dist/esm/classes/webgl-buffer.js +1 -1
- package/dist/esm/classes/webgl-buffer.js.map +1 -1
- package/dist/esm/classes/webgl-resource.js +1 -1
- package/dist/esm/classes/webgl-resource.js.map +1 -1
- package/dist/esm/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/esm/context/parameters/webgl-parameters.js.map +1 -1
- package/dist/esm/helpers/get-program-bindings.js +228 -0
- package/dist/esm/helpers/get-program-bindings.js.map +1 -0
- package/dist/esm/helpers/program-bindings.js +2 -0
- package/dist/esm/helpers/program-bindings.js.map +1 -0
- package/dist/esm/index.js +4 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/init.js +1 -1
- package/dist/esm/init.js.map +1 -1
- package/dist/esm/types/accessor.d.ts +29 -0
- package/dist/helpers/get-program-bindings.d.ts +8 -0
- package/dist/helpers/get-program-bindings.d.ts.map +1 -0
- package/dist/helpers/get-program-bindings.js +228 -0
- package/dist/helpers/get-program-bindings.js.map +1 -0
- package/dist/helpers/program-bindings.d.ts +41 -0
- package/dist/helpers/program-bindings.d.ts.map +1 -0
- package/dist/helpers/program-bindings.js +2 -0
- package/dist/helpers/program-bindings.js.map +1 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/init.js +1 -1
- package/dist/init.js.map +1 -1
- package/dist/types/accessor.d.ts +29 -0
- package/package.json +5 -5
- package/src/adapter/converters/set-device-parameters.ts +182 -0
- package/src/adapter/converters/webgpu-texture-formats.ts +167 -0
- package/src/{device → adapter/device-helpers}/device-features.ts +4 -4
- package/src/{device → adapter/device-helpers}/device-limits.ts +1 -1
- package/src/{device → adapter/device-helpers}/get-device-info.ts +2 -2
- package/src/{webgl-utils → adapter/device-helpers}/is-old-ie.ts +0 -0
- package/src/{device → adapter}/webgl-device.ts +9 -9
- package/src/adapter/webgl-shader.ts +84 -0
- package/src/classes/framebuffer.ts +1 -1
- package/src/classes/program-configuration.ts +28 -81
- package/src/classes/program.ts +70 -62
- package/src/classes/query.ts +1 -1
- package/src/classes/renderbuffer.ts +1 -1
- package/src/classes/{webgl-shader.ts → shader.ts} +6 -79
- package/src/classes/texture-3d.ts +1 -1
- package/src/classes/texture-cube.ts +1 -1
- package/src/classes/texture.ts +1 -1
- package/src/classes/transform-feedback.ts +1 -1
- package/src/classes/vertex-array-object.ts +9 -8
- package/src/classes/vertex-array.ts +14 -8
- package/src/classes/webgl-buffer.ts +1 -1
- package/src/classes/webgl-resource.ts +1 -1
- package/src/context/parameters/unified-parameter-api.ts +3 -2
- package/src/context/parameters/webgl-parameters.ts +115 -115
- package/src/helpers/get-program-bindings.ts +244 -0
- package/src/helpers/program-bindings.ts +46 -0
- package/src/index.ts +12 -6
- package/src/init.ts +1 -1
- package/src/types/accessor.d.ts +29 -0
- package/dist/api/device2.d.ts +0 -52
- package/dist/api/device2.d.ts.map +0 -1
- package/dist/api/device2.js +0 -23
- package/dist/api/device2.js.map +0 -1
- package/dist/classes/webgl-shader.d.ts.map +0 -1
- package/dist/classes/webgl-shader.js.map +0 -1
- package/dist/device/check-glsl-extension.d.ts +0 -4
- package/dist/device/check-glsl-extension.d.ts.map +0 -1
- package/dist/device/check-glsl-extension.js +0 -22
- package/dist/device/check-glsl-extension.js.map +0 -1
- package/dist/device/device-features.d.ts.map +0 -1
- package/dist/device/device-features.js.map +0 -1
- package/dist/device/device-limits.d.ts.map +0 -1
- package/dist/device/device-limits.js.map +0 -1
- package/dist/device/get-device-info.d.ts.map +0 -1
- package/dist/device/get-device-info.js.map +0 -1
- package/dist/device/webgl-device.d.ts.map +0 -1
- package/dist/device/webgl-device.js.map +0 -1
- package/dist/es5/api/device2.js +0 -42
- package/dist/es5/api/device2.js.map +0 -1
- package/dist/es5/classes/webgl-shader.js.map +0 -1
- package/dist/es5/device/check-glsl-extension.js +0 -33
- package/dist/es5/device/check-glsl-extension.js.map +0 -1
- package/dist/es5/device/device-features.js.map +0 -1
- package/dist/es5/device/device-limits.js.map +0 -1
- package/dist/es5/device/get-device-info.js.map +0 -1
- package/dist/es5/device/webgl-device.js.map +0 -1
- package/dist/es5/webgl-utils/is-old-ie.js.map +0 -1
- package/dist/es5/webgl-utils/webgl-info.ts.disabled +0 -135
- package/dist/esm/api/device2.js +0 -23
- package/dist/esm/api/device2.js.map +0 -1
- package/dist/esm/classes/webgl-shader.js.map +0 -1
- package/dist/esm/device/check-glsl-extension.js +0 -22
- package/dist/esm/device/check-glsl-extension.js.map +0 -1
- package/dist/esm/device/device-features.js.map +0 -1
- package/dist/esm/device/device-limits.js.map +0 -1
- package/dist/esm/device/get-device-info.js.map +0 -1
- package/dist/esm/device/webgl-device.js.map +0 -1
- package/dist/esm/webgl-utils/is-old-ie.js.map +0 -1
- package/dist/esm/webgl-utils/webgl-info.ts.disabled +0 -135
- package/dist/webgl-utils/is-old-ie.d.ts.map +0 -1
- package/dist/webgl-utils/is-old-ie.js.map +0 -1
- package/dist/webgl-utils/webgl-info.ts.disabled +0 -135
- package/src/api/device2.ts +0 -71
- package/src/device/check-glsl-extension.ts +0 -44
- package/src/webgl-utils/webgl-info.ts.disabled +0 -135
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import GL from '@luma.gl/constants';
|
|
2
|
+
|
|
3
|
+
// Define local extension strings to optimize minification
|
|
4
|
+
const SRGB = 'EXT_sRGB';
|
|
5
|
+
const EXT_FLOAT_WEBGL1 = 'WEBGL.color_buffer_float';
|
|
6
|
+
const EXT_FLOAT_WEBGL2 = 'EXT_color_buffer_float';
|
|
7
|
+
const EXT_HALF_FLOAT_WEBGL1 = 'EXT_color_buffer_half_float';
|
|
8
|
+
|
|
9
|
+
// const S3TC = 'WEBGL_compressed_texture_s3tc';
|
|
10
|
+
// const PVRTC = 'WEBGL_compressed_texture_pvrtc';
|
|
11
|
+
// const ES3 = 'WEBGL_compressed_texture_es3';
|
|
12
|
+
// const ETC1 = 'WEBGL_compressed_texture_etc1';
|
|
13
|
+
// const SRGB = 'EXT_sRGB';
|
|
14
|
+
// const DEPTH = 'WEBGL_depth_texture';
|
|
15
|
+
|
|
16
|
+
// NOTES:
|
|
17
|
+
// - gl2: format requires WebGL2, when using a WebGL 1 context, color renderbuffer formats are limited
|
|
18
|
+
// - b (bytes per pixel), for memory usage calculations.
|
|
19
|
+
// - c (channels)
|
|
20
|
+
// - p (packed)
|
|
21
|
+
|
|
22
|
+
export const TEXTURE_FORMAT_DEFINITIONS = {
|
|
23
|
+
// 8-bit formats
|
|
24
|
+
'r8unorm': {b: 1, c: 1, gl: GL.R8, gl2: true},
|
|
25
|
+
'r8snorm': {b: 1, c: 1},
|
|
26
|
+
'r8uint': {b: 1, c: 1, gl: GL.R8UI, gl2: true},
|
|
27
|
+
'r8sint': {b: 1, c: 1, gl: GL.R8I, gl2: true},
|
|
28
|
+
|
|
29
|
+
// 16-bit formats
|
|
30
|
+
'r16uint': {b: 2, c: 1, gl: GL.R16UI, gl2: true},
|
|
31
|
+
'r16sint': {b: 2, c: 1, gl: GL.R16I, gl2: true},
|
|
32
|
+
'r16float': {b: 2, c: 1, gl: GL.R16F, gl2: EXT_FLOAT_WEBGL2},
|
|
33
|
+
'rg8unorm': {b: 2, c: 2, gl: GL.RG8, gl2: true},
|
|
34
|
+
'rg8snorm': {b: 2, c: 2},
|
|
35
|
+
'rg8uint': {b: 2, c: 2, gl: GL.RG8UI, gl2: true},
|
|
36
|
+
'rg8sint': {b: 2, c: 2, gl: GL.RG8I, gl2: true},
|
|
37
|
+
|
|
38
|
+
// Packed 16-bit formats
|
|
39
|
+
// 'rgba4norm?': {b: 2, c: 4, gl: GL.RGBA4, wgpu: false},
|
|
40
|
+
// 'rgb565norm?': {b: 2, c: 4, gl: GL.RGB565, wgpu: false},
|
|
41
|
+
// 'rgb5a1norm?': {b: 2, c: 4, gl: GL.RGB5_A1, wgpu: false},
|
|
42
|
+
|
|
43
|
+
// 24-bit formats
|
|
44
|
+
// 'rbg8norm?': {b: 3, c: 3, gl: GL.RGB8, gl2: true, wgpu: false},
|
|
45
|
+
|
|
46
|
+
// 32-bit formats
|
|
47
|
+
'r32uint': {b: 4, c: 1, gl: GL.R32UI, gl2: true, bpp: 4},
|
|
48
|
+
'r32sint': {b: 4, c: 1, gl: GL.R32I, gl2: true, bpp: 4},
|
|
49
|
+
'r32float': {b: 4, c: 1, gl: GL.R32F, gl2: EXT_FLOAT_WEBGL2, bpp: 4},
|
|
50
|
+
'rg16uint': {b: 4, c: 1, gl: GL.RG16UI, gl2: true, bpp: 4},
|
|
51
|
+
'rg16sint': {b: 4, c: 2, gl: GL.RG16I, gl2: true, bpp: 4},
|
|
52
|
+
// When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
|
|
53
|
+
'rg16float': {b: 4, c: 2, gl: GL.RG16F, gl2: EXT_FLOAT_WEBGL2, bpp: 4},
|
|
54
|
+
'rgba8unorm': {b: 4, c: 2, gl: GL.RGBA8, gl2: true, bpp: 4},
|
|
55
|
+
|
|
56
|
+
'rgba8unorm-srgb': {b: 4, c: 4, gl: GL.SRGB8_ALPHA8, gl2: true, gl1: SRGB, bpp: 4},
|
|
57
|
+
'rgba8snorm': {b: 4, c: 4},
|
|
58
|
+
'rgba8uint': {b: 4, c: 4, gl: GL.RGBA8UI, gl2: true, bpp: 4},
|
|
59
|
+
'rgba8sint': {b: 4, c: 4, gl: GL.RGBA8I, gl2: true, bpp: 4},
|
|
60
|
+
'bgra8unorm': {b: 4, c: 4},
|
|
61
|
+
'bgra8unorm-srgb': {b: 4, c: 4},
|
|
62
|
+
|
|
63
|
+
// Packed 32-bit formats
|
|
64
|
+
'rgb9e5ufloat': {b: 4, c: 3, p: 1, gl: GL.RGB9_E5, gl2: true, gl1: 'WEBGL_color_buffer_half_float'},
|
|
65
|
+
'rg11b10ufloat': {b: 4, c: 3, p: 1, gl: GL.R11F_G11F_B10F, gl2: EXT_FLOAT_WEBGL2},
|
|
66
|
+
'rgb10a2unorm': {b: 4, c: 4, p: 1, gl: GL.RGB10_A2, gl2: true},
|
|
67
|
+
// webgl2 only
|
|
68
|
+
// '?rgb10a2unorm?': {b: 4, c: 4, p: 1, webgpu: false, gl: GL.RGB10_A2UI, gl2: true, bpp: 4},
|
|
69
|
+
|
|
70
|
+
// 64-bit formats
|
|
71
|
+
'rg32uint': {b: 8, c: 2, gl: GL.RG32UI, gl2: true},
|
|
72
|
+
'rg32sint': {b: 8, c: 2, gl: GL.RG32I, gl2: true},
|
|
73
|
+
'rg32float': {b: 8, c: 2, gl: GL.RG32F, gl2: EXT_FLOAT_WEBGL2},
|
|
74
|
+
'rgba16uint': {b: 8, c: 4, gl: GL.RGBA16UI, gl2: true},
|
|
75
|
+
'rgba16sint': {b: 8, c: 4, gl: GL.RGBA16I, gl2: true},
|
|
76
|
+
'rgba16float': {b: 8, c: 4, gl: GL.RGBA16F, gl2: EXT_FLOAT_WEBGL2},
|
|
77
|
+
|
|
78
|
+
// 96-bit formats
|
|
79
|
+
// {gl: GL.RGB32F, dataFormat: GL.RGB, types: [GL.FLOAT], gl2: true},
|
|
80
|
+
|
|
81
|
+
// 128-bit formats
|
|
82
|
+
'rgba32uint': {b: 16, c: 4, gl: GL.RGBA32UI, gl2: true},
|
|
83
|
+
'rgba32sint': {b: 16, c: 4, gl: GL.RGBA32I, gl2: true},
|
|
84
|
+
'rgba32float': {b: 16, c: 4, gl: GL.RGBA32F, gl2: EXT_FLOAT_WEBGL2}, // gl1: EXT_FLOAT_WEBGL1
|
|
85
|
+
|
|
86
|
+
// Depth and stencil formats
|
|
87
|
+
'stencil8': {b: 1, c: 1, gl: GL.STENCIL_INDEX8}, // 8 stencil bits
|
|
88
|
+
'depth16unorm': {b: 2, c: 1, gl: GL.DEPTH_COMPONENT16}, // 16 depth bits
|
|
89
|
+
'depth24plus': {b: 3, c: 1, gl: GL.DEPTH_COMPONENT24, gl2: true},
|
|
90
|
+
'depth24plus-stencil8': {b: 4, c: 2, p: 1, gl: GL.DEPTH24_STENCIL8, gl2: true},
|
|
91
|
+
'depth32float': {b: 4, c: 1, gl: GL.DEPTH_COMPONENT32F, gl2: true},
|
|
92
|
+
|
|
93
|
+
// "depth24unorm-stencil8" feature
|
|
94
|
+
'depth24unorm-stencil8': {b: 4, c: 2, p: 1, gl: GL.DEPTH_STENCIL},
|
|
95
|
+
|
|
96
|
+
// "depth32float-stencil8" feature
|
|
97
|
+
"depth32float-stencil8": {b: 5, c: 2, p: 1, gl: GL.DEPTH32F_STENCIL8, gl2: true},
|
|
98
|
+
|
|
99
|
+
// BC compressed formats usable if "texture-compression-bc" is both
|
|
100
|
+
// supported by the device/user agent and enabled in requestDevice.
|
|
101
|
+
'bc1-rgba-unorm': {},
|
|
102
|
+
'bc1-rgba-unorm-srgb': {},
|
|
103
|
+
'bc2-rgba-unorm': {},
|
|
104
|
+
'bc2-rgba-unorm-srgb': {},
|
|
105
|
+
'bc3-rgba-unorm': {},
|
|
106
|
+
'bc3-rgba-unorm-srgb': {},
|
|
107
|
+
'bc4-r-unorm': {},
|
|
108
|
+
'bc4-r-snorm': {},
|
|
109
|
+
'bc5-rg-unorm': {},
|
|
110
|
+
'bc5-rg-snorm': {},
|
|
111
|
+
'bc6h-rgb-ufloat': {},
|
|
112
|
+
'bc6h-rgb-float': {},
|
|
113
|
+
'bc7-rgba-unorm': {},
|
|
114
|
+
'bc7-rgba-unorm-srgb': {}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
////////////////////////////////////////////////////
|
|
118
|
+
// Compressed formats
|
|
119
|
+
|
|
120
|
+
// WEBGL_compressed_texture_s3tc
|
|
121
|
+
|
|
122
|
+
// {gl: GL.COMPRESSED_RGB_S3TC_DXT1_EXT, compressed: true, gl1: S3TC},
|
|
123
|
+
// {gl: GL.COMPRESSED_RGBA_S3TC_DXT1_EXT, compressed: true, gl1: S3TC},
|
|
124
|
+
// {gl: GL.COMPRESSED_RGBA_S3TC_DXT3_EXT, compressed: true, gl1: S3TC},
|
|
125
|
+
// {gl: GL.COMPRESSED_RGBA_S3TC_DXT5_EXT, compressed: true, gl1: S3TC},
|
|
126
|
+
|
|
127
|
+
// WEBGL_compressed_texture_es3
|
|
128
|
+
|
|
129
|
+
// {gl: GL.COMPRESSED_R11_EAC, compressed: true, gl1: ES3}, // RED
|
|
130
|
+
// {gl: GL.COMPRESSED_SIGNED_R11_EAC, compressed: true, gl1: ES3}, // RED
|
|
131
|
+
// {gl: GL.COMPRESSED_RG11_EAC, compressed: true, gl1: ES3}, // RG
|
|
132
|
+
// {gl: GL.COMPRESSED_SIGNED_RG11_EAC, compressed: true, gl1: ES3}, // RG
|
|
133
|
+
// {gl: GL.COMPRESSED_RGB8_ETC2, compressed: true, gl1: ES3}, // RGB
|
|
134
|
+
// {gl: GL.COMPRESSED_RGBA8_ETC2_EAC, compressed: true, gl1: ES3}, // RBG
|
|
135
|
+
// {gl: GL.COMPRESSED_SRGB8_ETC2, compressed: true, gl1: ES3}, // RGB
|
|
136
|
+
// {gl: GL.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, compressed: true, gl1: ES3}, // RGBA
|
|
137
|
+
// {gl: GL.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, compressed: true, gl1: ES3}, // RGBA
|
|
138
|
+
// {gl: GL.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, compressed: true, gl1: ES3}, // RGBA
|
|
139
|
+
/* WebGL2 guaranteed availability compressed formats?
|
|
140
|
+
COMPRESSED_R11_EAC RED
|
|
141
|
+
COMPRESSED_SIGNED_R11_EAC RED
|
|
142
|
+
COMPRESSED_RG11_EAC RG
|
|
143
|
+
COMPRESSED_SIGNED_RG11_EAC RG
|
|
144
|
+
COMPRESSED_RGB8_ETC2 RGB
|
|
145
|
+
COMPRESSED_SRGB8_ETC2 RGB
|
|
146
|
+
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 RGBA
|
|
147
|
+
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 RGBA
|
|
148
|
+
COMPRESSED_RGBA8_ETC2_EAC RGBA
|
|
149
|
+
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
|
|
150
|
+
*/
|
|
151
|
+
|
|
152
|
+
// WEBGL_compressed_texture_pvrtc
|
|
153
|
+
|
|
154
|
+
// {gl: GL.COMPRESSED_RGB_PVRTC_4BPPV1_IMG, compressed: true, gl1: PVRTC},
|
|
155
|
+
// {gl: GL.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, compressed: true, gl1: PVRTC},
|
|
156
|
+
// {gl: GL.COMPRESSED_RGB_PVRTC_2BPPV1_IMG, compressed: true, gl1: PVRTC},
|
|
157
|
+
// {gl: GL.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, compressed: true, gl1: PVRTC},
|
|
158
|
+
|
|
159
|
+
// WEBGL_compressed_texture_etc1
|
|
160
|
+
|
|
161
|
+
// {gl: GL.COMPRESSED_RGB_ETC1_WEBGL, compressed: true, gl1: ETC1},
|
|
162
|
+
|
|
163
|
+
// WEBGL_compressed_texture_atc
|
|
164
|
+
|
|
165
|
+
// {gl: GL.COMPRESSED_RGB_ATC_WEBGL, compressed: true, gl1: ETC1},
|
|
166
|
+
// {gl: GL.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL, compressed: true, gl1: ETC1},
|
|
167
|
+
// {gl: GL.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL, compressed: true, gl1: ETC1}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
// available in an WebGL1 or WebGL2 environment.
|
|
4
4
|
|
|
5
5
|
import GL from '@luma.gl/constants';
|
|
6
|
-
import {isWebGL2} from '
|
|
7
|
-
import {isOldIE} from '
|
|
6
|
+
import {isWebGL2} from '../../context/context/webgl-checks';
|
|
7
|
+
import {isOldIE} from './is-old-ie';
|
|
8
8
|
|
|
9
|
-
export type DeviceFeature =
|
|
9
|
+
export type DeviceFeature =
|
|
10
10
|
'depth-clamping' |
|
|
11
11
|
'depth24unorm-stencil8' |
|
|
12
12
|
'depth32float-stencil8' |
|
|
@@ -15,7 +15,7 @@ export type DeviceFeature =
|
|
|
15
15
|
'texture-compression-bc';
|
|
16
16
|
|
|
17
17
|
// TODO - this should be the default export, test cases need updating
|
|
18
|
-
export type WebGLFeature =
|
|
18
|
+
export type WebGLFeature =
|
|
19
19
|
'webgl2' |
|
|
20
20
|
|
|
21
21
|
// api support (unify with WebGPU timestamp-query?)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// luma.gl, MIT license
|
|
2
2
|
import type {DeviceLimits} from '@luma.gl/api';
|
|
3
3
|
import GL from '@luma.gl/constants';
|
|
4
|
-
import {getWebGL2Context} from '
|
|
4
|
+
import {getWebGL2Context} from '../../context/context/webgl-checks';
|
|
5
5
|
|
|
6
6
|
/** Populate a WebGPU style device limits */
|
|
7
7
|
export function getDeviceLimits(gl: WebGLRenderingContext): DeviceLimits {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {DeviceInfo} from '@luma.gl/api';
|
|
2
2
|
import GL from '@luma.gl/constants';
|
|
3
|
-
import {isWebGL2} from '
|
|
4
|
-
|
|
3
|
+
import {isWebGL2} from '../../context/context/webgl-checks';
|
|
4
|
+
|
|
5
5
|
/** @returns strings identifying the GPU vendor and driver. */
|
|
6
6
|
export function getDeviceInfo(gl: WebGLRenderingContext): DeviceInfo {
|
|
7
7
|
const vendorMasked = gl.getParameter(GL.VENDOR);
|
|
File without changes
|
|
@@ -7,14 +7,14 @@ import {getDevicePixelRatio, setDevicePixelRatio} from '../context/context/devic
|
|
|
7
7
|
import {createBrowserContext} from '../context/context/create-context';
|
|
8
8
|
import {getCanvas} from '../context/context/get-canvas';
|
|
9
9
|
import {isWebGL, isWebGL2} from '../context/context/webgl-checks';
|
|
10
|
-
import {getDeviceInfo} from './get-device-info';
|
|
11
|
-
import {getDeviceFeatures, Feature} from './device-features';
|
|
12
|
-
import {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-limits';
|
|
10
|
+
import {getDeviceInfo} from './device-helpers/get-device-info';
|
|
11
|
+
import {getDeviceFeatures, Feature} from './device-helpers/device-features';
|
|
12
|
+
import {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';
|
|
13
13
|
|
|
14
14
|
// WebGL classes
|
|
15
15
|
import type {BufferProps, ShaderProps} from '@luma.gl/api';
|
|
16
16
|
import WEBGLBuffer from '../classes/webgl-buffer';
|
|
17
|
-
import {WEBGLShader} from '../
|
|
17
|
+
import {WEBGLShader} from '../adapter/webgl-shader';
|
|
18
18
|
import Texture2D, {Texture2DProps} from '../classes/texture-2d';
|
|
19
19
|
import type {default as Framebuffer} from '../classes/framebuffer';
|
|
20
20
|
import type {default as VertexArrayObject} from '../classes/vertex-array-object';
|
|
@@ -111,7 +111,7 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
111
111
|
_polyfilled: boolean = false;
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
|
-
*
|
|
114
|
+
*
|
|
115
115
|
*/
|
|
116
116
|
static fromContext(gl: WebGLRenderingContext): WebGLDevice {
|
|
117
117
|
// @ts-expect-error
|
|
@@ -130,7 +130,7 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
130
130
|
): WebGLDevice {
|
|
131
131
|
if (gl instanceof WebGLDevice) {
|
|
132
132
|
return gl;
|
|
133
|
-
}
|
|
133
|
+
}
|
|
134
134
|
if (!isWebGL(gl)) {
|
|
135
135
|
throw new Error('Invalid WebGLRenderingContext');
|
|
136
136
|
}
|
|
@@ -140,7 +140,7 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
140
140
|
|
|
141
141
|
constructor(props: WebGLDeviceProps) {
|
|
142
142
|
super();
|
|
143
|
-
|
|
143
|
+
|
|
144
144
|
this.props = {...DEFAULT_DEVICE_PROPS, ...props};
|
|
145
145
|
|
|
146
146
|
// If attaching to an already attached context, return the attached device
|
|
@@ -275,11 +275,11 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
createTexture(props: Texture2DProps): Texture2D {
|
|
278
|
-
return new Texture2D(this
|
|
278
|
+
return new Texture2D(this, props);
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
createShader(props: ShaderProps): WEBGLShader {
|
|
282
|
-
return new WEBGLShader(this
|
|
282
|
+
return new WEBGLShader(this, props);
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
/**
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
import {log, uid, Shader, ShaderProps} from '@luma.gl/api';
|
|
3
|
+
import GL from '@luma.gl/constants';
|
|
4
|
+
import {getShaderInfo, CompilerMessage, formatCompilerLog} from '@luma.gl/shadertools';
|
|
5
|
+
import {parseShaderCompilerLog} from '../webgl-utils/parse-shader-compiler-log';
|
|
6
|
+
import WebGLDevice from '../adapter/webgl-device';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* An immutable compiled shader program that execute portions of the GPU Pipeline
|
|
10
|
+
*/
|
|
11
|
+
export class WEBGLShader extends Shader {
|
|
12
|
+
readonly device: WebGLDevice;
|
|
13
|
+
readonly gl: WebGLRenderingContext;
|
|
14
|
+
readonly handle: WebGLShader;
|
|
15
|
+
|
|
16
|
+
readonly stage: 'vertex' | 'fragment';
|
|
17
|
+
readonly source: string;
|
|
18
|
+
|
|
19
|
+
constructor(device: WebGLDevice, props: ShaderProps) {
|
|
20
|
+
super(device, {id: getShaderIdFromProps(props), ...props});
|
|
21
|
+
this.device = device;
|
|
22
|
+
this.gl = device.gl;
|
|
23
|
+
switch (this.props.stage) {
|
|
24
|
+
case 'vertex':
|
|
25
|
+
this.handle = this.props.handle || this.gl.createShader(GL.VERTEX_SHADER);
|
|
26
|
+
break;
|
|
27
|
+
case 'fragment':
|
|
28
|
+
this.handle = this.props.handle || this.gl.createShader(GL.FRAGMENT_SHADER);
|
|
29
|
+
break;
|
|
30
|
+
default:
|
|
31
|
+
throw new Error(this.props.stage);
|
|
32
|
+
}
|
|
33
|
+
this.stage = this.props.stage;
|
|
34
|
+
this.source = this.props.source;
|
|
35
|
+
this._compile(this.source);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
destroy(): void {
|
|
39
|
+
if (this.handle) {
|
|
40
|
+
this.removeStats();
|
|
41
|
+
this.gl.deleteShader(this.handle);
|
|
42
|
+
// @ts-expect-error
|
|
43
|
+
this.handle = null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async compilationInfo(): Promise<readonly CompilerMessage[]> {
|
|
48
|
+
const log = this.gl.getShaderInfoLog(this.handle);
|
|
49
|
+
return parseShaderCompilerLog(log);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// PRIVATE METHODS
|
|
53
|
+
|
|
54
|
+
_compile(source) {
|
|
55
|
+
const addGLSLVersion = source => source.startsWith('#version ') ? source : `#version 100\n${source}`;
|
|
56
|
+
source = addGLSLVersion(source);
|
|
57
|
+
|
|
58
|
+
this.gl.shaderSource(this.handle, source);
|
|
59
|
+
this.gl.compileShader(this.handle);
|
|
60
|
+
|
|
61
|
+
// TODO - For performance reasons, avoid checking shader compilation errors on production?
|
|
62
|
+
// TODO - Load log even when no error reported, to catch warnings?
|
|
63
|
+
// https://gamedev.stackexchange.com/questions/30429/how-to-detect-glsl-warnings
|
|
64
|
+
const compileStatus = this.gl.getShaderParameter(this.handle, GL.COMPILE_STATUS);
|
|
65
|
+
if (!compileStatus) {
|
|
66
|
+
const shaderLog = this.gl.getShaderInfoLog(this.handle);
|
|
67
|
+
const messages = parseShaderCompilerLog(shaderLog).filter(message => message.type === 'error');
|
|
68
|
+
const formattedLog = formatCompilerLog(messages, source);
|
|
69
|
+
const shaderName: string = getShaderInfo(source).name;
|
|
70
|
+
const shaderDescription = `${this.stage} shader ${shaderName}`;
|
|
71
|
+
log.error(`GLSL compilation errors in ${shaderDescription}\n${formattedLog}`)();
|
|
72
|
+
throw new Error(`GLSL compilation errors in ${shaderName}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// HELPERS
|
|
78
|
+
|
|
79
|
+
/** Deduce an id, from shader source, or supplied id, or shader type */
|
|
80
|
+
function getShaderIdFromProps(props: ShaderProps): string {
|
|
81
|
+
return getShaderInfo(props.source).name ||
|
|
82
|
+
props.id ||
|
|
83
|
+
uid(`unnamed ${props.stage}-shader`);
|
|
84
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {log, assert} from '@luma.gl/api';
|
|
2
2
|
import GL from '@luma.gl/constants';
|
|
3
|
-
import WebGLDevice from '../
|
|
3
|
+
import WebGLDevice from '../adapter/webgl-device';
|
|
4
4
|
import {getWebGL2Context, assertWebGL2Context} from '../context/context/webgl-checks';
|
|
5
5
|
import {getKey} from '../webgl-utils/constants-to-keys';
|
|
6
6
|
import Resource, {ResourceProps} from './webgl-resource';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Contains metadata describing attribute configurations for a program's shaders
|
|
2
2
|
// Much of this is automatically extracted from shaders after program linking
|
|
3
|
-
import Accessor from './accessor';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
3
|
+
// import Accessor from './accessor';
|
|
4
|
+
import type Program from './program';
|
|
5
|
+
import type {AttributeBinding, VaryingBinding} from '../helpers/program-bindings';
|
|
6
|
+
import {getProgramBindings} from '../helpers/get-program-bindings';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* is a mechanism for taking a program object and querying information
|
|
@@ -12,22 +13,32 @@ import {decomposeCompositeGLType} from '../webgl-utils/attribute-utils';
|
|
|
12
13
|
*/
|
|
13
14
|
export default class ProgramConfiguration {
|
|
14
15
|
id: string;
|
|
15
|
-
attributeInfos:
|
|
16
|
-
attributeInfosByName: Record<string,
|
|
16
|
+
attributeInfos: AttributeBinding[] = [];
|
|
17
|
+
attributeInfosByName: Record<string, AttributeBinding> = {};
|
|
17
18
|
// Locations may not be contiguous the case of matrix attributes
|
|
18
19
|
// so keep a separate location->attribute map.
|
|
19
|
-
attributeInfosByLocation:
|
|
20
|
-
varyingInfos:
|
|
21
|
-
varyingInfosByName: Record<string,
|
|
20
|
+
attributeInfosByLocation: AttributeBinding[] = [];
|
|
21
|
+
varyingInfos: VaryingBinding[] = [];
|
|
22
|
+
varyingInfosByName: Record<string, VaryingBinding> = {};
|
|
22
23
|
|
|
23
|
-
constructor(program) {
|
|
24
|
+
constructor(program: Program) {
|
|
24
25
|
this.id = program.id;
|
|
25
26
|
Object.seal(this);
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
|
|
28
|
+
const bindings = getProgramBindings(program.gl2, program.handle);
|
|
29
|
+
|
|
30
|
+
this.attributeInfos = bindings.attributes;
|
|
31
|
+
for (const attributeInfo of bindings.attributes) {
|
|
32
|
+
this.attributeInfosByName[attributeInfo.name] = attributeInfo;
|
|
33
|
+
this.attributeInfosByLocation[attributeInfo.location] = attributeInfo;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
for (const varyingInfo of bindings.varyings) {
|
|
37
|
+
this.varyingInfosByName[varyingInfo.name] = varyingInfo;
|
|
38
|
+
}
|
|
28
39
|
}
|
|
29
40
|
|
|
30
|
-
getAttributeInfo(locationOrName) {
|
|
41
|
+
getAttributeInfo(locationOrName: number | string): AttributeBinding {
|
|
31
42
|
const location = Number(locationOrName);
|
|
32
43
|
if (Number.isFinite(location)) {
|
|
33
44
|
return this.attributeInfosByLocation[location];
|
|
@@ -36,17 +47,17 @@ import {decomposeCompositeGLType} from '../webgl-utils/attribute-utils';
|
|
|
36
47
|
}
|
|
37
48
|
|
|
38
49
|
// Resolves an attribute name or index to an index
|
|
39
|
-
getAttributeLocation(locationOrName) {
|
|
50
|
+
getAttributeLocation(locationOrName: number | string): number {
|
|
40
51
|
const attributeInfo = this.getAttributeInfo(locationOrName);
|
|
41
52
|
return attributeInfo ? attributeInfo.location : -1;
|
|
42
53
|
}
|
|
43
54
|
|
|
44
|
-
getAttributeAccessor(locationOrName) {
|
|
55
|
+
getAttributeAccessor(locationOrName: number | string) {
|
|
45
56
|
const attributeInfo = this.getAttributeInfo(locationOrName);
|
|
46
57
|
return attributeInfo ? attributeInfo.accessor : null;
|
|
47
58
|
}
|
|
48
59
|
|
|
49
|
-
getVaryingInfo(locationOrName) {
|
|
60
|
+
getVaryingInfo(locationOrName: number | string): VaryingBinding {
|
|
50
61
|
const location = Number(locationOrName);
|
|
51
62
|
if (Number.isFinite(location)) {
|
|
52
63
|
return this.varyingInfos[location];
|
|
@@ -54,77 +65,13 @@ import {decomposeCompositeGLType} from '../webgl-utils/attribute-utils';
|
|
|
54
65
|
return this.varyingInfosByName[locationOrName] || null;
|
|
55
66
|
}
|
|
56
67
|
|
|
57
|
-
getVaryingIndex(locationOrName) {
|
|
68
|
+
getVaryingIndex(locationOrName: number | string): number {
|
|
58
69
|
const varying = this.getVaryingInfo(locationOrName);
|
|
59
70
|
return varying ? varying.location : -1;
|
|
60
71
|
}
|
|
61
72
|
|
|
62
|
-
getVaryingAccessor(locationOrName) {
|
|
73
|
+
getVaryingAccessor(locationOrName: number | string) {
|
|
63
74
|
const varying = this.getVaryingInfo(locationOrName);
|
|
64
75
|
return varying ? varying.accessor : null;
|
|
65
76
|
}
|
|
66
|
-
|
|
67
|
-
// PRIVATE METHODS
|
|
68
|
-
|
|
69
|
-
// linkProgram needs to have been called, although linking does not need to have been successful
|
|
70
|
-
_readAttributesFromProgram(program) {
|
|
71
|
-
const {gl} = program;
|
|
72
|
-
const count = gl.getProgramParameter(program.handle, gl.ACTIVE_ATTRIBUTES);
|
|
73
|
-
|
|
74
|
-
for (let index = 0; index < count; index++) {
|
|
75
|
-
const {name, type, size} = gl.getActiveAttrib(program.handle, index);
|
|
76
|
-
const location = gl.getAttribLocation(program.handle, name);
|
|
77
|
-
// Add only user provided attributes, for built-in attributes like
|
|
78
|
-
// `gl_InstanceID` locaiton will be < 0
|
|
79
|
-
if (location >= 0) {
|
|
80
|
-
this._addAttribute(location, name, type, size);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
this.attributeInfos.sort((a, b) => a.location - b.location);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// linkProgram needs to have been called, although linking does not need to have been successful
|
|
88
|
-
_readVaryingsFromProgram(program) {
|
|
89
|
-
const {gl} = program;
|
|
90
|
-
if (!isWebGL2(gl)) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const count = gl.getProgramParameter(program.handle, gl.TRANSFORM_FEEDBACK_VARYINGS);
|
|
95
|
-
for (let location = 0; location < count; location++) {
|
|
96
|
-
const {name, type, size} = gl.getTransformFeedbackVarying(program.handle, location);
|
|
97
|
-
this._addVarying(location, name, type, size);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
this.varyingInfos.sort((a, b) => a.location - b.location);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
_addAttribute(location, name, compositeType, size) {
|
|
104
|
-
const {type, components} = decomposeCompositeGLType(compositeType);
|
|
105
|
-
const accessor = {type, size: size * components};
|
|
106
|
-
this._inferProperties(location, name, accessor);
|
|
107
|
-
|
|
108
|
-
const attributeInfo = {location, name, accessor: new Accessor(accessor)}; // Base values
|
|
109
|
-
this.attributeInfos.push(attributeInfo);
|
|
110
|
-
this.attributeInfosByLocation[location] = attributeInfo; // For quick location based lookup
|
|
111
|
-
this.attributeInfosByName[attributeInfo.name] = attributeInfo; // For quick name based lookup
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Extract additional attribute metadata from shader names (based on attribute naming conventions)
|
|
115
|
-
_inferProperties(location, name, accessor) {
|
|
116
|
-
if (/instance/i.test(name)) {
|
|
117
|
-
// Any attribute containing the word "instance" will be assumed to be instanced
|
|
118
|
-
accessor.divisor = 1;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
_addVarying(location, name, compositeType, size) {
|
|
123
|
-
const {type, components} = decomposeCompositeGLType(compositeType);
|
|
124
|
-
const accessor = new Accessor({type, size: size * components});
|
|
125
|
-
|
|
126
|
-
const varying = {location, name, accessor}; // Base values
|
|
127
|
-
this.varyingInfos.push(varying);
|
|
128
|
-
this.varyingInfosByName[varying.name] = varying; // For quick name based lookup
|
|
129
|
-
}
|
|
130
77
|
}
|