@luma.gl/webgl 9.0.4 → 9.0.6

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.4",
3
+ "version": "9.0.6",
4
4
  "description": "WebGL2 adapter for the luma.gl core API",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -43,8 +43,8 @@
43
43
  "@luma.gl/core": "^9.0.0"
44
44
  },
45
45
  "dependencies": {
46
- "@luma.gl/constants": "9.0.4",
46
+ "@luma.gl/constants": "9.0.6",
47
47
  "@probe.gl/env": "^4.0.2"
48
48
  },
49
- "gitHead": "d8d47a36bd014fc4848043082bdff31604f6b5c1"
49
+ "gitHead": "937f4cffd47819854b44ce1532add35f6a8d049c"
50
50
  }
@@ -16,6 +16,7 @@ const GL_STENCIL_BUFFER_BIT = 0x00000400;
16
16
  const GL_COLOR_BUFFER_BIT = 0x00004000;
17
17
 
18
18
  const GL_COLOR = 0x1800;
19
+ const COLOR_CHANNELS = [0x1, 0x2, 0x4, 0x8]; // GPUColorWrite RED, GREEN, BLUE, ALPHA
19
20
 
20
21
  export class WEBGLRenderPass extends RenderPass {
21
22
  readonly device: WebGLDevice;
@@ -82,8 +83,8 @@ export class WEBGLRenderPass extends RenderPass {
82
83
  glParameters.viewport = parameters.viewport;
83
84
  }
84
85
  }
85
- glParameters.scissorTest = Boolean(parameters.scissorRect);
86
86
  if (parameters.scissorRect) {
87
+ glParameters.scissorTest = true;
87
88
  glParameters.scissor = parameters.scissorRect;
88
89
  }
