@luma.gl/webgl 9.0.0-beta.9 → 9.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/webgl",
3
- "version": "9.0.0-beta.9",
3
+ "version": "9.0.3",
4
4
  "description": "WebGL2 adapter for the luma.gl core API",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,11 +40,11 @@
40
40
  "prepublishOnly": "npm run build-minified-bundle && npm run build-dev-bundle"
41
41
  },
42
42
  "peerDependencies": {
43
- "@luma.gl/core": "^9.0.0-beta"
43
+ "@luma.gl/core": "^9.0.0"
44
44
  },
45
45
  "dependencies": {
46
- "@luma.gl/constants": "9.0.0-beta.9",
46
+ "@luma.gl/constants": "9.0.3",
47
47
  "@probe.gl/env": "^4.0.2"
48
48
  },
49
- "gitHead": "6a91ba24a0f78ef190c51e52c31271ea1a5a7a1f"
49
+ "gitHead": "543e03b2d4bd865ac86cc8927611b91cc3e0393c"
50
50
  }
@@ -61,12 +61,8 @@ export class WebGLDeviceFeatures extends DeviceFeatures {
61
61
  }
62
62
 
63
63
  *[Symbol.iterator](): IterableIterator<DeviceFeature> {
64
- for (const feature of Object.keys(WEBGL_FEATURES) as DeviceFeature[]) {
65
- if (this.has(feature)) {
66
- yield feature;
67
- }
68
- }
69
- for (const feature of Object.keys(TEXTURE_FEATURES) as DeviceFeature[]) {
64
+ const features = this.getFeatures();
65
+ for (const feature of features) {
70
66
  if (this.has(feature)) {
71
67
  yield feature;
72
68
  }
@@ -98,15 +94,20 @@ export class WebGLDeviceFeatures extends DeviceFeatures {
98
94
  // FOR DEVICE
99
95
 
100
96
  initializeFeatures() {
101
- // @ts-expect-error
102
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
103
- for (const feature of this) {
104
- // WebGL extensions are initialized by requesting them
97
+ // Initialize all features by checking them.
98
+ // Except WEBGL_polygon_mode since Chrome logs ugly console warnings
99
+ const features = this.getFeatures().filter(feature => feature !== 'polygon-mode-webgl');
100
+ for (const feature of features) {
101
+ this.has(feature);
105
102
  }
106
103
  }
107
104
 
108
105
  // IMPLEMENTATION
109
106
 
107
+ getFeatures() {
108
+ return [...Object.keys(WEBGL_FEATURES), ...Object.keys(TEXTURE_FEATURES)] as DeviceFeature[];
109
+ }
110
+
110
111
  /** Extract all WebGL features */
111
112
  protected getWebGLFeature(feature: DeviceFeature): boolean {
112
113
  const featureInfo = WEBGL_FEATURES[feature];
@@ -72,9 +72,9 @@ export class WEBGLRenderPipeline extends RenderPipeline {
72
72
 
73
73
  this._linkShaders();
74
74
 
75
- log.time(0, `RenderPipeline ${this.id} - shaderLayout introspection`)();
75
+ log.time(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();
76
76
  this.introspectedLayout = getShaderLayout(this.device.gl, this.handle);
77
- log.timeEnd(0, `RenderPipeline ${this.id} - shaderLayout introspection`)();
77
+ log.timeEnd(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();
78
78
 
79
79
  // Merge provided layout with introspected layout
80
80
  this.shaderLayout = mergeShaderLayout(this.introspectedLayout, props.shaderLayout);
@@ -103,7 +103,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
103
103
  * Bindings include: textures, samplers and uniform buffers
104
104
  * @todo needed for portable model
105
105
  */
106
- setBindings(bindings: Record<string, Binding>): void {
106
+ setBindings(bindings: Record<string, Binding>, options?: {disableWarnings?: boolean}): void {
107
107
  // if (log.priority >= 2) {
108
108
  // checkUniformValues(uniforms, this.id, this._uniformSetters);
109
109
  // }
@@ -121,9 +121,11 @@ export class WEBGLRenderPipeline extends RenderPipeline {
121
121
  const validBindings = this.shaderLayout.bindings
122
122
  .map(binding => `"${binding.name}"`)
123
123
  .join(', ');
124
- log.warn(
125
- `Unknown binding "${name}" in render pipeline "${this.id}", expected one of ${validBindings}`
126
- )();
124
+ if (options?.disableWarnings) {
125
+ log.warn(
126
+ `Unknown binding "${name}" in render pipeline "${this.id}", expected one of ${validBindings}`
127
+ )();
128
+ }
127
129
  continue; // eslint-disable-line no-continue
128
130
  }
129
131
  if (!value) {
@@ -461,12 +463,12 @@ export class WEBGLRenderPipeline extends RenderPipeline {
461
463
  texture = value;
462
464
  } else if (
463
465
  value instanceof WEBGLFramebuffer &&
464
- value.colorAttachments[0] instanceof WEBGLTexture
466
+ value.colorAttachments[0] instanceof WEBGLTextureView
465
467
  ) {
466
468
  log.warn(
467
469
  'Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead'
468
470
  )();
469
- texture = value.colorAttachments[0];
471
+ texture = value.colorAttachments[0].texture;
470
472
  } else {
471
473
  throw new Error('No texture');
472
474
  }
@@ -57,8 +57,8 @@ export class WEBGLVertexArray extends VertexArray {
57
57
  /**
58
58
  // Set (bind/unbind) an elements buffer, for indexed rendering.
59
59
  // Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER or null. Constants not supported
60
- *
61
- * @param elementBuffer
60
+ *
61
+ * @param elementBuffer
62
62
  */
63
63
  setIndexBuffer(indexBuffer: Buffer | null): void {
64
64
  const buffer = indexBuffer as WEBGLBuffer;
@@ -68,12 +68,12 @@ export class WEBGLVertexArray extends VertexArray {
68
68
  }
69
69
  // In WebGL The GL.ELEMENT_ARRAY_BUFFER_BINDING is stored on the VertexArrayObject
70
70
  this.device.gl.bindVertexArray(this.handle);
71
- // TODO - this initial binding does not seem to take effect? see bindBeforeRender()
72
71
  this.device.gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, buffer ? buffer.handle : null);
73
- // log.log(1, 'VertexArray.setIndexBuffer', indexBuffer)();
74
- // log.log(1, `Binding vertex array ${this.id}`, buffer?.id)();
75
72
 
76
73
  this.indexBuffer = buffer;
74
+
75
+ // Unbind to prevent unintended changes to the VAO.
76
+ this.device.gl.bindVertexArray(null);
77
77
  }
78
78
 
79
79
  /** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */
@@ -104,6 +104,9 @@ export class WEBGLVertexArray extends VertexArray {
104
104
  this.device.gl.vertexAttribDivisor(location, divisor || 0);
105
105
 
106
106
  this.attributes[location] = buffer;
107
+
108
+ // Unbind to prevent unintended changes to the VAO.
109
+ this.device.gl.bindVertexArray(null);
107
110
  }
108
111
 
109
112
  /** Set a location in vertex attributes array to a constant value, disables the location */
@@ -112,26 +115,14 @@ export class WEBGLVertexArray extends VertexArray {
112
115
  this.attributes[location] = value;
113
116
  }
114
117
 
115
- init = false;
116
-
117
118
  override bindBeforeRender(): void {
118
119
  this.device.gl.bindVertexArray(this.handle);
119
- // TODO - the initial bind does not seem to take effect.
120
- if (!this.init) {
121
- // log.log(1, `Binding vertex array ${this.id}`, this.indexBuffer?.id)();
122
- const webglBuffer = this.indexBuffer as WEBGLBuffer;
123
- this.device.gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, webglBuffer?.handle || null);
124
- this.init = true;
125
- }
126
120
  this._applyConstantAttributes();
127
121
  }
128
122
 
129
123
  override unbindAfterRender(): void {
130
- // log.log(1, `Unbinding vertex array ${this.id}`)();
131
- // TODO technically this is not necessary, but we might be interfacing
132
- // with code that does not use vertex array objects
124
+ // Unbind to prevent unintended changes to the VAO.
133
125
  this.device.gl.bindVertexArray(null);
134
- // this.device.gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, null);
135
126
  }
136
127
 
137
128
  // Internal methods