@luma.gl/webgl 9.0.0-beta.6 → 9.0.0-beta.7

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 (93) hide show
  1. package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
  2. package/dist/adapter/converters/device-parameters.js +81 -84
  3. package/dist/adapter/converters/sampler-parameters.js +17 -17
  4. package/dist/adapter/converters/shader-formats.js +12 -12
  5. package/dist/adapter/converters/texture-formats.d.ts +10 -8
  6. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  7. package/dist/adapter/converters/texture-formats.js +175 -168
  8. package/dist/adapter/converters/vertex-formats.js +20 -20
  9. package/dist/adapter/device-helpers/webgl-device-features.d.ts +2 -1
  10. package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
  11. package/dist/adapter/device-helpers/webgl-device-features.js +14 -2
  12. package/dist/adapter/device-helpers/webgl-device-info.js +5 -5
  13. package/dist/adapter/device-helpers/webgl-device-limits.js +10 -10
  14. package/dist/adapter/helpers/decode-webgl-types.js +45 -45
  15. package/dist/adapter/helpers/get-shader-layout.js +29 -29
  16. package/dist/adapter/helpers/set-uniform.js +40 -40
  17. package/dist/adapter/helpers/webgl-topology-utils.js +38 -38
  18. package/dist/adapter/objects/webgl-renderbuffer.js +6 -6
  19. package/dist/adapter/objects/webgl-resource.js +1 -2
  20. package/dist/adapter/resources/webgl-buffer.js +14 -14
  21. package/dist/adapter/resources/webgl-command-buffer.js +25 -25
  22. package/dist/adapter/resources/webgl-external-texture.js +3 -3
  23. package/dist/adapter/resources/webgl-framebuffer.d.ts +2 -4
  24. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  25. package/dist/adapter/resources/webgl-framebuffer.js +41 -36
  26. package/dist/adapter/resources/webgl-query-set.js +6 -6
  27. package/dist/adapter/resources/webgl-render-pass.js +5 -5
  28. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  29. package/dist/adapter/resources/webgl-render-pipeline.js +19 -13
  30. package/dist/adapter/resources/webgl-sampler.js +2 -2
  31. package/dist/adapter/resources/webgl-shader.js +4 -4
  32. package/dist/adapter/resources/webgl-texture.d.ts +2 -1
  33. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  34. package/dist/adapter/resources/webgl-texture.js +29 -27
  35. package/dist/adapter/resources/webgl-transform-feedback.js +8 -8
  36. package/dist/adapter/resources/webgl-vertex-array.d.ts +1 -1
  37. package/dist/adapter/resources/webgl-vertex-array.js +5 -5
  38. package/dist/adapter/webgl-device.d.ts +6 -3
  39. package/dist/adapter/webgl-device.d.ts.map +1 -1
  40. package/dist/adapter/webgl-device.js +22 -17
  41. package/dist/classic/accessor.js +4 -4
  42. package/dist/classic/clear.js +2 -2
  43. package/dist/classic/copy-and-blit.js +15 -16
  44. package/dist/classic/format-utils.d.ts +2 -2
  45. package/dist/classic/format-utils.js +14 -14
  46. package/dist/classic/typed-array-utils.js +18 -18
  47. package/dist/context/parameters/unified-parameter-api.d.ts +3 -4
  48. package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
  49. package/dist/context/parameters/unified-parameter-api.js +4 -9
  50. package/dist/context/parameters/webgl-parameter-tables.d.ts +2 -13
  51. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  52. package/dist/context/parameters/webgl-parameter-tables.js +292 -298
  53. package/dist/context/state-tracker/with-parameters.d.ts +1 -2
  54. package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
  55. package/dist/context/state-tracker/with-parameters.js +2 -5
  56. package/dist/dist.dev.js +877 -840
  57. package/dist/index.cjs +1253 -1188
  58. package/dist/index.cjs.map +4 -4
  59. package/dist/index.d.ts +2 -2
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +1 -1
  62. package/dist.min.js +6 -6
  63. package/package.json +4 -4
  64. package/src/adapter/converters/device-parameters.ts +9 -11
  65. package/src/adapter/converters/texture-formats.ts +64 -61
  66. package/src/adapter/device-helpers/webgl-device-features.ts +22 -2
  67. package/src/adapter/objects/webgl-renderbuffer.ts +1 -1
  68. package/src/adapter/objects/webgl-resource.ts +1 -1
  69. package/src/adapter/resources/webgl-external-texture.ts +3 -3
  70. package/src/adapter/resources/webgl-framebuffer.ts +29 -26
  71. package/src/adapter/resources/webgl-render-pass.ts +3 -3
  72. package/src/adapter/resources/webgl-render-pipeline.ts +13 -6
  73. package/src/adapter/resources/webgl-texture.ts +7 -3
  74. package/src/adapter/webgl-device.ts +24 -19
  75. package/src/classic/clear.ts +2 -2
  76. package/src/context/parameters/unified-parameter-api.ts +4 -16
  77. package/src/context/state-tracker/with-parameters.ts +2 -7
  78. package/src/index.ts +4 -4
  79. package/dist/adapter/device-helpers/device-features.d.ts +0 -6
  80. package/dist/adapter/device-helpers/device-features.d.ts.map +0 -1
  81. package/dist/adapter/device-helpers/device-features.js +0 -65
  82. package/dist/adapter/device-helpers/device-limits.d.ts +0 -50
  83. package/dist/adapter/device-helpers/device-limits.d.ts.map +0 -1
  84. package/dist/adapter/device-helpers/device-limits.js +0 -92
  85. package/dist/adapter/device-helpers/get-device-info.d.ts +0 -4
  86. package/dist/adapter/device-helpers/get-device-info.d.ts.map +0 -1
  87. package/dist/adapter/device-helpers/get-device-info.js +0 -87
  88. package/dist/context/context/context-data.d.ts +0 -14
  89. package/dist/context/context/context-data.d.ts.map +0 -1
  90. package/dist/context/context/context-data.js +0 -33
  91. package/dist/context/context/create-browser-context.d.ts +0 -35
  92. package/dist/context/context/create-browser-context.d.ts.map +0 -1
  93. package/dist/context/context/create-browser-context.js +0 -66
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/webgl",
3
- "version": "9.0.0-beta.6",
3
+ "version": "9.0.0-beta.7",
4
4
  "description": "WebGL2 adapter for the luma.gl core API",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -43,9 +43,9 @@
