• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visgl / loaders.gl / 23489006929

24 Mar 2026 12:18PM UTC coverage: 35.305% (-0.07%) from 35.372%
23489006929

push

github

web-flow
fix(textures): Fix format strings, serialize basis transcoding. (#3329)

1201 of 2016 branches covered (59.57%)

Branch coverage included in aggregate %.

118 of 458 new or added lines in 12 files covered. (25.76%)

1 existing line in 1 file now uncovered.

38084 of 109257 relevant lines covered (34.86%)

0.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.82
/modules/textures/src/lib/utils/texture-format-map.ts
1
// loaders.gl
1✔
2
// SPDX-License-Identifier: MIT
1✔
3
// Copyright (c) vis.gl contributors
1✔
4

1✔
5
/* eslint-disable camelcase */
1✔
6
import type {TextureFormat} from '@loaders.gl/schema';
1✔
7
import type {GLTextureFormat} from '../gl-types';
1✔
8
import {
1✔
9
  GL_COMPRESSED_R11_EAC,
1✔
10
  GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
1✔
11
  GL_COMPRESSED_RED_RGTC1_EXT,
1✔
12
  GL_COMPRESSED_RG11_EAC,
1✔
13
  GL_COMPRESSED_RGB8_ETC2,
1✔
14
  GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
1✔
15
  GL_COMPRESSED_RGB_ATC_WEBGL,
1✔
16
  GL_COMPRESSED_RGB_ETC1_WEBGL,
1✔
17
  GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
1✔
18
  GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
1✔
19
  GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
1✔
20
  GL_COMPRESSED_RGBA8_ETC2_EAC,
1✔
21
  GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
1✔
22
  GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
1✔
23
  GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
1✔
24
  GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
1✔
25
  GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
1✔
26
  GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
1✔
27
  GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
1✔
28
  GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
1✔
29
  GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
1✔
30
  GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
1✔
31
  GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
1✔
32
  GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
1✔
33
  GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
1✔
34
  GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
1✔
35
  GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,
1✔
36
  GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,
1✔
37
  GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
1✔
38
  GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
1✔
39
  GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
1✔
40
  GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
1✔
41
  GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
1✔
42
  GL_COMPRESSED_SIGNED_R11_EAC,
1✔
43
  GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
1✔
44
  GL_COMPRESSED_SIGNED_RED_RGTC1_EXT,
1✔
45
  GL_COMPRESSED_SIGNED_RG11_EAC,
1✔
46
  GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
1✔
47
  GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
1✔
48
  GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
1✔
49
  GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
1✔
50
  GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
1✔
51
  GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
1✔
52
  GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
1✔
53
  GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
1✔
54
  GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
1✔
55
  GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
1✔
56
  GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
1✔
57
  GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
1✔
58
  GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
1✔
59
  GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
1✔
60
  GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
1✔
61
  GL_COMPRESSED_SRGB8_ETC2,
1✔
62
  GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
1✔
63
  GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
1✔
64
  GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
1✔
65
  GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
1✔
66
  GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
1✔
67
} from '../gl-extensions';
1✔
68

1✔
69
const WEBGL_TO_TEXTURE_FORMAT: Record<number, TextureFormat> = {
1✔
70
  [GL_COMPRESSED_RGB_S3TC_DXT1_EXT]: 'bc1-rgb-unorm-ext',
1✔
71
  [GL_COMPRESSED_SRGB_S3TC_DXT1_EXT]: 'bc1-rgb-unorm-srgb-ext',
1✔
72
  [GL_COMPRESSED_RGBA_S3TC_DXT1_EXT]: 'bc1-rgba-unorm',
1✔
73
  [GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT]: 'bc1-rgba-unorm-srgb',
1✔
74
  [GL_COMPRESSED_RGBA_S3TC_DXT3_EXT]: 'bc2-rgba-unorm',
1✔
75
  [GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT]: 'bc2-rgba-unorm-srgb',
1✔
76
  [GL_COMPRESSED_RGBA_S3TC_DXT5_EXT]: 'bc3-rgba-unorm',
1✔
77
  [GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT]: 'bc3-rgba-unorm-srgb',
1✔
78
  [GL_COMPRESSED_RED_RGTC1_EXT]: 'bc4-r-unorm',
1✔
79
  [GL_COMPRESSED_SIGNED_RED_RGTC1_EXT]: 'bc4-r-snorm',
1✔
80
  [GL_COMPRESSED_RED_GREEN_RGTC2_EXT]: 'bc5-rg-unorm',
1✔
81
  [GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT]: 'bc5-rg-snorm',
1✔
82
  [GL_COMPRESSED_RGB8_ETC2]: 'etc2-rgb8unorm',
1✔
83
  [GL_COMPRESSED_SRGB8_ETC2]: 'etc2-rgb8unorm-srgb',
1✔
84
  [GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2]: 'etc2-rgb8a1unorm',
1✔
85
  [GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2]: 'etc2-rgb8a1unorm-srgb',
1✔
86
  [GL_COMPRESSED_RGBA8_ETC2_EAC]: 'etc2-rgba8unorm',
1✔
87
  [GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC]: 'etc2-rgba8unorm-srgb',
1✔
88
  [GL_COMPRESSED_R11_EAC]: 'eac-r11unorm',
1✔
89
  [GL_COMPRESSED_SIGNED_R11_EAC]: 'eac-r11snorm',
1✔
90
  [GL_COMPRESSED_RG11_EAC]: 'eac-rg11unorm',
1✔
91
  [GL_COMPRESSED_SIGNED_RG11_EAC]: 'eac-rg11snorm',
1✔
92
  [GL_COMPRESSED_RGBA_ASTC_4x4_KHR]: 'astc-4x4-unorm',
1✔
93
  [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR]: 'astc-4x4-unorm-srgb',
1✔
94
  [GL_COMPRESSED_RGBA_ASTC_5x4_KHR]: 'astc-5x4-unorm',
1✔
95
  [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR]: 'astc-5x4-unorm-srgb',
1✔
96
  [GL_COMPRESSED_RGBA_ASTC_5x5_KHR]: 'astc-5x5-unorm',
1✔
97
  [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR]: 'astc-5x5-unorm-srgb',
1✔
98
  [GL_COMPRESSED_RGBA_ASTC_6x5_KHR]: 'astc-6x5-unorm',
1✔
99
  [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR]: 'astc-6x5-unorm-srgb',
1✔
100
  [GL_COMPRESSED_RGBA_ASTC_6x6_KHR]: 'astc-6x6-unorm',
1✔
101
  [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR]: 'astc-6x6-unorm-srgb',
1✔
102
  [GL_COMPRESSED_RGBA_ASTC_8x5_KHR]: 'astc-8x5-unorm',
1✔
103
  [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR]: 'astc-8x5-unorm-srgb',
1✔
104
  [GL_COMPRESSED_RGBA_ASTC_8x6_KHR]: 'astc-8x6-unorm',
1✔
105
  [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR]: 'astc-8x6-unorm-srgb',
1✔
106
  [GL_COMPRESSED_RGBA_ASTC_8x8_KHR]: 'astc-8x8-unorm',
1✔
107
  [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR]: 'astc-8x8-unorm-srgb',
1✔
108
  [GL_COMPRESSED_RGBA_ASTC_10x5_KHR]: 'astc-10x5-unorm',
1✔
109
  [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR]: 'astc-10x5-unorm-srgb',
1✔
110
  [GL_COMPRESSED_RGBA_ASTC_10x6_KHR]: 'astc-10x6-unorm',
1✔
111
  [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR]: 'astc-10x6-unorm-srgb',
1✔
112
  [GL_COMPRESSED_RGBA_ASTC_10x8_KHR]: 'astc-10x8-unorm',
1✔
113
  [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR]: 'astc-10x8-unorm-srgb',
1✔
114
  [GL_COMPRESSED_RGBA_ASTC_10x10_KHR]: 'astc-10x10-unorm',
1✔
115
  [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR]: 'astc-10x10-unorm-srgb',
1✔
116
  [GL_COMPRESSED_RGBA_ASTC_12x10_KHR]: 'astc-12x10-unorm',
1✔
117
  [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR]: 'astc-12x10-unorm-srgb',
1✔
118
  [GL_COMPRESSED_RGBA_ASTC_12x12_KHR]: 'astc-12x12-unorm',
1✔
119
  [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR]: 'astc-12x12-unorm-srgb',
1✔
120
  [GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG]: 'pvrtc-rgb4unorm-ext',
1✔
121
  [GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG]: 'pvrtc-rgba4unorm-ext',
1✔
122
  [GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG]: 'pvrtc-rgb2unorm-ext',
1✔
123
  [GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG]: 'pvrtc-rgba2unorm-ext',
1✔
124
  [GL_COMPRESSED_RGB_ETC1_WEBGL]: 'etc1-rbg-unorm-ext',
1✔
125
  [GL_COMPRESSED_RGB_ATC_WEBGL]: 'atc-rgb-unorm-ext',
1✔
126
  [GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL]: 'atc-rgba-unorm-ext',
1✔
127
  [GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL]: 'atc-rgbai-unorm-ext'
1✔
128
};
1✔
129

1✔
130
const TEXTURE_FORMAT_TO_WEBGL = Object.fromEntries(
1✔
131
  Object.entries(WEBGL_TO_TEXTURE_FORMAT).map(([format, textureFormat]) => [
1✔
NEW
132
    textureFormat,
×
NEW
133
    Number(format)
×
134
  ])
1✔
135
) as Partial<Record<TextureFormat, GLTextureFormat>>;
1✔
136

1✔
137
export function getTextureFormatFromWebGLFormat(
1✔
NEW
138
  format?: GLTextureFormat
×
NEW
139
): TextureFormat | undefined {
×
140
  if (format === undefined) {
×
141
    return undefined;
×
142
  }
×
143

×
144
  return WEBGL_TO_TEXTURE_FORMAT[format];
×
145
}
×
146

1✔
147
/**
1✔
148
 * Returns the WebGL/OpenGL compressed texture constant for a canonical loaders.gl texture format.
1✔
149
 * @param textureFormat - Canonical texture format string.
1✔
150
 * @returns Matching WebGL/OpenGL constant, if known.
1✔
151
 */
1✔
152
export function getWebGLFormatFromTextureFormat(
1✔
NEW
153
  textureFormat?: TextureFormat
×
NEW
154
): GLTextureFormat | undefined {
×
NEW
155
  if (textureFormat === undefined) {
×
NEW
156
    return undefined;
×
NEW
157
  }
×
NEW
158

×
NEW
159
  return TEXTURE_FORMAT_TO_WEBGL[textureFormat];
×
NEW
160
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc