@luma.gl/webgl 9.0.0-alpha.50 → 9.0.0-alpha.51

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-alpha.50",
3
+ "version": "9.0.0-alpha.51",
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.50",
48
- "@luma.gl/core": "9.0.0-alpha.50",
47
+ "@luma.gl/constants": "9.0.0-alpha.51",
48
+ "@luma.gl/core": "9.0.0-alpha.51",
49
49
  "@probe.gl/env": "^4.0.2"
50
50
  },
51
51
  "devDependencies": {
52
- "@luma.gl/test-utils": "9.0.0-alpha.50"
52
+ "@luma.gl/test-utils": "9.0.0-alpha.51"
53
53
  },
54
- "gitHead": "83899806fcfab67f97cc8b308f81e4844a05ca05"
54
+ "gitHead": "368b615bdd46d0006717f004244a942f3d2812e7"
55
55
  }
@@ -1,9 +1,8 @@
1
1
  // luma.gl, MIT license
2
2
  // Copyright (c) vis.gl contributors
3
3
 
4
- import {log, uid, Shader, ShaderProps, CompilerMessage, formatCompilerLog} from '@luma.gl/core';
4
+ import {Shader, ShaderProps, CompilerMessage} from '@luma.gl/core';
5
5
  import {GL} from '@luma.gl/constants';
6
- import {getShaderInfo} from '../helpers/get-shader-info';
7
6
  import {parseShaderCompilerLog} from '../helpers/parse-shader-compiler-log';
8
7
  import {WebGLDevice} from '../webgl-device';
9
8
 