43
43
  "@luma.gl/constants": "^9.0.0-beta.4"
44
44
  },
45
45
  "dependencies": {
46
- "@luma.gl/constants": "9.0.0-beta.6",
47
- "@luma.gl/core": "9.0.0-beta.6",
46
+ "@luma.gl/constants": "9.0.0-beta.7",
47
+ "@luma.gl/core": "9.0.0-beta.7",
48
48
  "@probe.gl/env": "^4.0.2"
49
49
  },
50
- "gitHead": "cb2f0938d03a65e3588622ac99650b14a10488b6"
50
+ "gitHead": "e9606a88e0aab3dc27c87020cac89040ea1a8a02"
51
51
  }
@@ -40,15 +40,14 @@ export function withDeviceAndGLParameters<T = unknown>(
40
40
  }
41
41
 
42
42
  // Wrap in a try-catch to ensure that parameters are restored on exceptions
43
- // @ts-expect-error
44
- pushContextState(device.gl);
43
+ const webglDevice = device as WebGLDevice;
44
+ pushContextState(webglDevice.gl);
45
45
  try {
46
46
  setDeviceParameters(device, parameters);
47
- setGLParameters(device, glParameters);
47
+ setGLParameters(webglDevice.gl, glParameters);
48
48
  return func(device);
49
49
  } finally {
50
- // @ts-expect-error
51
- popContextState(device.gl);
50
+ popContextState(webglDevice.gl);
52
51
  }
53
52
  }
54
53
 
@@ -72,14 +71,13 @@ export function withGLParameters<T = unknown>(
72
71
  }
73
72
 
74
73
  // Wrap in a try-catch to ensure that parameters are restored on exceptions
75
- // @ts-expect-error
76
- pushContextState(device.gl);
74
+ const webglDevice = device as WebGLDevice;
75
+ pushContextState(webglDevice.gl);
77
76
  try {
78
- setGLParameters(device, parameters);
77
+ setGLParameters(webglDevice.gl, parameters);
79
78
  return func(device);
80
79
  } finally {
81
- // @ts-expect-error
82
- popContextState(device.gl);
80
+ popContextState(webglDevice.gl);
83
81
  }
84
82
  }
85
83
 
