@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
@@ -82,159 +82,164 @@ export function checkTextureFeature(gl, feature, extensions) {
82
82
  */
83
83
  // prettier-ignore
84
84
  export const TEXTURE_FORMATS = {
85
- // Unsized formats that leave the precision up to the driver.
86
- // TODO - Fix bpp constants
85
+ // Unsized formats that leave the precision up to the driver. TODO - Fix bpp constants
86
+ 'rgb8unorm-unsized': { gl: 6407, b: 4, c: 2, bpp: 4,
87
+ dataFormat: 6407, types: [5121, 33635] },
88
+ 'rgba8unorm-unsized': { gl: 6408, b: 4, c: 2, bpp: 4,
89
+ dataFormat: 6408, types: [5121, 32819, 32820] },
87
90
  // 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
88
- 'rgb8unorm-unsized': { gl: GL.RGB, b: 4, c: 2, bpp: 4,
89
- dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_6_5] },
90
- 'rgba8unorm-unsized': { gl: GL.RGBA, b: 4, c: 2, bpp: 4,
91
- dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_4_4_4_4, GL.UNSIGNED_SHORT_5_5_5_1] },
92
91
  // 'rgb8unorm-srgb-unsized': {gl: GL.SRGB_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
93
92
  // 'rgba8unorm-srgb-unsized': {gl: GL.SRGB_ALPHA_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
94
93
  // 8-bit formats
95
- 'r8unorm': { gl: GL.R8, b: 1, c: 1, renderbuffer: true },
96
- 'r8snorm': { gl: GL.R8_SNORM, b: 1, c: 1, render: snorm8_renderable },
97
- 'r8uint': { gl: GL.R8UI, b: 1, c: 1, renderbuffer: true },
98
- 'r8sint': { gl: GL.R8I, b: 1, c: 1, renderbuffer: true },
94
+ 'r8unorm': { gl: 33321, b: 1, c: 1, rb: true },
95
+ 'r8snorm': { gl: 36756, b: 1, c: 1, render: snorm8_renderable },
96
+ 'r8uint': { gl: 33330, b: 1, c: 1, rb: true },
97
+ 'r8sint': { gl: 33329, b: 1, c: 1, rb: true },
99
98
  // 16-bit formats
100
- 'rg8unorm': { gl: GL.RG8, b: 2, c: 2, renderbuffer: true },
101
- 'rg8snorm': { gl: GL.RG8_SNORM, b: 2, c: 2, render: snorm8_renderable },
102
- 'rg8uint': { gl: GL.RG8UI, b: 2, c: 2, renderbuffer: true },
103
- 'rg8sint': { gl: GL.RG8I, b: 2, c: 2, renderbuffer: true },
104
- 'r16uint': { gl: GL.R16UI, b: 2, c: 1, renderbuffer: true },
105
- 'r16sint': { gl: GL.R16I, b: 2, c: 1, renderbuffer: true },
106
- 'r16float': { gl: GL.R16F, b: 2, c: 1, render: float16_renderable, filter: 'float16-filterable-webgl', renderbuffer: true },
107
- 'r16unorm-webgl': { gl: GL.R16_EXT, b: 2, c: 1, f: norm16_renderable, renderbuffer: true },
108
- 'r16snorm-webgl': { gl: GL.R16_SNORM_EXT, b: 2, c: 1, f: snorm16_renderable },
99
+ 'rg8unorm': { gl: 33323, b: 2, c: 2, rb: true },
100
+ 'rg8snorm': { gl: 36757, b: 2, c: 2, render: snorm8_renderable },
101
+ 'rg8uint': { gl: 33336, b: 2, c: 2, rb: true },
102
+ 'rg8sint': { gl: 33335, b: 2, c: 2, rb: true },
103
+ 'r16uint': { gl: 33332, b: 2, c: 1, rb: true },
104
+ 'r16sint': { gl: 33331, b: 2, c: 1, rb: true },
105
+ 'r16float': { gl: 33325, b: 2, c: 1, render: float16_renderable, filter: 'float16-filterable-webgl', rb: true },
106
+ 'r16unorm-webgl': { gl: 33322, b: 2, c: 1, f: norm16_renderable, rb: true },
107
+ 'r16snorm-webgl': { gl: 36760, b: 2, c: 1, f: snorm16_renderable },
109
108
  // Packed 16-bit formats
110
- 'rgba4unorm-webgl': { gl: GL.RGBA4, b: 2, c: 4, wgpu: false, renderbuffer: true },
111
- 'rgb565unorm-webgl': { gl: GL.RGB565, b: 2, c: 4, wgpu: false, renderbuffer: true },
112
- 'rgb5a1unorm-webgl': { gl: GL.RGB5_A1, b: 2, c: 4, wgpu: false, renderbuffer: true },
109
+ 'rgba4unorm-webgl': { gl: 32854, b: 2, c: 4, wgpu: false, rb: true },
110
+ 'rgb565unorm-webgl': { gl: 36194, b: 2, c: 4, wgpu: false, rb: true },
111
+ 'rgb5a1unorm-webgl': { gl: 32855, b: 2, c: 4, wgpu: false, rb: true },
113
112
  // 24-bit formats
114
- 'rgb8unorm-webgl': { gl: GL.RGB8, b: 3, c: 3, wgpu: false },
115
- 'rgb8snorm-webgl': { gl: GL.RGB8_SNORM, b: 3, c: 3, wgpu: false },
113
+ 'rgb8unorm-webgl': { gl: 32849, b: 3, c: 3, wgpu: false },
114
+ 'rgb8snorm-webgl': { gl: 36758, b: 3, c: 3, wgpu: false },
116
115
  // 32-bit formats