89
90
  if (parameters.blendConstant) {
@@ -97,6 +98,12 @@ export class WEBGLRenderPass extends RenderPass {
97
98
  parameters[GL.STENCIL_REF] = parameters.stencilReference;
98
99
  }
99
100
 
101
+ if (parameters.colorMask) {
102
+ glParameters.colorMask = COLOR_CHANNELS.map(channel =>
103
+ Boolean(channel & parameters.colorMask)
104
+ );
105
+ }
106
+
100
107
  this.glParameters = glParameters;
101
108
 
102
109
  setGLParameters(this.device.gl, glParameters);
@@ -2,8 +2,8 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import type {UniformValue, RenderPipelineProps, Binding} from '@luma.gl/core';
6
- import type {ShaderLayout} from '@luma.gl/core';
5
+ import type {RenderPipelineProps, RenderPipelineParameters, PrimitiveTopology} from '@luma.gl/core';
6
+ import type {ShaderLayout, UniformValue, Binding} from '@luma.gl/core';
7
7
  import type {RenderPass, VertexArray} from '@luma.gl/core';
8
8
  import {RenderPipeline, cast, splitUniformsAndBindings, log} from '@luma.gl/core';
9
9
  import {mergeShaderLayout} from '@luma.gl/core';
@@ -166,7 +166,8 @@ export class WEBGLRenderPipeline extends RenderPipeline {
166
166
  */
167
167
  draw(options: {
168
168
  renderPass: RenderPass;
169
- /** vertex attributes */
169
+ parameters?: RenderPipelineParameters;
170
+ topology?: PrimitiveTopology;
170
171
  vertexArray: VertexArray;
171
172
  vertexCount?: number;
172
173
  indexCount?: number;
@@ -179,6 +180,8 @@ export class WEBGLRenderPipeline extends RenderPipeline {
179
180
  }): boolean {
180
181
  const {
181
182
  renderPass,
183
+ parameters = this.props.parameters,
184
+ topology = this.props.topology,
182
185
  vertexArray,
183
186
  vertexCount,
184
187
  // indexCount,
@@ -190,7 +193,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
190
193
  transformFeedback
191
194
  } = options;
192
195
 
193
- const glDrawMode = getGLDrawMode(this.props.topology);
196
+ const glDrawMode = getGLDrawMode(topology);
194
197
  const isIndexed: boolean = Boolean(vertexArray.indexBuffer);
195
198
  const glIndexType = (vertexArray.indexBuffer as WEBGLBuffer)?.glIndexType;
196
199
  const isInstanced: boolean = Number(instanceCount) > 0;
@@ -231,39 +234,34 @@ export class WEBGLRenderPipeline extends RenderPipeline {
231
234
 
232
235
  const webglRenderPass = renderPass as WEBGLRenderPass;
233
236
 
234
- withDeviceAndGLParameters(
235
- this.device,
236
- this.props.parameters,
237
- webglRenderPass.glParameters,
238
- () => {
239
- if (isIndexed && isInstanced) {
240
- this.device.gl.drawElementsInstanced(
241
- glDrawMode,
242
- vertexCount || 0, // indexCount?
243
- glIndexType,
244
- firstVertex,
245
- instanceCount || 0
246
- );
247
- // } else if (isIndexed && this.device.isWebGL2 && !isNaN(start) && !isNaN(end)) {
248
- // this.device.gldrawRangeElements(glDrawMode, start, end, vertexCount, glIndexType, offset);
249
- } else if (isIndexed) {
250
- this.device.gl.drawElements(glDrawMode, vertexCount || 0, glIndexType, firstVertex); // indexCount?
251
- } else if (isInstanced) {
252
- this.device.gl.drawArraysInstanced(
253
- glDrawMode,
254
- firstVertex,
255
- vertexCount || 0,
256
- instanceCount || 0
257
- );
258
- } else {
259
- this.device.gl.drawArrays(glDrawMode, firstVertex, vertexCount || 0);
260
- }
237
+ withDeviceAndGLParameters(this.device, parameters, webglRenderPass.glParameters, () => {
238
+ if (isIndexed && isInstanced) {
239
+ this.device.gl.drawElementsInstanced(
240
+ glDrawMode,
241
+ vertexCount || 0, // indexCount?
242
+ glIndexType,
243
+ firstVertex,
244
+ instanceCount || 0
245
+ );
246
+ // } else if (isIndexed && this.device.isWebGL2 && !isNaN(start) && !isNaN(end)) {
247
+ // this.device.gldrawRangeElements(glDrawMode, start, end, vertexCount, glIndexType, offset);
248
+ } else if (isIndexed) {
249
+ this.device.gl.drawElements(glDrawMode, vertexCount || 0, glIndexType, firstVertex); // indexCount?
250
+ } else if (isInstanced) {
251
+ this.device.gl.drawArraysInstanced(
252
+ glDrawMode,
253
+ firstVertex,
254
+ vertexCount || 0,
255
+ instanceCount || 0
256
+ );
257
+ } else {
258
+ this.device.gl.drawArrays(glDrawMode, firstVertex, vertexCount || 0);
259
+ }
261
260
 
262
- if (transformFeedback) {
263
- transformFeedback.end();
264
- }
261
+ if (transformFeedback) {
262
+ transformFeedback.end();
265
263
  }
266
- );
264
+ });
267
265
 
268
266
  vertexArray.unbindAfterRender(renderPass);
269
267
 
@@ -76,11 +76,11 @@ export class WEBGLShader extends Shader {
76
76
  // Sync case - slower, but advantage is that it throws in the constructor, making break on error more useful
77
77
  if (!this.device.features.has('compilation-status-async-webgl')) {
78
78
  this._getCompilationStatus();
79
+ // The `Shader` base class will determine if debug window should be opened based on this.compilationStatus
80
+ this.debugShader();
79
81
  if (this.compilationStatus === 'error') {
80
82
  throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);
81
83
  }
82
- // The `Shader` base class will determine if debug window should be opened based on this.compilationStatus
83
- this.debugShader();
84
84
  return;
85
85
  }
86
86
 
@@ -71,7 +71,11 @@ import {WEBGLTransformFeedback} from './resources/webgl-transform-feedback';
71
71
  import {WEBGLQuerySet} from './resources/webgl-query-set';
72
72
 
73
73
  import {readPixelsToArray, readPixelsToBuffer} from '../classic/copy-and-blit';
74
- import {setGLParameters, getGLParameters} from '../context/parameters/unified-parameter-api';
74
+ import {
75
+ setGLParameters,
76
+ getGLParameters,
77
+ resetGLParameters
78
+ } from '../context/parameters/unified-parameter-api';
75
79
  import {withGLParameters} from '../context/state-tracker/with-parameters';
76
80
  import {clear} from '../classic/clear';
77
81
  import {getWebGLExtension} from '../context/helpers/webgl-extensions';
@@ -408,7 +412,7 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
408
412
  }
409
413
 
410
414
  override withParametersWebGL(parameters: any, func: any): any {
411
- withGLParameters(this.gl, parameters, func);
415
+ return withGLParameters(this.gl, parameters, func);
412
416
  }
413
417
 
414
418
  override clearWebGL(options?: {
@@ -420,6 +424,11 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
420
424
  clear(this, options);
421
425
  }
422
426
 
427
+ override resetWebGL(): void {
428
+ log.warn('WebGLDevice.resetWebGL is deprecated, use only for debugging')();
429
+ resetGLParameters(this.gl);
430
+ }
431
+
423
432
  //
424
433
  // WebGL-only API (not part of `Device` API)
425
434
  //