@luma.gl/webgl 9.0.0-alpha.21 → 9.0.0-alpha.24

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 (165) hide show
  1. package/dist/adapter/converters/device-parameters.d.ts +1 -1
  2. package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
  3. package/dist/adapter/converters/device-parameters.js +9 -9
  4. package/dist/adapter/converters/device-parameters.js.map +1 -1
  5. package/dist/adapter/converters/sampler-parameters.d.ts +1 -1
  6. package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
  7. package/dist/adapter/converters/sampler-parameters.js +1 -1
  8. package/dist/adapter/converters/sampler-parameters.js.map +1 -1
  9. package/dist/adapter/converters/texture-formats.d.ts +29 -40
  10. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  11. package/dist/adapter/converters/texture-formats.js +152 -114
  12. package/dist/adapter/converters/texture-formats.js.map +1 -1
  13. package/dist/adapter/device-helpers/device-limits.d.ts +1 -1
  14. package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
  15. package/dist/adapter/helpers/attribute-utils.d.ts +1 -1
  16. package/dist/adapter/helpers/attribute-utils.d.ts.map +1 -1
  17. package/dist/adapter/helpers/attribute-utils.js +1 -1
  18. package/dist/adapter/helpers/attribute-utils.js.map +1 -1
  19. package/dist/adapter/helpers/get-shader-info.d.ts +1 -1
  20. package/dist/adapter/helpers/get-shader-info.d.ts.map +1 -1
  21. package/dist/adapter/helpers/get-shader-info.js.map +1 -1
  22. package/dist/adapter/helpers/uniforms.d.ts +7 -8
  23. package/dist/adapter/helpers/uniforms.d.ts.map +1 -1
  24. package/dist/adapter/helpers/uniforms.js +4 -4
  25. package/dist/adapter/helpers/uniforms.js.map +1 -1
  26. package/dist/adapter/objects/constants-to-keys.d.ts +0 -2
  27. package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
  28. package/dist/adapter/objects/constants-to-keys.js +0 -20
  29. package/dist/adapter/objects/constants-to-keys.js.map +1 -1
  30. package/dist/adapter/objects/webgl-renderbuffer.d.ts +12 -9
  31. package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
  32. package/dist/adapter/objects/webgl-renderbuffer.js +29 -19
  33. package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
  34. package/dist/adapter/objects/webgl-resource.d.ts +0 -1
  35. package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
  36. package/dist/adapter/objects/webgl-resource.js +4 -7
  37. package/dist/adapter/objects/webgl-resource.js.map +1 -1
  38. package/dist/adapter/objects/webgl-vertex-array-object.d.ts +1 -1
  39. package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
  40. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  41. package/dist/adapter/resources/webgl-buffer.js +3 -2
  42. package/dist/adapter/resources/webgl-buffer.js.map +1 -1
  43. package/dist/adapter/resources/webgl-command-buffer.d.ts +13 -7
  44. package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
  45. package/dist/adapter/resources/webgl-command-buffer.js +168 -25
  46. package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
  47. package/dist/adapter/resources/webgl-command-encoder.d.ts +3 -2
  48. package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
  49. package/dist/adapter/resources/webgl-command-encoder.js +6 -2
  50. package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
  51. package/dist/adapter/resources/webgl-framebuffer.d.ts +11 -14
  52. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  53. package/dist/adapter/resources/webgl-framebuffer.js +29 -79
  54. package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
  55. package/dist/adapter/resources/webgl-render-pass.d.ts +16 -1
  56. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  57. package/dist/adapter/resources/webgl-render-pass.js +80 -0
  58. package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
  59. package/dist/adapter/resources/webgl-render-pipeline.d.ts +1 -1
  60. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  61. package/dist/adapter/resources/webgl-render-pipeline.js +5 -5
  62. package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
  63. package/dist/adapter/resources/webgl-sampler.d.ts +1 -1
  64. package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
  65. package/dist/adapter/resources/webgl-sampler.js +1 -1
  66. package/dist/adapter/resources/webgl-sampler.js.map +1 -1
  67. package/dist/adapter/resources/webgl-texture.d.ts +43 -23
  68. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  69. package/dist/adapter/resources/webgl-texture.js +32 -30
  70. package/dist/adapter/resources/webgl-texture.js.map +1 -1
  71. package/dist/adapter/webgl-canvas-context.d.ts +1 -2
  72. package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
  73. package/dist/adapter/webgl-canvas-context.js.map +1 -1
  74. package/dist/adapter/webgl-device.d.ts +13 -6
  75. package/dist/adapter/webgl-device.d.ts.map +1 -1
  76. package/dist/adapter/webgl-device.js +20 -2
  77. package/dist/adapter/webgl-device.js.map +1 -1
  78. package/dist/classic/buffer.d.ts +1 -2
  79. package/dist/classic/buffer.d.ts.map +1 -1
  80. package/dist/classic/buffer.js +0 -6
  81. package/dist/classic/buffer.js.map +1 -1
  82. package/dist/classic/clear.d.ts +22 -0
  83. package/dist/classic/clear.d.ts.map +1 -0
  84. package/dist/classic/clear.js +88 -0
  85. package/dist/classic/clear.js.map +1 -0
  86. package/dist/classic/copy-and-blit.d.ts +45 -0
  87. package/dist/classic/copy-and-blit.d.ts.map +1 -0
  88. package/dist/classic/copy-and-blit.js +136 -0
  89. package/dist/classic/copy-and-blit.js.map +1 -0
  90. package/dist/classic/format-utils.d.ts +3 -0
  91. package/dist/classic/format-utils.d.ts.map +1 -0
  92. package/dist/classic/format-utils.js +38 -0
  93. package/dist/classic/format-utils.js.map +1 -0
  94. package/dist/classic/typed-array-utils.d.ts +15 -17
  95. package/dist/classic/typed-array-utils.d.ts.map +1 -1
  96. package/dist/classic/typed-array-utils.js +1 -1
  97. package/dist/classic/typed-array-utils.js.map +1 -1
  98. package/dist/context/context/create-browser-context.d.ts +17 -19
  99. package/dist/context/context/create-browser-context.d.ts.map +1 -1
  100. package/dist/context/context/create-browser-context.js +4 -4
  101. package/dist/context/context/create-browser-context.js.map +1 -1
  102. package/dist/context/context/create-headless-context.d.ts +1 -1
  103. package/dist/context/context/create-headless-context.d.ts.map +1 -1
  104. package/dist/context/debug/spector.d.ts +1 -3
  105. package/dist/context/debug/spector.d.ts.map +1 -1
  106. package/dist/context/debug/webgl-developer-tools.d.ts +1 -1
  107. package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
  108. package/dist/context/parameters/unified-parameter-api.d.ts +1 -1
  109. package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
  110. package/dist/context/parameters/unified-parameter-api.js.map +1 -1
  111. package/dist/context/parameters/webgl-parameter-tables.d.ts +2 -3
  112. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  113. package/dist/context/parameters/webgl-parameter-tables.js +1 -1
  114. package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
  115. package/dist/dist.dev.js +1306 -659
  116. package/dist/index.cjs +1269 -897
  117. package/dist/index.d.ts +5 -2
  118. package/dist/index.d.ts.map +1 -1
  119. package/dist/index.js +4 -1
  120. package/dist/index.js.map +1 -1
  121. package/dist/types.d.ts +1 -1
  122. package/dist/types.d.ts.map +1 -1
  123. package/dist.min.js +22 -21
  124. package/package.json +7 -4
  125. package/src/adapter/converters/device-parameters.ts +46 -22
  126. package/src/adapter/converters/sampler-parameters.ts +1 -2
  127. package/src/adapter/converters/texture-formats.ts +242 -161
  128. package/src/adapter/helpers/attribute-utils.ts +1 -2
  129. package/src/adapter/helpers/get-shader-info.ts +3 -0
  130. package/src/adapter/helpers/uniforms.ts +9 -10
  131. package/src/adapter/objects/constants-to-keys.ts +0 -25
  132. package/src/adapter/objects/webgl-renderbuffer.ts +32 -29
  133. package/src/adapter/objects/webgl-resource.ts +4 -8
  134. package/src/adapter/resources/webgl-buffer.ts +4 -5
  135. package/src/adapter/resources/webgl-command-buffer.ts +328 -21
  136. package/src/adapter/resources/webgl-command-encoder.ts +7 -2
  137. package/src/adapter/resources/webgl-framebuffer.ts +63 -111
  138. package/src/adapter/resources/webgl-render-pass.ts +146 -2
  139. package/src/adapter/resources/webgl-render-pipeline.ts +7 -4
  140. package/src/adapter/resources/webgl-sampler.ts +1 -2
  141. package/src/adapter/resources/webgl-texture.ts +61 -43
  142. package/src/adapter/webgl-canvas-context.ts +2 -2
  143. package/src/adapter/webgl-device.ts +37 -8
  144. package/src/classic/buffer.ts +3 -3
  145. package/src/classic/clear.ts +110 -0
  146. package/src/classic/copy-and-blit.ts +189 -0
  147. package/src/classic/format-utils.ts +43 -0
  148. package/src/classic/typed-array-utils.ts +15 -26
  149. package/src/context/context/create-browser-context.ts +37 -30
  150. package/src/context/parameters/unified-parameter-api.ts +1 -1
  151. package/src/context/parameters/webgl-parameter-tables.ts +2 -2
  152. package/src/index.ts +10 -3
  153. package/dist/adapter/converters/renderbuffer-formats.d.ts +0 -16
  154. package/dist/adapter/converters/renderbuffer-formats.d.ts.map +0 -1
  155. package/dist/adapter/converters/renderbuffer-formats.js +0 -180
  156. package/dist/adapter/converters/renderbuffer-formats.js.map +0 -1
  157. package/dist/types/webgl.d.ts +0 -145
  158. package/dist/types/webgl.d.ts.map +0 -1
  159. package/dist/types/webgl.js +0 -2
  160. package/dist/types/webgl.js.map +0 -1
  161. package/src/.DS_Store +0 -0
  162. package/src/adapter/.DS_Store +0 -0
  163. package/src/adapter/converters/renderbuffer-formats.ts +0 -90
  164. package/src/context/.DS_Store +0 -0
  165. package/src/types/webgl.ts +0 -286
