@luma.gl/webgl 9.0.5 → 9.0.7

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.5",
3
+ "version": "9.0.7",
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.5",
46
+ "@luma.gl/constants": "9.0.7",
47
47
  "@probe.gl/env": "^4.0.2"
48
48
  },
49
- "gitHead": "f8224e596919b431978f87d4f0fd2382d74851b7"
49
+ "gitHead": "776cf7b8d758df78dba231f4ef7b9b9693f10373"
50
50
  }
@@ -159,11 +159,11 @@ export function setDeviceParameters(device: Device, parameters: Parameters) {
159
159
 
160
160
  // WEBGL EXTENSIONS
161
161
 
162
- if (device.features.has('provoking-vertex-webgl')) {
163
- const extensions = webglDevice.getExtension('WEBGL_provoking_vertex');
164
- const ext = extensions.WEBGL_provoking_vertex;
162
+ if (parameters.provokingVertex) {
163
+ if (device.features.has('provoking-vertex-webgl')) {
164
+ const extensions = webglDevice.getExtension('WEBGL_provoking_vertex');
165
+ const ext = extensions.WEBGL_provoking_vertex;
165
166
 
166
- if (parameters.provokingVertex) {
167
167
  const vertex = map<ProvokingVertex, GLProvokingVertex>(
168
168
  'provokingVertex',
169
169
  parameters.provokingVertex,
@@ -176,21 +176,22 @@ export function setDeviceParameters(device: Device, parameters: Parameters) {
176
176
  }
177
177
  }
178
178
 
179
- if (device.features.has('polygon-mode-webgl')) {
180
- const extensions = webglDevice.getExtension('WEBGL_polygon_mode');
181
- const ext = extensions.WEBGL_polygon_mode;
182
-
183
- if (parameters.polygonMode) {
184
- const mode = map<PolygonMode, GLPolygonMode>('polygonMode', parameters.polygonMode, {
185
- fill: GL.FILL_WEBGL,
186
- line: GL.LINE_WEBGL
187
- });
188
- ext?.polygonModeWEBGL(GL.FRONT, mode);
189
- ext?.polygonModeWEBGL(GL.BACK, mode);
190
- }
191
-
192
- if (parameters.polygonOffsetLine) {
193
- gl.enable(GL.POLYGON_OFFSET_LINE_WEBGL);
179
+ if (parameters.polygonMode || parameters.polygonOffsetLine) {
180
+ if (device.features.has('polygon-mode-webgl')) {
181
+ if (parameters.polygonMode) {
182
+ const extensions = webglDevice.getExtension('WEBGL_polygon_mode');
183
+ const ext = extensions.WEBGL_polygon_mode;
184
+ const mode = map<PolygonMode, GLPolygonMode>('polygonMode', parameters.polygonMode, {
185
+ fill: GL.FILL_WEBGL,
186
+ line: GL.LINE_WEBGL
187
+ });
188
+ ext?.polygonModeWEBGL(GL.FRONT, mode);
189
+ ext?.polygonModeWEBGL(GL.BACK, mode);
190
+ }
191
+
192
+ if (parameters.polygonOffsetLine) {
193
+ gl.enable(GL.POLYGON_OFFSET_LINE_WEBGL);
194
+ }
194
195
  }
195
196
  }
196
197
 
@@ -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;
@@ -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';
@@ -121,7 +121,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
121
121
  const validBindings = this.shaderLayout.bindings
122
122
  .map(binding => `"${binding.name}"`)
123
123
  .join(', ');
124
- if (options?.disableWarnings) {
124
+ if (!options?.disableWarnings) {
125
125
  log.warn(
126
126
  `Unknown binding "${name}" in render pipeline "${this.id}", expected one of ${validBindings}`
127
127
  )();
@@ -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