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