@@ -73,7 +73,8 @@ export const TEXTURE_FORMATS = {
73
73
  'r8unorm': {
74
74
  gl: GL.R8,
75
75
  b: 1,
76
- c: 1
76
+ c: 1,
77
+ renderbuffer: true
77
78
  },
78
79
  'r8snorm': {
79
80
  gl: GL.R8_SNORM,
@@ -83,17 +84,20 @@ export const TEXTURE_FORMATS = {
83
84
  'r8uint': {
84
85
  gl: GL.R8UI,
85
86
  b: 1,
86
- c: 1
87
+ c: 1,
88
+ renderbuffer: true
87
89
  },
88
90
  'r8sint': {
89
91
  gl: GL.R8I,
90
92
  b: 1,
91
- c: 1
93
+ c: 1,
94
+ renderbuffer: true
92
95
  },
93
96
  'rg8unorm': {
94
97
  gl: GL.RG8,
95
98
  b: 2,
96
- c: 2
99
+ c: 2,
100
+ renderbuffer: true
97
101
  },
98
102
  'rg8snorm': {
99
103
  gl: GL.RG8_SNORM,
@@ -103,67 +107,78 @@ export const TEXTURE_FORMATS = {
103
107
  'rg8uint': {
104
108
  gl: GL.RG8UI,
105
109
  b: 2,
106
- c: 2
110
+ c: 2,
111
+ renderbuffer: true
107
112
  },
108
113
  'rg8sint': {
109
114
  gl: GL.RG8I,
110
115
  b: 2,
111
- c: 2
116
+ c: 2,
117
+ renderbuffer: true
112
118
  },
113
119
  'r16uint': {
114
120
  gl: GL.R16UI,
115
121
  b: 2,
116
- c: 1
122
+ c: 1,
123
+ renderbuffer: true
117
124
  },
118
125
  'r16sint': {
119
126
  gl: GL.R16I,
120
127
  b: 2,
121
- c: 1
128
+ c: 1,
129
+ renderbuffer: true
122
130
  },
123
131
  'r16float': {
124
132
  gl: GL.R16F,
125
133
  b: 2,
126
134
  c: 1,
127
135
  render: 'texture-renderable-float16-webgl',
128
- filter: 'texture-filter-linear-float16-webgl'
136
+ filter: 'texture-filter-linear-float16-webgl',
137
+ renderbuffer: true
129
138
  },
130
139
  'r16unorm-webgl': {
131
140
  gl: GL.R16_EXT,
132
141
  b: 2,
133
142
  c: 1,
134
- f: 'texture-formats-norm16-webgl'
143
+ f: 'texture-formats-norm16-webgl',
144
+ renderbuffer: true,
145
+ x: EXT_TEXTURE_NORM16
135
146
  },
136
147
  'r16snorm-webgl': {
137
148
  gl: GL.R16_SNORM_EXT,
138
149
  b: 2,
139
150
  c: 1,
140
- f: 'texture-formats-norm16-webgl'
151
+ f: 'texture-formats-norm16-webgl',
152
+ x: EXT_TEXTURE_NORM16
141
153
  },
142
154
  'rgba4unorm-webgl': {
143
155
  gl: GL.RGBA4,
144
156
  b: 2,
145
157
  c: 4,
146
- wgpu: false
158
+ wgpu: false,
159
+ renderbuffer: true
147
160
  },
148
161
  'rgb565unorm-webgl': {
149
162
  gl: GL.RGB565,
150
163
  b: 2,
151
164
  c: 4,
152
- wgpu: false
165
+ wgpu: false,
166
+ renderbuffer: true
153
167
  },
154
168
  'rgb5a1unorm-webgl': {
155
169
  gl: GL.RGB5_A1,
156
170
  b: 2,
157
171
  c: 4,
158
- wgpu: false
172
+ wgpu: false,
173
+ renderbuffer: true
159
174
  },
160
- 'rbg8unorm-webgl': {
175
+ 'rgb8unorm-webgl': {
161
176
  gl: GL.RGB8,
162
177
  b: 3,
163
178
  c: 3,
164
179
  wgpu: false
165
180
  },
166
- 'rbg8snorm-webgl': {
181
+ 'rgb8snorm-webgl': {
167
182
  gl: GL.RGB8_SNORM,
168
183
  b: 3,
169
184
  c: 3,
@@ -227,31 +242,36 @@ export const TEXTURE_FORMATS = {
227
242
  b: 4,
228
243
  c: 2,
229
244
  render: 'texture-renderable-float16-webgl',
230
- filter: 'texture-filter-linear-float16-webgl'
245
+ filter: 'texture-filter-linear-float16-webgl',
246
+ renderbuffer: true
231
247
  },
232
248
  'rg16unorm-webgl': {
233
249
  gl: GL.RG16_EXT,
234
250
  b: 2,
235
251
  c: 2,
236
- f: 'texture-formats-norm16-webgl'
252
+ f: 'texture-formats-norm16-webgl',
253
+ x: EXT_TEXTURE_NORM16
237
254
  },
238
255
  'rg16snorm-webgl': {
239
256
  gl: GL.RG16_SNORM_EXT,
240
257
  b: 2,
241
258
  c: 2,
242
- f: 'texture-formats-norm16-webgl'
259
+ f: 'texture-formats-norm16-webgl',
260
+ x: EXT_TEXTURE_NORM16
243
261
  },
244
262
  'r32uint': {
245
263
  gl: GL.R32UI,
246
264
  b: 4,
247
265
  c: 1,
248
- bpp: 4
266
+ bpp: 4,
267
+ renderbuffer: true
249
268
  },
250
269
  'r32sint': {
251
270
  gl: GL.R32I,
252
271
  b: 4,
253
272
  c: 1,
254
- bpp: 4
273
+ bpp: 4,
274
+ renderbuffer: true
255
275
  },
256
276
  'r32float': {
257
277
  gl: GL.R32F,
@@ -274,13 +294,15 @@ export const TEXTURE_FORMATS = {
274
294
  b: 4,
275
295
  c: 3,
276
296
  p: 1,
277
- render: 'texture-renderable-float32-webgl'
297
+ render: 'texture-renderable-float32-webgl',
298
+ renderbuffer: true
278
299
  },
279
300
  'rgb10a2unorm': {
280
301
  gl: GL.RGB10_A2,
281
302
  b: 4,
282
303
  c: 4,
283
- p: 1
304
+ p: 1,
305
+ renderbuffer: true
284
306
  },
285
307
  'rgb10a2unorm-webgl': {
286
308
  b: 4,
@@ -288,46 +310,54 @@ export const TEXTURE_FORMATS = {
288
310
  gl: GL.RGB10_A2UI,
289
311
  p: 1,
290
312
  wgpu: false,
291
- bpp: 4
313
+ bpp: 4,
314
+ renderbuffer: true
292
315
  },
293
316
  'rgb16unorm-webgl': {
294
317
  gl: GL.RGB16_EXT,
295
318
  b: 2,
296
319
  c: 3,
297
- f: 'texture-formats-norm16-webgl'
320
+ f: 'texture-formats-norm16-webgl',
321
+ x: EXT_TEXTURE_NORM16
298
322
  },
299
323
  'rgb16snorm-webgl': {
300
324
  gl: GL.RGB16_SNORM_EXT,
301
325
  b: 2,
302
326
  c: 3,
303
- f: 'texture-formats-norm16-webgl'
327
+ f: 'texture-formats-norm16-webgl',
328
+ x: EXT_TEXTURE_NORM16
304
329
  },
305
330
  'rg32uint': {
306
331
  gl: GL.RG32UI,
307
332
  b: 8,
308
- c: 2
333
+ c: 2,
334
+ renderbuffer: true
309
335
  },
310
336
  'rg32sint': {
311
337
  gl: GL.RG32I,
312
338
  b: 8,
313
- c: 2
339
+ c: 2,
340
+ renderbuffer: true
314
341
  },
315
342
  'rg32float': {
316
343
  gl: GL.RG32F,
317
344
  b: 8,
318
345
  c: 2,
319
346
  render: 'texture-renderable-float32-webgl',
320
- filter: 'texture-filter-linear-float32-webgl'
347
+ filter: 'texture-filter-linear-float32-webgl',
348
+ renderbuffer: true
321
349
  },
322
350
  'rgba16uint': {
323
351
  gl: GL.RGBA16UI,
324
352
  b: 8,
325
- c: 4
353
+ c: 4,
354
+ renderbuffer: true
326
355
  },
327
356
  'rgba16sint': {
328
357
  gl: GL.RGBA16I,
329
358
  b: 8,
330
- c: 4
359
+ c: 4,
360
+ renderbuffer: true
331
361
  },
332
362
  'rgba16float': {
333
363
  gl: GL.RGBA16F,
@@ -341,13 +371,16 @@ export const TEXTURE_FORMATS = {
341
371
  gl: GL.RGBA16_EXT,
342
372
  b: 2,
343
373
  c: 4,
344
- f: 'texture-formats-norm16-webgl'
374
+ f: 'texture-formats-norm16-webgl',
375
+ renderbuffer: true,
376
+ x: EXT_TEXTURE_NORM16
345
377
  },
346
378
  'rgba16snorm-webgl': {
347
379
  gl: GL.RGBA16_SNORM_EXT,
348
380
  b: 2,
349
381
  c: 4,
350
- f: 'texture-formats-norm16-webgl'
382
+ f: 'texture-formats-norm16-webgl',
383
+ x: EXT_TEXTURE_NORM16
351
384
  },
352
385
  'rgb32float-webgl': {
353
386
  gl: GL.RGB32F,
@@ -362,33 +395,38 @@ export const TEXTURE_FORMATS = {
362
395
  'rgba32uint': {
363
396
  gl: GL.RGBA32UI,
364
397
  b: 16,
365
- c: 4
398
+ c: 4,
399
+ renderbuffer: true
366
400
  },
367
401
  'rgba32sint': {
368
402
  gl: GL.RGBA32I,
369
403
  b: 16,
370
- c: 4
404
+ c: 4,
405
+ renderbuffer: true
371
406
  },
372
407
  'rgba32float': {
373
408
  gl: GL.RGBA32F,
374
- gl1: GL.RGBA,
375
409
  b: 16,
376
410
  c: 4,
377
411
  render: 'texture-renderable-float32-webgl',
378
- filter: 'texture-filter-linear-float32-webgl'
412
+ filter: 'texture-filter-linear-float32-webgl',
413
+ renderbuffer: true
379
414
  },
380
415
  'stencil8': {
381
416
  gl: GL.STENCIL_INDEX8,
417
+ gl1: GL.STENCIL_INDEX8,
382
418
  b: 1,
383
419
  c: 1,
384
- attachment: GL.STENCIL_ATTACHMENT
420
+ attachment: GL.STENCIL_ATTACHMENT,
421
+ renderbuffer: true
385
422
  },
386
423
  'depth16unorm': {
387
424
  gl: GL.DEPTH_COMPONENT16,
388
425
  gl1: GL.DEPTH_COMPONENT16,
389
426
  b: 2,
390
427
  c: 1,
391
- attachment: GL.DEPTH_ATTACHMENT
428
+ attachment: GL.DEPTH_ATTACHMENT,
429
+ renderbuffer: true
392
430
  },
393
431
  'depth24plus': {
394
432
  gl: GL.DEPTH_COMPONENT24,
@@ -400,29 +438,34 @@ export const TEXTURE_FORMATS = {
400
438
  gl: GL.DEPTH_COMPONENT32F,
401
439
  b: 4,
402
440
  c: 1,
403
- attachment: GL.DEPTH_ATTACHMENT
441
+ attachment: GL.DEPTH_ATTACHMENT,
442
+ renderbuffer: true
404
443
  },
405
444
  'depth24plus-stencil8': {
406
- b: 4,
407
- gl: GL.UNSIGNED_INT_24_8,
445
+ gl: GL.DEPTH_STENCIL,
408
446
  gl1: GL.DEPTH_STENCIL,
447
+ b: 4,
409
448
  c: 2,
410
449
  p: 1,
411
- attachment: GL.DEPTH_STENCIL_ATTACHMENT
450
+ attachment: GL.DEPTH_STENCIL_ATTACHMENT,
451
+ renderbuffer: true,
452
+ depthTexture: true
412
453
  },
413
454
  'depth24unorm-stencil8': {
414
455
  gl: GL.DEPTH24_STENCIL8,
415
456
  b: 4,
416
457
  c: 2,
417
458
  p: 1,
418
- attachment: GL.DEPTH_STENCIL_ATTACHMENT
459
+ attachment: GL.DEPTH_STENCIL_ATTACHMENT,
460
+ renderbuffer: true
419
461
  },
420
462
  'depth32float-stencil8': {
421
463
  gl: GL.DEPTH32F_STENCIL8,
422
464
  b: 5,
423
465
  c: 2,
424
466
  p: 1,
425
- attachment: GL.DEPTH_STENCIL_ATTACHMENT
467
+ attachment: GL.DEPTH_STENCIL_ATTACHMENT,
468
+ renderbuffer: true
426
469
  },
427
470
  'bc1-rgb-unorm-webgl': {
428
471
  gl: GL.COMPRESSED_RGB_S3TC_DXT1_EXT,
@@ -689,21 +732,33 @@ export const TEXTURE_FORMATS = {
689
732
  f: texture_compression_atc_webgl
690
733
  }
691
734
  };
692
- function getTextureFormat(format) {
693
- if (typeof format === 'string') {
694
- return format;
695
- }
696
- const entry = Object.entries(TEXTURE_FORMATS).find(_ref => {
697
- let [, entry] = _ref;
698
- return entry.gl === format || entry.gl1 === format;
699
- });
700
- if (!entry) {
701
- throw new Error("Unknown texture format ".concat(format));
702
- }
703
- return entry[0];
704
- }
735
+ const DATA_FORMAT_CHANNELS = {
736
+ [GL.RED]: 1,
737
+ [GL.RED_INTEGER]: 1,
738
+ [GL.RG]: 2,
739
+ [GL.RG_INTEGER]: 2,
740
+ [GL.RGB]: 3,
741
+ [GL.RGB_INTEGER]: 3,
742
+ [GL.RGBA]: 4,
743
+ [GL.RGBA_INTEGER]: 4,
744
+ [GL.DEPTH_COMPONENT]: 1,
745
+ [GL.DEPTH_STENCIL]: 1,
746
+ [GL.ALPHA]: 1,
747
+ [GL.LUMINANCE]: 1,
748
+ [GL.LUMINANCE_ALPHA]: 2
749
+ };
750
+ const TYPE_SIZES = {
751
+ [GL.FLOAT]: 4,
752
+ [GL.UNSIGNED_INT]: 4,
753
+ [GL.INT]: 4,
754
+ [GL.UNSIGNED_SHORT]: 2,
755
+ [GL.SHORT]: 2,
756
+ [GL.HALF_FLOAT]: 2,
757
+ [GL.BYTE]: 1,
758
+ [GL.UNSIGNED_BYTE]: 1
759
+ };
705
760
  export function isTextureFormatSupported(gl, formatOrGL) {
706
- const format = getTextureFormat(formatOrGL);
761
+ const format = convertGLToTextureFormat(formatOrGL);
707
762
  const info = TEXTURE_FORMATS[format];
708
763
  if (!info) {
709
764
  return false;
@@ -717,8 +772,33 @@ export function isTextureFormatSupported(gl, formatOrGL) {
717
772
  }
718
773
  return true;
719
774
  }
775
+ export function isRenderbufferFormatSupported(gl, format) {
776
+ var _TEXTURE_FORMATS$form;
777
+ return isTextureFormatSupported(gl, format) && ((_TEXTURE_FORMATS$form = TEXTURE_FORMATS[format]) === null || _TEXTURE_FORMATS$form === void 0 ? void 0 : _TEXTURE_FORMATS$form.renderbuffer);
778
+ }
779
+ export function convertGLToTextureFormat(format) {
780
+ if (typeof format === 'string') {
781
+ return format;
782
+ }
783
+ const entry = Object.entries(TEXTURE_FORMATS).find(_ref => {
784
+ let [, entry] = _ref;
785
+ return entry.gl === format || entry.gl1 === format;
786
+ });
787
+ if (!entry) {
788
+ throw new Error("Unknown texture format ".concat(format));
789
+ }
790
+ return entry[0];
791
+ }
792
+ export function convertTextureFormatToGL(format, isWebGL2) {
793
+ const formatInfo = TEXTURE_FORMATS[format];
794
+ const webglFormat = isWebGL2 ? formatInfo === null || formatInfo === void 0 ? void 0 : formatInfo.gl : formatInfo === null || formatInfo === void 0 ? void 0 : formatInfo.gl1;
795
+ if (webglFormat === undefined) {
796
+ throw new Error("Unsupported texture format ".concat(format));
797
+ }
798
+ return webglFormat;
799
+ }
720
800
  export function getTextureFormatSupport(gl, formatOrGL) {
721
- const format = getTextureFormat(formatOrGL);
801
+ const format = convertGLToTextureFormat(formatOrGL);
722
802
  const info = TEXTURE_FORMATS[format];
723
803
  if (!info) {
724
804
  return {
@@ -736,7 +816,7 @@ export function getTextureFormatSupport(gl, formatOrGL) {
736
816
  };
737
817
  }
738
818
  export function isTextureFormatFilterable(gl, formatOrGL) {
739
- const format = getTextureFormat(formatOrGL);
819
+ const format = convertGLToTextureFormat(formatOrGL);
740
820
  if (!isTextureFormatSupported(gl, format)) {
741
821
  return false;
742
822
  }
@@ -757,7 +837,7 @@ export function isTextureFormatFilterable(gl, formatOrGL) {
757
837
  return true;
758
838
  }
759
839
  export function isTextureFormatRenderable(gl, formatOrGL) {
760
- const format = getTextureFormat(formatOrGL);
840
+ const format = convertGLToTextureFormat(formatOrGL);
761
841
  if (!isTextureFormatSupported(gl, format)) {
762
842
  return false;
763
843
  }
@@ -766,21 +846,9 @@ export function isTextureFormatRenderable(gl, formatOrGL) {
766
846
  }
767
847
  return true;
768
848
  }
769
- export function getWebGLTextureFormat(gl, formatOrGL) {
770
- const format = getTextureFormat(formatOrGL);
771
- const formatInfo = TEXTURE_FORMATS[format];
772
- const webglFormat = isWebGL2(gl) ? formatInfo === null || formatInfo === void 0 ? void 0 : formatInfo.gl : formatInfo === null || formatInfo === void 0 ? void 0 : formatInfo.gl1;
773
- if (typeof format === 'number') {
774
- return webglFormat || format;
775
- }
776
- if (webglFormat === undefined) {
777
- throw new Error("Unsupported texture format ".concat(format));
778
- }
779
- return webglFormat;
780
- }
781
- export function getWebGLTextureParameters(gl, formatOrGL) {
782
- const format = getTextureFormat(formatOrGL);
783
- const webglFormat = getWebGLTextureFormat(gl, format);
849
+ export function getWebGLTextureParameters(formatOrGL, isWebGL2) {
850
+ const format = convertGLToTextureFormat(formatOrGL);
851
+ const webglFormat = convertTextureFormatToGL(format, isWebGL2);
784
852
  const decoded = decodeTextureFormat(format);
785
853
  return {
786
854
  format: webglFormat,
@@ -789,17 +857,12 @@ export function getWebGLTextureParameters(gl, formatOrGL) {
789
857
  compressed: decoded.compressed
790
858
  };
791
859
  }
792
- export function getWebGLDepthStencilAttachment(formatOrGL) {
793
- const format = getTextureFormat(formatOrGL);
794
- if (typeof format === 'number') {
795
- throw new Error('unsupported depth stencil format');
796
- }
860
+ export function getDepthStencilAttachmentWebGL(format) {
797
861
  const info = TEXTURE_FORMATS[format];
798
- const attachment = info.attachment;
799
- if (!attachment) {
800
- throw new Error('not a depth stencil format');
862
+ if (!(info !== null && info !== void 0 && info.attachment)) {
863
+ throw new Error("".concat(format, " is not a depth stencil format"));
801
864
  }
802
- return attachment;
865
+ return info.attachment;
803
866
  }
804
867
  export function _checkFloat32ColorAttachment(gl) {
805
868
  let internalFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gl.RGBA;
@@ -827,34 +890,9 @@ export function _checkFloat32ColorAttachment(gl) {
827
890
  gl.deleteFramebuffer(framebuffer);
828
891
  }
829
892
  }
830
- const DATA_FORMAT_CHANNELS = {
831
- [GL.RED]: 1,
832
- [GL.RED_INTEGER]: 1,
833
- [GL.RG]: 2,
834
- [GL.RG_INTEGER]: 2,
835
- [GL.RGB]: 3,
836
- [GL.RGB_INTEGER]: 3,
837
- [GL.RGBA]: 4,
838
- [GL.RGBA_INTEGER]: 4,
839
- [GL.DEPTH_COMPONENT]: 1,
840
- [GL.DEPTH_STENCIL]: 1,
841
- [GL.ALPHA]: 1,
842
- [GL.LUMINANCE]: 1,
843
- [GL.LUMINANCE_ALPHA]: 2
844
- };
845
- const TYPE_SIZES = {
846
- [GL.FLOAT]: 4,
847
- [GL.UNSIGNED_INT]: 4,
848
- [GL.INT]: 4,
849
- [GL.UNSIGNED_SHORT]: 2,
850
- [GL.SHORT]: 2,
851
- [GL.HALF_FLOAT]: 2,
852
- [GL.BYTE]: 1,
853
- [GL.UNSIGNED_BYTE]: 1
854
- };
855
- export function getTextureFormatBytesPerPixel(gl, formatOrGL) {
856
- const format = getTextureFormat(formatOrGL);
857
- const params = getWebGLTextureParameters(gl, format);
893
+ export function getTextureFormatBytesPerPixel(formatOrGL, isWebGL2) {
894
+ const format = convertGLToTextureFormat(formatOrGL);
895
+ const params = getWebGLTextureParameters(format, isWebGL2);
858
896
  const channels = DATA_FORMAT_CHANNELS[params.dataFormat] || 4;
859
897
  const channelSize = TYPE_SIZES[params.type] || 1;
860
898
  return channels * channelSize;