117
- 'rgba8unorm': { gl: GL.RGBA8, b: 4, c: 2, bpp: 4 },
118
- 'rgba8unorm-srgb': { gl: GL.SRGB8_ALPHA8, b: 4, c: 4, bpp: 4 },
119
- 'rgba8snorm': { gl: GL.RGBA8_SNORM, b: 4, c: 4, render: snorm8_renderable },
120
- 'rgba8uint': { gl: GL.RGBA8UI, b: 4, c: 4, bpp: 4 },
121
- 'rgba8sint': { gl: GL.RGBA8I, b: 4, c: 4, bpp: 4 },
116
+ 'rgba8unorm': { gl: 32856, b: 4, c: 2, bpp: 4 },
117
+ 'rgba8unorm-srgb': { gl: 35907, b: 4, c: 4, bpp: 4 },
118
+ 'rgba8snorm': { gl: 36759, b: 4, c: 4, render: snorm8_renderable },
119
+ 'rgba8uint': { gl: 36220, b: 4, c: 4, bpp: 4 },
120
+ 'rgba8sint': { gl: 36238, b: 4, c: 4, bpp: 4 },
122
121
  // reverse colors, webgpu only
123
122
  'bgra8unorm': { b: 4, c: 4 },
124
123
  'bgra8unorm-srgb': { b: 4, c: 4 },
125
- 'rg16uint': { gl: GL.RG16UI, b: 4, c: 1, bpp: 4 },
126
- 'rg16sint': { gl: GL.RG16I, b: 4, c: 2, bpp: 4 },
124
+ 'rg16uint': { gl: 33338, b: 4, c: 1, bpp: 4 },
125
+ 'rg16sint': { gl: 33337, b: 4, c: 2, bpp: 4 },
127
126
  // When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
128
- 'rg16float': { gl: GL.RG16F, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable, renderbuffer: true },
129
- 'rg16unorm-webgl': { gl: GL.RG16_EXT, b: 2, c: 2, render: norm16_renderable },
130
- 'rg16snorm-webgl': { gl: GL.RG16_SNORM_EXT, b: 2, c: 2, render: snorm16_renderable },
131
- 'r32uint': { gl: GL.R32UI, b: 4, c: 1, bpp: 4, renderbuffer: true },
132
- 'r32sint': { gl: GL.R32I, b: 4, c: 1, bpp: 4, renderbuffer: true },
133
- 'r32float': { gl: GL.R32F, bpp: 4, b: 4, c: 1, render: float32_renderable, filter: float32_filterable },
127
+ 'rg16float': { gl: 33327, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable, rb: true },
128
+ 'rg16unorm-webgl': { gl: 33324, b: 2, c: 2, render: norm16_renderable },
129
+ 'rg16snorm-webgl': { gl: 36761, b: 2, c: 2, render: snorm16_renderable },
130
+ 'r32uint': { gl: 33334, b: 4, c: 1, bpp: 4, rb: true },
131
+ 'r32sint': { gl: 33333, b: 4, c: 1, bpp: 4, rb: true },
132
+ 'r32float': { gl: 33326, bpp: 4, b: 4, c: 1, render: float32_renderable, filter: float32_filterable },
134
133
  // Packed 32-bit formats
135
- 'rgb9e5ufloat': { gl: GL.RGB9_E5, b: 4, c: 3, p: 1, render: rgb9e5ufloat_renderable }, // , filter: true},
136
- 'rg11b10ufloat': { gl: GL.R11F_G11F_B10F, b: 4, c: 3, p: 1, render: float32_renderable, renderbuffer: true },
137
- 'rgb10a2unorm': { gl: GL.RGB10_A2, b: 4, c: 4, p: 1, renderbuffer: true },
138
- 'rgb10a2uint-webgl': { b: 4, c: 4, gl: GL.RGB10_A2UI, p: 1, wgpu: false, bpp: 4, renderbuffer: true },
134
+ 'rgb9e5ufloat': { gl: 35901, b: 4, c: 3, p: 1, render: rgb9e5ufloat_renderable }, // , filter: true},
135
+ 'rg11b10ufloat': { gl: 35898, b: 4, c: 3, p: 1, render: float32_renderable, rb: true },
136
+ 'rgb10a2unorm': { gl: 32857, b: 4, c: 4, p: 1, rb: true },
137
+ 'rgb10a2uint-webgl': { b: 4, c: 4, gl: 36975, p: 1, wgpu: false, bpp: 4, rb: true },
139
138
  // 48-bit formats
140
- 'rgb16unorm-webgl': { gl: GL.RGB16_EXT, b: 2, c: 3, f: norm16_renderable }, // rgb not renderable
141
- 'rgb16snorm-webgl': { gl: GL.RGB16_SNORM_EXT, b: 2, c: 3, f: norm16_renderable }, // rgb not renderable
139
+ 'rgb16unorm-webgl': { gl: 32852, b: 2, c: 3, f: norm16_renderable }, // rgb not renderable
140
+ 'rgb16snorm-webgl': { gl: 36762, b: 2, c: 3, f: norm16_renderable }, // rgb not renderable
142
141
  // 64-bit formats
143
- 'rg32uint': { gl: GL.RG32UI, b: 8, c: 2, renderbuffer: true },
144
- 'rg32sint': { gl: GL.RG32I, b: 8, c: 2, renderbuffer: true },
145
- 'rg32float': { gl: GL.RG32F, b: 8, c: 2, render: float32_renderable, filter: float32_filterable, renderbuffer: true },
146
- 'rgba16uint': { gl: GL.RGBA16UI, b: 8, c: 4, renderbuffer: true },
147
- 'rgba16sint': { gl: GL.RGBA16I, b: 8, c: 4, renderbuffer: true },
148
- 'rgba16float': { gl: GL.RGBA16F, b: 8, c: 4, render: float16_renderable, filter: float16_filterable },
149
- 'rgba16unorm-webgl': { gl: GL.RGBA16_EXT, b: 2, c: 4, render: norm16_renderable, renderbuffer: true },
150
- 'rgba16snorm-webgl': { gl: GL.RGBA16_SNORM_EXT, b: 2, c: 4, render: snorm16_renderable },
142
+ 'rg32uint': { gl: 33340, b: 8, c: 2, rb: true },
143
+ 'rg32sint': { gl: 33339, b: 8, c: 2, rb: true },
144
+ 'rg32float': { gl: 33328, b: 8, c: 2, render: float32_renderable, filter: float32_filterable, rb: true },
145
+ 'rgba16uint': { gl: 36214, b: 8, c: 4, rb: true },
146
+ 'rgba16sint': { gl: 36232, b: 8, c: 4, rb: true },
147
+ 'rgba16float': { gl: 34842, b: 8, c: 4, render: float16_renderable, filter: float16_filterable },
148
+ 'rgba16unorm-webgl': { gl: 32859, b: 2, c: 4, render: norm16_renderable, rb: true },
149
+ 'rgba16snorm-webgl': { gl: 36763, b: 2, c: 4, render: snorm16_renderable },
151
150
  // 96-bit formats (deprecated!)
