@luma.gl/webgl 9.0.0-beta.6 → 9.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +81 -84
- package/dist/adapter/converters/sampler-parameters.js +17 -17
- package/dist/adapter/converters/shader-formats.js +12 -12
- package/dist/adapter/converters/texture-formats.d.ts +10 -8
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +175 -168
- package/dist/adapter/converters/vertex-formats.js +20 -20
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +2 -1
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +14 -2
- package/dist/adapter/device-helpers/webgl-device-info.js +5 -5
- package/dist/adapter/device-helpers/webgl-device-limits.js +10 -10
- package/dist/adapter/helpers/decode-webgl-types.js +45 -45
- package/dist/adapter/helpers/get-shader-layout.js +29 -29
- package/dist/adapter/helpers/set-uniform.js +40 -40
- package/dist/adapter/helpers/webgl-topology-utils.js +38 -38
- package/dist/adapter/objects/webgl-renderbuffer.js +6 -6
- package/dist/adapter/objects/webgl-resource.js +1 -2
- package/dist/adapter/resources/webgl-buffer.js +14 -14
- package/dist/adapter/resources/webgl-command-buffer.js +25 -25
- package/dist/adapter/resources/webgl-external-texture.js +3 -3
- package/dist/adapter/resources/webgl-framebuffer.d.ts +2 -4
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +41 -36
- package/dist/adapter/resources/webgl-query-set.js +6 -6
- package/dist/adapter/resources/webgl-render-pass.js +5 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +19 -13
- package/dist/adapter/resources/webgl-sampler.js +2 -2
- package/dist/adapter/resources/webgl-shader.js +4 -4
- package/dist/adapter/resources/webgl-texture.d.ts +2 -1
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +29 -27
- package/dist/adapter/resources/webgl-transform-feedback.js +8 -8
- package/dist/adapter/resources/webgl-vertex-array.d.ts +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +5 -5
- package/dist/adapter/webgl-device.d.ts +6 -3
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +22 -17
- package/dist/classic/accessor.js +4 -4
- package/dist/classic/clear.js +2 -2
- package/dist/classic/copy-and-blit.js +15 -16
- package/dist/classic/format-utils.d.ts +2 -2
- package/dist/classic/format-utils.js +14 -14
- package/dist/classic/typed-array-utils.js +18 -18
- package/dist/context/parameters/unified-parameter-api.d.ts +3 -4
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +4 -9
- package/dist/context/parameters/webgl-parameter-tables.d.ts +2 -13
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +292 -298
- package/dist/context/state-tracker/with-parameters.d.ts +1 -2
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +2 -5
- package/dist/dist.dev.js +3796 -5522
- package/dist/dist.min.js +10 -0
- package/dist/index.cjs +1253 -1188
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +6 -7
- package/src/.DS_Store +0 -0
- package/src/adapter/.DS_Store +0 -0
- package/src/adapter/converters/device-parameters.ts +9 -11
- package/src/adapter/converters/texture-formats.ts +64 -61
- package/src/adapter/device-helpers/webgl-device-features.ts +22 -2
- package/src/adapter/objects/webgl-renderbuffer.ts +1 -1
- package/src/adapter/objects/webgl-resource.ts +1 -1
- package/src/adapter/resources/webgl-external-texture.ts +3 -3
- package/src/adapter/resources/webgl-framebuffer.ts +29 -26
- package/src/adapter/resources/webgl-render-pass.ts +3 -3
- package/src/adapter/resources/webgl-render-pipeline.ts +13 -6
- package/src/adapter/resources/webgl-texture.ts +7 -3
- package/src/adapter/webgl-device.ts +24 -19
- package/src/classic/clear.ts +2 -2
- package/src/context/.DS_Store +0 -0
- package/src/context/parameters/unified-parameter-api.ts +4 -16
- package/src/context/state-tracker/with-parameters.ts +2 -7
- package/src/index.ts +4 -4
- package/dist/adapter/device-helpers/device-features.d.ts +0 -6
- package/dist/adapter/device-helpers/device-features.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-features.js +0 -65
- package/dist/adapter/device-helpers/device-limits.d.ts +0 -50
- package/dist/adapter/device-helpers/device-limits.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-limits.js +0 -92
- package/dist/adapter/device-helpers/get-device-info.d.ts +0 -4
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +0 -1
- package/dist/adapter/device-helpers/get-device-info.js +0 -87
- package/dist/context/context/context-data.d.ts +0 -14
- package/dist/context/context/context-data.d.ts.map +0 -1
- package/dist/context/context/context-data.js +0 -33
- package/dist/context/context/create-browser-context.d.ts +0 -35
- package/dist/context/context/create-browser-context.d.ts.map +0 -1
- package/dist/context/context/create-browser-context.js +0 -66
- package/dist.min.js +0 -19
|
@@ -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
|
-
|
|
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:
|
|
96
|
-
'r8snorm': { gl:
|
|
97
|
-
'r8uint': { gl:
|
|
98
|
-
'r8sint': { gl:
|
|
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:
|
|
101
|
-
'rg8snorm': { gl:
|
|
102
|
-
'rg8uint': { gl:
|
|
103
|
-
'rg8sint': { gl:
|
|
104
|
-
'r16uint': { gl:
|
|
105
|
-
'r16sint': { gl:
|
|
106
|
-
'r16float': { gl:
|
|
107
|
-
'r16unorm-webgl': { gl:
|
|
108
|
-
'r16snorm-webgl': { gl:
|
|
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:
|
|
111
|
-
'rgb565unorm-webgl': { gl:
|
|
112
|
-
'rgb5a1unorm-webgl': { gl:
|
|
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:
|
|
115
|
-
'rgb8snorm-webgl': { gl:
|
|
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:
|
|
118
|
-
'rgba8unorm-srgb': { gl:
|
|
119
|
-
'rgba8snorm': { gl:
|
|
120
|
-
'rgba8uint': { gl:
|
|
121
|
-
'rgba8sint': { gl:
|
|
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:
|
|
126
|
-
'rg16sint': { gl:
|
|
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:
|
|
129
|
-
'rg16unorm-webgl': { gl:
|
|
130
|
-
'rg16snorm-webgl': { gl:
|
|
131
|
-
'r32uint': { gl:
|
|
132
|
-
'r32sint': { gl:
|
|
133
|
-
'r32float': { gl:
|
|
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:
|
|
136
|
-
'rg11b10ufloat': { gl:
|
|
137
|
-
'rgb10a2unorm': { gl:
|
|
138
|
-
'rgb10a2uint-webgl': { b: 4, c: 4, gl:
|
|
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:
|
|
141
|
-
'rgb16snorm-webgl': { gl:
|
|
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:
|
|
144
|
-
'rg32sint': { gl:
|
|
145
|
-
'rg32float': { gl:
|
|
146
|
-
'rgba16uint': { gl:
|
|
147
|
-
'rgba16sint': { gl:
|
|
148
|
-
'rgba16float': { gl:
|
|
149
|
-
'rgba16unorm-webgl': { gl:
|
|
150
|
-
'rgba16snorm-webgl': { gl:
|
|
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:
|
|
153
|
-
gl2ext: EXT_color_buffer_float, dataFormat:
|
|
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:
|
|
156
|
-
'rgba32sint': { gl:
|
|
157
|
-
'rgba32float': { gl:
|
|
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:
|
|
160
|
-
'depth16unorm': { gl:
|
|
161
|
-
|
|
162
|
-
'
|
|
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:
|
|
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:
|
|
167
|
-
|
|
168
|
-
|
|
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:
|
|
171
|
-
'bc1-rgb-unorm-srgb-webgl': { gl:
|
|
172
|
-
'bc1-rgba-unorm': { gl:
|
|
173
|
-
'bc1-rgba-unorm-srgb': { gl:
|
|
174
|
-
'bc2-rgba-unorm': { gl:
|
|
175
|
-
'bc2-rgba-unorm-srgb': { gl:
|
|
176
|
-
'bc3-rgba-unorm': { gl:
|
|
177
|
-
'bc3-rgba-unorm-srgb': { gl:
|
|
178
|
-
'bc4-r-unorm': { gl:
|
|
179
|
-
'bc4-r-snorm': { gl:
|
|
180
|
-
'bc5-rg-unorm': { gl:
|
|
181
|
-
'bc5-rg-snorm': { gl:
|
|
182
|
-
'bc6h-rgb-ufloat': { gl:
|
|
183
|
-
'bc6h-rgb-float': { gl:
|
|
184
|
-
'bc7-rgba-unorm': { gl:
|
|
185
|
-
'bc7-rgba-unorm-srgb': { gl:
|
|
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:
|
|
189
|
-
'etc2-rgb8unorm-srgb': { gl:
|
|
190
|
-
'etc2-rgb8a1unorm': { gl:
|
|
191
|
-
'etc2-rgb8a1unorm-srgb': { gl:
|
|
192
|
-
'etc2-rgba8unorm': { gl:
|
|
193
|
-
'etc2-rgba8unorm-srgb': { gl:
|
|
194
|
-
'eac-r11unorm': { gl:
|
|
195
|
-
'eac-r11snorm': { gl:
|
|
196
|
-
'eac-rg11unorm': { gl:
|
|
197
|
-
'eac-rg11snorm': { gl:
|
|
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:
|
|
200
|
-
'astc-4x4-unorm-srgb': { gl:
|
|
201
|
-
'astc-5x4-unorm': { gl:
|
|
202
|
-
'astc-5x4-unorm-srgb': { gl:
|
|
203
|
-
'astc-5x5-unorm': { gl:
|
|
204
|
-
'astc-5x5-unorm-srgb': { gl:
|
|
205
|
-
'astc-6x5-unorm': { gl:
|
|
206
|
-
'astc-6x5-unorm-srgb': { gl:
|
|
207
|
-
'astc-6x6-unorm': { gl:
|
|
208
|
-
'astc-6x6-unorm-srgb': { gl:
|
|
209
|
-
'astc-8x5-unorm': { gl:
|
|
210
|
-
'astc-8x5-unorm-srgb': { gl:
|
|
211
|
-
'astc-8x6-unorm': { gl:
|
|
212
|
-
'astc-8x6-unorm-srgb': { gl:
|
|
213
|
-
'astc-8x8-unorm': { gl:
|
|
214
|
-
'astc-8x8-unorm-srgb': { gl:
|
|
215
|
-
'astc-10x5-unorm': { gl:
|
|
216
|
-
'astc-10x5-unorm-srgb': { gl:
|
|
217
|
-
'astc-10x6-unorm': { gl:
|
|
218
|
-
'astc-10x6-unorm-srgb': { gl:
|
|
219
|
-
'astc-10x8-unorm': { gl:
|
|
220
|
-
'astc-10x8-unorm-srgb': { gl:
|
|
221
|
-
'astc-10x10-unorm': { gl:
|
|
222
|
-
'astc-10x10-unorm-srgb': { gl:
|
|
223
|
-
'astc-12x10-unorm': { gl:
|
|
224
|
-
'astc-12x10-unorm-srgb': { gl:
|
|
225
|
-
'astc-12x12-unorm': { gl:
|
|
226
|
-
'astc-12x12-unorm-srgb': { gl:
|
|
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:
|
|
229
|
-
'pvrtc-rgba4unorm-webgl': { gl:
|
|
230
|
-
'pvrtc-rbg2unorm-webgl': { gl:
|
|
231
|
-
'pvrtc-rgba2unorm-webgl': { gl:
|
|
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:
|
|
238
|
+
'etc1-rbg-unorm-webgl': { gl: 36196, f: texture_compression_etc1_webgl },
|
|
234
239
|
// WEBGL_compressed_texture_atc
|
|
235
|
-
'atc-rgb-unorm-webgl': { gl:
|
|
236
|
-
'atc-rgba-unorm-webgl': { gl:
|
|
237
|
-
'atc-rgbai-unorm-webgl': { gl:
|
|
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
|
-
[
|
|
334
|
-
[
|
|
335
|
-
[
|
|
336
|
-
[
|
|
337
|
-
[
|
|
338
|
-
[
|
|
339
|
-
[
|
|
340
|
-
[
|
|
341
|
-
[
|
|
342
|
-
[
|
|
343
|
-
[
|
|
344
|
-
[
|
|
345
|
-
[
|
|
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
|
-
[
|
|
350
|
-
[
|
|
351
|
-
[
|
|
352
|
-
[
|
|
353
|
-
[
|
|
354
|
-
[
|
|
355
|
-
[
|
|
356
|
-
[
|
|
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,
|
|
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]?.
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
-
|
|
469
|
-
|
|
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:
|
|
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
|
|
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(
|
|
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 ===
|
|
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 ?
|
|
507
|
-
case 'rg': return integer && !normalized ?
|
|
508
|
-
case 'rgb': return integer && !normalized ?
|
|
509
|
-
case 'rgba': return integer && !normalized ?
|
|
510
|
-
default: return
|
|
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
|
|
26
|
-
case
|
|
27
|
-
case
|
|
28
|
-
case
|
|
29
|
-
case
|
|
30
|
-
case
|
|
31
|
-
case
|
|
32
|
-
case
|
|
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
|
|
41
|
-
case 'sint8': return
|
|
42
|
-
case 'unorm8': return
|
|
43
|
-
case 'snorm8': return
|
|
44
|
-
case 'uint16': return
|
|
45
|
-
case 'sint16': return
|
|
46
|
-
case 'unorm16': return
|
|
47
|
-
case 'snorm16': return
|
|
48
|
-
case 'uint32': return
|
|
49
|
-
case 'sint32': return
|
|
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
|
|
54
|
-
case 'float32': return
|
|
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;
|
|
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(
|
|
10
|
-
const rendererMasked = gl.getParameter(
|
|
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 :
|
|
16
|
-
const rendererUnmasked = gl.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL :
|
|
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(
|
|
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);
|