@luma.gl/webgl 9.1.0-alpha.15 → 9.1.0-alpha.17

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.
Files changed (69) hide show
  1. package/dist/adapter/converters/device-parameters.d.ts +3 -3
  2. package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
  3. package/dist/adapter/converters/sampler-parameters.js +6 -4
  4. package/dist/adapter/converters/texture-formats.d.ts +49 -11
  5. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  6. package/dist/adapter/converters/texture-formats.js +150 -160
  7. package/dist/adapter/helpers/format-utils.d.ts.map +1 -1
  8. package/dist/adapter/helpers/format-utils.js +6 -0
  9. package/dist/adapter/helpers/webgl-texture-utils.d.ts +34 -30
  10. package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
  11. package/dist/adapter/helpers/webgl-texture-utils.js +52 -256
  12. package/dist/adapter/resources/webgl-command-buffer.d.ts +59 -2
  13. package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
  14. package/dist/adapter/resources/webgl-command-buffer.js +87 -31
  15. package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
  16. package/dist/adapter/resources/webgl-command-encoder.js +3 -0
  17. package/dist/adapter/resources/webgl-external-texture.js +14 -0
  18. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  19. package/dist/adapter/resources/webgl-framebuffer.js +1 -2
  20. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  21. package/dist/adapter/resources/webgl-render-pass.js +38 -20
  22. package/dist/adapter/resources/webgl-render-pipeline.d.ts +1 -1
  23. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  24. package/dist/adapter/resources/webgl-render-pipeline.js +30 -16
  25. package/dist/adapter/resources/webgl-shader.d.ts +1 -0
  26. package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
  27. package/dist/adapter/resources/webgl-shader.js +7 -5
  28. package/dist/adapter/resources/webgl-texture.d.ts +8 -14
  29. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  30. package/dist/adapter/resources/webgl-texture.js +119 -208
  31. package/dist/adapter/webgl-adapter.d.ts.map +1 -1
  32. package/dist/adapter/webgl-adapter.js +4 -10
  33. package/dist/adapter/webgl-device.d.ts +8 -3
  34. package/dist/adapter/webgl-device.d.ts.map +1 -1
  35. package/dist/adapter/webgl-device.js +53 -22
  36. package/dist/context/debug/spector-types.js +1 -1
  37. package/dist/context/debug/spector.d.ts +5 -5
  38. package/dist/context/debug/spector.d.ts.map +1 -1
  39. package/dist/context/debug/spector.js +6 -6
  40. package/dist/context/debug/webgl-developer-tools.d.ts +2 -3
  41. package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
  42. package/dist/context/debug/webgl-developer-tools.js +6 -19
  43. package/dist/context/helpers/create-browser-context.d.ts +6 -22
  44. package/dist/context/helpers/create-browser-context.d.ts.map +1 -1
  45. package/dist/context/helpers/create-browser-context.js +40 -32
  46. package/dist/dist.dev.js +366 -400
  47. package/dist/dist.min.js +2 -2
  48. package/dist/index.cjs +341 -384
  49. package/dist/index.cjs.map +3 -3
  50. package/package.json +4 -4
  51. package/src/adapter/converters/device-parameters.ts +3 -3
  52. package/src/adapter/converters/sampler-parameters.ts +6 -4
  53. package/src/adapter/converters/texture-formats.ts +171 -177
  54. package/src/adapter/helpers/format-utils.ts +6 -0
  55. package/src/adapter/helpers/webgl-texture-utils.ts +99 -75
  56. package/src/adapter/resources/webgl-command-buffer.ts +124 -40
  57. package/src/adapter/resources/webgl-command-encoder.ts +6 -0
  58. package/src/adapter/resources/webgl-external-texture.ts +14 -0
  59. package/src/adapter/resources/webgl-framebuffer.ts +1 -2
  60. package/src/adapter/resources/webgl-render-pass.ts +44 -23
  61. package/src/adapter/resources/webgl-render-pipeline.ts +32 -16
  62. package/src/adapter/resources/webgl-shader.ts +8 -6
  63. package/src/adapter/resources/webgl-texture.ts +126 -235
  64. package/src/adapter/webgl-adapter.ts +4 -12
  65. package/src/adapter/webgl-device.ts +88 -48
  66. package/src/context/debug/spector-types.ts +1 -1
  67. package/src/context/debug/spector.ts +11 -11
  68. package/src/context/debug/webgl-developer-tools.ts +8 -31
  69. package/src/context/helpers/create-browser-context.ts +53 -63
@@ -9,7 +9,7 @@ import type { GLFunction, GLParameters } from '@luma.gl/constants';
9
9
  * - Restores parameters
10
10
  * - Returns the return value of the supplied function
11
11
  */