152
- 'rgb32float-webgl': { gl: GL.RGB32F, render: float32_renderable, filter: float32_filterable,
153
- gl2ext: EXT_color_buffer_float, dataFormat: GL.RGB, types: [GL.FLOAT] },
151
+ 'rgb32float-webgl': { gl: 34837, render: float32_renderable, filter: float32_filterable,
152
+ gl2ext: EXT_color_buffer_float, dataFormat: 6407, types: [5126] },
154
153
  // 128-bit formats
155
- 'rgba32uint': { gl: GL.RGBA32UI, b: 16, c: 4, renderbuffer: true },
156
- 'rgba32sint': { gl: GL.RGBA32I, b: 16, c: 4, renderbuffer: true },
157
- 'rgba32float': { gl: GL.RGBA32F, b: 16, c: 4, render: float32_renderable, filter: float32_filterable, renderbuffer: true },
154
+ 'rgba32uint': { gl: 36208, b: 16, c: 4, rb: true },
155
+ 'rgba32sint': { gl: 36226, b: 16, c: 4, rb: true },
156
+ 'rgba32float': { gl: 34836, b: 16, c: 4, render: float32_renderable, filter: float32_filterable, rb: true },
158
157
  // Depth and stencil formats
159
- 'stencil8': { gl: GL.STENCIL_INDEX8, b: 1, c: 1, attachment: GL.STENCIL_ATTACHMENT, renderbuffer: true }, // 8 stencil bits
160
- 'depth16unorm': { gl: GL.DEPTH_COMPONENT16, b: 2, c: 1, attachment: GL.DEPTH_ATTACHMENT, renderbuffer: true }, // 16 depth bits
161
- 'depth24plus': { gl: GL.DEPTH_COMPONENT24, b: 3, c: 1, attachment: GL.DEPTH_ATTACHMENT },
162
- 'depth32float': { gl: GL.DEPTH_COMPONENT32F, b: 4, c: 1, attachment: GL.DEPTH_ATTACHMENT, renderbuffer: true },
158
+ 'stencil8': { gl: 36168, b: 1, c: 1, attachment: 36128, rb: true }, // 8 stencil bits
159
+ 'depth16unorm': { gl: 33189, b: 2, c: 1, attachment: 36096,
160
+ dataFormat: 6402, types: [5123], rb: true }, // 16 depth bits
161
+ 'depth24plus': { gl: 33190, b: 3, c: 1, attachment: 36096,
162
+ dataFormat: 6402, types: [5125] },
163
+ 'depth32float': { gl: 36012, b: 4, c: 1, attachment: 36096,
164
+ dataFormat: 6402, types: [5126], rb: true },
163
165
  // The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
164
- 'depth24plus-stencil8': { gl: GL.DEPTH_STENCIL, b: 4, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true, depthTexture: true },
166
+ 'depth24plus-stencil8': { gl: 35056, b: 4, c: 2, p: 1, attachment: 33306, rb: true, depthTexture: true,
167
+ dataFormat: 34041, types: [34042] },
165
168
  // "depth24unorm-stencil8" feature
166
- 'depth24unorm-stencil8': { gl: GL.DEPTH24_STENCIL8, b: 4, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true },
167
- // "depth32float-stencil8" feature
168
- 'depth32float-stencil8': { gl: GL.DEPTH32F_STENCIL8, b: 5, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true },
169
+ 'depth24unorm-stencil8': { gl: 35056, b: 4, c: 2, p: 1, attachment: 33306,
170
+ dataFormat: 34041, types: [34042], rb: true },
171
+ // "depth32float-stencil8" feature - TODO below is render buffer only?
172
+ 'depth32float-stencil8': { gl: 36013, b: 5, c: 2, p: 1, attachment: 33306,
173
+ dataFormat: 34041, types: [36269], rb: true },
169
174
  // BC compressed formats: check device.features.has("texture-compression-bc");
