@luma.gl/webgl 9.0.0-alpha.52 → 9.0.0-alpha.54

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 (29) hide show
  1. package/dist/adapter/converters/sampler-parameters.d.ts +2 -8
  2. package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
  3. package/dist/adapter/converters/sampler-parameters.js +12 -107
  4. package/dist/adapter/converters/sampler-parameters.js.map +1 -1
  5. package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
  6. package/dist/adapter/device-helpers/get-device-info.js +21 -3
  7. package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
  8. package/dist/adapter/resources/webgl-buffer.d.ts +4 -7
  9. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  10. package/dist/adapter/resources/webgl-buffer.js +13 -19
  11. package/dist/adapter/resources/webgl-buffer.js.map +1 -1
  12. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  13. package/dist/adapter/resources/webgl-texture.js +2 -3
  14. package/dist/adapter/resources/webgl-texture.js.map +1 -1
  15. package/dist/adapter/webgl-device.d.ts.map +1 -1
  16. package/dist/adapter/webgl-device.js +9 -7
  17. package/dist/adapter/webgl-device.js.map +1 -1
  18. package/dist/context/polyfill/polyfill-context.js +5 -2
  19. package/dist/context/polyfill/polyfill-context.js.map +1 -1
  20. package/dist/dist.dev.js +87 -65
  21. package/dist/index.cjs +161 -148
  22. package/dist.min.js +38 -38
  23. package/package.json +5 -5
  24. package/src/adapter/converters/sampler-parameters.ts +26 -151
  25. package/src/adapter/device-helpers/get-device-info.ts +24 -5
  26. package/src/adapter/resources/webgl-buffer.ts +46 -56
  27. package/src/adapter/resources/webgl-texture.ts +3 -4
  28. package/src/adapter/webgl-device.ts +13 -10
  29. package/src/context/polyfill/polyfill-context.ts +6 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/webgl",
3
- "version": "9.0.0-alpha.52",
3
+ "version": "9.0.0-alpha.54",
4
4
  "description": "WebGL2 adapter for the luma.gl API",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -44,12 +44,12 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@babel/runtime": "^7.0.0",
47
- "@luma.gl/constants": "9.0.0-alpha.52",
48
- "@luma.gl/core": "9.0.0-alpha.52",
47
+ "@luma.gl/constants": "9.0.0-alpha.54",
48
+ "@luma.gl/core": "9.0.0-alpha.54",
49
49
  "@probe.gl/env": "^4.0.2"
50
50
  },
51
51
  "devDependencies": {
52
- "@luma.gl/test-utils": "9.0.0-alpha.52"
52
+ "@luma.gl/test-utils": "9.0.0-alpha.54"
53
53
  },
54
- "gitHead": "41fa29f78dc260e5ef4c6a48e657fb5d23c96e8f"
54
+ "gitHead": "6028eb651303eadbc8f25e86d135d28f118fa3cf"
55
55
  }
@@ -2,19 +2,17 @@
2
2
  // Copyright (c) vis.gl contributors
3
3
 
4
4
  // SAMPLER FILTERS
5
- import {SamplerParameters} from '@luma.gl/core';
5
+ import {SamplerProps} from '@luma.gl/core';
6
6
  import {GL, GLSamplerParameters} from '@luma.gl/constants';
7
- import {convertCompareFunction, convertToCompareFunction} from './device-parameters';
8
-
9
- /* eslint-disable consistent-return */
7
+ import {convertCompareFunction} from './device-parameters';
10
8
 
11
9
  /**
12
10
  * Convert WebGPU-style sampler props to WebGL
13
11
  * @param props
14
12
  * @returns
15
13
  */