12
- export declare function withDeviceAndGLParameters<T = unknown>(device: Device, parameters: Parameters, glParameters: GLParameters, func: (device?: Device) => T): T;
12
+ export declare function withDeviceAndGLParameters<T = unknown>(device: Device, parameters: Parameters, glParameters: GLParameters, func: (_?: Device) => T): T;
13
13
  /**
14
14
  * Execute a function with a set of temporary WebGL parameter overrides
15
15
  * - Saves current "global" WebGL context settings
@@ -19,7 +19,7 @@ export declare function withDeviceAndGLParameters<T = unknown>(device: Device, p
19
19
  * - Returns the return value of the supplied function
20
20
  * @deprecated use withDeviceParameters instead
21
21
  */
22
- export declare function withGLParameters<T = unknown>(device: Device, parameters: GLParameters, func: (device?: Device) => T): T;
22
+ export declare function withGLParameters<T = unknown>(device: Device, parameters: GLParameters, func: (_?: Device) => T): T;
23
23
  /**
24
24
  * Execute a function with a set of temporary WebGL parameter overrides
25
25
  * - Saves current "global" WebGL context settings
@@ -28,7 +28,7 @@ export declare function withGLParameters<T = unknown>(device: Device, parameters
28
28
  * - Restores parameters
29
29
  * - Returns the return value of the supplied function
30
30
  */
31
- export declare function withDeviceParameters<T = unknown>(device: Device, parameters: Parameters, func: (device?: Device) => T): T;
31
+ export declare function withDeviceParameters<T = unknown>(device: Device, parameters: Parameters, func: (_?: Device) => T): T;
32
32
  /** Set WebGPU Style Parameters */
33
33
  export declare function setDeviceParameters(device: Device, parameters: Parameters): void;
34
34
  export declare function convertCompareFunction(parameter: string, value: CompareFunction): GLFunction;