@@ -115,7 +113,7 @@ export function withDeviceParameters<T = unknown>(
115
113
 
116
114
  /** Set WebGPU Style Parameters */
117
115
  export function setDeviceParameters(device: Device, parameters: Parameters) {
118
- const webglDevice = WebGLDevice.attach(device);
116
+ const webglDevice = device as WebGLDevice;
119
117
  const {gl} = webglDevice;
120
118
 
121
119
  // RASTERIZATION SETTINGS
@@ -130,8 +130,8 @@ type Format = {
130
130
  attachment?: GL.DEPTH_ATTACHMENT | GL.STENCIL_ATTACHMENT | GL.DEPTH_STENCIL_ATTACHMENT;
131
131
  /** if depthTexture is set this is a depth/stencil format that can be set to a texture */
132
132
  depthTexture?: boolean;
133
-
134
- renderbuffer?: boolean;
133
+ /** @deprecated can this format be used with renderbuffers */
134
+ rb?: boolean;
135
135
  };
136
136
 
137
137
  // TABLES
@@ -142,38 +142,37 @@ type Format = {
142
142
  */
143
143
  // prettier-ignore
144
144
  export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
145
- // Unsized formats that leave the precision up to the driver.
146
- // TODO - Fix bpp constants
147
- // 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
145
+ // Unsized formats that leave the precision up to the driver. TODO - Fix bpp constants
148
146
  'rgb8unorm-unsized': {gl: GL.RGB, b: 4, c: 2, bpp: 4,
149
147
  dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_6_5]},
150
148
  'rgba8unorm-unsized': {gl: GL.RGBA, b: 4, c: 2, bpp: 4,
151
149
  dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_4_4_4_4, GL.UNSIGNED_SHORT_5_5_5_1]},
150
+ // 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
152
151
  // 'rgb8unorm-srgb-unsized': {gl: GL.SRGB_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
153
152
  // 'rgba8unorm-srgb-unsized': {gl: GL.SRGB_ALPHA_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
154
153
 
155
154
  // 8-bit formats
156
- 'r8unorm': {gl: GL.R8, b: 1, c: 1, renderbuffer: true},
155
+ 'r8unorm': {gl: GL.R8, b: 1, c: 1, rb: true},
157
156
  'r8snorm': {gl: GL.R8_SNORM, b: 1, c: 1, render: snorm8_renderable},
158
- 'r8uint': {gl: GL.R8UI, b: 1, c: 1, renderbuffer: true},
159
- 'r8sint': {gl: GL.R8I, b: 1, c: 1, renderbuffer: true},
157
+ 'r8uint': {gl: GL.R8UI, b: 1, c: 1, rb: true},
158
+ 'r8sint': {gl: GL.R8I, b: 1, c: 1, rb: true},
160
159
 
161
160
  // 16-bit formats
162
- 'rg8unorm': {gl: GL.RG8, b: 2, c: 2, renderbuffer: true},
161
+ 'rg8unorm': {gl: GL.RG8, b: 2, c: 2, rb: true},
163
162
  'rg8snorm': {gl: GL.RG8_SNORM, b: 2, c: 2, render: snorm8_renderable},
164
- 'rg8uint': {gl: GL.RG8UI, b: 2, c: 2, renderbuffer: true},
165
- 'rg8sint': {gl: GL.RG8I, b: 2, c: 2, renderbuffer: true},
163
+ 'rg8uint': {gl: GL.RG8UI, b: 2, c: 2, rb: true},
164
+ 'rg8sint': {gl: GL.RG8I, b: 2, c: 2, rb: true},
166
165
 
167
- 'r16uint': {gl: GL.R16UI, b: 2, c: 1, renderbuffer: true},
168
- 'r16sint': {gl: GL.R16I, b: 2, c: 1, renderbuffer: true},
169
- 'r16float': {gl: GL.R16F, b: 2, c: 1, render: float16_renderable, filter: 'float16-filterable-webgl', renderbuffer: true},
170
- 'r16unorm-webgl': {gl: GL.R16_EXT, b:2, c:1, f: norm16_renderable, renderbuffer: true},
166
+ 'r16uint': {gl: GL.R16UI, b: 2, c: 1, rb: true},
167
+ 'r16sint': {gl: GL.R16I, b: 2, c: 1, rb: true},
168
+ 'r16float': {gl: GL.R16F, b: 2, c: 1, render: float16_renderable, filter: 'float16-filterable-webgl', rb: true},
169
+ 'r16unorm-webgl': {gl: GL.R16_EXT, b:2, c:1, f: norm16_renderable, rb: true},
171
170
  'r16snorm-webgl': {gl: GL.R16_SNORM_EXT, b:2, c:1, f: snorm16_renderable},
172
171
 
173
172
  // Packed 16-bit formats
174
- 'rgba4unorm-webgl': {gl: GL.RGBA4, b: 2, c: 4, wgpu: false, renderbuffer: true},
175
- 'rgb565unorm-webgl': {gl: GL.RGB565, b: 2, c: 4, wgpu: false, renderbuffer: true},
176
- 'rgb5a1unorm-webgl': {gl: GL.RGB5_A1, b: 2, c: 4, wgpu: false, renderbuffer: true},
173
+ 'rgba4unorm-webgl': {gl: GL.RGBA4, b: 2, c: 4, wgpu: false, rb: true},
174
+ 'rgb565unorm-webgl': {gl: GL.RGB565, b: 2, c: 4, wgpu: false, rb: true},
175
+ 'rgb5a1unorm-webgl': {gl: GL.RGB5_A1, b: 2, c: 4, wgpu: false, rb: true},
177
176
 
178
177
  // 24-bit formats
179
178
  'rgb8unorm-webgl': {gl: GL.RGB8, b: 3, c: 3, wgpu: false},
@@ -192,32 +191,32 @@ export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
192
191
  'rg16uint': {gl: GL.RG16UI, b: 4, c: 1, bpp: 4},
193
192
  'rg16sint': {gl: GL.RG16I, b: 4, c: 2, bpp: 4},
194
193
  // When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
195
- 'rg16float': {gl: GL.RG16F, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable, renderbuffer: true},
194
+ 'rg16float': {gl: GL.RG16F, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable, rb: true},
196
195
  'rg16unorm-webgl': {gl: GL.RG16_EXT, b:2, c:2, render: norm16_renderable},
197
196
  'rg16snorm-webgl': {gl: GL.RG16_SNORM_EXT, b:2, c:2, render: snorm16_renderable},
198
197
 
199
- 'r32uint': {gl: GL.R32UI, b: 4, c: 1, bpp: 4, renderbuffer: true},
200
- 'r32sint': {gl: GL.R32I, b: 4, c: 1, bpp: 4, renderbuffer: true},
198
+ 'r32uint': {gl: GL.R32UI, b: 4, c: 1, bpp: 4, rb: true},
199
+ 'r32sint': {gl: GL.R32I, b: 4, c: 1, bpp: 4, rb: true},
201
200
  'r32float': {gl: GL.R32F, bpp: 4, b: 4, c: 1, render: float32_renderable, filter: float32_filterable},
202
201
 
203
202
  // Packed 32-bit formats
204
203
  'rgb9e5ufloat': {gl: GL.RGB9_E5, b: 4, c: 3, p: 1, render: rgb9e5ufloat_renderable}, // , filter: true},
205
- 'rg11b10ufloat': {gl: GL.R11F_G11F_B10F, b: 4, c: 3, p: 1,render: float32_renderable, renderbuffer: true},
206
- 'rgb10a2unorm': {gl: GL.RGB10_A2, b: 4, c: 4, p: 1, renderbuffer: true},
207
- 'rgb10a2uint-webgl': {b: 4, c: 4, gl: GL.RGB10_A2UI, p: 1, wgpu: false, bpp: 4, renderbuffer: true},
204
+ 'rg11b10ufloat': {gl: GL.R11F_G11F_B10F, b: 4, c: 3, p: 1,render: float32_renderable, rb: true},
205
+ 'rgb10a2unorm': {gl: GL.RGB10_A2, b: 4, c: 4, p: 1, rb: true},
206
+ 'rgb10a2uint-webgl': {b: 4, c: 4, gl: GL.RGB10_A2UI, p: 1, wgpu: false, bpp: 4, rb: true},
208
207
 
209
208
  // 48-bit formats
210
209
  'rgb16unorm-webgl': {gl: GL.RGB16_EXT, b:2, c:3, f: norm16_renderable}, // rgb not renderable
211
210
  'rgb16snorm-webgl': {gl: GL.RGB16_SNORM_EXT, b:2, c:3, f: norm16_renderable}, // rgb not renderable
212
211
 
213
212
  // 64-bit formats
214
- 'rg32uint': {gl: GL.RG32UI, b: 8, c: 2, renderbuffer: true},
215
- 'rg32sint': {gl: GL.RG32I, b: 8, c: 2, renderbuffer: true},
216
- 'rg32float': {gl: GL.RG32F, b: 8, c: 2, render: float32_renderable, filter: float32_filterable, renderbuffer: true},
217
- 'rgba16uint': {gl: GL.RGBA16UI, b: 8, c: 4, renderbuffer: true},
218
- 'rgba16sint': {gl: GL.RGBA16I, b: 8, c: 4, renderbuffer: true},
213
+ 'rg32uint': {gl: GL.RG32UI, b: 8, c: 2, rb: true},
214
+ 'rg32sint': {gl: GL.RG32I, b: 8, c: 2, rb: true},
215
+ 'rg32float': {gl: GL.RG32F, b: 8, c: 2, render: float32_renderable, filter: float32_filterable, rb: true},
216
+ 'rgba16uint': {gl: GL.RGBA16UI, b: 8, c: 4, rb: true},
217
+ 'rgba16sint': {gl: GL.RGBA16I, b: 8, c: 4, rb: true},
219
218
  'rgba16float': {gl: GL.RGBA16F, b: 8, c: 4, render: float16_renderable, filter: float16_filterable},
220
- 'rgba16unorm-webgl': {gl: GL.RGBA16_EXT, b:2, c:4, render: norm16_renderable, renderbuffer: true},
219
+ 'rgba16unorm-webgl': {gl: GL.RGBA16_EXT, b:2, c:4, render: norm16_renderable, rb: true},
221
220
  'rgba16snorm-webgl': {gl: GL.RGBA16_SNORM_EXT, b:2, c:4, render: snorm16_renderable},
222
221
 
223
222
  // 96-bit formats (deprecated!)
@@ -225,23 +224,29 @@ export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
225
224
  gl2ext: EXT_color_buffer_float, dataFormat: GL.RGB, types: [GL.FLOAT]},