170
- 'bc1-rgb-unorm-webgl': { gl: GL.COMPRESSED_RGB_S3TC_DXT1_EXT, x: X_S3TC, f: texture_compression_bc },
171
- 'bc1-rgb-unorm-srgb-webgl': { gl: GL.COMPRESSED_SRGB_S3TC_DXT1_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
172
- 'bc1-rgba-unorm': { gl: GL.COMPRESSED_RGBA_S3TC_DXT1_EXT, x: X_S3TC, f: texture_compression_bc },
173
- 'bc1-rgba-unorm-srgb': { gl: GL.COMPRESSED_SRGB_S3TC_DXT1_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
174
- 'bc2-rgba-unorm': { gl: GL.COMPRESSED_RGBA_S3TC_DXT3_EXT, x: X_S3TC, f: texture_compression_bc },
175
- 'bc2-rgba-unorm-srgb': { gl: GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
176
- 'bc3-rgba-unorm': { gl: GL.COMPRESSED_RGBA_S3TC_DXT5_EXT, x: X_S3TC, f: texture_compression_bc },
177
- 'bc3-rgba-unorm-srgb': { gl: GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
178
- 'bc4-r-unorm': { gl: GL.COMPRESSED_RED_RGTC1_EXT, x: X_RGTC, f: texture_compression_bc },
179
- 'bc4-r-snorm': { gl: GL.COMPRESSED_SIGNED_RED_RGTC1_EXT, x: X_RGTC, f: texture_compression_bc },
180
- 'bc5-rg-unorm': { gl: GL.COMPRESSED_RED_GREEN_RGTC2_EXT, x: X_RGTC, f: texture_compression_bc },
181
- 'bc5-rg-snorm': { gl: GL.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT, x: X_RGTC, f: texture_compression_bc },
182
- 'bc6h-rgb-ufloat': { gl: GL.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, x: X_BPTC, f: texture_compression_bc },
183
- 'bc6h-rgb-float': { gl: GL.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, x: X_BPTC, f: texture_compression_bc },
184
- 'bc7-rgba-unorm': { gl: GL.COMPRESSED_RGBA_BPTC_UNORM_EXT, x: X_BPTC, f: texture_compression_bc },
185
- 'bc7-rgba-unorm-srgb': { gl: GL.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, x: X_BPTC, f: texture_compression_bc },
175
+ 'bc1-rgb-unorm-webgl': { gl: 33776, x: X_S3TC, f: texture_compression_bc },
176
+ 'bc1-rgb-unorm-srgb-webgl': { gl: 35916, x: X_S3TC_SRGB, f: texture_compression_bc },
177
+ 'bc1-rgba-unorm': { gl: 33777, x: X_S3TC, f: texture_compression_bc },
178
+ 'bc1-rgba-unorm-srgb': { gl: 35916, x: X_S3TC_SRGB, f: texture_compression_bc },
179
+ 'bc2-rgba-unorm': { gl: 33778, x: X_S3TC, f: texture_compression_bc },
180
+ 'bc2-rgba-unorm-srgb': { gl: 35918, x: X_S3TC_SRGB, f: texture_compression_bc },
181
+ 'bc3-rgba-unorm': { gl: 33779, x: X_S3TC, f: texture_compression_bc },
182
+ 'bc3-rgba-unorm-srgb': { gl: 35919, x: X_S3TC_SRGB, f: texture_compression_bc },
183
+ 'bc4-r-unorm': { gl: 36283, x: X_RGTC, f: texture_compression_bc },
184
+ 'bc4-r-snorm': { gl: 36284, x: X_RGTC, f: texture_compression_bc },
185
+ 'bc5-rg-unorm': { gl: 36285, x: X_RGTC, f: texture_compression_bc },
186
+ 'bc5-rg-snorm': { gl: 36286, x: X_RGTC, f: texture_compression_bc },
187
+ 'bc6h-rgb-ufloat': { gl: 36495, x: X_BPTC, f: texture_compression_bc },
188
+ 'bc6h-rgb-float': { gl: 36494, x: X_BPTC, f: texture_compression_bc },
189
+ 'bc7-rgba-unorm': { gl: 36492, x: X_BPTC, f: texture_compression_bc },
190
+ 'bc7-rgba-unorm-srgb': { gl: 36493, x: X_BPTC, f: texture_compression_bc },
186
191
  // WEBGL_compressed_texture_etc: device.features.has("texture-compression-etc2")
187
192
  // Note: Supposedly guaranteed availability compressed formats in WebGL2, but through CPU decompression
188
- 'etc2-rgb8unorm': { gl: GL.COMPRESSED_RGB8_ETC2, f: texture_compression_etc2 },
189
- 'etc2-rgb8unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ETC2, f: texture_compression_etc2 },
190
- 'etc2-rgb8a1unorm': { gl: GL.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, f: texture_compression_etc2 },
191
- 'etc2-rgb8a1unorm-srgb': { gl: GL.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, f: texture_compression_etc2 },
192
- 'etc2-rgba8unorm': { gl: GL.COMPRESSED_RGBA8_ETC2_EAC, f: texture_compression_etc2 },
193
- 'etc2-rgba8unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, f: texture_compression_etc2 },
194
- 'eac-r11unorm': { gl: GL.COMPRESSED_R11_EAC, f: texture_compression_etc2 },
195
- 'eac-r11snorm': { gl: GL.COMPRESSED_SIGNED_R11_EAC, f: texture_compression_etc2 },
196
- 'eac-rg11unorm': { gl: GL.COMPRESSED_RG11_EAC, f: texture_compression_etc2 },
197
- 'eac-rg11snorm': { gl: GL.COMPRESSED_SIGNED_RG11_EAC, f: texture_compression_etc2 },
193
+ 'etc2-rgb8unorm': { gl: 37492, f: texture_compression_etc2 },
194
+ 'etc2-rgb8unorm-srgb': { gl: 37494, f: texture_compression_etc2 },
195
+ 'etc2-rgb8a1unorm': { gl: 37496, f: texture_compression_etc2 },
196
+ 'etc2-rgb8a1unorm-srgb': { gl: 37497, f: texture_compression_etc2 },
197
+ 'etc2-rgba8unorm': { gl: 37493, f: texture_compression_etc2 },
198
+ 'etc2-rgba8unorm-srgb': { gl: 37495, f: texture_compression_etc2 },
199
+ 'eac-r11unorm': { gl: 37488, f: texture_compression_etc2 },
200
+ 'eac-r11snorm': { gl: 37489, f: texture_compression_etc2 },
201
+ 'eac-rg11unorm': { gl: 37490, f: texture_compression_etc2 },
202
+ 'eac-rg11snorm': { gl: 37491, f: texture_compression_etc2 },
198
203
  // X_ASTC compressed formats: device.features.has("texture-compression-astc")
199
- 'astc-4x4-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_4x4_KHR, f: texture_compression_astc },
200
- 'astc-4x4-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, f: texture_compression_astc },
201
- 'astc-5x4-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_5x4_KHR, f: texture_compression_astc },
202
- 'astc-5x4-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, f: texture_compression_astc },
203
- 'astc-5x5-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_5x5_KHR, f: texture_compression_astc },
204
- 'astc-5x5-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, f: texture_compression_astc },
205
- 'astc-6x5-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_6x5_KHR, f: texture_compression_astc },
206
- 'astc-6x5-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, f: texture_compression_astc },
207
- 'astc-6x6-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_6x6_KHR, f: texture_compression_astc },
208
- 'astc-6x6-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, f: texture_compression_astc },
209
- 'astc-8x5-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_8x5_KHR, f: texture_compression_astc },
210
- 'astc-8x5-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, f: texture_compression_astc },
211
- 'astc-8x6-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_8x6_KHR, f: texture_compression_astc },
212
- 'astc-8x6-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, f: texture_compression_astc },
213
- 'astc-8x8-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_8x8_KHR, f: texture_compression_astc },
214
- 'astc-8x8-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, f: texture_compression_astc },
215
- 'astc-10x5-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_10x10_KHR, f: texture_compression_astc },
216
- 'astc-10x5-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, f: texture_compression_astc },
217
- 'astc-10x6-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_10x6_KHR, f: texture_compression_astc },
218
- 'astc-10x6-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, f: texture_compression_astc },
219
- 'astc-10x8-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_10x8_KHR, f: texture_compression_astc },
220
- 'astc-10x8-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, f: texture_compression_astc },
221
- 'astc-10x10-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_10x10_KHR, f: texture_compression_astc },
222
- 'astc-10x10-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, f: texture_compression_astc },
223
- 'astc-12x10-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_12x10_KHR, f: texture_compression_astc },
224
- 'astc-12x10-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, f: texture_compression_astc },
225
- 'astc-12x12-unorm': { gl: GL.COMPRESSED_RGBA_ASTC_12x12_KHR, f: texture_compression_astc },
226
- 'astc-12x12-unorm-srgb': { gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, f: texture_compression_astc },
204
+ 'astc-4x4-unorm': { gl: 37808, f: texture_compression_astc },
205
+ 'astc-4x4-unorm-srgb': { gl: 37840, f: texture_compression_astc },
206
+ 'astc-5x4-unorm': { gl: 37809, f: texture_compression_astc },
207
+ 'astc-5x4-unorm-srgb': { gl: 37841, f: texture_compression_astc },
208
+ 'astc-5x5-unorm': { gl: 37810, f: texture_compression_astc },
209
+ 'astc-5x5-unorm-srgb': { gl: 37842, f: texture_compression_astc },
210
+ 'astc-6x5-unorm': { gl: 37811, f: texture_compression_astc },
211
+ 'astc-6x5-unorm-srgb': { gl: 37843, f: texture_compression_astc },
212
+ 'astc-6x6-unorm': { gl: 37812, f: texture_compression_astc },
213
+ 'astc-6x6-unorm-srgb': { gl: 37844, f: texture_compression_astc },
214
+ 'astc-8x5-unorm': { gl: 37813, f: texture_compression_astc },
215
+ 'astc-8x5-unorm-srgb': { gl: 37845, f: texture_compression_astc },
216
+ 'astc-8x6-unorm': { gl: 37814, f: texture_compression_astc },
217
+ 'astc-8x6-unorm-srgb': { gl: 37846, f: texture_compression_astc },
218
+ 'astc-8x8-unorm': { gl: 37815, f: texture_compression_astc },
219
+ 'astc-8x8-unorm-srgb': { gl: 37847, f: texture_compression_astc },
220
+ 'astc-10x5-unorm': { gl: 37819, f: texture_compression_astc },
221
+ 'astc-10x5-unorm-srgb': { gl: 37851, f: texture_compression_astc },
222
+ 'astc-10x6-unorm': { gl: 37817, f: texture_compression_astc },
223
+ 'astc-10x6-unorm-srgb': { gl: 37849, f: texture_compression_astc },
224
+ 'astc-10x8-unorm': { gl: 37818, f: texture_compression_astc },
225
+ 'astc-10x8-unorm-srgb': { gl: 37850, f: texture_compression_astc },
226
+ 'astc-10x10-unorm': { gl: 37819, f: texture_compression_astc },
227
+ 'astc-10x10-unorm-srgb': { gl: 37851, f: texture_compression_astc },
228
+ 'astc-12x10-unorm': { gl: 37820, f: texture_compression_astc },
229
+ 'astc-12x10-unorm-srgb': { gl: 37852, f: texture_compression_astc },
230
+ 'astc-12x12-unorm': { gl: 37821, f: texture_compression_astc },
231
+ 'astc-12x12-unorm-srgb': { gl: 37853, f: texture_compression_astc },
227
232
  // WEBGL_compressed_texture_pvrtc
228
- 'pvrtc-rgb4unorm-webgl': { gl: GL.COMPRESSED_RGB_PVRTC_4BPPV1_IMG, f: texture_compression_pvrtc_webgl },
229
- 'pvrtc-rgba4unorm-webgl': { gl: GL.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, f: texture_compression_pvrtc_webgl },
230
- 'pvrtc-rbg2unorm-webgl': { gl: GL.COMPRESSED_RGB_PVRTC_2BPPV1_IMG, f: texture_compression_pvrtc_webgl },
231
- 'pvrtc-rgba2unorm-webgl': { gl: GL.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, f: texture_compression_pvrtc_webgl },
233
+ 'pvrtc-rgb4unorm-webgl': { gl: 35840, f: texture_compression_pvrtc_webgl },
234
+ 'pvrtc-rgba4unorm-webgl': { gl: 35842, f: texture_compression_pvrtc_webgl },
235
+ 'pvrtc-rbg2unorm-webgl': { gl: 35841, f: texture_compression_pvrtc_webgl },
236
+ 'pvrtc-rgba2unorm-webgl': { gl: 35843, f: texture_compression_pvrtc_webgl },
232
237
  // WEBGL_compressed_texture_etc1
233
- 'etc1-rbg-unorm-webgl': { gl: GL.COMPRESSED_RGB_ETC1_WEBGL, f: texture_compression_etc1_webgl },
238
+ 'etc1-rbg-unorm-webgl': { gl: 36196, f: texture_compression_etc1_webgl },
234
239
  // WEBGL_compressed_texture_atc
235
- 'atc-rgb-unorm-webgl': { gl: GL.COMPRESSED_RGB_ATC_WEBGL, f: texture_compression_atc_webgl },
236
- 'atc-rgba-unorm-webgl': { gl: GL.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL, f: texture_compression_atc_webgl },
237
- 'atc-rgbai-unorm-webgl': { gl: GL.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL, f: texture_compression_atc_webgl }
240
+ 'atc-rgb-unorm-webgl': { gl: 35986, f: texture_compression_atc_webgl },
241
+ 'atc-rgba-unorm-webgl': { gl: 35986, f: texture_compression_atc_webgl },
242
+ 'atc-rgbai-unorm-webgl': { gl: 34798, f: texture_compression_atc_webgl }
238
243
  };
239
244
  /** Legal combinations for internalFormat, format and type *
240
245
  // [GL.DEPTH_COMPONENT]: {types: [GL.UNSIGNED_SHORT, GL.UNSIGNED_INT, GL.UNSIGNED_INT_24_8]},
@@ -330,35 +335,34 @@ export const RENDERBUFFER_FORMATS: Record<string, RenderbufferFormat> = {
330
335
  */
331
336
  /** @deprecated should be removed */
332
337
  const DATA_FORMAT_CHANNELS = {
333
- [GL.RED]: 1,
334
- [GL.RED_INTEGER]: 1,
335
- [GL.RG]: 2,
336
- [GL.RG_INTEGER]: 2,
337
- [GL.RGB]: 3,
338
- [GL.RGB_INTEGER]: 3,
339
- [GL.RGBA]: 4,
340
- [GL.RGBA_INTEGER]: 4,
341
- [GL.DEPTH_COMPONENT]: 1,
342
- [GL.DEPTH_STENCIL]: 1,
343
- [GL.ALPHA]: 1,
344
- [GL.LUMINANCE]: 1,
345
- [GL.LUMINANCE_ALPHA]: 2
338
+ [6403]: 1,
339
+ [36244]: 1,
340
+ [33319]: 2,
341
+ [33320]: 2,
342
+ [6407]: 3,
343
+ [36248]: 3,
344
+ [6408]: 4,
345
+ [36249]: 4,
346
+ [6402]: 1,
347
+ [34041]: 1,
348
+ [6406]: 1,
349
+ [6409]: 1,
350
+ [6410]: 2
346
351
  };
347
352
  /** @deprecated should be removed */
348
353
  const TYPE_SIZES = {
349
- [GL.FLOAT]: 4,
350
- [GL.UNSIGNED_INT]: 4,
351
- [GL.INT]: 4,
352
- [GL.UNSIGNED_SHORT]: 2,
353
- [GL.SHORT]: 2,
354
- [GL.HALF_FLOAT]: 2,
355
- [GL.BYTE]: 1,
356
- [GL.UNSIGNED_BYTE]: 1
354
+ [5126]: 4,
355
+ [5125]: 4,
356
+ [5124]: 4,
357
+ [5123]: 2,
358
+ [5122]: 2,
359
+ [5131]: 2,
360
+ [5120]: 1,
361
+ [5121]: 1
357
362
  };
358
363
  // FUNCTIONS
359
364
  /** Checks if a texture format is supported */
360
- export function isTextureFormatSupported(gl, formatOrGL, extensions) {
361
- const format = convertGLToTextureFormat(formatOrGL);
365
+ export function isTextureFormatSupported(gl, format, extensions) {
362
366
  const info = TEXTURE_FORMATS[format];
363
367
  if (!info) {
364
368
  return false;
@@ -376,7 +380,7 @@ export function isTextureFormatSupported(gl, formatOrGL, extensions) {
376
380
  }
377
381
  export function isRenderbufferFormatSupported(gl, format, extensions) {
378
382
  // Note: Order is important since the function call initializes extensions.
379
- return isTextureFormatSupported(gl, format, extensions) && TEXTURE_FORMATS[format]?.renderbuffer;
383
+ return isTextureFormatSupported(gl, format, extensions) && TEXTURE_FORMATS[format]?.rb;
380
384
  }
381
385
  /**
382
386
  * Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
@@ -403,8 +407,7 @@ export function convertTextureFormatToGL(format) {
403
407
  return webglFormat;
404
408
  }
405
409
  /** Checks if a texture format is supported */
406
- export function getTextureFormatSupport(gl, formatOrGL, extensions) {
407
- const format = convertGLToTextureFormat(formatOrGL);
410
+ export function getTextureFormatSupport(gl, format, extensions) {
408
411
  const info = TEXTURE_FORMATS[format];
409
412
  if (!info) {
410
413
  return { supported: false };
@@ -432,11 +435,13 @@ export function getTextureFormatSupport(gl, formatOrGL, extensions) {
432
435
  };
433
436
  }
434
437
  /** Checks whether linear filtering (interpolated sampling) is available for floating point textures */
435
- export function isTextureFormatFilterable(gl, formatOrGL, extensions) {
436
- const format = convertGLToTextureFormat(formatOrGL);
438
+ export function isTextureFormatFilterable(gl, format, extensions) {
437
439
  if (!isTextureFormatSupported(gl, format, extensions)) {
438
440
  return false;
439
441
  }
442
+ if (format.startsWith('depth') || format.startsWith('stencil')) {
443
+ return false;
444
+ }
440
445
  try {
441
446
  const decoded = decodeTextureFormat(format);
442
447
  if (decoded.signed) {
@@ -454,8 +459,7 @@ export function isTextureFormatFilterable(gl, formatOrGL, extensions) {
454
459
  }
455
460
  return true;
456
461
  }
457
- export function isTextureFormatRenderable(gl, formatOrGL, extensions) {
458
- const format = convertGLToTextureFormat(formatOrGL);
462
+ export function isTextureFormatRenderable(gl, format, extensions) {
459
463
  if (!isTextureFormatSupported(gl, format, extensions)) {
460
464
  return false;
461
465
  }
@@ -465,15 +469,19 @@ export function isTextureFormatRenderable(gl, formatOrGL, extensions) {
465
469
  // TODO depends on device...
466
470
  return true;
467
471
  }
468
- export function getWebGLTextureParameters(formatOrGL) {
469
- const format = convertGLToTextureFormat(formatOrGL);
472
+ /** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */
473
+ export function getWebGLTextureParameters(format) {
474
+ const formatData = TEXTURE_FORMATS[format];
470
475
  const webglFormat = convertTextureFormatToGL(format);
471
476
  const decoded = decodeTextureFormat(format);
472
477
  return {
473
478
  format: webglFormat,
474
- dataFormat: getWebGLPixelDataFormat(decoded.format, decoded.integer, decoded.normalized, webglFormat),
479
+ dataFormat: formatData?.dataFormat ||
480
+ getWebGLPixelDataFormat(decoded.format, decoded.integer, decoded.normalized, webglFormat),
475
481
  // depth formats don't have a type
476
- type: decoded.dataType ? getGLFromVertexType(decoded.dataType) : GL.UNSIGNED_BYTE,
482
+ type: decoded.dataType
483
+ ? getGLFromVertexType(decoded.dataType)
484
+ : formatData?.types?.[0] || 5121,
477
485
  // @ts-expect-error
478
486
  compressed: decoded.compressed
479
487
  };
@@ -486,9 +494,8 @@ export function getDepthStencilAttachmentWebGL(format) {
486
494
  return info.attachment;
487
495
  }
488
496
  /** TODO - VERY roundabout legacy way of calculating bytes per pixel */
489
- export function getTextureFormatBytesPerPixel(formatOrGL) {
497
+ export function getTextureFormatBytesPerPixel(format) {
490
498
  // TODO remove webgl1 support
491
- const format = convertGLToTextureFormat(formatOrGL);
492
499
  const params = getWebGLTextureParameters(format);
493
500
  // NOTE(Tarek): Default to RGBA bytes
494
501
  const channels = DATA_FORMAT_CHANNELS[params.dataFormat] || 4;
@@ -498,15 +505,15 @@ export function getTextureFormatBytesPerPixel(formatOrGL) {
498
505
  // DATA TYPE HELPERS
499
506
  function getWebGLPixelDataFormat(dataFormat, integer, normalized, format) {
500
507
  // WebGL1 formats use same internalFormat
501
- if (format === GL.RGBA || format === GL.RGB) {
508
+ if (format === 6408 || format === 6407) {
502
509
  return format;
503
510
  }
504
511
  // prettier-ignore
505
512
  switch (dataFormat) {
506
- case 'r': return integer && !normalized ? GL.RED_INTEGER : GL.RED;
507
- case 'rg': return integer && !normalized ? GL.RG_INTEGER : GL.RG;
508
- case 'rgb': return integer && !normalized ? GL.RGB_INTEGER : GL.RGB;
509
- case 'rgba': return integer && !normalized ? GL.RGBA_INTEGER : GL.RGBA;
510
- default: return GL.RGBA;
513
+ case 'r': return integer && !normalized ? 36244 : 6403;
514
+ case 'rg': return integer && !normalized ? 33320 : 33319;
515
+ case 'rgb': return integer && !normalized ? 36248 : 6407;
516
+ case 'rgba': return integer && !normalized ? 36249 : 6408;
517
+ default: return 6408;
511
518
  }
512
519
  }
@@ -22,14 +22,14 @@ export function getVertexTypeFromGL(type, normalized = false) {
22
22
  // prettier-ignore
23
23
  switch (type) {
24
24
  // WebGPU does not support normalized 32 bit integer attributes
25
- case GL.INT: return normalized ? 'sint32' : 'sint32';
26
- case GL.UNSIGNED_INT: return normalized ? 'uint32' : 'uint32';
27
- case GL.SHORT: return normalized ? 'sint16' : 'unorm16';
28
- case GL.UNSIGNED_SHORT: return normalized ? 'uint16' : 'unorm16';
29
- case GL.BYTE: return normalized ? 'sint8' : 'snorm16';
30
- case GL.UNSIGNED_BYTE: return normalized ? 'uint8' : 'unorm8';
31
- case GL.FLOAT: return 'float32';
32
- case GL.HALF_FLOAT: return 'float16';
25
+ case 5124: return normalized ? 'sint32' : 'sint32';
26
+ case 5125: return normalized ? 'uint32' : 'uint32';
27
+ case 5122: return normalized ? 'sint16' : 'unorm16';
28
+ case 5123: return normalized ? 'uint16' : 'unorm16';
29
+ case 5120: return normalized ? 'sint8' : 'snorm16';
30
+ case 5121: return normalized ? 'uint8' : 'unorm8';
31
+ case 5126: return 'float32';
32
+ case 5131: return 'float16';
33
33
  }
34
34
  // @ts-ignore unreachable
35
35
  throw new Error(String(type));
@@ -37,21 +37,21 @@ export function getVertexTypeFromGL(type, normalized = false) {
37
37
  export function getGLFromVertexType(dataType) {
38
38
  // prettier-ignore
39
39
  switch (dataType) {
40
- case 'uint8': return GL.UNSIGNED_BYTE;
41
- case 'sint8': return GL.BYTE;
42
- case 'unorm8': return GL.UNSIGNED_BYTE;
43
- case 'snorm8': return GL.BYTE;
44
- case 'uint16': return GL.UNSIGNED_SHORT;
45
- case 'sint16': return GL.SHORT;
46
- case 'unorm16': return GL.UNSIGNED_SHORT;
47
- case 'snorm16': return GL.SHORT;
48
- case 'uint32': return GL.UNSIGNED_INT;
49
- case 'sint32': return GL.INT;
40
+ case 'uint8': return 5121;
41
+ case 'sint8': return 5120;
42
+ case 'unorm8': return 5121;
43
+ case 'snorm8': return 5120;
44
+ case 'uint16': return 5123;
45
+ case 'sint16': return 5122;
46
+ case 'unorm16': return 5123;
47
+ case 'snorm16': return 5122;
48
+ case 'uint32': return 5125;
49
+ case 'sint32': return 5124;
50
50
  // WebGPU does not support normalized 32 bit integer attributes
51
51
  // case 'unorm32': return GL.UNSIGNED_INT;
52
52
  // case 'snorm32': return GL.INT;
53
- case 'float16': return GL.HALF_FLOAT;
54
- case 'float32': return GL.FLOAT;
53
+ case 'float16': return 5131;
54
+ case 'float32': return 5126;
55
55
  }
56
56
  // @ts-ignore unreachable
57
57
  throw new Error(String(dataType));
@@ -10,9 +10,10 @@ export declare class WebGLDeviceFeatures extends DeviceFeatures {
10
10
  protected gl: WebGL2RenderingContext;
11
11
  protected extensions: GLExtensions;
12
12
  protected testedFeatures: Set<DeviceFeature>;
13
- constructor(gl: WebGL2RenderingContext, extensions: GLExtensions);
13
+ constructor(gl: WebGL2RenderingContext, extensions: GLExtensions, disabledFeatures: Partial<Record<DeviceFeature, boolean>>);
14
14
  [Symbol.iterator](): IterableIterator<DeviceFeature>;
15
15
  has(feature: DeviceFeature): boolean;
16
+ initializeFeatures(): void;
16
17
  /** Extract all WebGL features */
17
18
  protected getWebGLFeature(feature: DeviceFeature): boolean;
18
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"webgl-device-features.d.ts","sourceRoot":"","sources":["../../../src/adapter/device-helpers/webgl-device-features.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AA8BhD;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,SAAS,CAAC,EAAE,EAAE,sBAAsB,CAAC;IACrC,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC;IACnC,SAAS,CAAC,cAAc,qBAA4B;gBAExC,EAAE,EAAE,sBAAsB,EAAE,UAAU,EAAE,YAAY;IAS/D,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,aAAa,CAAC;IAc5C,GAAG,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO;IAiB7C,iCAAiC;IACjC,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO;CAU3D"}
1
+ {"version":3,"file":"webgl-device-features.d.ts","sourceRoot":"","sources":["../../../src/adapter/device-helpers/webgl-device-features.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AA8BhD;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,SAAS,CAAC,EAAE,EAAE,sBAAsB,CAAC;IACrC,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC;IACnC,SAAS,CAAC,cAAc,qBAA4B;gBAGlD,EAAE,EAAE,sBAAsB,EAC1B,UAAU,EAAE,YAAY,EACxB,gBAAgB,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAU1D,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,aAAa,CAAC;IAc5C,GAAG,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO;IAuB7C,kBAAkB;IAUlB,iCAAiC;IACjC,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO;CAU3D"}
@@ -39,8 +39,8 @@ export class WebGLDeviceFeatures extends DeviceFeatures {
39
39
  gl;
40
40
  extensions;
41
41
  testedFeatures = new Set();
42
- constructor(gl, extensions) {
43
- super();
42
+ constructor(gl, extensions, disabledFeatures) {
43
+ super([], disabledFeatures);
44
44
  this.gl = gl;
45
45
  this.extensions = extensions;
46
46
  // TODO - is this really needed?
@@ -61,6 +61,9 @@ export class WebGLDeviceFeatures extends DeviceFeatures {
61
61
  return [];
62
62
  }
63
63
  has(feature) {
64
+ if (this.disabledFeatures[feature]) {
65
+ return false;
66
+ }
64
67
  // We have already tested this feature
65
68
  if (!this.testedFeatures.has(feature)) {
66
69
  this.testedFeatures.add(feature);
@@ -74,6 +77,15 @@ export class WebGLDeviceFeatures extends DeviceFeatures {
74
77
  }
75
78
  return this.features.has(feature);
76
79
  }
80
+ // FOR DEVICE
81
+ initializeFeatures() {
82
+ // @ts-expect-error
83
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
84
+ for (const feature of this) {
85
+ // WebGL extensions are initialized by requesting them
86
+ }
87
+ }
88
+ // IMPLEMENTATION
77
89
  /** Extract all WebGL features */
78
90
  getWebGLFeature(feature) {
79
91
  const featureInfo = WEBGL_FEATURES[feature];
@@ -6,18 +6,18 @@ import { getWebGLExtension } from "../../context/helpers/webgl-extensions.js";
6
6
  /** @returns strings identifying the GPU vendor and driver. */
7
7
  export function getDeviceInfo(gl, extensions) {
8
8
  // "Masked" info is always available, but don't contain much useful information
9
- const vendorMasked = gl.getParameter(GL.VENDOR);
10
- const rendererMasked = gl.getParameter(GL.RENDERER);
9
+ const vendorMasked = gl.getParameter(7936);
10
+ const rendererMasked = gl.getParameter(7937);
11
11
  // If we are lucky, unmasked info is available
12
12
  // https://www.khronos.org/registry/webgl/extensions/WEBGL_debug_renderer_info/
13
13
  getWebGLExtension(gl, 'WEBGL_debug_renderer_info', extensions);
14
14
  const ext = extensions.WEBGL_debug_renderer_info;
15
- const vendorUnmasked = gl.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : GL.VENDOR);
16
- const rendererUnmasked = gl.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : GL.RENDERER);
15
+ const vendorUnmasked = gl.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : 7936);
16
+ const rendererUnmasked = gl.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : 7937);
17
17
  const vendor = vendorUnmasked || vendorMasked;
18
18
  const renderer = rendererUnmasked || rendererMasked;
19
19
  // Driver version
20
- const version = gl.getParameter(GL.VERSION);
20
+ const version = gl.getParameter(7938);
21
21
  // "Sniff" the GPU type and backend from the info. This works best if unmasked info is available.
22
22
  const gpu = identifyGPUVendor(vendor, renderer);
23
23
  const gpuBackend = identifyGPUBackend(vendor, renderer);