@@ -1 +1 @@
1
- {"version":3,"file":"device-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/device-parameters.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAgD,MAAM,eAAe,CAAC;AAClG,OAAO,EAAC,MAAM,EAAO,UAAU,EAA+B,MAAM,eAAe,CAAC;AAEpF,OAAO,KAAK,EAGV,UAAU,EACV,YAAY,EAIb,MAAM,oBAAoB,CAAC;AAM5B;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,GAAG,OAAO,EACnD,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,GAC3B,CAAC,CAgBH;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAC1C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,YAAY,EACxB,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,GAC3B,CAAC,CAeH;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,OAAO,EAC9C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,GAC3B,CAAC,CAeH;AAED,kCAAkC;AAClC,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,QAgNzE;AAyBD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,UAAU,CAW5F;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,eAAe,CAW9F"}
1
+ {"version":3,"file":"device-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/device-parameters.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAgD,MAAM,eAAe,CAAC;AAClG,OAAO,EAAC,MAAM,EAAO,UAAU,EAA+B,MAAM,eAAe,CAAC;AAEpF,OAAO,KAAK,EAGV,UAAU,EACV,YAAY,EAIb,MAAM,oBAAoB,CAAC;AAM5B;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,GAAG,OAAO,EACnD,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,CAAC,GACtB,CAAC,CAgBH;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAC1C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,YAAY,EACxB,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,CAAC,GACtB,CAAC,CAeH;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,OAAO,EAC9C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,CAAC,GACtB,CAAC,CAeH;AAED,kCAAkC;AAClC,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,QAgNzE;AAyBD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,UAAU,CAW5F;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,eAAe,CAW9F"}
@@ -69,14 +69,16 @@ function convertMaxFilterMode(maxFilter) {
69
69
  * WebGPU has separate min filter and mipmap filter,
70
70
  * WebGL is combined and effectively offers 6 options
71
71
  */
72
- function convertMinFilterMode(minFilter, mipmapFilter) {
72
+ function convertMinFilterMode(minFilter, mipmapFilter = 'none') {
73
73
  if (!mipmapFilter) {
74
74
  return convertMaxFilterMode(minFilter);
75
75
  }
76
- switch (minFilter) {
76
+ switch (mipmapFilter) {
77
+ case 'none':
78
+ return convertMaxFilterMode(minFilter);
77
79
  case 'nearest':
78
- return mipmapFilter === 'nearest' ? 9984 : 9986;
80
+ return minFilter === 'nearest' ? 9984 : 9986;
79
81
  case 'linear':
80
- return mipmapFilter === 'nearest' ? 9985 : 9987;
82
+ return minFilter === 'nearest' ? 9985 : 9987;
81
83
  }
82
84
  }
@@ -1,7 +1,6 @@
1
1
  import type { TextureFormat, DeviceFeature } from '@luma.gl/core';
2
2
  import { GL, GLPixelType, GLExtensions, GLTexelDataFormat } from '@luma.gl/constants';
3
3
  export declare const TEXTURE_FEATURES: Partial<Record<DeviceFeature, string[]>>;
4
- /** Return a list of texture feature strings (for Device.features). Mainly compressed texture support */
5
4
  export declare function isTextureFeature(feature: DeviceFeature): boolean;
6
5
  /** Checks a texture feature (for Device.features). Mainly compressed texture support */
7
6
  export declare function checkTextureFeature(gl: WebGL2RenderingContext, feature: DeviceFeature, extensions: GLExtensions): boolean;
@@ -21,10 +20,10 @@ type Format = {
21
20
  x?: string;
22
21
  /** for compressed texture formats */
23
22
  f?: DeviceFeature;
24
- /** renderable if feature is present */
25
- render?: DeviceFeature;
26
- /** filterable if feature is present */
27
- filter?: DeviceFeature;
23
+ /** renderable if feature is present. false means the spec does not support this format */
24
+ render?: DeviceFeature | false;
25
+ /** filterable if feature is present. false means the spec does not support this format */
26
+ filter?: DeviceFeature | false;
28
27
  /** If not supported on WebGPU */
29
28
  wgpu?: false;
30
29
  types?: GLPixelType[];
@@ -43,18 +42,17 @@ type Format = {
43
42
  export declare const TEXTURE_FORMATS: Record<TextureFormat, Format>;
44
43
  /** Checks if a texture format is supported */
45
44
  export declare function isTextureFormatSupported(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
46
- export declare function isRenderbufferFormatSupported(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
47
- /** Checks if a texture format is supported */
48
- export declare function getTextureFormatSupport(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): {
45
+ /** Checks whether linear filtering (interpolated sampling) is available for floating point textures */
46
+ export declare function isTextureFormatFilterable(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
47
+ export declare function isTextureFormatRenderable(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
48
+ /** Checks if a texture format is supported, renderable, filterable etc */
49
+ export declare function getTextureFormatSupportWebGL(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): {
49
50
  supported: boolean;
50
51
  filterable?: boolean;
51
52
  renderable?: boolean;
52
53
  blendable?: boolean;
53
54
  storable?: boolean;
54
55
  };
55
- /** Checks whether linear filtering (interpolated sampling) is available for floating point textures */
56
- export declare function isTextureFormatFilterable(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
57
- export declare function isTextureFormatRenderable(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
58
56
  /** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */
59
57
  export declare function getTextureFormatWebGL(format: TextureFormat): {
60
58
  internalFormat: GL;
@@ -67,6 +65,17 @@ export declare function getDepthStencilAttachmentWebGL(format: TextureFormat): G
67
65
  export declare function getTextureFormatBytesPerPixel(format: TextureFormat): number;
68
66
  export declare function getWebGLPixelDataFormat(channels: 'r' | 'rg' | 'rgb' | 'rgba' | 'bgra', integer: boolean, normalized: boolean, format: GL): GLTexelDataFormat;
69
67
  export {};
68
+ /** luma.gl v9 does not user renderbufers
69
+ export function isRenderbufferFormatSupported(
70
+ gl: WebGL2RenderingContext,
71
+ format: TextureFormat,
72
+ extensions: GLExtensions
73
+ ): boolean {
74
+ // Note: Order is important since the function call initializes extensions.
75
+ return isTextureFormatSupported(gl, format, extensions) && Boolean(TEXTURE_FORMATS[format]?.rb);
76
+ }
77
+ */
78
+ /** Return a list of texture feature strings (for Device.features). Mainly compressed texture support */
70
79
  /**
71
80
  * Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
72
81
  export function convertGLToTextureFormat(format: GL | TextureFormat): TextureFormat {
@@ -80,4 +89,33 @@ export function convertGLToTextureFormat(format: GL | TextureFormat): TextureFor
80
89
  return entry[0] as TextureFormat;
81
90
  }
82
91
  */
92
+ /** Legal combinations for internalFormat, format and type *
93
+ // [GL.DEPTH_COMPONENT]: {types: [GL.UNSIGNED_SHORT, GL.UNSIGNED_INT, GL.UNSIGNED_INT_24_8]},
94
+ // [GL.DEPTH_STENCIL]: ,
95
+ // Sized texture format
96
+ // R
97
+ [GL.R8]: {dataFormat: GL.RED, types: [GL.UNSIGNED_BYTE], gl2: true},
98
+ [GL.R16F]: {dataFormat: GL.RED, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
99
+ [GL.R8UI]: {dataFormat: GL.RED_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
100
+ // // RG
101
+ [GL.RG8]: {dataFormat: GL.RG, types: [GL.UNSIGNED_BYTE], gl2: true},
102
+ [GL.RG16F]: {dataFormat: GL.RG, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
103
+ [GL.RG8UI]: {dataFormat: GL.RG_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
104
+ // // RGB
105
+ [GL.RGB8]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE], gl2: true},
106
+ [GL.SRGB8]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE], gl2: true},
107
+ [GL.RGB16F]: {dataFormat: GL.RGB, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
108
+ [GL.RGB8UI]: {dataFormat: GL.RGB_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
109
+ // // RGBA
110
+
111
+ [GL.RGB565]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_6_5], gl2: true},
112
+ [GL.R11F_G11F_B10F]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_INT_10F_11F_11F_REV, GL.HALF_FLOAT, GL.FLOAT], gl2: true},
113
+ [GL.RGB9_E5]: {dataFormat: GL.RGB, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
114
+ [GL.RGBA8]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE], gl2: true},
115
+ [GL.SRGB8_ALPHA8]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE], gl2: true, gl1ext: EXT_SRGB},
116
+ [GL.RGB5_A1]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_5_5_1], gl2: true},
117
+ [GL.RGBA4]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_4_4_4_4], gl2: true},
118
+ [GL.RGBA16F]: {dataFormat: GL.RGBA, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
119
+ [GL.RGBA8UI]: {dataFormat: GL.RGBA_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true}
120
+ */
83
121
  //# sourceMappingURL=texture-formats.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"texture-formats.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/texture-formats.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAC,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AA2CpF,eAAO,MAAM,gBAAgB,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,CAwBrE,CAAC;AAEF,wGAAwG;AASxG,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAEhE;AAED,wFAAwF;AACxF,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,sBAAsB,EAC1B,OAAO,E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,gBAAgB,GAAG,EAAE,CAAC,kBAAkB,GAAG,EAAE,CAAC,wBAAwB,CAM3E;AAED,uEAAuE;AACvE,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAO3E;AAID,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,GAAG,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,EAC9C,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,OAAO,EACnB,MAAM,EAAE,EAAE,GACT,iBAAiB,CAcnB;;AAiBD;;;;;;;;;EASE;AAEF,wGAAwG;AASxG;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BE"}
@@ -59,14 +59,6 @@ export const TEXTURE_FEATURES = {
59
59
  'texture-compression-pvrtc-webgl': [X_PVRTC],
60
60
  'texture-compression-atc-webgl': [X_ATC]
61
61
  };
62
- /** Return a list of texture feature strings (for Device.features). Mainly compressed texture support */
63
- // export function getTextureFeatures(
64
- // gl: WebGL2RenderingContext,
65
- // extensions: GLExtensions
66
- // ): DeviceFeature[] {
67
- // const textureFeatures = Object.keys(TEXTURE_FEATURES) as DeviceFeature[];
68
- // return textureFeatures.filter(feature => checkTextureFeature(gl, feature, extensions));
69
- // }
70
62
  export function isTextureFeature(feature) {
71
63
  return feature in TEXTURE_FEATURES;
72
64
  }
@@ -132,7 +124,7 @@ export const TEXTURE_FORMATS = {
132
124
  // 64-bit formats
133
125
  'rg32uint': { gl: 33340, b: 8, c: 2, rb: true },
134
126
  'rg32sint': { gl: 33339, b: 8, c: 2, rb: true },
135
- 'rg32float': { gl: 33328, b: 8, c: 2, render: float32_renderable, filter: float32_filterable, rb: true },
127
+ 'rg32float': { gl: 33328, b: 8, c: 2, render: false, filter: float32_filterable, rb: true },
136
128
  'rgba16uint': { gl: 36214, b: 8, c: 4, rb: true },
137
129
  'rgba16sint': { gl: 36232, b: 8, c: 4, rb: true },
138
130
  'rgba16float': { gl: 34842, b: 8, c: 4, render: float16_renderable, filter: float16_filterable },
@@ -229,98 +221,6 @@ export const TEXTURE_FORMATS = {
229
221
  'atc-rgba-unorm-webgl': { gl: 35986, f: texture_compression_atc_webgl },
230
222
  'atc-rgbai-unorm-webgl': { gl: 34798, f: texture_compression_atc_webgl }
231
223
  };
232
- /** Legal combinations for internalFormat, format and type *
233
- // [GL.DEPTH_COMPONENT]: {types: [GL.UNSIGNED_SHORT, GL.UNSIGNED_INT, GL.UNSIGNED_INT_24_8]},
234
- // [GL.DEPTH_STENCIL]: ,
235
- // Sized texture format
236
- // R
237
- [GL.R8]: {dataFormat: GL.RED, types: [GL.UNSIGNED_BYTE], gl2: true},
238
- [GL.R16F]: {dataFormat: GL.RED, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
239
- [GL.R8UI]: {dataFormat: GL.RED_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
240
- // // RG
241
- [GL.RG8]: {dataFormat: GL.RG, types: [GL.UNSIGNED_BYTE], gl2: true},
242
- [GL.RG16F]: {dataFormat: GL.RG, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
243
- [GL.RG8UI]: {dataFormat: GL.RG_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
244
- // // RGB
245
- [GL.RGB8]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE], gl2: true},
246
- [GL.SRGB8]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE], gl2: true},
247
- [GL.RGB16F]: {dataFormat: GL.RGB, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
248
- [GL.RGB8UI]: {dataFormat: GL.RGB_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
249
- // // RGBA
250
-
251
- [GL.RGB565]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_6_5], gl2: true},
252
- [GL.R11F_G11F_B10F]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_INT_10F_11F_11F_REV, GL.HALF_FLOAT, GL.FLOAT], gl2: true},
253
- [GL.RGB9_E5]: {dataFormat: GL.RGB, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
254
- [GL.RGBA8]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE], gl2: true},
255
- [GL.SRGB8_ALPHA8]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE], gl2: true, gl1ext: EXT_SRGB},
256
- [GL.RGB5_A1]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_5_5_1], gl2: true},
257
- [GL.RGBA4]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_4_4_4_4], gl2: true},
258
- [GL.RGBA16F]: {dataFormat: GL.RGBA, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
259
- [GL.RGBA8UI]: {dataFormat: GL.RGBA_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true}
260
- */
261
- /* This table is now baked into the above table
262
- type RenderbufferFormat = {
263
- bpp: number;
264
- gl2?: boolean;
265
- ext?: string;
266
- };
267
-
268
- export const RENDERBUFFER_FORMATS: Record<string, RenderbufferFormat> = {
269
- [GL.DEPTH_COMPONENT16]: {bpp: 2}, // 16 depth bits.
270
- // TODO - Not clear which webgpu value to map this to.
271
- // [GL.DEPTH_COMPONENT24]: {gl2: true, bpp: 3},
272
- [GL.DEPTH_COMPONENT32F]: {gl2: true, bpp: 4},
273
-
274
- [GL.STENCIL_INDEX8]: {bpp: 1}, // 8 stencil bits.
275
-
276
- [GL.DEPTH_STENCIL]: {bpp: 4},
277
- [GL.DEPTH24_STENCIL8]: {gl2: true, bpp: 4},
278
- [GL.DEPTH32F_STENCIL8]: {gl2: true, bpp: 5},
279
-
280
- // When using a WebGL 1 context, color renderbuffer formats are limited
281
- [GL.RGBA4]: {gl2: true, bpp: 2},
282
- [GL.RGB565]: {gl2: true, bpp: 2},
283
- [GL.RGB5_A1]: {gl2: true, bpp: 2},
284
-
285
- // When using a WebGL 2 context, the following values are available additionally:
286
- [GL.R8]: {gl2: true, bpp: 1},
287
- [GL.R8UI]: {gl2: true, bpp: 1},
288
- [GL.R8I]: {gl2: true, bpp: 1},
289
- [GL.R16UI]: {gl2: true, bpp: 2},
290
- [GL.R16I]: {gl2: true, bpp: 2},
291
- [GL.R32UI]: {gl2: true, bpp: 4},
292
- [GL.R32I]: {gl2: true, bpp: 4},
293
- [GL.RG8]: {gl2: true, bpp: 2},
294
- [GL.RG8UI]: {gl2: true, bpp: 2},
295
- [GL.RG8I]: {gl2: true, bpp: 2},
296
- [GL.RG16UI]: {gl2: true, bpp: 4},
297
- [GL.RG16I]: {gl2: true, bpp: 4},
298
- [GL.RG32UI]: {gl2: true, bpp: 8},
299
- [GL.RG32I]: {gl2: true, bpp: 8},
300
- [GL.RGB8]: {gl2: true, bpp: 3},
301
- [GL.RGBA8]: {gl2: true, bpp: 4},
302
- // [GL.SRGB8_ALPHA8]: {gl2: true, gl1: SRGB}, // When using the EXT_sRGB WebGL1 extension
303
- [GL.RGB10_A2]: {gl2: true, bpp: 4},
304
- [GL.RGBA8UI]: {gl2: true, bpp: 4},
305
- [GL.RGBA8I]: {gl2: true, bpp: 4},
306
- [GL.RGB10_A2UI]: {gl2: true, bpp: 4},
307
- [GL.RGBA16UI]: {gl2: true, bpp: 8},
308
- [GL.RGBA16I]: {gl2: true, bpp: 8},
309
- [GL.RGBA32I]: {gl2: true, bpp: 16},
310
- [GL.RGBA32UI]: {gl2: true, bpp: 16},
311
-
312
- // When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
313
- [GL.R16F]: {ext: EXT_FLOAT_WEBGL2, bpp: 2},
314
- [GL.RG16F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4},
315
- [GL.RGBA16F]: {ext: EXT_FLOAT_WEBGL2, bpp: 8},
316
- [GL.R32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4},
317
- [GL.RG32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 8},
318
- // TODO - can't get WEBGL_color_buffer_float to work on renderbuffers
319
- [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 16},
320
- // [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2},
321
- [GL.R11F_G11F_B10F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4}
322
- };
323
- */
324
224
  /** @deprecated should be removed */
325
225
  const DATA_FORMAT_CHANNELS = {
326
226
  [6403]: 1,
@@ -370,73 +270,51 @@ export function isTextureFormatSupported(gl, format, extensions) {
370
270
  }
371
271
  return true;
372
272
  }
373
- export function isRenderbufferFormatSupported(gl, format, extensions) {
374
- // Note: Order is important since the function call initializes extensions.
375
- return isTextureFormatSupported(gl, format, extensions) && Boolean(TEXTURE_FORMATS[format]?.rb);
273
+ /** Checks whether linear filtering (interpolated sampling) is available for floating point textures */
274
+ export function isTextureFormatFilterable(gl, format, extensions) {
275
+ return getTextureFormatSupportWebGL(gl, format, extensions).filterable || false;
276
+ }
277
+ export function isTextureFormatRenderable(gl, format, extensions) {
278
+ return getTextureFormatSupportWebGL(gl, format, extensions).renderable || false;
376
279
  }
377
- /** Checks if a texture format is supported */
378
- export function getTextureFormatSupport(gl, format, extensions) {
379
- const info = TEXTURE_FORMATS[format];
380
- if (!info) {
280
+ /** Checks if a texture format is supported, renderable, filterable etc */
281
+ export function getTextureFormatSupportWebGL(gl, format, extensions) {
282
+ const formatInto = decodeTextureFormat(format);
283
+ if (!formatInto) {
284
+ return { supported: false };
285
+ }
286
+ const webglFormatInfo = TEXTURE_FORMATS[format];
287
+ if (!webglFormatInfo) {
381
288
  return { supported: false };
382
289
  }
383
- // let decoded;
384
- // try {
385
- // decoded = decodeTextureFormat(format);
386
- // } catch {}
387
290
  // Support Check that we have a GL constant
388
- let supported = info.gl === undefined;
389
- supported = supported && checkTextureFeature(gl, info.f, extensions);
390
- // Filtering
391
- // const filterable = info.filter
392
- // ? checkTextureFeature(gl, infofilter])
393
- // : decoded && !decoded.signed;
394
- // const renderable = info.filter
395
- // ? checkTextureFeature(gl, inforender])
396
- // : decoded && !decoded.signed;
291
+ let supported = webglFormatInfo.gl !== undefined;
292
+ supported = supported && checkTextureFeature(gl, webglFormatInfo.f, extensions);
293
+ const isDepthStencil = format.startsWith('depth') || format.startsWith('stencil');
294
+ const isSigned = formatInto?.signed;
295
+ const renderable = supported &&
296
+ !isSigned &&
297
+ webglFormatInfo.render &&
298
+ checkTextureFeature(gl, webglFormatInfo.render, extensions);
299
+ const filterable = supported &&
300
+ !isDepthStencil &&
301
+ !isSigned &&
302
+ webglFormatInfo.filter &&
303
+ checkTextureFeature(gl, webglFormatInfo.filter, extensions);
304
+ // if (format.endsWith('32float')) {
305
+ // return Boolean(getWebGLExtension(gl, 'OES_texture_float_linear, extensions', extensions));
306
+ // }
307
+ // if (format.endsWith('16float')) {
308
+ // return Boolean(getWebGLExtension(gl, 'OES_texture_half_float_linear, extensions', extensions));
309
+ // }
397
310
  return {
398
311
  supported,
399
- renderable: supported && checkTextureFeature(gl, info.render, extensions),
400
- filterable: supported && checkTextureFeature(gl, info.filter, extensions),
401
- blendable: false, // tod,
402
- storable: false
312
+ renderable,
313
+ filterable,
314
+ blendable: false, // TODO,
315
+ storable: false // TODO
403
316
  };
404
317
  }
405
- /** Checks whether linear filtering (interpolated sampling) is available for floating point textures */
406
- export function isTextureFormatFilterable(gl, format, extensions) {
407
- if (!isTextureFormatSupported(gl, format, extensions)) {
408
- return false;
409
- }
410
- if (format.startsWith('depth') || format.startsWith('stencil')) {
411
- return false;
412
- }
413
- try {
414
- const decoded = decodeTextureFormat(format);
415
- if (decoded.signed) {
416
- return false;
417
- }
418
- }
419
- catch {
420
- return false;
421
- }
422
- if (format.endsWith('32float')) {
423
- return Boolean(getWebGLExtension(gl, 'OES_texture_float_linear, extensions', extensions));
424
- }
425
- if (format.endsWith('16float')) {
426
- return Boolean(getWebGLExtension(gl, 'OES_texture_half_float_linear, extensions', extensions));
427
- }
428
- return true;
429
- }
430
- export function isTextureFormatRenderable(gl, format, extensions) {
431
- if (!isTextureFormatSupported(gl, format, extensions)) {
432
- return false;
433
- }
434
- if (typeof format === 'number') {
435
- return false; // isTextureFormatFilterableWebGL(gl, format);
436
- }
437
- // TODO depends on device...
438
- return true;
439
- }
440
318
  /** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */
441
319
  export function getTextureFormatWebGL(format) {
442
320
  const formatData = TEXTURE_FORMATS[format];
@@ -496,6 +374,26 @@ function convertTextureFormatToGL(format) {
496
374
  }
497
375
  return webglFormat;
498
376
  }
377
+ // LEGACY CODE
378
+ // TODO - remove when confident in above implementation
379
+ /** luma.gl v9 does not user renderbufers
380
+ export function isRenderbufferFormatSupported(
381
+ gl: WebGL2RenderingContext,
382
+ format: TextureFormat,
383
+ extensions: GLExtensions
384
+ ): boolean {
385
+ // Note: Order is important since the function call initializes extensions.
386
+ return isTextureFormatSupported(gl, format, extensions) && Boolean(TEXTURE_FORMATS[format]?.rb);
387
+ }
388
+ */
389
+ /** Return a list of texture feature strings (for Device.features). Mainly compressed texture support */
390
+ // export function getTextureFeatures(
391
+ // gl: WebGL2RenderingContext,
392
+ // extensions: GLExtensions
393
+ // ): DeviceFeature[] {
394
+ // const textureFeatures = Object.keys(TEXTURE_FEATURES) as DeviceFeature[];
395
+ // return textureFeatures.filter(feature => checkTextureFeature(gl, feature, extensions));
396
+ // }
499
397
  /**
500
398
  * Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
501
399
  export function convertGLToTextureFormat(format: GL | TextureFormat): TextureFormat {
@@ -509,3 +407,95 @@ export function convertGLToTextureFormat(format: GL | TextureFormat): TextureFor
509
407
  return entry[0] as TextureFormat;
510
408
  }
511
409
  */
410
+ /** Legal combinations for internalFormat, format and type *
411
+ // [GL.DEPTH_COMPONENT]: {types: [GL.UNSIGNED_SHORT, GL.UNSIGNED_INT, GL.UNSIGNED_INT_24_8]},
412
+ // [GL.DEPTH_STENCIL]: ,
413
+ // Sized texture format
414
+ // R
415
+ [GL.R8]: {dataFormat: GL.RED, types: [GL.UNSIGNED_BYTE], gl2: true},
416
+ [GL.R16F]: {dataFormat: GL.RED, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
417
+ [GL.R8UI]: {dataFormat: GL.RED_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
418
+ // // RG
419
+ [GL.RG8]: {dataFormat: GL.RG, types: [GL.UNSIGNED_BYTE], gl2: true},
420
+ [GL.RG16F]: {dataFormat: GL.RG, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
421
+ [GL.RG8UI]: {dataFormat: GL.RG_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
422
+ // // RGB
423
+ [GL.RGB8]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE], gl2: true},
424
+ [GL.SRGB8]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE], gl2: true},
425
+ [GL.RGB16F]: {dataFormat: GL.RGB, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
426
+ [GL.RGB8UI]: {dataFormat: GL.RGB_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
427
+ // // RGBA
428
+
429
+ [GL.RGB565]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_6_5], gl2: true},
430
+ [GL.R11F_G11F_B10F]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_INT_10F_11F_11F_REV, GL.HALF_FLOAT, GL.FLOAT], gl2: true},
431
+ [GL.RGB9_E5]: {dataFormat: GL.RGB, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
432
+ [GL.RGBA8]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE], gl2: true},
433
+ [GL.SRGB8_ALPHA8]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE], gl2: true, gl1ext: EXT_SRGB},
434
+ [GL.RGB5_A1]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_5_5_1], gl2: true},
435
+ [GL.RGBA4]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_4_4_4_4], gl2: true},
436
+ [GL.RGBA16F]: {dataFormat: GL.RGBA, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
437
+ [GL.RGBA8UI]: {dataFormat: GL.RGBA_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true}
438
+ */
439
+ /* This table is now baked into the above table
440
+ type RenderbufferFormat = {
441
+ bpp: number;
442
+ gl2?: boolean;
443
+ ext?: string;
444
+ };
445
+
446
+ export const RENDERBUFFER_FORMATS: Record<string, RenderbufferFormat> = {
447
+ [GL.DEPTH_COMPONENT16]: {bpp: 2}, // 16 depth bits.
448
+ // TODO - Not clear which webgpu value to map this to.
449
+ // [GL.DEPTH_COMPONENT24]: {gl2: true, bpp: 3},
450
+ [GL.DEPTH_COMPONENT32F]: {gl2: true, bpp: 4},
451
+
452
+ [GL.STENCIL_INDEX8]: {bpp: 1}, // 8 stencil bits.
453
+
454
+ [GL.DEPTH_STENCIL]: {bpp: 4},
455
+ [GL.DEPTH24_STENCIL8]: {gl2: true, bpp: 4},
456
+ [GL.DEPTH32F_STENCIL8]: {gl2: true, bpp: 5},
457
+
458
+ // When using a WebGL 1 context, color renderbuffer formats are limited
459
+ [GL.RGBA4]: {gl2: true, bpp: 2},
460
+ [GL.RGB565]: {gl2: true, bpp: 2},
461
+ [GL.RGB5_A1]: {gl2: true, bpp: 2},
462
+
463
+ // When using a WebGL 2 context, the following values are available additionally:
464
+ [GL.R8]: {gl2: true, bpp: 1},
465
+ [GL.R8UI]: {gl2: true, bpp: 1},
466
+ [GL.R8I]: {gl2: true, bpp: 1},
467
+ [GL.R16UI]: {gl2: true, bpp: 2},
468
+ [GL.R16I]: {gl2: true, bpp: 2},
469
+ [GL.R32UI]: {gl2: true, bpp: 4},
470
+ [GL.R32I]: {gl2: true, bpp: 4},
471
+ [GL.RG8]: {gl2: true, bpp: 2},
472
+ [GL.RG8UI]: {gl2: true, bpp: 2},
473
+ [GL.RG8I]: {gl2: true, bpp: 2},
474
+ [GL.RG16UI]: {gl2: true, bpp: 4},
475
+ [GL.RG16I]: {gl2: true, bpp: 4},
476
+ [GL.RG32UI]: {gl2: true, bpp: 8},
477
+ [GL.RG32I]: {gl2: true, bpp: 8},
478
+ [GL.RGB8]: {gl2: true, bpp: 3},
479
+ [GL.RGBA8]: {gl2: true, bpp: 4},
480
+ // [GL.SRGB8_ALPHA8]: {gl2: true, gl1: SRGB}, // When using the EXT_sRGB WebGL1 extension
481
+ [GL.RGB10_A2]: {gl2: true, bpp: 4},
482
+ [GL.RGBA8UI]: {gl2: true, bpp: 4},
483
+ [GL.RGBA8I]: {gl2: true, bpp: 4},
484
+ [GL.RGB10_A2UI]: {gl2: true, bpp: 4},
485
+ [GL.RGBA16UI]: {gl2: true, bpp: 8},
486
+ [GL.RGBA16I]: {gl2: true, bpp: 8},
487
+ [GL.RGBA32I]: {gl2: true, bpp: 16},
488
+ [GL.RGBA32UI]: {gl2: true, bpp: 16},
489
+
490
+ // When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
491
+ [GL.R16F]: {ext: EXT_FLOAT_WEBGL2, bpp: 2},
492
+ [GL.RG16F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4},
493
+ [GL.RGBA16F]: {ext: EXT_FLOAT_WEBGL2, bpp: 8},
494
+ [GL.R32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4},
495
+ [GL.RG32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 8},
496
+ // TODO - can't get WEBGL_color_buffer_float to work on renderbuffers
497
+ [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 16},
498
+ // [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2},
499
+ [GL.R11F_G11F_B10F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4}
500
+ };
501
+ */
@@ -1 +1 @@
1
- {"version":3,"file":"format-utils.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/format-utils.ts"],"names":[],"mappings":"AAOA,wBAAgB,oBAAoB,CAAC,MAAM,KAAA,qBAmB1C;AAGD,wBAAgB,aAAa,CAAC,IAAI,KAAA,iBAcjC"}
1
+ {"version":3,"file":"format-utils.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/format-utils.ts"],"names":[],"mappings":"AAOA,wBAAgB,oBAAoB,CAAC,MAAM,KAAA,qBAyB1C;AAGD,wBAAgB,aAAa,CAAC,IAAI,KAAA,iBAcjC"}
@@ -8,14 +8,20 @@ export function glFormatToComponents(format) {
8
8
  case 6406:
9
9
  case 33326:
10
10
  case 6403:
11
+ case 36244:
11
12
  return 1;
13
+ case 33339:
14
+ case 33340:
12
15
  case 33328:
16
+ case 33320:
13
17
  case 33319:
14
18
  return 2;
15
19
  case 6407:
20
+ case 36248:
16
21
  case 34837:
17
22
  return 3;
18
23
  case 6408:
24
+ case 36249:
19
25
  case 34836:
20
26
  return 4;
21
27
  // TODO: Add support for additional WebGL2 formats