226
225
 
227
226
  // 128-bit formats
228
- 'rgba32uint': {gl: GL.RGBA32UI, b: 16, c: 4, renderbuffer: true},
229
- 'rgba32sint': {gl: GL.RGBA32I, b: 16, c: 4, renderbuffer: true},
230
- 'rgba32float': {gl: GL.RGBA32F, b: 16, c: 4, render: float32_renderable, filter: float32_filterable, renderbuffer: true},
227
+ 'rgba32uint': {gl: GL.RGBA32UI, b: 16, c: 4, rb: true},
228
+ 'rgba32sint': {gl: GL.RGBA32I, b: 16, c: 4, rb: true},
229
+ 'rgba32float': {gl: GL.RGBA32F, b: 16, c: 4, render: float32_renderable, filter: float32_filterable, rb: true},
231
230
 
232
231
  // Depth and stencil formats
233
- 'stencil8': {gl: GL.STENCIL_INDEX8, b: 1, c: 1, attachment: GL.STENCIL_ATTACHMENT, renderbuffer: true}, // 8 stencil bits
232
+ 'stencil8': {gl: GL.STENCIL_INDEX8, b: 1, c: 1, attachment: GL.STENCIL_ATTACHMENT, rb: true}, // 8 stencil bits
234
233
 