@@ -15,7 +14,7 @@ export class WEBGLShader extends Shader {
15
14
  readonly handle: WebGLShader;
16
15
 
17
16
  constructor(device: WebGLDevice, props: ShaderProps) {
18
- super(device, {id: getShaderIdFromProps(props), ...props});
17
+ super(device, props);
19
18
  this.device = device;
20
19
  switch (this.props.stage) {
21
20
  case 'vertex':
@@ -39,15 +38,20 @@ export class WEBGLShader extends Shader {
39
38
  }
40
39
  }
41
40
 
42
- async compilationInfo(): Promise<readonly CompilerMessage[]> {
41
+ override async getCompilationInfo(): Promise<readonly CompilerMessage[]> {
42
+ return this.getCompilationInfoSync();
43
+ }
44
+
45
+ override getCompilationInfoSync() {
43
46
  const log = this.device.gl.getShaderInfoLog(this.handle);
44
- return log ? parseShaderCompilerLog(log) : [];
47
+ return parseShaderCompilerLog(log);
45
48
  }
46
49
 
47
50
  // PRIVATE METHODS
48
51
 
49
52
  _compile(source: string): void {
50
- const addGLSLVersion = (source: string) => source.startsWith('#version ') ? source : `#version 100\n${source}`;
53
+ const addGLSLVersion = (source: string) =>
54
+ source.startsWith('#version ') ? source : `#version 100\n${source}`;
51
55
  source = addGLSLVersion(source);
52
56
 
53
57
  const {gl} = this.device;
@@ -57,25 +61,24 @@ export class WEBGLShader extends Shader {
57
61
  // TODO - For performance reasons, avoid checking shader compilation errors on production?
58
62
  // TODO - Load log even when no error reported, to catch warnings?
59
63
  // https://gamedev.stackexchange.com/questions/30429/how-to-detect-glsl-warnings
60
- const compileStatus = gl.getShaderParameter(this.handle, GL.COMPILE_STATUS);
61
- if (!compileStatus) {
62
- const shaderLog = gl.getShaderInfoLog(this.handle);
63
- const parsedLog = shaderLog ? parseShaderCompilerLog(shaderLog) : [];
64
- const messages = parsedLog.filter(message => message.type === 'error');
65
- const formattedLog = formatCompilerLog(messages, source, {showSourceCode: true});
66
- const shaderName: string = getShaderInfo(source).name;
67
- const shaderDescription = `${this.stage} shader ${shaderName}`;
68
- log.error(`GLSL compilation errors in ${shaderDescription}\n${formattedLog}`)();
69
- throw new Error(`GLSL compilation errors in ${shaderName}`);
64
+ this.compilationStatus = gl.getShaderParameter(this.handle, GL.COMPILE_STATUS) ? 'success' : 'error';
65
+
66
+ // The `Shader` base class will determine if debug window should be opened based on props
67
+ this.debugShader();
68
+
69
+ if (this.compilationStatus === 'error') {
70
+ throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);
70
71
  }
71
72
  }
72
73
  }
73
74
 
74
- // HELPERS
75
+ // TODO - Original code from luma.gl v8 - keep until new debug functionality has matured
76
+ // if (!compilationSuccess) {
77
+ // const parsedLog = shaderLog ? parseShaderCompilerLog(shaderLog) : [];
78
+ // const messages = parsedLog.filter(message => message.type === 'error');
79
+ // const formattedLog = formatCompilerLog(messages, source, {showSourceCode: 'all', html: true});
80
+ // const shaderDescription = `${this.stage} shader ${shaderName}`;
81
+ // log.error(`GLSL compilation errors in ${shaderDescription}\n${formattedLog}`)();
82
+ // displayShaderLog(parsedLog, source, shaderName);
83
+ // }
75
84
 
76
- /** Deduce an id, from shader source, or supplied id, or shader type */
77
- function getShaderIdFromProps(props: ShaderProps): string {
78
- return getShaderInfo(props.source).name ||
79
- props.id ||
80
- uid(`unnamed ${props.stage}-shader`);
81
- }
@@ -1,9 +0,0 @@
1
- /** Information extracted from shader source code */
2
- export type ShaderInfo = {
3
- name: string;
4
- language: 'glsl' | 'wgsl';
5
- version: number;
6
- };
7
- /** Extracts information from shader source code */
8
- export declare function getShaderInfo(source: string, defaultName?: string): ShaderInfo;
9
- //# sourceMappingURL=get-shader-info.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-shader-info.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-shader-info.ts"],"names":[],"mappings":"AAMA,oDAAoD;AACpD,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,mDAAmD;AACnD,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,UAAU,CAM9E"}
@@ -1,25 +0,0 @@
1
- export function getShaderInfo(source, defaultName) {
2
- return {
3
- name: getShaderName(source, defaultName),
4
- language: 'glsl',
5
- version: getShaderVersion(source)
6
- };
7
- }
8
- function getShaderName(shader) {
9
- let defaultName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'unnamed';
10
- const SHADER_NAME_REGEXP = /#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/;
11
- const match = SHADER_NAME_REGEXP.exec(shader);
12
- return match ? match[1] : defaultName;
13
- }
14
- function getShaderVersion(source) {
15
- let version = 100;
16
- const words = source.match(/[^\s]+/g);
17
- if (words && words.length >= 2 && words[0] === '#version') {
18
- const v = parseInt(words[1], 10);
19
- if (Number.isFinite(v)) {
20
- version = v;
21
- }
22
- }
23
- return version;
24
- }
25
- //# sourceMappingURL=get-shader-info.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-shader-info.js","names":["getShaderInfo","source","defaultName","name","getShaderName","language","version","getShaderVersion","shader","arguments","length","undefined","SHADER_NAME_REGEXP","match","exec","words","v","parseInt","Number","isFinite"],"sources":["../../../src/adapter/helpers/get-shader-info.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n// Note: This was the only dependency that made @luma.gl/webgl depend on @luma.gl/shadertools\n// This file was coped from shadertools to avoid the dependency\n\n/** Information extracted from shader source code */\nexport type ShaderInfo = {\n name: string;\n language: 'glsl' | 'wgsl';\n version: number;\n};\n\n/** Extracts information from shader source code */\nexport function getShaderInfo(source: string, defaultName?: string): ShaderInfo {\n return {\n name: getShaderName(source, defaultName),\n language: 'glsl',\n version: getShaderVersion(source)\n };\n}\n\n/** Extracts GLSLIFY style naming of shaders: `#define SHADER_NAME ...` */\nfunction getShaderName(shader: string, defaultName: string = 'unnamed'): string {\n const SHADER_NAME_REGEXP = /#define[\\s*]SHADER_NAME[\\s*]([A-Za-z0-9_-]+)[\\s*]/;\n const match = SHADER_NAME_REGEXP.exec(shader);\n return match ? match[1] : defaultName;\n}\n\n/** returns GLSL shader version of given shader string */\nfunction getShaderVersion(source: string): number {\n let version = 100;\n const words = source.match(/[^\\s]+/g);\n if (words && words.length >= 2 && words[0] === '#version') {\n const v = parseInt(words[1], 10);\n if (Number.isFinite(v)) {\n version = v;\n }\n }\n return version;\n}\n"],"mappings":"AAcA,OAAO,SAASA,aAAaA,CAACC,MAAc,EAAEC,WAAoB,EAAc;EAC9E,OAAO;IACLC,IAAI,EAAEC,aAAa,CAACH,MAAM,EAAEC,WAAW,CAAC;IACxCG,QAAQ,EAAE,MAAM;IAChBC,OAAO,EAAEC,gBAAgB,CAACN,MAAM;EAClC,CAAC;AACH;AAGA,SAASG,aAAaA,CAACI,MAAc,EAA2C;EAAA,IAAzCN,WAAmB,GAAAO,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,SAAS;EACpE,MAAMG,kBAAkB,GAAG,mDAAmD;EAC9E,MAAMC,KAAK,GAAGD,kBAAkB,CAACE,IAAI,CAACN,MAAM,CAAC;EAC7C,OAAOK,KAAK,GAAGA,KAAK,CAAC,CAAC,CAAC,GAAGX,WAAW;AACvC;AAGA,SAASK,gBAAgBA,CAACN,MAAc,EAAU;EAChD,IAAIK,OAAO,GAAG,GAAG;EACjB,MAAMS,KAAK,GAAGd,MAAM,CAACY,KAAK,CAAC,SAAS,CAAC;EACrC,IAAIE,KAAK,IAAIA,KAAK,CAACL,MAAM,IAAI,CAAC,IAAIK,KAAK,CAAC,CAAC,CAAC,KAAK,UAAU,EAAE;IACzD,MAAMC,CAAC,GAAGC,QAAQ,CAACF,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAChC,IAAIG,MAAM,CAACC,QAAQ,CAACH,CAAC,CAAC,EAAE;MACtBV,OAAO,GAAGU,CAAC;IACb;EACF;EACA,OAAOV,OAAO;AAChB"}
@@ -1,41 +0,0 @@
1
- // luma.gl, MIT license
2
- // Copyright (c) vis.gl contributors
3
-
4
- // Note: This was the only dependency that made @luma.gl/webgl depend on @luma.gl/shadertools
5
- // This file was coped from shadertools to avoid the dependency
6
-
7
- /** Information extracted from shader source code */
8
- export type ShaderInfo = {
9
- name: string;
10
- language: 'glsl' | 'wgsl';
11
- version: number;
12
- };
13
-
14
- /** Extracts information from shader source code */
15
- export function getShaderInfo(source: string, defaultName?: string): ShaderInfo {
16
- return {
17
- name: getShaderName(source, defaultName),
18
- language: 'glsl',
19
- version: getShaderVersion(source)
20
- };
21
- }
22
-
23
- /** Extracts GLSLIFY style naming of shaders: `#define SHADER_NAME ...` */
24
- function getShaderName(shader: string, defaultName: string = 'unnamed'): string {
25
- const SHADER_NAME_REGEXP = /#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/;
26
- const match = SHADER_NAME_REGEXP.exec(shader);
27
- return match ? match[1] : defaultName;
28
- }
29
-
30
- /** returns GLSL shader version of given shader string */
31
- function getShaderVersion(source: string): number {
32
- let version = 100;
33
- const words = source.match(/[^\s]+/g);
34
- if (words && words.length >= 2 && words[0] === '#version') {
35
- const v = parseInt(words[1], 10);
36
- if (Number.isFinite(v)) {
37
- version = v;
38
- }
39
- }
40
- return version;
41
- }