16
- export function convertSamplerParametersToWebGL(props: SamplerParameters): GLSamplerParameters {
17
- const params: Record<number, number> = {};
14
+ export function convertSamplerParametersToWebGL(props: SamplerProps): GLSamplerParameters {
15
+ const params: GLSamplerParameters = {};
18
16
  if (props.addressModeU) {
19
17
  params[GL.TEXTURE_WRAP_S] = convertAddressMode(props.addressModeU);
20
18
  }
@@ -54,8 +52,27 @@ export function convertSamplerParametersToWebGL(props: SamplerParameters): GLSam
54
52
  return params;
55
53
  }
56
54
 
55
+ /**
56
+ * Override sampler settings that are not supported by Non-Power-of-Two textures in WebGL1.
57
+ */
58
+ export function updateSamplerParametersForNPOT(
59
+ parameters: GLSamplerParameters
60
+ ): GLSamplerParameters {
61
+ const newParameters = {...parameters};
62
+ if (parameters[GL.TEXTURE_MIN_FILTER] !== GL.NEAREST) {
63
+ // log.warn(`texture: ${this} is Non-Power-Of-Two, forcing TEXTURE_MIN_FILTER to LINEAR`)();
64
+ newParameters[GL.TEXTURE_MIN_FILTER] = GL.LINEAR;
65
+ }
66
+ // log.warn(`texture: ${this} is Non-Power-Of-Two, forcing TEXTURE_WRAP_S to CLAMP_TO_EDGE`)();
67
+ newParameters[GL.TEXTURE_WRAP_S] = GL.CLAMP_TO_EDGE;
68
+ newParameters[GL.TEXTURE_WRAP_T] = GL.CLAMP_TO_EDGE;
69
+ return newParameters;
70
+ }
71
+
72
+ // HELPERS
73
+
57
74
  /** Convert address more */
58
- function convertAddressMode(addressMode: 'clamp-to-edge' | 'repeat' | 'mirror-repeat'): GL {
75
+ function convertAddressMode(addressMode: 'clamp-to-edge' | 'repeat' | 'mirror-repeat'): GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT {
59
76
  switch (addressMode) {
60
77
  case 'clamp-to-edge':
61
78
  return GL.CLAMP_TO_EDGE;
@@ -66,7 +83,7 @@ function convertAddressMode(addressMode: 'clamp-to-edge' | 'repeat' | 'mirror-re
66
83
  }
67
84
  }
68
85
 
69
- function convertMaxFilterMode(maxFilter: 'nearest' | 'linear'): GL {
86
+ function convertMaxFilterMode(maxFilter: 'nearest' | 'linear'): GL.NEAREST | GL.LINEAR {
70
87
  switch (maxFilter) {
71
88
  case 'nearest':
72
89
  return GL.NEAREST;
@@ -82,7 +99,7 @@ function convertMaxFilterMode(maxFilter: 'nearest' | 'linear'): GL {
82
99
  function convertMinFilterMode(
83
100
  minFilter: 'nearest' | 'linear',
84
101
  mipmapFilter?: 'nearest' | 'linear'
85
- ): GL {
102
+ ): GL.NEAREST | GL.LINEAR | GL.NEAREST_MIPMAP_NEAREST | GL.LINEAR_MIPMAP_NEAREST | GL.NEAREST_MIPMAP_LINEAR | GL.LINEAR_MIPMAP_LINEAR {
86
103
  if (!mipmapFilter) {
87
104
  return convertMaxFilterMode(minFilter);
88
105
  }
@@ -93,145 +110,3 @@ function convertMinFilterMode(
93
110
  return mipmapFilter === 'nearest' ? GL.LINEAR_MIPMAP_NEAREST : GL.LINEAR_MIPMAP_LINEAR;
94
111
  }
95
112
  }
96
-
97
- // Convert from WebGL to WebGPU
98
-
99
- /**
100
- * Convert WebGL-style sampler props to WebGPU
101
- * @param props
102
- * @returns
103
- */
104
- export function convertToSamplerParameters(params: GLSamplerParameters): SamplerParameters {
105
- const props: SamplerParameters = {};
106
- if (params[GL.TEXTURE_WRAP_S]) {
107
- props.addressModeU = convertToAddressMode(params[GL.TEXTURE_WRAP_S]);
108
- }
109
- if (params[GL.TEXTURE_WRAP_T]) {
110
- props.addressModeV = convertToAddressMode(params[GL.TEXTURE_WRAP_T]);
111
- }
112
- if (params[GL.TEXTURE_WRAP_R]) {
113
- props.addressModeW = convertToAddressMode(params[GL.TEXTURE_WRAP_R]);
114
- }
115
- if (params[GL.TEXTURE_MAG_FILTER]) {
116
- props.magFilter = convertToMaxFilterMode(params[GL.TEXTURE_MAG_FILTER]);
117
- }
118
- if (params[GL.TEXTURE_MIN_FILTER]) {
119
- props.minFilter = convertToMinFilterMode(params[GL.TEXTURE_MIN_FILTER]);
120
- }
121
- if (params[GL.TEXTURE_MIN_FILTER]) {
122
- props.mipmapFilter = convertToMipmapFilterMode(params[GL.TEXTURE_MIN_FILTER]);
123
- }
124
- if (params[GL.TEXTURE_MIN_LOD]) {
125
- props.lodMinClamp = params[GL.TEXTURE_MIN_LOD];
126
- }
127
- if (params[GL.TEXTURE_MAX_LOD]) {
128
- props.lodMaxClamp = params[GL.TEXTURE_MAX_LOD];
129
- }
130
- if (params[GL.TEXTURE_COMPARE_MODE]) {
131
- props.type =
132
- params[GL.TEXTURE_COMPARE_MODE] === GL.COMPARE_REF_TO_TEXTURE
133
- ? 'comparison-sampler'
134
- : 'color-sampler';
135
- }
136
- if (params[GL.TEXTURE_COMPARE_FUNC]) {
137
- props.compare = convertToCompareFunction('compare', params[GL.TEXTURE_COMPARE_FUNC]);
138
- }
139
- // NOTE depends on extension (very common)
140
- if (params[GL.TEXTURE_MAX_ANISOTROPY_EXT]) {
141
- props.maxAnisotropy = params[GL.TEXTURE_MAX_ANISOTROPY_EXT];
142
- }
143
- return props;
144
- }
145
-
146
- /** Convert address more */
147
- function convertToAddressMode(
148
- addressMode: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT
149
- ): 'clamp-to-edge' | 'repeat' | 'mirror-repeat' {
150
- switch (addressMode) {
151
- case GL.CLAMP_TO_EDGE:
152
- return 'clamp-to-edge';
153
- case GL.REPEAT:
154
- return 'repeat';
155
- case GL.MIRRORED_REPEAT:
156
- return 'mirror-repeat';
157
- default:
158
- throw new Error('address');
159
- }
160
- }
161
-
162
- function convertToMaxFilterMode(filterMode: GL.NEAREST | GL.LINEAR): 'nearest' | 'linear' {
163
- switch (filterMode) {
164
- case GL.NEAREST:
165
- return 'nearest';
166
- case GL.LINEAR:
167
- return 'linear';
168
- default:
169
- throw new Error('maxfilter');
170
- }
171
- }
172
-
173
- type GLMinFilter =
174
- | GL.NEAREST
175
- | GL.LINEAR
176
- | GL.NEAREST_MIPMAP_NEAREST
177
- | GL.LINEAR_MIPMAP_NEAREST
178
- | GL.NEAREST_MIPMAP_LINEAR
179
- | GL.LINEAR_MIPMAP_LINEAR;
180
-
181
- /** WebGPU has separate min filter and mipmap filter, WebGL is combined */
182
- function convertToMinFilterMode(filterMode: GLMinFilter): 'nearest' | 'linear' {
183
- switch (filterMode) {
184
- // TODO is this correct?
185
- case GL.NEAREST:
186
- return 'nearest';
187
- case GL.LINEAR:
188
- return 'linear';
189
- case GL.NEAREST_MIPMAP_NEAREST:
190
- return 'nearest';
191
- case GL.LINEAR_MIPMAP_NEAREST:
192
- return 'linear';
193
- case GL.NEAREST_MIPMAP_LINEAR:
194
- return 'nearest';
195
- case GL.LINEAR_MIPMAP_LINEAR:
196
- return 'linear';
197
- default:
198
- throw new Error('minfilter');
199
- }
200
- }
201
-
202
- function convertToMipmapFilterMode(filterMode: GLMinFilter): 'nearest' | 'linear' {
203
- switch (filterMode) {
204
- // TODO is this correct?
205
- case GL.NEAREST:
206
- return 'nearest';
207
- case GL.LINEAR:
208
- return 'linear';
209
- case GL.NEAREST_MIPMAP_NEAREST:
210
- return 'nearest';
211
- case GL.LINEAR_MIPMAP_NEAREST:
212
- return 'nearest';
213
- case GL.NEAREST_MIPMAP_LINEAR:
214
- return 'linear';
215
- case GL.LINEAR_MIPMAP_LINEAR:
216
- return 'linear';
217
- default:
218
- throw new Error('mipmap');
219
- }
220
- }
221
-
222
- /**
223
- * Override sampler settings that are not supported by Non-Power-of-Two textures in WebGL1.
224
- */
225
- export function updateSamplerParametersForNPOT(
226
- parameters: GLSamplerParameters
227
- ): GLSamplerParameters {
228
- const newParameters = {...parameters};
229
- if (parameters[GL.TEXTURE_MIN_FILTER] !== GL.NEAREST) {
230
- // log.warn(`texture: ${this} is Non-Power-Of-Two, forcing TEXTURE_MIN_FILTER to LINEAR`)();
231
- newParameters[GL.TEXTURE_MIN_FILTER] = GL.LINEAR;
232
- }
233
- // log.warn(`texture: ${this} is Non-Power-Of-Two, forcing TEXTURE_WRAP_S to CLAMP_TO_EDGE`)();
234
- newParameters[GL.TEXTURE_WRAP_S] = GL.CLAMP_TO_EDGE;
235
- newParameters[GL.TEXTURE_WRAP_T] = GL.CLAMP_TO_EDGE;
236
- return newParameters;
237
- }
@@ -25,6 +25,7 @@ export function getDeviceInfo(gl: WebGLRenderingContext): DeviceInfo {
25
25
  // "Sniff" the GPU type and backend from the info. This works best if unmasked info is available.
26
26
  const gpu = identifyGPUVendor(vendor, renderer);
27
27
  const gpuBackend = identifyGPUBackend(vendor, renderer);
28
+ const gpuType = identifyGPUType(vendor, renderer);
28
29
 
29
30
  // Determine GLSL version
30
31
  // For now, skip parsing of the long version string, just use context type below to deduce version
@@ -36,6 +37,7 @@ export function getDeviceInfo(gl: WebGLRenderingContext): DeviceInfo {
36
37
  return {
37
38
  type: isWebGL2(gl) ? 'webgl2' : 'webgl',
38
39
  gpu,
40
+ gpuType,
39
41
  gpuBackend,
40
42
  vendor,
41
43
  renderer,
@@ -72,13 +74,30 @@ function identifyGPUVendor(vendor: string, renderer: string): 'nvidia' | 'intel'
72
74
  }
73
75
 
74
76
  /** "Sniff" the GPU backend from the info. This works best if unmasked info is available. */
75
- function identifyGPUBackend(vendor: string, renderer: string): 'angle' | 'metal' | 'unknown' {
76
- if ((/ANGLE/i.exec(vendor)) || (/ANGLE/i.exec(renderer))) {
77
- return 'angle';
78
- }
77
+ function identifyGPUBackend(vendor: string, renderer: string): 'opengl' | 'metal' | 'unknown' {
79
78
  if ((/Metal/i.exec(vendor)) || (/Metal/i.exec(renderer))) {
80
79
  return 'metal';
81
80
  }
82
-
81
+ if ((/ANGLE/i.exec(vendor)) || (/ANGLE/i.exec(renderer))) {
82
+ return 'opengl';
83
+ }
83
84
  return 'unknown';
84
85
  }
86
+
87
+ function identifyGPUType(vendor: string, renderer: string): 'discrete' | 'integrated' | 'cpu' | 'unknown' {
88
+ if ((/SwiftShader/i.exec(vendor)) || (/SwiftShader/i.exec(renderer))) {
89
+ return 'cpu';
90
+ }
91
+
92
+ const gpuVendor = identifyGPUVendor(vendor, renderer);
93
+ switch (gpuVendor) {
94
+ case 'intel':
95
+ return 'integrated';
96
+ case 'software':
97
+ return 'cpu';
98
+ case 'unknown':
99
+ return 'unknown';
100
+ default:
101
+ return 'discrete';
102
+ }
103
+ }
@@ -6,8 +6,6 @@ import {Buffer, assert} from '@luma.gl/core';
6
6
  import {GL} from '@luma.gl/constants';
7
7
  import {WebGLDevice} from '../webgl-device';
8
8
 
9
- const DEBUG_DATA_LENGTH = 10;
10
-
11
9
  /** WebGL Buffer interface */
12
10
  export class WEBGLBuffer extends Buffer {
13
11
  readonly device: WebGLDevice;
@@ -26,8 +24,6 @@ export class WEBGLBuffer extends Buffer {
26
24
  byteLength: number;
27
25
  /** Number of bytes used */
28
26
  bytesUsed: number;
29
- /** A partial CPU-side copy of the data in this buffer, for debugging purposes */
30
- debugData: ArrayBuffer | null = null;
31
27
 
32
28
  constructor(device: WebGLDevice, props: BufferProps = {}) {
33
29
  super(device, props);
@@ -47,8 +43,6 @@ export class WEBGLBuffer extends Buffer {
47
43
  this.glUsage = getWebGLUsage(this.props.usage);
48
44
  this.glIndexType = this.props.indexType === 'uint32' ? GL.UNSIGNED_INT : GL.UNSIGNED_SHORT;
49
45
 
50
- this.debugData = null;
51
-
52
46
  // Set data: (re)initializes the buffer
53
47
  if (props.data) {
54
48
  this._initWithData(props.data, props.byteOffset, props.byteLength);
@@ -61,24 +55,22 @@ export class WEBGLBuffer extends Buffer {
61
55
 
62
56
  /** Allocate a new buffer and initialize to contents of typed array */
63
57
  _initWithData(
64
- data,
58
+ data: ArrayBuffer | ArrayBufferView,
65
59
  byteOffset: number = 0,
66
60
  byteLength: number = data.byteLength + byteOffset
67
- ): this {
68
- assert(ArrayBuffer.isView(data));
69
-
70
- const glTarget = this._getWriteTarget();
61
+ ): void {
62
+ // const glTarget = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.glTarget;
63
+ const glTarget = this.glTarget;
71
64
  this.gl.bindBuffer(glTarget, this.handle);
72
65
  this.gl.bufferData(glTarget, byteLength, this.glUsage);
73
66
  this.gl.bufferSubData(glTarget, byteOffset, data);
74
67
  this.gl.bindBuffer(glTarget, null);
75
68
 
76
- this.debugData = data.slice(0, DEBUG_DATA_LENGTH);
77
69
  this.bytesUsed = byteLength;
78
70
  this.byteLength = byteLength;
79
- this.trackAllocatedMemory(byteLength);
80
71
 
81
- return this;
72
+ this._setDebugData(data, byteOffset, byteLength);
73
+ this.trackAllocatedMemory(byteLength);
82
74
  }
83
75
 
84
76
  // Allocate a GPU buffer of specified size.
@@ -93,16 +85,19 @@ export class WEBGLBuffer extends Buffer {
93
85
  data = new Float32Array(0);
94
86
  }
95
87
 
96
- const glTarget = this._getWriteTarget();
88
+ // const glTarget = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.glTarget;
89
+ const glTarget = this.glTarget;
97
90
 
98
91
  this.gl.bindBuffer(glTarget, this.handle);
99
92
  this.gl.bufferData(glTarget, data, this.glUsage);
100
93
  this.gl.bindBuffer(glTarget, null);
101
94
 
102
- this.debugData = null;
103
95
  this.bytesUsed = byteLength;
104
96
  this.byteLength = byteLength;
105
97
 
98
+ this._setDebugData(null, 0, byteLength);
99
+ this.trackAllocatedMemory(byteLength);
100
+
106
101
  return this;
107
102
  }
108
103
 
@@ -134,15 +129,19 @@ export class WEBGLBuffer extends Buffer {
134
129
  }
135
130
  this.gl.bindBuffer(glTarget, null);
136
131
 
137
- // TODO - update local `data` if offsets are right
138
- // this.debugData = data.slice(byteOffset, 40);
132
+ this._setDebugData(data, byteOffset, data.byteLength);
139
133
  }
140
134
 
141
- /** Read data from the buffer */
135
+ /** Asynchronously read data from the buffer */
142
136
  override async readAsync(byteOffset = 0, byteLength?: number): Promise<Uint8Array> {
137
+ return this.readSyncWebGL2(byteOffset, byteLength);
138
+ }
139
+
140
+ /** Synchronously read data from the buffer. WebGL only. */
141
+ override readSyncWebGL2(byteOffset = 0, byteLength?: number): Uint8Array {
143
142
  this.device.assertWebGL2();
144
143
 
145
- byteLength = byteLength ?? this.byteLength;
144
+ byteLength = byteLength ?? this.byteLength - byteOffset;
146
145
  const data = new Uint8Array(byteLength);
147
146
  const dstOffset = 0;
148
147
 
@@ -151,40 +150,37 @@ export class WEBGLBuffer extends Buffer {
151
150
  this.gl2.getBufferSubData(GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);
152
151
  this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);
153
152
 
154
- // TODO - update local `data` if offsets are 0
155
- // this.debugData = null;
153
+ // Update local `data` if offsets are 0
154
+ this._setDebugData(data, byteOffset, byteLength);
156
155
 
157
156
  return data;
158
157
  }
159
-
160
- // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)
161
-
162
- _invalidateDebugData() {
163
- this.debugData = null;
164
- }
165
-
166
- _getWriteTarget() {
167
- return this.glTarget;
168
- // return this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.glTarget;
169
- }
170
-
171
- _getReadTarget() {
172
- return this.glTarget;
173
- // return this.device.isWebGL2 ? GL.COPY_READ_BUFFER : this.glTarget;
174
- }
175
158
  }
176
159
 
177
- // static MAP_READ = 0x01;
178
- // static MAP_WRITE = 0x02;
179
- // static COPY_SRC = 0x0004;
180
- // static COPY_DST = 0x0008;
181
- // static INDEX = 0x0010;
182
- // static VERTEX = 0x0020;
183
- // static UNIFORM = 0x0040;
184
- // static STORAGE = 0x0080;
185
- // static INDIRECT = 0x0100;
186
- // static QUERY_RESOLVE = 0x0200;
187
-
160
+ /**
161
+ * Returns a WebGL buffer target
162
+ *
163
+ * @param usage
164
+ * static MAP_READ = 0x01;
165
+ * static MAP_WRITE = 0x02;
166
+ * static COPY_SRC = 0x0004;
167
+ * static COPY_DST = 0x0008;
168
+ * static INDEX = 0x0010;
169
+ * static VERTEX = 0x0020;
170
+ * static UNIFORM = 0x0040;
171
+ * static STORAGE = 0x0080;
172
+ * static INDIRECT = 0x0100;
173
+ * static QUERY_RESOLVE = 0x0200;
174
+ *
175
+ * @returns WebGL buffer targe
176
+ *
177
+ * Buffer bind points in WebGL2
178
+ * gl.COPY_READ_BUFFER: Buffer for copying from one buffer object to another.
179
+ * gl.COPY_WRITE_BUFFER: Buffer for copying from one buffer object to another.
180
+ * gl.TRANSFORM_FEEDBACK_BUFFER: Buffer for transform feedback operations.
181
+ * gl.PIXEL_PACK_BUFFER: Buffer used for pixel transfer operations.
182
+ * gl.PIXEL_UNPACK_BUFFER: Buffer used for pixel transfer operations.
183
+ */
188
184
  function getWebGLTarget(
189
185
  usage: number
190
186
  ): GL.ARRAY_BUFFER | GL.ELEMENT_ARRAY_BUFFER | GL.UNIFORM_BUFFER {
@@ -198,14 +194,8 @@ function getWebGLTarget(
198
194
  return GL.UNIFORM_BUFFER;
199
195
  }
200
196
 
201
- // gl.COPY_READ_BUFFER: Buffer for copying from one buffer object to another.
202
- // gl.COPY_WRITE_BUFFER: Buffer for copying from one buffer object to another.
203
- // gl.TRANSFORM_FEEDBACK_BUFFER: Buffer for transform feedback operations.
204
- // gl.PIXEL_PACK_BUFFER: Buffer used for pixel transfer operations.
205
- // gl.PIXEL_UNPACK_BUFFER: Buffer used for pixel transfer operations.
206
-
207
197
  // Binding a buffer for the first time locks the type
208
- // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type
198
+ // In WebGL2, we can use GL.COPY_WRITE_BUFFER to avoid locking the type
209
199
  return GL.ARRAY_BUFFER;
210
200
  }
211
201
 
@@ -12,10 +12,9 @@ import {
12
12
  Sampler,
13
13
  SamplerProps,
14
14
  SamplerParameters,
15
- TypedArray,
16
- isObjectEmpty
15
+ TypedArray
17
16
  } from '@luma.gl/core';
18
- import {Texture, cast, log, assert, isPowerOfTwo, loadImage} from '@luma.gl/core';
17
+ import {Texture, log, assert, isPowerOfTwo, loadImage, isObjectEmpty} from '@luma.gl/core';
19
18
  import {GL, GLSamplerParameters} from '@luma.gl/constants';
20
19
  import {withGLParameters} from '../../context/state-tracker/with-parameters';
21
20
  import {
@@ -193,7 +192,7 @@ export class WEBGLTexture extends Texture<WEBGLTextureProps> {
193
192
  constructor(device: Device, props: WEBGLTextureProps) {
194
193
  super(device, {...DEFAULT_WEBGL_TEXTURE_PROPS, format: 'rgba8unorm', ...props});
195
194
 
196
- this.device = cast<WebGLDevice>(device);
195
+ this.device = device as WebGLDevice;
197
196
  this.gl = this.device.gl;
198
197
  this.gl2 = this.device.gl2;
199
198
  this.handle = this.props.handle || this.gl.createTexture();
@@ -132,7 +132,7 @@ export class WebGLDevice extends Device {
132
132
  }
133
133
 
134
134
  static async create(props: DeviceProps = {}): Promise<WebGLDevice> {
135
- log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created');
135
+ log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created')();
136
136
 
137
137
  // Wait for page to load. Only wait when props. canvas is string
138
138
  // to avoid setting page onload callback unless necessary
@@ -158,7 +158,18 @@ export class WebGLDevice extends Device {
158
158
  return WebGLDevice.attach(props.gl);
159
159
  }
160
160
 
161
- return new WebGLDevice(props);
161
+ const device = new WebGLDevice(props);
162
+
163
+ // Log some debug info about the newly created context
164
+ const message = `\
165
+ Created ${device.info.type}${device.debug ? ' debug' : ''} context: \
166
+ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
167
+ log.probe(LOG_LEVEL, message)();
168
+ log.table(LOG_LEVEL, device.info)();
169
+
170
+ log.groupEnd(LOG_LEVEL)();
171
+
172
+ return device;
162
173
  }
163
174
 
164
175
  //
@@ -240,14 +251,6 @@ export class WebGLDevice extends Device {
240
251
  const canvas = this.handle.canvas || (props.canvas as HTMLCanvasElement);
241
252
  this.spector = initializeSpectorJS({...this.props, canvas});
242
253
  }
243
-
244
- // Log some debug info about the newly created context
245
- const message = `\
246
- Created ${this.info.type}${this.debug ? ' debug' : ''} context: \
247
- ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;
248
- log.probe(LOG_LEVEL, message)();
249
-
250
- log.groupEnd(LOG_LEVEL)();
251
254
  }
252
255
 
253
256
  /**
@@ -38,9 +38,13 @@ function initializeExtensions(gl: WebGLRenderingContext): void {
38
38
  const contextState = getContextData(gl);
39
39
  // `getSupportedExtensions` can return null when context is lost.
40
40
  const EXTENSIONS = gl.getSupportedExtensions() || [];
41
+ // Generates warnings in Chrome
42
+ const IGNORE_EXTENSIONS = ['WEBGL_polygon_mode'];
41
43
  for (const extensionName of EXTENSIONS) {
42
- const extension = gl.getExtension(extensionName);
43
- contextState._extensions[extensionName] = extension;
44
+ if (!IGNORE_EXTENSIONS.includes(extensionName)) {
45
+ const extension = gl.getExtension(extensionName);
46
+ contextState._extensions[extensionName] = extension;
47
+ }
44
48
  }
45
49
  }
46
50