235
- 'depth16unorm': {gl: GL.DEPTH_COMPONENT16, b: 2, c: 1, attachment: GL.DEPTH_ATTACHMENT, renderbuffer: true}, // 16 depth bits
236
- 'depth24plus': {gl: GL.DEPTH_COMPONENT24, b: 3, c: 1, attachment: GL.DEPTH_ATTACHMENT},
237
- 'depth32float': {gl: GL.DEPTH_COMPONENT32F, b: 4, c: 1, attachment: GL.DEPTH_ATTACHMENT, renderbuffer: true},
234
+ 'depth16unorm': {gl: GL.DEPTH_COMPONENT16, b: 2, c: 1, attachment: GL.DEPTH_ATTACHMENT,
235
+ dataFormat: GL.DEPTH_COMPONENT, types: [GL.UNSIGNED_SHORT], rb: true}, // 16 depth bits
236
+ 'depth24plus': {gl: GL.DEPTH_COMPONENT24, b: 3, c: 1, attachment: GL.DEPTH_ATTACHMENT,
237
+ dataFormat: GL.DEPTH_COMPONENT, types: [GL.UNSIGNED_INT]},
238
+ 'depth32float': {gl: GL.DEPTH_COMPONENT32F, b: 4, c: 1, attachment: GL.DEPTH_ATTACHMENT,
239
+ dataFormat: GL.DEPTH_COMPONENT, types: [GL.FLOAT], rb: true},
238
240
 
239
241
  // The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
240
- 'depth24plus-stencil8': {gl: GL.DEPTH_STENCIL, b: 4, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true, depthTexture: true},
242
+ 'depth24plus-stencil8': {gl: GL.DEPTH24_STENCIL8, b: 4, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT, rb: true, depthTexture: true,
243
+ dataFormat: GL.DEPTH_STENCIL, types: [GL.UNSIGNED_INT_24_8]},
241
244
  // "depth24unorm-stencil8" feature
242
- 'depth24unorm-stencil8': {gl: GL.DEPTH24_STENCIL8, b: 4, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true},
243
- // "depth32float-stencil8" feature
244
- 'depth32float-stencil8': {gl: GL.DEPTH32F_STENCIL8, b: 5, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true},
245
+ 'depth24unorm-stencil8': {gl: GL.DEPTH24_STENCIL8, b: 4, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT,
246
+ dataFormat: GL.DEPTH_STENCIL, types: [GL.UNSIGNED_INT_24_8], rb: true},
247
+ // "depth32float-stencil8" feature - TODO below is render buffer only?
248
+ 'depth32float-stencil8': {gl: GL.DEPTH32F_STENCIL8, b: 5, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT,
249
+ dataFormat: GL.DEPTH_STENCIL, types: [GL.FLOAT_32_UNSIGNED_INT_24_8_REV], rb: true},
245
250
 
246
251
  // BC compressed formats: check device.features.has("texture-compression-bc");
247
252
 
@@ -455,10 +460,9 @@ const TYPE_SIZES = {
455
460
  /** Checks if a texture format is supported */
456
461
  export function isTextureFormatSupported(
457
462
  gl: WebGL2RenderingContext,
458
- formatOrGL: TextureFormat | GL,
463
+ format: TextureFormat,
459
464
  extensions: GLExtensions
460
465
  ): boolean {
461
- const format = convertGLToTextureFormat(formatOrGL);
462
466
  const info = TEXTURE_FORMATS[format];
463
467
  if (!info) {
464
468
  return false;
@@ -481,7 +485,7 @@ export function isRenderbufferFormatSupported(
481
485
  extensions: GLExtensions
482
486
  ): boolean {
483
487
  // Note: Order is important since the function call initializes extensions.
484
- return isTextureFormatSupported(gl, format, extensions) && TEXTURE_FORMATS[format]?.renderbuffer;
488
+ return isTextureFormatSupported(gl, format, extensions) && TEXTURE_FORMATS[format]?.rb;
485
489
  }
486
490
 
487
491
  /**
@@ -513,7 +517,7 @@ export function convertTextureFormatToGL(format: TextureFormat): GL | undefined
513
517
  /** Checks if a texture format is supported */
514
518
  export function getTextureFormatSupport(
515
519
  gl: WebGL2RenderingContext,
516
- formatOrGL: TextureFormat | GL,
520
+ format: TextureFormat,
517
521
  extensions: GLExtensions
518
522
  ): {
519
523
  supported: boolean;
@@ -522,7 +526,6 @@ export function getTextureFormatSupport(
522
526
  blendable?: boolean;
523
527
  storable?: boolean;
524
528
  } {
525
- const format = convertGLToTextureFormat(formatOrGL);
526
529
  const info = TEXTURE_FORMATS[format];
527
530
  if (!info) {
528
531
  return {supported: false};
@@ -556,13 +559,15 @@ export function getTextureFormatSupport(
556
559
  /** Checks whether linear filtering (interpolated sampling) is available for floating point textures */
557
560
  export function isTextureFormatFilterable(
558
561
  gl: WebGL2RenderingContext,
559
- formatOrGL: TextureFormat | GL,
562
+ format: TextureFormat,
560
563
  extensions: GLExtensions
561
564
  ): boolean {
562
- const format = convertGLToTextureFormat(formatOrGL);
563
565
  if (!isTextureFormatSupported(gl, format, extensions)) {
564
566
  return false;
565
567
  }
568
+ if (format.startsWith('depth') || format.startsWith('stencil')) {
569
+ return false;
570
+ }
566
571
  try {
567
572
  const decoded = decodeTextureFormat(format);
568
573
  if (decoded.signed) {
@@ -582,10 +587,9 @@ export function isTextureFormatFilterable(
582
587
 
583
588
  export function isTextureFormatRenderable(
584
589
  gl: WebGL2RenderingContext,
585
- formatOrGL: TextureFormat | GL,
590
+ format: TextureFormat,
586
591
  extensions: GLExtensions
587
592
  ): boolean {
588
- const format = convertGLToTextureFormat(formatOrGL);
589
593
  if (!isTextureFormatSupported(gl, format, extensions)) {
590
594
  return false;
591
595
  }
@@ -596,20 +600,20 @@ export function isTextureFormatRenderable(
596
600
  return true;
597
601
  }
598
602
 
599
- export function getWebGLTextureParameters(formatOrGL: TextureFormat | GL) {
600
- const format = convertGLToTextureFormat(formatOrGL);
603
+ /** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */
604
+ export function getWebGLTextureParameters(format: TextureFormat) {
605
+ const formatData = TEXTURE_FORMATS[format];
601
606
  const webglFormat = convertTextureFormatToGL(format);
602
607
  const decoded = decodeTextureFormat(format);
603
608
  return {
604
609
  format: webglFormat,
605
- dataFormat: getWebGLPixelDataFormat(
606
- decoded.format,
607
- decoded.integer,
608
- decoded.normalized,
609
- webglFormat
610
- ),
610
+ dataFormat:
611
+ formatData?.dataFormat ||
612
+ getWebGLPixelDataFormat(decoded.format, decoded.integer, decoded.normalized, webglFormat),
611
613
  // depth formats don't have a type
612
- type: decoded.dataType ? getGLFromVertexType(decoded.dataType) : GL.UNSIGNED_BYTE,
614
+ type: decoded.dataType
615
+ ? getGLFromVertexType(decoded.dataType)
616
+ : formatData?.types?.[0] || GL.UNSIGNED_BYTE,
613
617
  // @ts-expect-error
614
618
  compressed: decoded.compressed
615
619
  };
@@ -626,9 +630,8 @@ export function getDepthStencilAttachmentWebGL(
626
630
  }
627
631
 
628
632
  /** TODO - VERY roundabout legacy way of calculating bytes per pixel */
629
- export function getTextureFormatBytesPerPixel(formatOrGL: TextureFormat | GL): number {
633
+ export function getTextureFormatBytesPerPixel(format: TextureFormat): number {
630
634
  // TODO remove webgl1 support
631
- const format = convertGLToTextureFormat(formatOrGL);
632
635
  const params = getWebGLTextureParameters(format);
633
636
  // NOTE(Tarek): Default to RGBA bytes
634
637
  const channels = DATA_FORMAT_CHANNELS[params.dataFormat] || 4;
@@ -47,8 +47,12 @@ export class WebGLDeviceFeatures extends DeviceFeatures {
47
47
  protected extensions: GLExtensions;
48
48
  protected testedFeatures = new Set<DeviceFeature>();
49
49
 
50
- constructor(gl: WebGL2RenderingContext, extensions: GLExtensions) {
51
- super();
50
+ constructor(
51
+ gl: WebGL2RenderingContext,
52
+ extensions: GLExtensions,
53
+ disabledFeatures: Partial<Record<DeviceFeature, boolean>>
54
+ ) {
55
+ super([], disabledFeatures);
52
56
  this.gl = gl;
53
57
  this.extensions = extensions;
54
58
  // TODO - is this really needed?
@@ -71,6 +75,10 @@ export class WebGLDeviceFeatures extends DeviceFeatures {
71
75
  }
72
76
 
73
77
  override has(feature: DeviceFeature): boolean {
78
+ if (this.disabledFeatures[feature]) {
79
+ return false;
80
+ }
81
+
74
82
  // We have already tested this feature
75
83
  if (!this.testedFeatures.has(feature)) {
76
84
  this.testedFeatures.add(feature);
@@ -87,6 +95,18 @@ export class WebGLDeviceFeatures extends DeviceFeatures {
87
95
  return this.features.has(feature);
88
96
  }
89
97
 
98
+ // FOR DEVICE
99
+
100
+ initializeFeatures() {
101
+ // @ts-expect-error
102
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
103
+ for (const feature of this) {
104
+ // WebGL extensions are initialized by requesting them
105
+ }
106
+ }
107
+
108
+ // IMPLEMENTATION
109
+
90
110
  /** Extract all WebGL features */
91
111
  protected getWebGLFeature(feature: DeviceFeature): boolean {
92
112
  const featureInfo = WEBGL_FEATURES[feature];
@@ -111,7 +111,7 @@ export class WEBGLRenderbuffer extends WebGLResource<RenderbufferProps> {
111
111
  this.gl.bindRenderbuffer(GL.RENDERBUFFER, null);
112
112
 
113
113
  this.trackAllocatedMemory(
114
- width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat)
114
+ width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.format)
115
115
  );
116
116
  }
117
117
 
@@ -25,7 +25,7 @@ export abstract class WebGLResource<Props extends ResourceProps> extends Resourc
25
25
  constructor(device: Device, props: Props, defaultProps: Required<Props>) {
26
26
  super(device, props, defaultProps);
27
27
 
28
- this.device = WebGLDevice.attach(device);
28
+ this.device = device as WebGLDevice;
29
29
  const gl = this.device.gl;
30
30
 
31
31
  // extends
@@ -53,12 +53,12 @@ export class WEBGLExternalTexture extends WEBGLTexture {
53
53
  }
54
54
 
55
55
  // eslint-disable-next-line max-statements
56
- constructor(device: Device | WebGL2RenderingContext, props: TextureProps) {
57
- super(WebGLDevice.attach(device), {id: uid('texture'), ...props});
56
+ constructor(device: Device , props: TextureProps) {
57
+ super(device as WebGLDevice, {id: uid('texture'), ...props});
58
58
 
59
59
  this.glTarget = getWebGLTextureTarget(props);
60
60
 
61
- this.device = WebGLDevice.attach(device);
61
+ this.device = device as WebGLDevice;
62
62
  this.gl = this.device.gl;
63
63
  this.gl2 = this.device.gl2;
64
64
  this.handle = this.props.handle || this.gl.createTexture();
@@ -8,10 +8,12 @@ import {GL} from '@luma.gl/constants';
8
8
  import {WebGLDevice} from '../webgl-device';
9
9
  import {WEBGLTexture} from './webgl-texture';
10
10
  import {WEBGLTextureView} from './webgl-texture-view';
11
- import {WEBGLRenderbuffer} from '../objects/webgl-renderbuffer';
12
11
  import {getDepthStencilAttachmentWebGL} from '../converters/texture-formats';
13
12
 
14
- export type Attachment = WEBGLTextureView | WEBGLTexture | WEBGLRenderbuffer;
13
+ // TODO - for now we don't see a usage for renderbuffers in WebGL 2.
14
+ // import {WEBGLRenderbuffer} from '../objects/webgl-renderbuffer';
15
+
16
+ export type Attachment = WEBGLTextureView | WEBGLTexture; // | WEBGLRenderbuffer;
15
17
 
16
18
  /** luma.gl Framebuffer, WebGL implementation */
17
19
  export class WEBGLFramebuffer extends Framebuffer {
@@ -86,14 +88,14 @@ export class WEBGLFramebuffer extends Framebuffer {
86
88
 
87
89
  /** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */
88
90
  protected override createDepthStencilTexture(format: TextureFormat): Texture {
89
- return new WEBGLRenderbuffer(this.device, {
90
- id: `${this.id}-depth-stencil`, // TODO misleading if not depth and stencil?
91
+ // return new WEBGLRenderbuffer(this.device, {
92
+ return new WEBGLTexture(this.device, {
93
+ id: `${this.id}-depth-stencil`,
91
94
  format,
92
- // dataFormat: GL.DEPTH_STENCIL,
93
- // type: GL.UNSIGNED_INT_24_8,
94
95
  width: this.width,
95
- height: this.height
96
- }) as unknown as WEBGLTexture;
96
+ height: this.height,
97
+ mipmaps: false
98
+ });
97
99
  }
98
100
 
99
101
  /**
@@ -127,21 +129,21 @@ export class WEBGLFramebuffer extends Framebuffer {
127
129
  }
128
130
 
129
131
  /** Attach one attachment */
130
- protected _attachOne(
131
- attachmentPoint: GL,
132
- attachment: Attachment
133
- ): WEBGLTexture | WEBGLRenderbuffer {
134
- if (attachment instanceof WEBGLRenderbuffer) {
135
- this._attachWEBGLRenderbuffer(attachmentPoint, attachment);
136
- return attachment;
137
- } else if (Array.isArray(attachment)) {
132
+ protected _attachOne(attachmentPoint: GL, attachment: Attachment): WEBGLTexture {
133
+ // if (attachment instanceof WEBGLRenderbuffer) {
134
+ // this._attachWEBGLRenderbuffer(attachmentPoint, attachment);
135
+ // return attachment;
136
+ // }
137
+ if (Array.isArray(attachment)) {
138
138
  const [texture, layer = 0, level = 0] = attachment;
139
139
  this._attachTexture(attachmentPoint, texture as unknown as WEBGLTexture, layer, level);
140
140
  return texture as unknown as WEBGLTexture;
141
- } else if (attachment instanceof WEBGLTexture) {
141
+ }
142
+ if (attachment instanceof WEBGLTexture) {
142
143
  this._attachTexture(attachmentPoint, attachment, 0, 0);
143
144
  return attachment;
144
- } else if (attachment instanceof WEBGLTextureView) {
145
+ }
146
+ if (attachment instanceof WEBGLTextureView) {
145
147
  const textureView = attachment;
146
148
  this._attachTexture(
147
149
  attachmentPoint,
@@ -154,14 +156,15 @@ export class WEBGLFramebuffer extends Framebuffer {
154
156
  throw new Error('attach');
155
157
  }
156
158
 
157
- protected _attachWEBGLRenderbuffer(attachment: GL, renderbuffer: WEBGLRenderbuffer): void {
158
- this.gl.framebufferRenderbuffer(
159
- GL.FRAMEBUFFER,
160
- attachment,
161
- GL.RENDERBUFFER,
162
- renderbuffer.handle
163
- );
164
- }
159
+ // TODO - we do not seem to need render buffers in WebGL 2
160
+ // protected _attachWEBGLRenderbuffer(attachment: GL, renderbuffer: WEBGLRenderbuffer): void {
161
+ // this.gl.framebufferRenderbuffer(
162
+ // GL.FRAMEBUFFER,
163
+ // attachment,
164
+ // GL.RENDERBUFFER,
165
+ // renderbuffer.handle
166
+ // );
167
+ // }
165
168
 
166
169
  /**
167
170
  * @param attachment
@@ -38,7 +38,7 @@ export class WEBGLRenderPass extends RenderPass {
38
38
  end(): void {
39
39
  popContextState(this.device.gl);
40
40
  if (this.props.framebuffer) {
41
- setGLParameters(this.device, {framebuffer: null});
41
+ setGLParameters(this.device.gl, {framebuffer: null});
42
42
  }
43
43
  // should add commands to CommandEncoder.
44
44
  }
@@ -99,7 +99,7 @@ export class WEBGLRenderPass extends RenderPass {
99
99
 
100
100
  this.glParameters = glParameters;
101
101
 
102
- setGLParameters(this.device, glParameters);
102
+ setGLParameters(this.device.gl, glParameters);
103
103
  }
104
104
 
105
105
  beginOcclusionQuery(queryIndex: number): void {
@@ -137,7 +137,7 @@ export class WEBGLRenderPass extends RenderPass {
137
137
 
138
138
  if (clearMask !== 0) {
139
139
  // Temporarily set any clear "colors" and call clear
140
- withGLParameters(this.device, glParameters, () => {
140
+ withGLParameters(this.device.gl, glParameters, () => {
141
141
  this.device.gl.clear(clearMask);
142
142
  });
143
143
 
@@ -175,11 +175,6 @@ export class WEBGLRenderPipeline extends RenderPipeline {
175
175
  baseVertex?: number;
176
176
  transformFeedback?: WEBGLTransformFeedback;
177
177
  }): boolean {
178
- // If we are using async linking, we need to wait until linking completes
179
- if (this.linkStatus !== 'success') {
180
- return false;
181
- }
182
-
183
178
  const {
184
179
  renderPass,
185
180
  vertexArray,
@@ -198,15 +193,27 @@ export class WEBGLRenderPipeline extends RenderPipeline {
198
193
  const glIndexType = (vertexArray.indexBuffer as WEBGLBuffer)?.glIndexType;
199
194
  const isInstanced: boolean = Number(instanceCount) > 0;
200
195
 
196
+ // If we are using async linking, we need to wait until linking completes
197
+ if (this.linkStatus !== 'success') {
198
+ log.info(2, `RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)();
199
+ return false;
200
+ }
201
+
201
202
  // Avoid WebGL draw call when not rendering any data or values are incomplete
202
203
  // Note: async textures set as uniforms might still be loading.
203
204
  // Now that all uniforms have been updated, check if any texture
204
205
  // in the uniforms is not yet initialized, then we don't draw
205
206
  if (!this._areTexturesRenderable() || vertexCount === 0) {
206
- // (isInstanced && instanceCount === 0)
207
+ log.info(2, `RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)();
207
208
  return false;
208
209
  }
209
210
 
211
+ // (isInstanced && instanceCount === 0)
212
+ if (vertexCount === 0) {
213
+ log.info(2, `RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)();
214
+ return true;
215
+ }
216
+
210
217
  this.device.gl.useProgram(this.handle);
211
218
 
212
219
  // Note: Rebinds constant attributes before each draw call
@@ -10,6 +10,7 @@
10
10
  import {
11
11
  Device,
12
12
  TextureProps,
13
+ TextureViewProps,
13
14
  Sampler,
14
15
  SamplerProps,
15
16
  SamplerParameters,
@@ -227,6 +228,10 @@ export class WEBGLTexture extends Texture<WEBGLTextureProps> {
227
228
  return `Texture(${this.id},${this.width}x${this.height})`;
228
229
  }
229
230
 
231
+ createView(props: TextureViewProps): WEBGLTextureView {
232
+ return new WEBGLTextureView(this.device, {...props, texture: this});
233
+ }
234
+
230
235
  // eslint-disable-next-line max-statements
231
236
  initialize(props: WEBGLTextureProps = {}): this {
232
237
  // Cube textures
@@ -318,10 +323,9 @@ export class WEBGLTexture extends Texture<WEBGLTextureProps> {
318
323
  this.setSampler(props.sampler);
319
324
  this._setSamplerParameters(parameters);
320
325
 
321
- // @ts-ignore
322
- this.view = new WEBGLTextureView(this.device, {...this.props, texture: this});
326
+ this.view = this.createView({...this.props, mipLevelCount: 1, arrayLayerCount: 1});
323
327
 
324
- if (mipmaps) {
328
+ if (mipmaps && this.device.isTextureFormatFilterable(props.format)) {
325
329
  this.generateMipmap();
326
330
  }
327
331